diff --git a/eeschema/lib_draw_item.h b/eeschema/lib_draw_item.h index 70aeeb5b26..bc73233c36 100644 --- a/eeschema/lib_draw_item.h +++ b/eeschema/lib_draw_item.h @@ -398,7 +398,7 @@ public: * * @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; } diff --git a/eeschema/libedit.cpp b/eeschema/libedit.cpp index 7fca9df69f..c2c903a2d4 100644 --- a/eeschema/libedit.cpp +++ b/eeschema/libedit.cpp @@ -1,9 +1,9 @@ /* * 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) 2008-2011 Wayne Stambaugh - * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2008-2013 Wayne Stambaugh + * 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 diff --git a/eeschema/libedit_onleftclick.cpp b/eeschema/libedit_onleftclick.cpp index 3ba219fa72..f4bfc1c81d 100644 --- a/eeschema/libedit_onleftclick.cpp +++ b/eeschema/libedit_onleftclick.cpp @@ -1,9 +1,9 @@ /* * 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) 2010 Wayne Stambaugh - * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2013 Wayne Stambaugh + * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.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 @@ -40,7 +40,10 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) { 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 ! return; @@ -63,7 +66,8 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) switch( GetToolId() ) { 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() ) { @@ -80,13 +84,9 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) case ID_LIBEDIT_PIN_BUTT: if( no_item_edited ) - { CreatePin( DC ); - } else - { PlacePin( DC ); - } break; case ID_LIBEDIT_BODY_LINE_BUTT: @@ -95,9 +95,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) case ID_LIBEDIT_BODY_RECT_BUTT: case ID_LIBEDIT_BODY_TEXT_BUTT: if( no_item_edited ) - { m_drawItem = CreateGraphicItem( m_component, DC ); - } else if( m_drawItem ) { if( m_drawItem->IsNew() ) diff --git a/eeschema/libedit_onrightclick.cpp b/eeschema/libedit_onrightclick.cpp index 1b8ffb9ab9..5758a6251f 100644 --- a/eeschema/libedit_onrightclick.cpp +++ b/eeschema/libedit_onrightclick.cpp @@ -1,8 +1,29 @@ /** * @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 @@ -247,7 +268,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) return true; } - +// Add menu items for pin edition void AddMenusForPin( wxMenu* PopMenu, LIB_PIN* Pin, LIB_EDIT_FRAME* frame ) { bool selected = Pin->IsSelected(); diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index 2ccd893c9b..48b976cf09 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -1,9 +1,9 @@ /* * 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) 2008-2011 Wayne Stambaugh - * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2008-2013 Wayne Stambaugh + * 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 @@ -804,8 +804,9 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; SaveCopyInUndoList( m_component ); - GlobalSetPins( &dc, (LIB_PIN*) m_drawItem, id ); + GlobalSetPins( (LIB_PIN*) m_drawItem, id ); m_canvas->MoveCursorToCrossHair(); + m_canvas->Refresh(); break; case ID_POPUP_ZOOM_BLOCK: diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index 329a3b018c..d8358874a6 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -585,7 +585,22 @@ public: virtual bool HandleBlockEnd( 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 void RepeatPinItem( wxDC* DC, LIB_PIN* Pin ); diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index 8bb813179b..c5f3775f37 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -1,9 +1,9 @@ /* * 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) 2008-2011 Wayne Stambaugh - * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2008-2013 Wayne Stambaugh + * 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 diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index 5573323e84..cfd2136ae4 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -159,7 +159,6 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event ) pin->SetFlags( item_flags ); } - /** * 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 } -/* Depending on "id": - * - Change pin text size (name or num) (range 10 .. 1000 mil) - * - Change pin length. +/* aMasterPin is the "template" pin + * 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 Pin is selected ( .m_flag == IS_SELECTED ) only the other selected - * pins are modified + * If aMasterPin is selected ( .m_flag == IS_SELECTED ), + * 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 = MasterPin->IsSelected(); - bool showPinText = true; + bool selected = aMasterPin->IsSelected(); - if( ( m_component == NULL ) || ( MasterPin == NULL ) ) + if( ( m_component == NULL ) || ( aMasterPin == NULL ) ) return; - if( MasterPin->Type() != LIB_PIN_T ) + if( aMasterPin->Type() != LIB_PIN_T ) return; 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; // Is it the "selected mode" ? - if( selected && !Pin->IsSelected() ) + if( selected && !pin->IsSelected() ) continue; - Pin->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, &showPinText, DefaultTransform ); - - switch( id ) + switch( aId ) { case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM: - Pin->SetNumberTextSize( MasterPin->GetNumberTextSize() ); + pin->SetNumberTextSize( aMasterPin->GetNumberTextSize() ); break; case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM: - Pin->SetNameTextSize( MasterPin->GetNameTextSize() ); + pin->SetNameTextSize( aMasterPin->GetNameTextSize() ); break; case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM: - Pin->SetLength( MasterPin->GetLength() ); + pin->SetLength( aMasterPin->GetLength() ); break; } - Pin->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, GR_DEFAULT_DRAWMODE, &showPinText, - DefaultTransform ); + // Clear the flag IS_CHANGED, which was set by previous changes (if any) + // but not used here. + pin->ClearFlags( IS_CHANGED ); } } diff --git a/include/base_struct.h b/include/base_struct.h index 993201504a..68f983ccba 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -1,9 +1,10 @@ /* * 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) 2008-2011 Wayne Stambaugh - * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2008-2013 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 2008-2013 Wayne Stambaugh + * 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