Commit dd3b684c authored by jean-pierre charras's avatar jean-pierre charras

Eeschema: fix Bug #1095005

parent aaf6cce6
...@@ -398,7 +398,7 @@ public: ...@@ -398,7 +398,7 @@ public:
* *
* @return True if the item is being edited. * @return True if the item is being edited.
*/ */
bool InEditMode() const { return ( m_Flags & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0; } bool InEditMode() const { return ( m_Flags & ( IS_NEW | IS_DRAGGED | IS_MOVED | IS_RESIZED ) ) != 0; }
void SetEraseLastDrawItem( bool aErase = true ) { m_eraseLastDrawItem = aErase; } void SetEraseLastDrawItem( bool aErase = true ) { m_eraseLastDrawItem = aErase; }
......
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2013 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
......
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2010 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -40,7 +40,10 @@ ...@@ -40,7 +40,10 @@
void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
{ {
LIB_ITEM* item = m_drawItem; LIB_ITEM* item = m_drawItem;
bool no_item_edited = item == NULL || item->GetFlags() == 0; bool item_in_edit = false;
if( item )
item_in_edit = item->IsNew() || item->IsMoving() || item->IsDragging();
bool no_item_edited = !item_in_edit;
if( m_component == NULL ) // No component loaded ! if( m_component == NULL ) // No component loaded !
return; return;
...@@ -63,7 +66,8 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) ...@@ -63,7 +66,8 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
switch( GetToolId() ) switch( GetToolId() )
{ {
case ID_NO_TOOL_SELECTED: case ID_NO_TOOL_SELECTED:
if( item && item->GetFlags() ) // moved object // If an item is currently in edit, finish edit
if( item_in_edit )
{ {
switch( item->Type() ) switch( item->Type() )
{ {
...@@ -80,13 +84,9 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) ...@@ -80,13 +84,9 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
case ID_LIBEDIT_PIN_BUTT: case ID_LIBEDIT_PIN_BUTT:
if( no_item_edited ) if( no_item_edited )
{
CreatePin( DC ); CreatePin( DC );
}
else else
{
PlacePin( DC ); PlacePin( DC );
}
break; break;
case ID_LIBEDIT_BODY_LINE_BUTT: case ID_LIBEDIT_BODY_LINE_BUTT:
...@@ -95,9 +95,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) ...@@ -95,9 +95,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
case ID_LIBEDIT_BODY_RECT_BUTT: case ID_LIBEDIT_BODY_RECT_BUTT:
case ID_LIBEDIT_BODY_TEXT_BUTT: case ID_LIBEDIT_BODY_TEXT_BUTT:
if( no_item_edited ) if( no_item_edited )
{
m_drawItem = CreateGraphicItem( m_component, DC ); m_drawItem = CreateGraphicItem( m_component, DC );
}
else if( m_drawItem ) else if( m_drawItem )
{ {
if( m_drawItem->IsNew() ) if( m_drawItem->IsNew() )
......
/** /**
* @file libedit_onrightclick.cpp * @file libedit_onrightclick.cpp
* @brief Library editor: create the pop menus when clicking on mouse right button
*/ */
/* , In library editor, create the pop menu when clicking on mouse right button /*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004-2013 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <fctsys.h> #include <fctsys.h>
...@@ -247,7 +268,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -247,7 +268,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
return true; return true;
} }
// Add menu items for pin edition
void AddMenusForPin( wxMenu* PopMenu, LIB_PIN* Pin, LIB_EDIT_FRAME* frame ) void AddMenusForPin( wxMenu* PopMenu, LIB_PIN* Pin, LIB_EDIT_FRAME* frame )
{ {
bool selected = Pin->IsSelected(); bool selected = Pin->IsSelected();
......
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2013 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -804,8 +804,9 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -804,8 +804,9 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
SaveCopyInUndoList( m_component ); SaveCopyInUndoList( m_component );
GlobalSetPins( &dc, (LIB_PIN*) m_drawItem, id ); GlobalSetPins( (LIB_PIN*) m_drawItem, id );
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
m_canvas->Refresh();
break; break;
case ID_POPUP_ZOOM_BLOCK: case ID_POPUP_ZOOM_BLOCK:
......
...@@ -585,7 +585,22 @@ public: ...@@ -585,7 +585,22 @@ public:
virtual bool HandleBlockEnd( wxDC* DC ); virtual bool HandleBlockEnd( wxDC* DC );
void PlacePin( wxDC* DC ); void PlacePin( wxDC* DC );
void GlobalSetPins( wxDC* DC, LIB_PIN* MasterPin, int id );
/**
* Function GlobalSetPins
* @param aMasterPin is the "template" pin
* @param aId is a param to select what should be mofified:
* - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
* Change pins text name size
* - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
* Change pins text num size
* - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
* Change pins length.
*
* If aMasterPin is selected ( .m_flag == IS_SELECTED ),
* only the other selected pins are modified
*/
void GlobalSetPins( LIB_PIN* aMasterPin, int aId );
// Automatic placement of pins // Automatic placement of pins
void RepeatPinItem( wxDC* DC, LIB_PIN* Pin ); void RepeatPinItem( wxDC* DC, LIB_PIN* Pin );
......
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2013 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
......
...@@ -159,7 +159,6 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event ) ...@@ -159,7 +159,6 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
pin->SetFlags( item_flags ); pin->SetFlags( item_flags );
} }
/** /**
* Clean up after aborting a move pin command. * Clean up after aborting a move pin command.
*/ */
...@@ -467,58 +466,60 @@ void LIB_EDIT_FRAME::CreateImagePins( LIB_PIN* aPin, int aUnit, int aConvert, bo ...@@ -467,58 +466,60 @@ void LIB_EDIT_FRAME::CreateImagePins( LIB_PIN* aPin, int aUnit, int aConvert, bo
} }
/* Depending on "id": /* aMasterPin is the "template" pin
* - Change pin text size (name or num) (range 10 .. 1000 mil) * aId is a param to select what should be mofified:
* - Change pin length. * - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
* Change pins text name size
* - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
* Change pins text num size
* - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
* Change pins length.
* *
* If Pin is selected ( .m_flag == IS_SELECTED ) only the other selected * If aMasterPin is selected ( .m_flag == IS_SELECTED ),
* pins are modified * only the other selected pins are modified
*/ */
void LIB_EDIT_FRAME::GlobalSetPins( wxDC* DC, LIB_PIN* MasterPin, int id ) void LIB_EDIT_FRAME::GlobalSetPins( LIB_PIN* aMasterPin, int aId )
{ {
LIB_PIN* Pin; bool selected = aMasterPin->IsSelected();
bool selected = MasterPin->IsSelected();
bool showPinText = true;
if( ( m_component == NULL ) || ( MasterPin == NULL ) ) if( ( m_component == NULL ) || ( aMasterPin == NULL ) )
return; return;
if( MasterPin->Type() != LIB_PIN_T ) if( aMasterPin->Type() != LIB_PIN_T )
return; return;
OnModify( ); OnModify( );
Pin = m_component->GetNextPin(); LIB_PIN* pin = m_component->GetNextPin();
for( ; Pin != NULL; Pin = m_component->GetNextPin( Pin ) ) for( ; pin != NULL; pin = m_component->GetNextPin( pin ) )
{ {
if( ( Pin->GetConvert() ) && ( Pin->GetConvert() != m_convert ) ) if( ( pin->GetConvert() ) && ( pin->GetConvert() != m_convert ) )
continue; continue;
// Is it the "selected mode" ? // Is it the "selected mode" ?
if( selected && !Pin->IsSelected() ) if( selected && !pin->IsSelected() )
continue; continue;
Pin->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, &showPinText, DefaultTransform ); switch( aId )
switch( id )
{ {
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM: case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM:
Pin->SetNumberTextSize( MasterPin->GetNumberTextSize() ); pin->SetNumberTextSize( aMasterPin->GetNumberTextSize() );
break; break;
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM: case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
Pin->SetNameTextSize( MasterPin->GetNameTextSize() ); pin->SetNameTextSize( aMasterPin->GetNameTextSize() );
break; break;
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM: case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
Pin->SetLength( MasterPin->GetLength() ); pin->SetLength( aMasterPin->GetLength() );
break; break;
} }
Pin->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, GR_DEFAULT_DRAWMODE, &showPinText, // Clear the flag IS_CHANGED, which was set by previous changes (if any)
DefaultTransform ); // but not used here.
pin->ClearFlags( IS_CHANGED );
} }
} }
......
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2008-2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2013 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment