diff --git a/common/sch_item_struct.cpp b/common/sch_item_struct.cpp index 55c6ba5752..9b5dd61749 100644 --- a/common/sch_item_struct.cpp +++ b/common/sch_item_struct.cpp @@ -1,6 +1,31 @@ -/************************/ -/* sch_item_struct.cpp */ -/************************/ +/* + * 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) 2011 Wayne Stambaugh + * Copyright (C) 1992-2011 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 + * 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 + */ + +/** + * @file sch_item_struct.cpp + */ #include "fctsys.h" #include "common.h" @@ -52,12 +77,6 @@ SCH_ITEM::~SCH_ITEM() } -/** - * place the struct in m_drawList. - * if it is a new item, it it also put in undo list - * for an "old" item, saving it in undo list must be done before editing, - * and not here! - */ void SCH_ITEM::Place( SCH_EDIT_FRAME* aFrame, wxDC* aDC ) { SCH_SCREEN* screen = aFrame->GetScreen(); @@ -70,6 +89,10 @@ void SCH_ITEM::Place( SCH_EDIT_FRAME* aFrame, wxDC* aDC ) aFrame->SetRepeatItem( this ); aFrame->SaveCopyInUndoList( this, UR_NEW ); } + else + { + aFrame->SaveUndoItemInUndoList( this ); + } m_Flags = 0; screen->SetModify(); diff --git a/eeschema/backanno.cpp b/eeschema/backanno.cpp index 08fd2adbc3..2fe48ede71 100644 --- a/eeschema/backanno.cpp +++ b/eeschema/backanno.cpp @@ -1,3 +1,28 @@ +/* + * 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. + * + * 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 + */ + /** * @file backanno.cpp * @brief Functions for backannotating footprint information. @@ -64,11 +89,12 @@ bool SCH_EDIT_FRAME::ProcessStuffFile( FILE* aFile, bool aSetFieldAttributeToVis * it is probably not yet initialized */ if( fpfield->m_Text.IsEmpty() - && ( fpfield->m_Pos == component->m_Pos ) ) + && ( fpfield->GetPosition() == component->GetPosition() ) ) { fpfield->m_Orient = component->GetField( VALUE )->m_Orient; - fpfield->m_Pos = component->GetField( VALUE )->m_Pos; + fpfield->SetPosition( component->GetField( VALUE )->GetPosition() ); fpfield->m_Size = component->GetField( VALUE )->m_Size; + if( fpfield->m_Orient == 0 ) fpfield->m_Pos.y += 100; else diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 11f126ca56..abf6bcc550 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -1,3 +1,28 @@ +/* + * 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. + * + * 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 + */ + /** * @file bus-wire-junction.cpp * @brief Code for editing buses, wires, and junctions. @@ -436,6 +461,60 @@ void SCH_EDIT_FRAME::DeleteCurrentSegment( wxDC* DC ) } +static void moveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) +{ + SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen(); + SCH_ITEM* item = screen->GetCurItem(); + + wxCHECK_RET( (item != NULL), wxT( "Cannot move invalid schematic item." ) ); + + // Erase the current item at its current position. + if( aErase ) + item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); + + item->SetPosition( screen->GetCrossHairPosition() ); + + // Draw the item item at it's new position. + item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); +} + + +static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) +{ + SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen(); + SCH_ITEM* item = screen->GetCurItem(); + SCH_EDIT_FRAME* parent = ( SCH_EDIT_FRAME* ) aPanel->GetParent(); + + parent->SetRepeatItem( NULL ); + screen->SetCurItem( NULL ); + + if( item == NULL ) /* no current item */ + return; + + if( item->IsNew() ) + { + delete item; + item = NULL; + } + else // Move command on an existing text item, restore the values of the original. + { + SCH_ITEM* olditem = parent->GetUndoItem(); + screen->SetCurItem( item ); + + wxCHECK_RET( olditem != NULL && item->Type() == olditem->Type(), + wxT( "Cannot restore undefined or bad last schematic item." ) ); + + // Never delete existing item, because it can be referenced by an undo/redo command + // Just restore its data + + item->SwapData( olditem ); + item->ClearFlags(); + } + + aPanel->Refresh(); +} + + /* Routine to create new connection struct. */ SCH_JUNCTION* SCH_EDIT_FRAME::AddJunction( wxDC* aDC, const wxPoint& aPosition, @@ -460,6 +539,29 @@ SCH_JUNCTION* SCH_EDIT_FRAME::AddJunction( wxDC* aDC, const wxPoint& aPosition, } +void SCH_EDIT_FRAME::MoveItem( SCH_ITEM* aItem, wxDC* aDC ) +{ + wxCHECK_RET( aItem != NULL, wxT( "Cannot move invalid schematic item" ) ); + + m_itemToRepeat = NULL; + + if( !aItem->IsNew() ) + SetUndoItem( aItem ); + + aItem->SetFlags( IS_MOVED ); + + DrawPanel->CrossHairOff( aDC ); + GetScreen()->SetCrossHairPosition( aItem->GetPosition() ); + DrawPanel->MoveCursorToCrossHair(); + + OnModify(); + DrawPanel->SetMouseCapture( moveItem, abortMoveItem ); + GetScreen()->SetCurItem( aItem ); + moveItem( DrawPanel, aDC, wxDefaultPosition, true ); + DrawPanel->CrossHairOn( aDC ); +} + + SCH_NO_CONNECT* SCH_EDIT_FRAME::AddNoConnect( wxDC* aDC, const wxPoint& aPosition ) { SCH_NO_CONNECT* NewNoConnect; @@ -517,12 +619,12 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC ) if( m_itemToRepeat->Type() == SCH_COMPONENT_T ) // If repeat component then put in move mode { wxPoint pos = GetScreen()->GetCrossHairPosition() - - ( (SCH_COMPONENT*) m_itemToRepeat )->m_Pos; + ( (SCH_COMPONENT*) m_itemToRepeat )->GetPosition(); m_itemToRepeat->SetFlags( IS_NEW ); ( (SCH_COMPONENT*) m_itemToRepeat )->m_TimeStamp = GetTimeStamp(); m_itemToRepeat->Move( pos ); m_itemToRepeat->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode ); - StartMovePart( (SCH_COMPONENT*) m_itemToRepeat, DC ); + MoveItem( m_itemToRepeat, DC ); return; } @@ -541,4 +643,3 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC ) m_itemToRepeat->ClearFlags(); } } - diff --git a/eeschema/busentry.cpp b/eeschema/busentry.cpp index c5f511bcb9..bd76f89f5f 100644 --- a/eeschema/busentry.cpp +++ b/eeschema/busentry.cpp @@ -1,3 +1,28 @@ +/* + * 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. + * + * 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 + */ + /** * @file busentry.cpp * @brief Code to handle manipulation of bus entry objects. @@ -16,55 +41,6 @@ static int s_LastShape = '\\'; -static wxPoint ItemInitialPosition; - - -static void ExitBusEntry( EDA_DRAW_PANEL* Panel, wxDC* DC ) -{ - /* Exit bus entry mode. */ - SCH_BUS_ENTRY* BusEntry = (SCH_BUS_ENTRY*) Panel->GetScreen()->GetCurItem(); - - if( BusEntry ) - { - BusEntry->Draw( Panel, DC, wxPoint( 0, 0 ), g_XorMode ); - - if( BusEntry->IsNew() ) - { - delete BusEntry; - Panel->GetScreen()->SetCurItem( NULL ); - } - else - { - BusEntry->m_Pos = ItemInitialPosition; - BusEntry->Draw( Panel, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); - BusEntry->m_Flags = 0; - } - } - - SCH_EDIT_FRAME* parent = ( SCH_EDIT_FRAME* ) Panel->GetParent(); - - parent->SetRepeatItem( NULL ); -} - - -static void ShowWhileMoving( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, - bool aErase ) -{ - // Draws the bus entry while moving the cursor - BASE_SCREEN* screen = aPanel->GetScreen(); - SCH_BUS_ENTRY* BusEntry = (SCH_BUS_ENTRY*) screen->GetCurItem(); - - if( BusEntry == NULL ) - return; - - /* Erase the last segment position. */ - if( aErase ) - BusEntry->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); - - /* Redraw at the new position. */ - BusEntry->m_Pos = screen->GetCrossHairPosition(); - BusEntry->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); -} SCH_BUS_ENTRY* SCH_EDIT_FRAME::CreateBusEntry( wxDC* DC, int entry_type ) @@ -79,30 +55,6 @@ SCH_BUS_ENTRY* SCH_EDIT_FRAME::CreateBusEntry( wxDC* DC, int entry_type ) } -void SCH_EDIT_FRAME::StartMoveBusEntry( SCH_BUS_ENTRY* BusEntry, wxDC* DC ) -{ - if( BusEntry == NULL ) - return; - - if( !BusEntry->IsNew() ) // not already in edit, save shape - SetUndoItem( BusEntry ); - - BusEntry->SetFlags( IS_MOVED ); - - ItemInitialPosition = BusEntry->m_Pos; - - DrawPanel->CrossHairOff( DC ); - GetScreen()->SetCrossHairPosition( BusEntry->m_Pos ); - DrawPanel->MoveCursorToCrossHair(); - - GetScreen()->SetCurItem( BusEntry ); - DrawPanel->m_mouseCaptureCallback = ShowWhileMoving; - DrawPanel->m_endMouseCaptureCallback = ExitBusEntry; - - DrawPanel->CrossHairOn( DC ); -} - - /* set the shape of BusEntry (shape = / or \ ) */ void SCH_EDIT_FRAME::SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY* BusEntry, int entry_shape ) @@ -147,5 +99,6 @@ int SCH_EDIT_FRAME::GetBusEntryShape( SCH_BUS_ENTRY* BusEntry ) if( BusEntry->m_Size.y < 0 ) entry_shape = '/'; + return entry_shape; } diff --git a/eeschema/component_references_lister.cpp b/eeschema/component_references_lister.cpp index 35e7042b50..71c60b8ad7 100644 --- a/eeschema/component_references_lister.cpp +++ b/eeschema/component_references_lister.cpp @@ -669,7 +669,7 @@ SCH_REFERENCE::SCH_REFERENCE( SCH_COMPONENT* aComponent, LIB_COMPONENT* aLibComp m_IsNew = false; m_Flag = 0; m_TimeStamp = aComponent->m_TimeStamp; - m_CmpPos = aComponent->m_Pos; + m_CmpPos = aComponent->GetPosition(); m_SheetNum = 0; if( aComponent->GetRef( &aSheetPath ).IsEmpty() ) diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index c38632aa86..49fd703934 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -1,6 +1,31 @@ -/****************/ -/* controle.cpp */ -/****************/ +/* + * 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. + * + * 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 + */ + +/** + * eeschema/controle.cpp + */ #include "fctsys.h" #include "gr_basic.h" @@ -106,7 +131,6 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, const KICAD_T aF else if( m_collectedItems.GetCount() == 1 ) { item = m_collectedItems[0]; - GetScreen()->SetCurItem( item ); } else { @@ -121,7 +145,6 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, const KICAD_T aF || m_collectedItems.IsDraggableJunction() ) { item = m_collectedItems[0]; - GetScreen()->SetCurItem( item ); } default: ; @@ -155,6 +178,8 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, const KICAD_T aF } } + GetScreen()->SetCurItem( item ); + if( item ) item->DisplayInfo( this ); else diff --git a/eeschema/dialogs/dialog_build_BOM.cpp b/eeschema/dialogs/dialog_build_BOM.cpp index 4f301c7250..50c20bcced 100644 --- a/eeschema/dialogs/dialog_build_BOM.cpp +++ b/eeschema/dialogs/dialog_build_BOM.cpp @@ -730,11 +730,11 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f, { #if defined(KICAD_GOST) strCur.Printf( wxT( "%c%s" ), s_ExportSeparatorSymbol, GetChars( msg ) ); - msg = m_Parent->GetXYSheetReferences( screen, comp->m_Pos ); + msg = m_Parent->GetXYSheetReferences( screen, comp->GetPosition() ); strCur.Printf( wxT( "%c%s)" ), s_ExportSeparatorSymbol, GetChars( msg ) ); #else fprintf( f, "%c%s", s_ExportSeparatorSymbol, TO_UTF8( msg ) ); - msg = m_Parent->GetXYSheetReferences( screen, comp->m_Pos ); + msg = m_Parent->GetXYSheetReferences( screen, comp->GetPosition() ); fprintf( f, "%c%s)", s_ExportSeparatorSymbol, TO_UTF8( msg ) ); #endif @@ -742,7 +742,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( FILE* f, else { fprintf( f, " (Sheet %s)", TO_UTF8( msg ) ); - msg = m_Parent->GetXYSheetReferences( screen, comp->m_Pos ); + msg = m_Parent->GetXYSheetReferences( screen, comp->GetPosition() ); fprintf( f, " (loc %s)", TO_UTF8( msg ) ); } } @@ -1017,7 +1017,7 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal( FILE* f, { msg = aList[ii].GetSheetPath().PathHumanReadable(); fprintf( f, " (Sheet %s)", TO_UTF8( msg ) ); - msg = m_Parent->GetXYSheetReferences( screen, DrawLibItem->m_Pos ); + msg = m_Parent->GetXYSheetReferences( screen, DrawLibItem->GetPosition() ); fprintf( f, " (loc %s)", TO_UTF8( msg ) ); } } diff --git a/eeschema/edit_bitmap.cpp b/eeschema/edit_bitmap.cpp index edae8db5ce..76fa2437e5 100644 --- a/eeschema/edit_bitmap.cpp +++ b/eeschema/edit_bitmap.cpp @@ -67,7 +67,7 @@ static void abortMoveBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) // Never delete existing item, because it can be referenced by an undo/redo command // Just restore its data - item->SwapData(olditem); + item->SwapData( olditem ); } screen->SetCurItem( item ); @@ -97,7 +97,7 @@ static void moveBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosit } // Draw the bitmap at it's new position. - image->m_Pos = screen->GetCrossHairPosition(); + image->SetPosition( screen->GetCrossHairPosition() ); image->Draw( aPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); } @@ -123,6 +123,7 @@ SCH_BITMAP* SCH_EDIT_FRAME::CreateNewImage( wxDC* aDC ) wxPoint pos = GetScreen()->GetCrossHairPosition(); SCH_BITMAP* image = new SCH_BITMAP( pos ); + if( !image->ReadImageFile( fullFilename ) ) { wxMessageBox( _( "Couldn't load image from <%s>" ), GetChars( fullFilename ) ); @@ -152,7 +153,7 @@ void SCH_EDIT_FRAME::MoveImage( SCH_BITMAP* aImageItem, wxDC* aDC ) SetUndoItem( aImageItem ); DrawPanel->CrossHairOff( aDC ); - GetScreen()->SetCrossHairPosition( aImageItem->m_Pos ); + GetScreen()->SetCrossHairPosition( aImageItem->GetPosition() ); DrawPanel->MoveCursorToCrossHair(); DrawPanel->CrossHairOn( aDC ); @@ -162,9 +163,9 @@ void SCH_EDIT_FRAME::MoveImage( SCH_BITMAP* aImageItem, wxDC* aDC ) void SCH_EDIT_FRAME::RotateImage( SCH_BITMAP* aItem ) { if( aItem->GetFlags( ) == 0 ) - SaveCopyInUndoList( aItem, UR_ROTATED, aItem->m_Pos ); + SaveCopyInUndoList( aItem, UR_ROTATED, aItem->GetPosition() ); - aItem->Rotate( aItem->m_Pos ); + aItem->Rotate( aItem->GetPosition() ); OnModify(); DrawPanel->Refresh(); } @@ -175,9 +176,9 @@ void SCH_EDIT_FRAME::MirrorImage( SCH_BITMAP* aItem, bool Is_X_axis ) SaveCopyInUndoList( aItem, UR_CHANGED ); if( Is_X_axis ) - aItem->Mirror_X( aItem->m_Pos.y ); + aItem->Mirror_X( aItem->GetPosition().y ); else - aItem->Mirror_Y( aItem->m_Pos.x ); + aItem->Mirror_Y( aItem->GetPosition().x ); OnModify(); DrawPanel->Refresh(); @@ -192,6 +193,7 @@ void SCH_EDIT_FRAME::EditImage( SCH_BITMAP* aItem ) if( aItem->GetFlags( ) == 0 ) SaveCopyInUndoList( aItem, UR_CHANGED ); + dlg.TransfertToImage(aItem->m_Image); OnModify(); DrawPanel->Refresh(); diff --git a/eeschema/edit_component_in_schematic.cpp b/eeschema/edit_component_in_schematic.cpp index 3abd947bd3..860dafdb52 100644 --- a/eeschema/edit_component_in_schematic.cpp +++ b/eeschema/edit_component_in_schematic.cpp @@ -1,3 +1,28 @@ +/* + * 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. + * + * 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 + */ + /** * @file edit_component_in_schematic.cpp * @brief Schematic component editing code. @@ -38,7 +63,7 @@ static void moveField( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPositi currentField->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); } - pos = ( (SCH_COMPONENT*) currentField->GetParent() )->m_Pos; + pos = ( (SCH_COMPONENT*) currentField->GetParent() )->GetPosition(); // Actual positions are calculated by the rotation/mirror transform // But here we want the relative position of the moved field @@ -47,7 +72,7 @@ static void moveField( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPositi wxPoint pt( screen->GetCrossHairPosition() - pos ); TRANSFORM itrsfm = component->GetTransform().InverseTransform(); - currentField->m_Pos = pos + itrsfm.TransformCoordinate( pt ); + currentField->SetPosition( pos + itrsfm.TransformCoordinate( pt ) ); currentField->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); } @@ -84,7 +109,7 @@ void SCH_EDIT_FRAME::MoveField( SCH_FIELD* aField, wxDC* aDC ) GetScreen()->SetCurItem( aField ); SetUndoItem( comp ); - pos = comp->m_Pos; + pos = comp->GetPosition(); /* Positions are computed by the rotation/mirror transform. */ newpos = aField->m_Pos - pos; @@ -174,7 +199,7 @@ create a new power component with the new value." ), GetChars( entry->GetName() { if( aField->m_Text.IsEmpty() ) // Means the field was not already in use { - aField->m_Pos = component->m_Pos; + aField->m_Pos = component->GetPosition(); aField->m_Size.x = aField->m_Size.y = m_TextFieldSize; } diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 4cece27fa5..d5fd510197 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -1,3 +1,28 @@ +/* + * 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. + * + * 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 + */ + /** * @file edit_label.cpp * @brief Label, global label and text creation and editing. @@ -24,83 +49,6 @@ static bool lastTextBold = false; static bool lastTextItalic = false; -static void moveText( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) -{ - SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen(); - SCH_TEXT* textItem = (SCH_TEXT*) screen->GetCurItem(); - - wxCHECK_RET( (textItem != NULL) && textItem->CanIncrementLabel(), - wxT( "Cannot move invalid text type." ) ); - - // Erase the current text at its current position. - if( aErase ) - textItem->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); - - textItem->m_Pos = screen->GetCrossHairPosition(); - - // Draw the text item at it's new position. - textItem->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); -} - - -static void abortMoveText( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) -{ - SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen(); - SCH_TEXT* item = (SCH_TEXT*)screen->GetCurItem(); - SCH_EDIT_FRAME* parent = ( SCH_EDIT_FRAME* ) aPanel->GetParent(); - - parent->SetRepeatItem( NULL ); - screen->SetCurItem( NULL ); - - if( item == NULL ) /* no current item */ - return; - - if( item->IsNew() ) - { - delete item; - item = NULL; - } - else // Move command on an existing text item, restore the values of the original. - { - SCH_TEXT* olditem = (SCH_TEXT* )parent->GetUndoItem(); - screen->SetCurItem( item ); - - wxCHECK_RET( olditem != NULL && item->Type() == olditem->Type(), - wxT( "Cannot restore undefined or bad last text item." ) ); - // Never delete existing item, because it can be referenced by an undo/redo command - // Just restore its data - item->SwapData(olditem); - item->ClearFlags(); - } - - aPanel->Refresh(); -} - - -void SCH_EDIT_FRAME::MoveText( SCH_TEXT* aTextItem, wxDC* aDC ) -{ - wxCHECK_RET( (aTextItem != NULL) && aTextItem->CanIncrementLabel(), - wxT( "Cannot move invalid text item" ) ); - - m_itemToRepeat = NULL; - - aTextItem->SetFlags( IS_MOVED ); - - SetUndoItem( aTextItem ); - - DrawPanel->CrossHairOff( aDC ); - GetScreen()->SetCrossHairPosition( aTextItem->m_Pos ); - DrawPanel->MoveCursorToCrossHair(); - - OnModify(); - DrawPanel->SetMouseCapture( moveText, abortMoveText ); - GetScreen()->SetCurItem( aTextItem ); - moveText( DrawPanel, aDC, wxDefaultPosition, true ); - - DrawPanel->CrossHairOn( aDC ); -} - - void SCH_EDIT_FRAME::ChangeTextOrient( SCH_TEXT* aTextItem, wxDC* aDC ) { wxCHECK_RET( (aTextItem != NULL) && aTextItem->CanIncrementLabel(), @@ -177,12 +125,12 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType ) } textItem->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); - DrawPanel->SetMouseCapture( moveText, abortMoveText ); - GetScreen()->SetCurItem( textItem ); + MoveItem( (SCH_ITEM*) textItem, aDC ); return textItem; } + /* * OnConvertTextType is a command event handler to change a text type to an other one. * The new text, label, hierarchical label, or global label is created from the old text @@ -300,13 +248,16 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent ) // and replace text with newtext PICKED_ITEMS_LIST pickList; ITEM_PICKER picker( text, UR_CHANGED ); + if( text->GetFlags() ) { // text is being edited, save initial text for undo command picker.SetLink( GetUndoItem() ); pickList.PushItem( picker ); + // the owner of undoItem is no more "this", it is now "picker": SetUndoItem( NULL ); + // save current newtext copy for undo/abort current command SetUndoItem( newtext ); } diff --git a/eeschema/eeschema_id.h b/eeschema/eeschema_id.h index 50b1743c4c..1553182532 100644 --- a/eeschema/eeschema_id.h +++ b/eeschema/eeschema_id.h @@ -1,3 +1,31 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2008 Wayne Stambaugh + * Copyright (C) 2004-2011 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 + */ + +/** + * @file eeschema_id.h + */ + #ifndef __EESCHEMA_ID_H__ #define __EESCHEMA_ID_H__ @@ -84,7 +112,6 @@ enum id_eeschema_frm ID_POPUP_SCH_RESIZE_SHEET, ID_POPUP_SCH_CLEANUP_SHEET, ID_POPUP_SCH_EDIT_SHEET_PIN, - ID_POPUP_SCH_MOVE_SHEET_PIN, ID_POPUP_IMPORT_GLABEL, ID_POPUP_SCH_GENERIC_ORIENT_CMP, ID_POPUP_SCH_GENERIC_EDIT_CMP, diff --git a/eeschema/events_called_functions_for_edit.cpp b/eeschema/events_called_functions_for_edit.cpp index 0ea3ae98eb..9edaa4872b 100644 --- a/eeschema/events_called_functions_for_edit.cpp +++ b/eeschema/events_called_functions_for_edit.cpp @@ -14,9 +14,6 @@ #include "sch_text.h" -/** Event function SCH_EDIT_FRAME::OnCopySchematicItemRequest - * duplicate the current located item - */ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event ) { SCH_ITEM * curr_item = GetScreen()->GetCurItem(); @@ -35,7 +32,7 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event ) newitem->m_TimeStamp = GetTimeStamp(); newitem->ClearAnnotation( NULL ); newitem->m_Flags = IS_NEW; - StartMovePart( newitem, &dc ); + MoveItem( (SCH_ITEM*) newitem, &dc ); /* Redraw the original part, because StartMovePart() erased * it from screen */ @@ -50,7 +47,8 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event ) { SCH_TEXT* newitem = (SCH_TEXT*) curr_item->Clone(); newitem->SetFlags( IS_NEW ); - MoveText( newitem, &dc ); + MoveItem( (SCH_ITEM*) newitem, &dc ); + /* Redraw the original part in XOR mode */ curr_item->Draw( DrawPanel, &dc, wxPoint( 0, 0 ), g_XorMode ); } diff --git a/eeschema/find.cpp b/eeschema/find.cpp index 9d285317ce..6be102b117 100644 --- a/eeschema/find.cpp +++ b/eeschema/find.cpp @@ -1,3 +1,28 @@ +/* + * 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. + * + * 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 + */ + /** * @file eeschema/find.cpp * @brief Functions for searching for a schematic item. @@ -64,14 +89,16 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event ) m_CurrentSheet->UpdateAllScreenReferences(); } - sheetFoundIn->LastScreen()->SetCrossHairPosition( lastMarker->m_Pos ); + sheetFoundIn->LastScreen()->SetCrossHairPosition( lastMarker->GetPosition() ); - RedrawScreen( lastMarker->m_Pos, warpCursor ); + RedrawScreen( lastMarker->GetPosition(), warpCursor ); wxString path = sheetFoundIn->Path(); wxString units = GetAbbreviatedUnitsLabel(); - double x = To_User_Unit( g_UserUnit, (double) lastMarker->m_Pos.x, m_InternalUnits ); - double y = To_User_Unit( g_UserUnit, (double) lastMarker->m_Pos.y, m_InternalUnits ); + double x = To_User_Unit( g_UserUnit, (double) lastMarker->GetPosition().x, + m_InternalUnits ); + double y = To_User_Unit( g_UserUnit, (double) lastMarker->GetPosition().y, + m_InternalUnits ); msg.Printf( _( "Design rule check marker found in sheet %s at %0.3f%s, %0.3f%s" ), GetChars( path ), x, GetChars( units ), y, GetChars( units) ); SetStatusText( msg ); @@ -83,21 +110,6 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event ) } -/** - * Function FindComponentAndItem - * finds a Component in the schematic, and an item in this component. - * @param component_reference The component reference to find. - * @param text_to_find - The text to search for, either in value, reference - * or elsewhere. - * @param Find_in_hierarchy: false => Search is made in current sheet - * true => the whole hierarchy - * @param SearchType: 0 => find component - * 1 => find pin - * 2 => find ref - * 3 => find value - * >= 4 => unused (same as 0) - * @param mouseWarp If true, then move the mouse cursor to the item. - */ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_reference, bool Find_in_hierarchy, int SearchType, @@ -141,11 +153,11 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere default: case 0: // Find component only NotFound = false; - pos = pSch->m_Pos; + pos = pSch->GetPosition(); break; case 1: // find a pin - pos = pSch->m_Pos; /* temporary: will be changed if the pin is found */ + pos = pSch->GetPosition(); // temporary: will be changed if the pin is found. pin = pSch->GetPin( text_to_find ); if( pin == NULL ) @@ -157,17 +169,17 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere case 2: // find reference NotFound = false; - pos = pSch->GetField( REFERENCE )->m_Pos; + pos = pSch->GetField( REFERENCE )->GetPosition(); break; case 3: // find value - pos = pSch->m_Pos; + pos = pSch->GetPosition(); if( text_to_find.CmpNoCase( pSch->GetField( VALUE )->m_Text ) != 0 ) break; NotFound = false; - pos = pSch->GetField( VALUE )->m_Pos; + pos = pSch->GetField( VALUE )->GetPosition(); break; } } @@ -189,9 +201,9 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere } wxPoint delta; - pos -= Component->m_Pos; + pos -= Component->GetPosition(); delta = Component->GetTransform().TransformCoordinate( pos ); - pos = delta + Component->m_Pos; + pos = delta + Component->GetPosition(); /* There may be need to reframe the drawing */ @@ -279,12 +291,7 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& component_refere } -/** - * Finds an item in the schematic matching the search string. - * - * @param event - Find dialog event containing the find parameters. - */ -void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& event ) +void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& aEvent ) { static SCH_ITEM* lastItem = NULL; /* last item found when searching a match * note: the actual matched item can be a @@ -296,18 +303,18 @@ void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& event ) wxString msg; SCH_SHEET_PATH* sheetFoundIn = NULL; wxFindReplaceData searchCriteria; - bool warpCursor = !( event.GetFlags() & FR_NO_WARP_CURSOR ); + bool warpCursor = !( aEvent.GetFlags() & FR_NO_WARP_CURSOR ); - searchCriteria.SetFlags( event.GetFlags() ); - searchCriteria.SetFindString( event.GetFindString() ); - searchCriteria.SetReplaceString( event.GetReplaceString() ); + searchCriteria.SetFlags( aEvent.GetFlags() ); + searchCriteria.SetFindString( aEvent.GetFindString() ); + searchCriteria.SetReplaceString( aEvent.GetReplaceString() ); - if( event.GetEventType() == wxEVT_COMMAND_FIND_CLOSE ) + if( aEvent.GetEventType() == wxEVT_COMMAND_FIND_CLOSE ) { sheetFoundIn = m_CurrentSheet; warpCursor = true; } - else if( event.GetFlags() & FR_CURRENT_SHEET_ONLY && g_RootSheet->CountSheets() > 1 ) + else if( aEvent.GetFlags() & FR_CURRENT_SHEET_ONLY && g_RootSheet->CountSheets() > 1 ) { sheetFoundIn = m_CurrentSheet; lastItem = m_CurrentSheet->MatchNextItem( searchCriteria, lastItem, &lastItemPosition ); @@ -331,12 +338,12 @@ void SCH_EDIT_FRAME::OnFindSchematicItem( wxFindDialogEvent& event ) RedrawScreen( lastItemPosition, warpCursor ); - msg = event.GetFindString() + _( " found in " ) + sheetFoundIn->PathHumanReadable(); + msg = aEvent.GetFindString() + _( " found in " ) + sheetFoundIn->PathHumanReadable(); SetStatusText( msg ); } else { - msg.Printf( _( "No item found matching %s." ), GetChars( event.GetFindString() ) ); + msg.Printf( _( "No item found matching %s." ), GetChars( aEvent.GetFindString() ) ); SetStatusText( msg ); } } diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index cfb94f73b5..e5e7ae7d05 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -1,3 +1,28 @@ +/* + * 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. + * + * 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 + */ + /** * @file getpart.cpp * @brief Cod to handle get & place library component. @@ -23,49 +48,6 @@ #include -/** - * Move a component. - */ -static void moveComponent( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, - bool aErase ) -{ - SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen(); - SCH_COMPONENT* component = (SCH_COMPONENT*) screen->GetCurItem(); - - if( aErase ) - { - component->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor ); - } - - component->Move( screen->GetCrossHairPosition() - component->m_Pos ); - component->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor ); -} - - -/* - * Abort a place component command in progress. - */ -static void abortMoveComponent( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) -{ - SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) aPanel->GetParent(); - SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen(); - SCH_COMPONENT* component = (SCH_COMPONENT*) screen->GetCurItem(); - - if( component->IsNew() ) - { - SAFE_DELETE( component ); - } - else - { - component->SwapData( (SCH_COMPONENT*) frame->GetUndoItem() ); - component->ClearFlags(); - } - - aPanel->Refresh( true ); - screen->SetCurItem( NULL ); -} - - wxString SCH_EDIT_FRAME::SelectFromLibBrowser( void ) { wxSemaphore semaphore( 0, 1 ); @@ -93,7 +75,6 @@ wxString SCH_EDIT_FRAME::SelectFromLibBrowser( void ) } - /* * load from a library and place a component * if libname != "", search in lib "libname" @@ -108,7 +89,7 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* DC, int unit = 1; int convert = 1; LIB_COMPONENT* Entry = NULL; - SCH_COMPONENT* Component = NULL; + SCH_COMPONENT* component = NULL; CMP_LIBRARY* Library = NULL; wxString Name, keys, msg; bool AllowWildSeach = true; @@ -196,6 +177,7 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* DC, { AllowWildSeach = false; Name = DataBaseGetName( this, keys, Name ); + if( Name.IsEmpty() ) { DrawPanel->m_IgnoreMouseEvents = false; @@ -236,21 +218,24 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* DC, lastCommponentName = Name; AddHistoryComponentName( HistoryList, Name ); - DrawPanel->SetMouseCapture( moveComponent, abortMoveComponent ); - Component = new SCH_COMPONENT( *Entry, GetSheet(), unit, convert, + component = new SCH_COMPONENT( *Entry, GetSheet(), unit, convert, GetScreen()->GetCrossHairPosition(), true ); + // Set the m_ChipName value, from component name in lib, for aliases // Note if Entry is found, and if Name is an alias of a component, // alias exists because its root component was found - Component->SetLibName( Name ); + component->SetLibName( Name ); // Set the component value that can differ from component name in lib, for aliases - Component->GetField( VALUE )->m_Text = Name; - Component->DisplayInfo( this ); - Component->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor ); + component->GetField( VALUE )->m_Text = Name; + component->DisplayInfo( this ); + component->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor ); + component->SetFlags( IS_NEW ); - return Component; + MoveItem( (SCH_ITEM*) component, DC ); + + return component; } @@ -435,45 +420,3 @@ void SCH_EDIT_FRAME::ConvertPart( SCH_COMPONENT* DrawComponent, wxDC* DC ) GetScreen()->TestDanglingEnds( DrawPanel, DC ); OnModify( ); } - - -void SCH_EDIT_FRAME::StartMovePart( SCH_COMPONENT* aComponent, wxDC* aDC ) -{ - wxCHECK_RET( (aComponent != NULL) && (aComponent->Type() == SCH_COMPONENT_T), - wxT( "Cannot move invalid component. Bad Programmer!" ) ); - - if( aComponent->GetFlags() == 0 ) - SetUndoItem( aComponent ); - - DrawPanel->CrossHairOff( aDC ); - GetScreen()->SetCrossHairPosition( aComponent->m_Pos ); - DrawPanel->MoveCursorToCrossHair(); - - DrawPanel->SetMouseCapture( moveComponent, abortMoveComponent ); - GetScreen()->SetCurItem( aComponent ); - -#if 1 - - // switch from normal mode to xor mode for the duration of the move, first - // by erasing fully any "normal drawing mode" primitives with the - // RefreshDrawingRect(), then by drawing the first time in xor mode so that - // subsequent xor drawing modes will fully erase this first copy. - - aComponent->SetFlags( IS_MOVED ); // omit redrawing the component, erase only - DrawPanel->RefreshDrawingRect( aComponent->GetBoundingBox() ); - - aComponent->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor ); - -#else - - aComponent->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); - - aComponent->SetFlags( IS_MOVED ); - - moveComponent( DrawPanel, aDC, false ); -#endif - - DrawPanel->m_AutoPAN_Request = true; - - DrawPanel->CrossHairOn( aDC ); -} diff --git a/eeschema/hotkeys.cpp b/eeschema/hotkeys.cpp index ae40774274..e66c6ab957 100644 --- a/eeschema/hotkeys.cpp +++ b/eeschema/hotkeys.cpp @@ -1,3 +1,28 @@ +/* + * 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. + * + * 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 + */ + /** * @file eeschema/hotkeys.cpp */ @@ -718,7 +743,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, break; - case HK_MOVE_COMPONENT_OR_ITEM: // Start move component or other schematic item + case HK_MOVE_COMPONENT_OR_ITEM: // Start move schematic item. if( itemInEdit ) break; @@ -731,47 +756,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, break; } - if( aItem->GetFlags() == 0 ) - { - switch( aItem->Type() ) - { - // select the correct event for moving an schematic object - // and add it to the event queue - case SCH_SHEET_T: - case SCH_COMPONENT_T: - case SCH_LABEL_T: - case SCH_GLOBAL_LABEL_T: - case SCH_HIERARCHICAL_LABEL_T: - case SCH_TEXT_T: - case SCH_FIELD_T: - case SCH_BUS_ENTRY_T: - case SCH_BITMAP_T: - cmd.SetId( HK_Descr->m_IdMenuEvent ); - wxPostEvent( this, cmd ); - break; - - case SCH_SHEET_PIN_T: - cmd.SetId( ID_POPUP_SCH_MOVE_SHEET_PIN ); - wxPostEvent( this, cmd ); - break; - - case SCH_LINE_T: - /** - * @todo Determine why moving bus lines are not handled here. - */ - if( ((SCH_ITEM*) aItem )->GetLayer() != LAYER_BUS ) - { - cmd.SetId( ID_POPUP_SCH_MOVE_ITEM ); - wxPostEvent( this, cmd ); - } - - break; - - default: - ; - } - } - + cmd.SetId( HK_Descr->m_IdMenuEvent ); + wxPostEvent( this, cmd ); break; case HK_EDIT: diff --git a/eeschema/onleftclick.cpp b/eeschema/onleftclick.cpp index 3a0eb52265..948ce9105e 100644 --- a/eeschema/onleftclick.cpp +++ b/eeschema/onleftclick.cpp @@ -1,3 +1,28 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2011 Wayne Stambaugh + * Copyright (C) 1992-2011 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 + * 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 + */ + /** * @file eeschema/onleftclick.cpp */ @@ -50,6 +75,7 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) case SCH_COMPONENT_T: case SCH_FIELD_T: case SCH_BITMAP_T: + case SCH_NO_CONNECT_T: item->Place( this, aDC ); GetScreen()->SetCurItem( NULL ); GetScreen()->TestDanglingEnds(); diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index 547f02abed..121256f7fb 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -1,3 +1,28 @@ +/* + * 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. + * + * 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 + */ + /** * @file eeschema/onrightclick.cpp */ @@ -77,11 +102,13 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) { if( item && item->GetFlags() ) { - AddMenuItem( PopMenu, ID_CANCEL_CURRENT_COMMAND, _( "Cancel" ), KiBitmap( cancel_xpm ) ); + AddMenuItem( PopMenu, ID_CANCEL_CURRENT_COMMAND, _( "Cancel" ), + KiBitmap( cancel_xpm ) ); } else { - AddMenuItem( PopMenu, ID_CANCEL_CURRENT_COMMAND, _( "End Tool" ), KiBitmap( cancel_tool_xpm ) ); + AddMenuItem( PopMenu, ID_CANCEL_CURRENT_COMMAND, _( "End Tool" ), + KiBitmap( cancel_tool_xpm ) ); } PopMenu->AppendSeparator(); @@ -90,7 +117,8 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) { if( item && item->GetFlags() ) { - AddMenuItem( PopMenu, ID_CANCEL_CURRENT_COMMAND, _( "Cancel" ), KiBitmap( cancel_xpm ) ); + AddMenuItem( PopMenu, ID_CANCEL_CURRENT_COMMAND, _( "Cancel" ), + KiBitmap( cancel_xpm ) ); PopMenu->AppendSeparator(); } } @@ -98,7 +126,8 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) if( item == NULL ) { if( GetSheet()->Last() != g_RootSheet ) - AddMenuItem( PopMenu, ID_POPUP_SCH_LEAVE_SHEET, _( "Leave Sheet" ), KiBitmap( leave_sheet_xpm ) ); + AddMenuItem( PopMenu, ID_POPUP_SCH_LEAVE_SHEET, _( "Leave Sheet" ), + KiBitmap( leave_sheet_xpm ) ); PopMenu->AppendSeparator(); return true; @@ -111,7 +140,8 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) { case SCH_NO_CONNECT_T: - AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete No Connect" ), KiBitmap( delete_xpm ) ); + AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete No Connect" ), + KiBitmap( delete_xpm ) ); break; case SCH_JUNCTION_T: @@ -131,7 +161,8 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) else PopMenu->Append( ID_POPUP_SCH_ENTRY_SELECT_ANTISLASH, _( "Set Bus Entry \\" ) ); - AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Bus Entry" ), KiBitmap( delete_bus_xpm ) ); + AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Bus Entry" ), + KiBitmap( delete_bus_xpm ) ); break; case SCH_MARKER_T: @@ -179,9 +210,11 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) default: if( is_new ) - AddMenuItem( PopMenu, ID_POPUP_END_LINE, _( "End Drawing" ), KiBitmap( apply_xpm ) ); + AddMenuItem( PopMenu, ID_POPUP_END_LINE, _( "End Drawing" ), + KiBitmap( apply_xpm ) ); - AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Drawing" ), KiBitmap( delete_xpm ) ); + AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Drawing" ), + KiBitmap( delete_xpm ) ); break; } break; @@ -252,8 +285,10 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component ) wxMenu* orientmenu = new wxMenu; msg = AddHotkeyName( _( "Rotate +" ), s_Schematic_Hokeys_Descr, HK_ROTATE ); - AddMenuItem( orientmenu, ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE, msg, KiBitmap( rotate_ccw_xpm ) ); - AddMenuItem( orientmenu, ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE, _( "Rotate -" ), KiBitmap( rotate_cw_xpm ) ); + AddMenuItem( orientmenu, ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE, msg, + KiBitmap( rotate_ccw_xpm ) ); + AddMenuItem( orientmenu, ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE, _( "Rotate -" ), + KiBitmap( rotate_cw_xpm ) ); msg = AddHotkeyName( _( "Mirror --" ), s_Schematic_Hokeys_Descr, HK_MIRROR_X_COMPONENT ); AddMenuItem( orientmenu, ID_POPUP_SCH_MIRROR_X_CMP, msg, KiBitmap( mirror_v_xpm ) ); msg = AddHotkeyName( _( "Mirror ||" ), s_Schematic_Hokeys_Descr, HK_MIRROR_Y_COMPONENT ); @@ -272,11 +307,13 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component ) msg = AddHotkeyName( _( "Value " ), s_Schematic_Hokeys_Descr, HK_EDIT_COMPONENT_VALUE ); AddMenuItem( editmenu, ID_POPUP_SCH_EDIT_VALUE_CMP, msg, KiBitmap( edit_comp_value_xpm ) ); - AddMenuItem( editmenu, ID_POPUP_SCH_EDIT_REF_CMP, _( "Reference" ), KiBitmap( edit_comp_ref_xpm ) ); + AddMenuItem( editmenu, ID_POPUP_SCH_EDIT_REF_CMP, _( "Reference" ), + KiBitmap( edit_comp_ref_xpm ) ); msg = AddHotkeyName( _( "Footprint " ), s_Schematic_Hokeys_Descr, HK_EDIT_COMPONENT_FOOTPRINT ); - AddMenuItem( editmenu, ID_POPUP_SCH_EDIT_FOOTPRINT_CMP, msg, KiBitmap( edit_comp_footprint_xpm ) ); + AddMenuItem( editmenu, ID_POPUP_SCH_EDIT_FOOTPRINT_CMP, msg, + KiBitmap( edit_comp_footprint_xpm ) ); } if( libComponent && libComponent->HasConversion() ) @@ -487,15 +524,18 @@ void SCH_EDIT_FRAME::addJunctionMenuEntries( wxMenu* aMenu, SCH_JUNCTION* aJunct if( !aJunction->IsNew() ) { if( m_collectedItems.IsDraggableJunction() ) - AddMenuItem( aMenu, ID_POPUP_SCH_DRAG_WIRE_REQUEST, _( "Drag Junction" ), KiBitmap( move_xpm ) ); + AddMenuItem( aMenu, ID_POPUP_SCH_DRAG_WIRE_REQUEST, _( "Drag Junction" ), + KiBitmap( move_xpm ) ); - if( screen->GetWire( aJunction->m_Pos, EXCLUDE_END_POINTS_T ) ) - AddMenuItem( aMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), KiBitmap( break_line_xpm ) ); + if( screen->GetWire( aJunction->GetPosition(), EXCLUDE_END_POINTS_T ) ) + AddMenuItem( aMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), + KiBitmap( break_line_xpm ) ); } - if( screen->GetWireOrBus( aJunction->m_Pos ) ) + if( screen->GetWireOrBus( aJunction->GetPosition() ) ) { - AddMenuItem( aMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ), KiBitmap( delete_node_xpm ) ); + AddMenuItem( aMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ), + KiBitmap( delete_node_xpm ) ); AddMenuItem( aMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ), KiBitmap( delete_connection_xpm ) ); } @@ -520,14 +560,16 @@ void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame ) PopMenu->AppendSeparator(); msg = AddHotkeyName( _( "Delete Wire" ), s_Schematic_Hokeys_Descr, HK_DELETE ); AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, msg, KiBitmap( delete_xpm ) ); - AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ), KiBitmap( delete_node_xpm ) ); + AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE_NODE, _( "Delete Node" ), + KiBitmap( delete_node_xpm ) ); AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE_CONNECTION, _( "Delete Connection" ), KiBitmap( delete_connection_xpm ) ); SCH_LINE* line = screen->GetWireOrBus( screen->GetCrossHairPosition() ); if( line && !line->IsEndPoint( screen->GetCrossHairPosition() ) ) - AddMenuItem( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), KiBitmap( break_line_xpm ) ); + AddMenuItem( PopMenu, ID_POPUP_SCH_BREAK_WIRE, _( "Break Wire" ), + KiBitmap( break_line_xpm ) ); PopMenu->AppendSeparator(); @@ -538,7 +580,8 @@ void AddMenusForWire( wxMenu* PopMenu, SCH_LINE* Wire, SCH_EDIT_FRAME* frame ) // Add global label command only if the cursor is over one end of the wire. if( ( pos == Wire->m_Start ) || ( pos == Wire->m_End ) ) - AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_GLABEL, _( "Add Global Label" ), KiBitmap( add_glabel_xpm ) ); + AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_GLABEL, _( "Add Global Label" ), + KiBitmap( add_glabel_xpm ) ); } @@ -567,7 +610,8 @@ void AddMenusForBus( wxMenu* PopMenu, SCH_LINE* Bus, SCH_EDIT_FRAME* frame ) // Add global label command only if the cursor is over one end of the bus. if( ( pos == Bus->m_Start ) || ( pos == Bus->m_End ) ) - AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_GLABEL, _( "Add Global Label" ), KiBitmap( add_glabel_xpm ) ); + AddMenuItem( PopMenu, ID_POPUP_SCH_ADD_GLABEL, _( "Add Global Label" ), + KiBitmap( add_glabel_xpm ) ); } @@ -577,7 +621,8 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet ) if( !Sheet->GetFlags() ) { - AddMenuItem( PopMenu, ID_POPUP_SCH_ENTER_SHEET, _( "Enter Sheet" ), KiBitmap( enter_sheet_xpm ) ); + AddMenuItem( PopMenu, ID_POPUP_SCH_ENTER_SHEET, _( "Enter Sheet" ), + KiBitmap( enter_sheet_xpm ) ); PopMenu->AppendSeparator(); msg = AddHotkeyName( _( "Move Sheet" ), s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT_OR_ITEM ); @@ -597,7 +642,7 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet ) AddMenuItem( PopMenu, ID_POPUP_SCH_EDIT_SHEET, msg, KiBitmap( edit_sheet_xpm ) ); AddMenuItem( PopMenu, ID_POPUP_SCH_RESIZE_SHEET, _( "Resize Sheet" ), - KiBitmap( resize_sheet_xpm ) ); + KiBitmap( resize_sheet_xpm ) ); PopMenu->AppendSeparator(); AddMenuItem( PopMenu, ID_POPUP_IMPORT_GLABEL, _( "Import Sheet Pins" ), KiBitmap( import_hierarchical_label_xpm ) ); @@ -621,13 +666,15 @@ void AddMenusForSheetPin( wxMenu* PopMenu, SCH_SHEET_PIN* PinSheet ) { msg = AddHotkeyName( _( "Move Sheet Pin" ), s_Schematic_Hokeys_Descr, HK_MOVE_COMPONENT_OR_ITEM ); - AddMenuItem( PopMenu, ID_POPUP_SCH_MOVE_SHEET_PIN, msg, KiBitmap( move_xpm ) ); + AddMenuItem( PopMenu, ID_POPUP_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) ); } - AddMenuItem( PopMenu, ID_POPUP_SCH_EDIT_SHEET_PIN, _( "Edit Sheet Pin" ), KiBitmap( edit_xpm ) ); + AddMenuItem( PopMenu, ID_POPUP_SCH_EDIT_SHEET_PIN, _( "Edit Sheet Pin" ), + KiBitmap( edit_xpm ) ); if( !PinSheet->GetFlags() ) - AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Sheet Pin" ), KiBitmap( delete_pinsheet_xpm ) ); + AddMenuItem( PopMenu, ID_POPUP_SCH_DELETE, _( "Delete Sheet Pin" ), + KiBitmap( delete_pinsheet_xpm ) ); } @@ -635,7 +682,8 @@ void AddMenusForBlock( wxMenu* PopMenu, SCH_EDIT_FRAME* frame ) { wxString msg; - AddMenuItem( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel Block" ), KiBitmap( cancel_xpm ) ); + AddMenuItem( PopMenu, ID_POPUP_CANCEL_CURRENT_COMMAND, _( "Cancel Block" ), + KiBitmap( cancel_xpm ) ); PopMenu->AppendSeparator(); @@ -654,9 +702,12 @@ void AddMenusForBlock( wxMenu* PopMenu, SCH_EDIT_FRAME* frame ) HK_MOVEBLOCK_TO_DRAGBLOCK ); AddMenuItem( PopMenu, ID_POPUP_DRAG_BLOCK, msg, KiBitmap( move_xpm ) ); AddMenuItem( PopMenu, ID_POPUP_DELETE_BLOCK, _( "Delete Block" ), KiBitmap( delete_xpm ) ); - AddMenuItem( PopMenu, ID_POPUP_MIRROR_Y_BLOCK, _( "Mirror Block ||" ), KiBitmap( mirror_h_xpm ) ); - AddMenuItem( PopMenu, ID_POPUP_MIRROR_X_BLOCK, _( "Mirror Block --" ), KiBitmap( mirror_v_xpm ) ); - AddMenuItem( PopMenu, ID_POPUP_ROTATE_BLOCK, _( "Rotate Block ccw" ), KiBitmap( rotate_ccw_xpm ) ); + AddMenuItem( PopMenu, ID_POPUP_MIRROR_Y_BLOCK, _( "Mirror Block ||" ), + KiBitmap( mirror_h_xpm ) ); + AddMenuItem( PopMenu, ID_POPUP_MIRROR_X_BLOCK, _( "Mirror Block --" ), + KiBitmap( mirror_v_xpm ) ); + AddMenuItem( PopMenu, ID_POPUP_ROTATE_BLOCK, _( "Rotate Block ccw" ), + KiBitmap( rotate_ccw_xpm ) ); #if 0 #ifdef __WINDOWS__ @@ -671,7 +722,8 @@ void AddMenusForBlock( wxMenu* PopMenu, SCH_EDIT_FRAME* frame ) void AddMenusForMarkers( wxMenu* aPopMenu, SCH_MARKER* aMarker, SCH_EDIT_FRAME* aFrame ) { AddMenuItem( aPopMenu, ID_POPUP_SCH_DELETE, _( "Delete Marker" ), KiBitmap( delete_xpm ) ); - AddMenuItem( aPopMenu, ID_POPUP_SCH_GETINFO_MARKER, _( "Marker Error Info" ), KiBitmap( info_xpm ) ); + AddMenuItem( aPopMenu, ID_POPUP_SCH_GETINFO_MARKER, _( "Marker Error Info" ), + KiBitmap( info_xpm ) ); } void AddMenusForBitmap( wxMenu* aPopMenu, SCH_BITMAP * aBitmap ) @@ -680,16 +732,16 @@ void AddMenusForBitmap( wxMenu* aPopMenu, SCH_BITMAP * aBitmap ) if( aBitmap->GetFlags() == 0 ) { msg = AddHotkeyName( _( "Move Image" ), s_Schematic_Hokeys_Descr, - HK_MOVE_COMPONENT_OR_ITEM ); + HK_MOVE_COMPONENT_OR_ITEM ); AddMenuItem( aPopMenu, ID_POPUP_SCH_MOVE_ITEM, msg, KiBitmap( move_xpm ) ); } msg = AddHotkeyName( _( "Rotate Image" ), s_Schematic_Hokeys_Descr, HK_ROTATE ); AddMenuItem( aPopMenu, ID_POPUP_SCH_ROTATE_IMAGE, msg, KiBitmap( rotate_ccw_xpm ) ); AddMenuItem( aPopMenu, ID_POPUP_SCH_MIRROR_X_IMAGE, - _( "Mirror --" ), KiBitmap( mirror_v_xpm ) ); + _( "Mirror --" ), KiBitmap( mirror_v_xpm ) ); AddMenuItem( aPopMenu, ID_POPUP_SCH_MIRROR_Y_IMAGE, - _( "Mirror ||" ), KiBitmap( mirror_h_xpm ) ); + _( "Mirror ||" ), KiBitmap( mirror_h_xpm ) ); if( aBitmap->GetFlags() == 0 ) { diff --git a/eeschema/sch_bitmap.cpp b/eeschema/sch_bitmap.cpp index 92a438bfda..acc92403a5 100644 --- a/eeschema/sch_bitmap.cpp +++ b/eeschema/sch_bitmap.cpp @@ -1,7 +1,3 @@ -/** - * @file sch_bitmap.cpp - */ - /* * This program source code file is part of KiCad, a free EDA CAD application. * @@ -26,6 +22,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +/** + * @file sch_bitmap.cpp + */ + #include "fctsys.h" #include "gr_basic.h" #include "macros.h" @@ -101,33 +101,6 @@ bool SCH_BITMAP::Save( FILE* aFile ) const } -void SCH_BITMAP::Place( SCH_EDIT_FRAME* frame, wxDC* DC ) -{ - if( !IsNew() ) - { - // save old bitmap in undo list - ClearFlags(); - SCH_ITEM* undoItem = frame->GetUndoItem(); - - wxCHECK_RET( undoItem != NULL && undoItem->Type() == Type(), - wxT( "Invalid bitmap undo item." ) ); - - undoItem->ClearFlags(); - PICKED_ITEMS_LIST pickList; - ITEM_PICKER picker( this, UR_CHANGED ); - picker.SetLink( undoItem ); - - // the owner of undoItem is no more frame, this is picker: - frame->SetUndoItem( NULL ); - - pickList.PushItem( picker ); - frame->SaveCopyInUndoList( pickList, UR_CHANGED ); - } - - SCH_ITEM::Place( frame, DC ); // For new items insert in draw list and in undo list -} - - EDA_ITEM* SCH_BITMAP::doClone() const { return new SCH_BITMAP( *this ); @@ -137,8 +110,8 @@ EDA_ITEM* SCH_BITMAP::doClone() const void SCH_BITMAP::SwapData( SCH_ITEM* aItem ) { wxCHECK_RET( aItem->Type() == SCH_BITMAP_T, - wxString::Format( wxT( "SCH_BITMAP object cannot swap data with %s object." ), - GetChars( aItem->GetClass() ) ) ); + wxString::Format( wxT( "SCH_BITMAP object cannot swap data with %s object." ), + GetChars( aItem->GetClass() ) ) ); SCH_BITMAP* item = (SCH_BITMAP*) aItem; EXCHG( m_Pos, item->m_Pos ); @@ -153,7 +126,7 @@ bool SCH_BITMAP::Load( LINE_READER& aLine, wxString& aErrorMsg ) if( strnicmp( line, "$Bitmap", 7 ) != 0 ) { aErrorMsg.Printf( wxT( "Eeschema file bitmap image load error at line %d, aborted" ), - aLine.LineNumber() ); + aLine.LineNumber() ); aErrorMsg << wxT( "\n" ) << FROM_UTF8( (char*) aLine ); return false; } diff --git a/eeschema/sch_bitmap.h b/eeschema/sch_bitmap.h index 05f2bcedd9..2bc43a2625 100644 --- a/eeschema/sch_bitmap.h +++ b/eeschema/sch_bitmap.h @@ -1,8 +1,3 @@ -/** - * @file sch_bitmap.h - * - */ - /* * This program source code file is part of KiCad, a free EDA CAD application. * @@ -27,6 +22,11 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +/** + * @file sch_bitmap.h + * + */ + #ifndef _SCH_BITMAP_H_ #define _SCH_BITMAP_H_ @@ -37,12 +37,14 @@ class SCH_BITMAP : public SCH_ITEM { -public: wxPoint m_Pos; // XY coordinates of center of the bitmap + +public: BITMAP_BASE* m_Image; // the BITMAP_BASE item -public: SCH_BITMAP( const wxPoint& pos = wxPoint( 0, 0 ) ); +public: + SCH_BITMAP( const wxPoint& pos = wxPoint( 0, 0 ) ); SCH_BITMAP( const SCH_BITMAP& aSchBitmap ); @@ -102,8 +104,6 @@ public: SCH_BITMAP( const wxPoint& pos = wxPoint( 0, 0 ) ); virtual void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, int aDrawMode, int aColor = -1 ); - virtual void Place( SCH_EDIT_FRAME* frame, wxDC* DC ); - /** * Function ReadImageFile * Reads and stores an image file. Init the bitmap used to draw this item @@ -166,9 +166,8 @@ public: SCH_BITMAP( const wxPoint& pos = wxPoint( 0, 0 ) ); virtual BITMAP_DEF GetMenuImage() const { return image_xpm; } - #if defined(DEBUG) +#if defined(DEBUG) void Show( int nestLevel, std::ostream& os ); - #endif private: @@ -177,6 +176,8 @@ private: virtual bool doIsConnected( const wxPoint& aPosition ) const; virtual EDA_ITEM* doClone() const; virtual void doPlot( PLOTTER* aPlotter ); + virtual wxPoint doGetPosition() const { return m_Pos; } + virtual void doSetPosition( const wxPoint& aPosition ) { m_Pos = aPosition; } }; diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index e71c51df6d..2192de443c 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -56,6 +56,18 @@ wxPoint SCH_BUS_ENTRY::m_End() const } +void SCH_BUS_ENTRY::SwapData( SCH_ITEM* aItem ) +{ + wxCHECK_RET( (aItem != NULL) && (aItem->Type() == SCH_BUS_ENTRY_T), + wxT( "Cannot swap bus entry data with invalid item." ) ); + + SCH_BUS_ENTRY* item = (SCH_BUS_ENTRY*)aItem; + EXCHG( m_Pos, item->m_Pos ); + EXCHG( m_Size, item->m_Size ); + EXCHG( m_Width, item->m_Width ); +} + + bool SCH_BUS_ENTRY::Save( FILE* aFile ) const { bool success = true; diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h index cf4a2b00e1..c2a96c03a8 100644 --- a/eeschema/sch_bus_entry.h +++ b/eeschema/sch_bus_entry.h @@ -1,3 +1,28 @@ +/* + * 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. + * + * 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 + */ + /** * @file sch_bus_entry.h * @@ -21,9 +46,10 @@ */ class SCH_BUS_ENTRY : public SCH_ITEM { + wxPoint m_Pos; + public: int m_Width; - wxPoint m_Pos; wxSize m_Size; public: @@ -40,6 +66,8 @@ public: wxPoint m_End() const; + virtual void SwapData( SCH_ITEM* aItem ); + virtual void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, int aDrawMode, int aColor = -1 ); @@ -116,6 +144,8 @@ private: virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const; virtual EDA_ITEM* doClone() const; virtual void doPlot( PLOTTER* aPlotter ); + virtual wxPoint doGetPosition() const { return m_Pos; } + virtual void doSetPosition( const wxPoint& aPosition ) { m_Pos = aPosition; } }; diff --git a/eeschema/sch_collectors.cpp b/eeschema/sch_collectors.cpp index 93d4dc9819..958a026a1e 100644 --- a/eeschema/sch_collectors.cpp +++ b/eeschema/sch_collectors.cpp @@ -90,7 +90,7 @@ const KICAD_T SCH_COLLECTOR::EditableItems[] = { const KICAD_T SCH_COLLECTOR::MovableItems[] = { SCH_MARKER_T, -// SCH_JUNCTION_T, + SCH_JUNCTION_T, SCH_NO_CONNECT_T, SCH_BUS_ENTRY_T, // SCH_LINE_T, @@ -188,7 +188,7 @@ SEARCH_RESULT SCH_COLLECTOR::Inspect( EDA_ITEM* aItem, const void* aTestData ) // schematic. The hit test position must be converted to library coordinates. SCH_COMPONENT* component = (SCH_COMPONENT*) aTestData; TRANSFORM transform = component->GetTransform().InverseTransform(); - wxPoint position = transform.TransformCoordinate( m_RefPos - component->m_Pos ); + wxPoint position = transform.TransformCoordinate( m_RefPos - component->GetPosition() ); position.y *= -1; // Y axis polarity in schematic is inverted from library. diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 86329977af..f913a66e61 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -681,16 +681,6 @@ void SCH_COMPONENT::SwapData( SCH_ITEM* aItem ) } -void SCH_COMPONENT::Place( SCH_EDIT_FRAME* frame, wxDC* DC ) -{ - /* save old text in undo list */ - if( !IsNew() ) - frame->SaveUndoItemInUndoList( this ); - - SCH_ITEM::Place( frame, DC ); -} - - void SCH_COMPONENT::ClearAnnotation( SCH_SHEET_PATH* aSheetPath ) { bool keepMulti = false; diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index 66a6d7324a..9b3b0c5453 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -55,6 +55,7 @@ class SCH_COMPONENT : public SCH_ITEM { friend class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC; + wxPoint m_Pos; wxString m_ChipName; ///< Name to look for in the library, i.e. "74LS00". int m_unit; ///< The unit for multiple part per package components. int m_convert; ///< The alternate body style for components that have more than @@ -75,11 +76,6 @@ class SCH_COMPONENT : public SCH_ITEM */ wxArrayString m_PathsAndReferences; -public: - wxPoint m_Pos; - -private: - void Init( const wxPoint& pos = wxPoint( 0, 0 ) ); EDA_RECT GetBodyBoundingBox() const; @@ -290,8 +286,6 @@ public: virtual void SwapData( SCH_ITEM* aItem ); - void Place( SCH_EDIT_FRAME* frame, wxDC* DC ); - // returns a unique ID, in the form of a path. wxString GetPath( SCH_SHEET_PATH* sheet ); @@ -433,6 +427,8 @@ private: virtual bool doIsConnected( const wxPoint& aPosition ) const; virtual EDA_ITEM* doClone() const; virtual void doPlot( PLOTTER* aPlotter ); + virtual wxPoint doGetPosition() const { return m_Pos; } + virtual void doSetPosition( const wxPoint& aPosition ) { m_Pos = aPosition; } }; diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 75a468a568..326c8c52c9 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -1,3 +1,28 @@ +/* + * 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. + * + * 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 + */ + /** * @file sch_field.cpp * @brief Implementation of the SCH_FIELD class. @@ -175,9 +200,9 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, /* Calculate the text position, according to the component * orientation/mirror */ - textpos = m_Pos - parentComponent->m_Pos; + textpos = m_Pos - parentComponent->GetPosition(); textpos = parentComponent->GetScreenCoord( textpos ); - textpos += parentComponent->m_Pos; + textpos += parentComponent->GetPosition(); x1 = textpos.x; y1 = textpos.y; int len = 10; @@ -201,20 +226,25 @@ void SCH_FIELD::ImportValues( const LIB_FIELD& aSource ) } -void SCH_FIELD::SwapData( SCH_FIELD* aField ) +void SCH_FIELD::SwapData( SCH_ITEM* aItem ) { - EXCHG( m_Text, aField->m_Text ); - EXCHG( m_Layer, aField->m_Layer ); - EXCHG( m_Pos, aField->m_Pos ); - EXCHG( m_Size, aField->m_Size ); - EXCHG( m_Thickness, aField->m_Thickness ); - EXCHG( m_Orient, aField->m_Orient ); - EXCHG( m_Mirror, aField->m_Mirror ); - EXCHG( m_Attributs, aField->m_Attributs ); - EXCHG( m_Italic, aField->m_Italic ); - EXCHG( m_Bold, aField->m_Bold ); - EXCHG( m_HJustify, aField->m_HJustify ); - EXCHG( m_VJustify, aField->m_VJustify ); + wxCHECK_RET( (aItem != NULL) && (aItem->Type() == SCH_FIELD_T), + wxT( "Cannot swap field data with invalid item." ) ); + + SCH_FIELD* item = (SCH_FIELD*) aItem; + + EXCHG( m_Text, item->m_Text ); + EXCHG( m_Layer, item->m_Layer ); + EXCHG( m_Pos, item->m_Pos ); + EXCHG( m_Size, item->m_Size ); + EXCHG( m_Thickness, item->m_Thickness ); + EXCHG( m_Orient, item->m_Orient ); + EXCHG( m_Mirror, item->m_Mirror ); + EXCHG( m_Attributs, item->m_Attributs ); + EXCHG( m_Italic, item->m_Italic ); + EXCHG( m_Bold, item->m_Bold ); + EXCHG( m_HJustify, item->m_HJustify ); + EXCHG( m_VJustify, item->m_VJustify ); } @@ -229,7 +259,7 @@ EDA_RECT SCH_FIELD::GetBoundingBox() const SCH_COMPONENT* parentComponent = (SCH_COMPONENT*) m_Parent; orient = m_Orient; - wxPoint pos = parentComponent->m_Pos; + wxPoint pos = parentComponent->GetPosition(); pos1 = m_Pos - pos; size.x = LenSize( m_Text ); diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h index f18ff20b8d..27e927edf9 100644 --- a/eeschema/sch_field.h +++ b/eeschema/sch_field.h @@ -1,3 +1,28 @@ +/* + * 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. + * + * 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 + */ + /** * @file sch_field.h * @brief Definition of the SCH_FIELD class for Eeschema. @@ -80,9 +105,9 @@ public: * Function SwapData * exchanges the date between the field and \a aField. * - * @param aField The field to exchange data with. + * @param aItem The field to exchange data with. */ - void SwapData( SCH_FIELD* aField ); + virtual void SwapData( SCH_ITEM* aItem ); /** * Function ImportValues @@ -183,6 +208,8 @@ private: virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const; virtual EDA_ITEM* doClone() const; virtual void doPlot( PLOTTER* aPlotter ); + virtual wxPoint doGetPosition() const { return m_Pos; } + virtual void doSetPosition( const wxPoint& aPosition ) { m_Pos = aPosition; } }; diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index 3d4dad161d..cacc64f94b 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -80,6 +80,17 @@ EDA_ITEM* SCH_JUNCTION::doClone() const } +void SCH_JUNCTION::SwapData( SCH_ITEM* aItem ) +{ + wxCHECK_RET( (aItem != NULL) && (aItem->Type() == SCH_JUNCTION_T), + wxT( "Cannot swap junction data with invalid item." ) ); + + SCH_JUNCTION* item = (SCH_JUNCTION*) aItem; + EXCHG( m_Pos, item->m_Pos ); + EXCHG( m_Size, item->m_Size ); +} + + bool SCH_JUNCTION::Load( LINE_READER& aLine, wxString& aErrorMsg ) { char name[256]; diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h index 9b3ce545ee..fd1b207ee8 100644 --- a/eeschema/sch_junction.h +++ b/eeschema/sch_junction.h @@ -36,8 +36,9 @@ class SCH_JUNCTION : public SCH_ITEM { -public: wxPoint m_Pos; /* XY coordinates of connection. */ + +public: wxSize m_Size; public: @@ -52,6 +53,8 @@ public: return wxT( "SCH_JUNCTION" ); } + virtual void SwapData( SCH_ITEM* aItem ); + /** * Function GetBoundingBox * returns the orthogonal, bounding box of this object for display @@ -130,6 +133,8 @@ private: virtual bool doIsConnected( const wxPoint& aPosition ) const; virtual EDA_ITEM* doClone() const; virtual void doPlot( PLOTTER* aPlotter ); + virtual wxPoint doGetPosition() const { return m_Pos; } + virtual void doSetPosition( const wxPoint& aPosition ) { m_Pos = aPosition; } }; diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 66aeee204c..ce4a2b1b33 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -582,3 +582,10 @@ void SCH_LINE::doPlot( PLOTTER* aPlotter ) if( m_Layer == LAYER_NOTES ) aPlotter->set_dash( false ); } + + +void SCH_LINE::doSetPosition( const wxPoint& aPosition ) +{ + m_End = m_End - ( m_Start - aPosition ); + m_Start = aPosition; +} diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index c5f02b45bb..7f1069db8e 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -176,6 +176,8 @@ private: virtual bool doIsConnected( const wxPoint& aPosition ) const; virtual EDA_ITEM* doClone() const; virtual void doPlot( PLOTTER* aPlotter ); + virtual wxPoint doGetPosition() const { return m_Start; } + virtual void doSetPosition( const wxPoint& aPosition ); }; diff --git a/eeschema/sch_marker.h b/eeschema/sch_marker.h index c8f7d2c652..055d7df26d 100644 --- a/eeschema/sch_marker.h +++ b/eeschema/sch_marker.h @@ -1,6 +1,32 @@ -/***************************************************/ -/* classes to handle markers used in schematic ... */ -/***************************************************/ +/* + * 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. + * + * 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 + */ + +/* + * @file sch_marker.h + * @brief SCH_MARKER class definition. + */ #ifndef _TYPE_SCH_MARKER_H_ #define _TYPE_SCH_MARKER_H_ @@ -108,6 +134,8 @@ public: virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const; virtual EDA_ITEM* doClone() const; + virtual wxPoint doGetPosition() const { return m_Pos; } + virtual void doSetPosition( const wxPoint& aPosition ) { m_Pos = aPosition; } }; #endif /* _TYPE_SCH_MARKER_H_ */ diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp index 66d3bf159b..3c4fe5a59a 100644 --- a/eeschema/sch_no_connect.cpp +++ b/eeschema/sch_no_connect.cpp @@ -69,6 +69,17 @@ EDA_ITEM* SCH_NO_CONNECT::doClone() const } +void SCH_NO_CONNECT::SwapData( SCH_ITEM* aItem ) +{ + wxCHECK_RET( (aItem != NULL) && (aItem->Type() == SCH_NO_CONNECT_T), + wxT( "Cannot swap no connect data with invalid item." ) ); + + SCH_NO_CONNECT* item = (SCH_NO_CONNECT*)aItem; + EXCHG( m_Pos, item->m_Pos ); + EXCHG( m_Size, item->m_Size ); +} + + EDA_RECT SCH_NO_CONNECT::GetBoundingBox() const { int delta = ( GetPenSize() + m_Size.x ) / 2; diff --git a/eeschema/sch_no_connect.h b/eeschema/sch_no_connect.h index bb2bb049c5..544501bae4 100644 --- a/eeschema/sch_no_connect.h +++ b/eeschema/sch_no_connect.h @@ -36,8 +36,9 @@ class SCH_NO_CONNECT : public SCH_ITEM { -public: wxPoint m_Pos; /* XY coordinates of NoConnect. */ + +public: wxSize m_Size; // size of this symbol public: @@ -58,6 +59,8 @@ public: */ virtual int GetPenSize() const; + virtual void SwapData( SCH_ITEM* aItem ); + virtual void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, int aDrawMode, int aColor = -1 ); @@ -131,6 +134,8 @@ private: virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const; virtual EDA_ITEM* doClone() const; virtual void doPlot( PLOTTER* aPlotter ); + virtual wxPoint doGetPosition() const { return m_Pos; } + virtual void doSetPosition( const wxPoint& aPosition ) { m_Pos = aPosition; } }; diff --git a/eeschema/sch_polyline.cpp b/eeschema/sch_polyline.cpp index 4cb4db12ad..baacbca650 100644 --- a/eeschema/sch_polyline.cpp +++ b/eeschema/sch_polyline.cpp @@ -267,3 +267,13 @@ bool SCH_POLYLINE::doHitTest( const EDA_RECT& aRect, bool aContained, int aAccur return rect.Intersects( GetBoundingBox() ); } + + +void SCH_POLYLINE::doSetPosition( const wxPoint& aPosition ) +{ + wxPoint offset = m_PolyPoints[0] - aPosition; + + for( size_t i = 0; i < m_PolyPoints.size(); i++ ) + m_PolyPoints[i] = m_PolyPoints[i] - offset; +} + diff --git a/eeschema/sch_polyline.h b/eeschema/sch_polyline.h index 2a282cc75f..1d4f848ce5 100644 --- a/eeschema/sch_polyline.h +++ b/eeschema/sch_polyline.h @@ -1,3 +1,28 @@ +/* + * 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. + * + * 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 + */ + /** * @file sch_polyline.h * @@ -102,6 +127,8 @@ private: virtual bool doHitTest( const wxPoint& aPoint, int aAccuracy ) const; virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const; virtual EDA_ITEM* doClone() const; + virtual wxPoint doGetPosition() const { return m_PolyPoints[0]; } + virtual void doSetPosition( const wxPoint& aPosition ); }; diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 9a26a9da87..9752dbbb1d 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -382,7 +382,7 @@ void SCH_SCREEN::MarkConnections( SCH_LINE* aSegment ) { SCH_JUNCTION* junction = (SCH_JUNCTION*) item; - if( aSegment->IsEndPoint( junction->m_Pos ) ) + if( aSegment->IsEndPoint( junction->GetPosition() ) ) item->SetFlags( CANDIDATE ); continue; @@ -984,14 +984,14 @@ bool SCH_SCREEN::BreakSegmentsOnJunctions() { SCH_JUNCTION* junction = ( SCH_JUNCTION* ) item; - if( BreakSegment( junction->m_Pos ) ) + if( BreakSegment( junction->GetPosition() ) ) brokenSegments = true; } else if( item->Type() == SCH_BUS_ENTRY_T ) { SCH_BUS_ENTRY* busEntry = ( SCH_BUS_ENTRY* ) item; - if( BreakSegment( busEntry->m_Pos ) || BreakSegment( busEntry->m_End() ) ) + if( BreakSegment( busEntry->GetPosition() ) || BreakSegment( busEntry->m_End() ) ) brokenSegments = true; } } @@ -1112,7 +1112,7 @@ bool SCH_SCREEN::SetComponentFootprint( SCH_SHEET_PATH* aSheetPath, const wxStri */ SCH_FIELD * fpfield = component->GetField( FOOTPRINT ); if( fpfield->m_Text.IsEmpty() - && ( fpfield->m_Pos == component->m_Pos ) ) + && ( fpfield->m_Pos == component->GetPosition() ) ) { fpfield->m_Orient = component->GetField( VALUE )->m_Orient; fpfield->m_Pos = component->GetField( VALUE )->m_Pos; @@ -1272,7 +1272,7 @@ int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aLis SCH_JUNCTION* junction = (SCH_JUNCTION*) item; - if( CountConnectedItems( junction->m_Pos, false ) <= 2 ) + if( CountConnectedItems( junction->GetPosition(), false ) <= 2 ) { item->SetFlags( STRUCT_DELETED ); @@ -1289,7 +1289,7 @@ int SCH_SCREEN::GetConnection( const wxPoint& aPosition, PICKED_ITEMS_LIST& aLis if( item->Type() != SCH_LABEL_T ) continue; - tmp = GetWireOrBus( ( (SCH_TEXT*) item )->m_Pos ); + tmp = GetWireOrBus( ( (SCH_TEXT*) item )->GetPosition() ); if( tmp && tmp->GetFlags() & STRUCT_DELETED ) { diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index c077a31866..30fafd8068 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -491,18 +491,11 @@ void SCH_SHEET::Place( SCH_EDIT_FRAME* frame, wxDC* DC ) delete this; return; } - } - else /* save old text in undo list */ - { - frame->SaveUndoItemInUndoList( this ); + + frame->SetSheetNumberAndCount(); } SCH_ITEM::Place( frame, DC ); //puts it on the GetDrawItems(). - - if( IsNew() ) - { - frame->SetSheetNumberAndCount(); - } } @@ -1061,7 +1054,7 @@ SEARCH_RESULT SCH_SHEET::Visit( INSPECTOR* aInspector, const void* aTestData, wxString SCH_SHEET::GetSelectMenuText() const { wxString tmp; - tmp.Printf( _( "Hierarchical Sheet " ), GetChars( m_SheetName ) ); + tmp.Printf( _( "Hierarchical Sheet %s" ), GetChars( m_SheetName ) ); return tmp; } diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index fb2a172be1..863eeffe69 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -616,6 +616,8 @@ private: virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const; virtual EDA_ITEM* doClone() const; virtual void doPlot( PLOTTER* aPlotter ); + virtual wxPoint doGetPosition() const { return m_Pos; } + virtual void doSetPosition( const wxPoint& aPosition ) { m_Pos = aPosition; } }; diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 64b2159a83..397cbc357c 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -331,46 +331,22 @@ void SCH_TEXT::SetOrientation( int aOrientation ) } -void SCH_TEXT::SwapData( SCH_TEXT* copyitem ) +void SCH_TEXT::SwapData( SCH_ITEM* aItem ) { - EXCHG( m_Text, copyitem->m_Text ); - EXCHG( m_Pos, copyitem->m_Pos ); - EXCHG( m_Size, copyitem->m_Size ); - EXCHG( m_Thickness, copyitem->m_Thickness ); - EXCHG( m_Shape, copyitem->m_Shape ); - EXCHG( m_Orient, copyitem->m_Orient ); + SCH_TEXT* item = (SCH_TEXT*) aItem; - EXCHG( m_Layer, copyitem->m_Layer ); - EXCHG( m_HJustify, copyitem->m_HJustify ); - EXCHG( m_VJustify, copyitem->m_VJustify ); - EXCHG( m_IsDangling, copyitem->m_IsDangling ); - EXCHG( m_SchematicOrientation, copyitem->m_SchematicOrientation ); -} + EXCHG( m_Text, item->m_Text ); + EXCHG( m_Pos, item->m_Pos ); + EXCHG( m_Size, item->m_Size ); + EXCHG( m_Thickness, item->m_Thickness ); + EXCHG( m_Shape, item->m_Shape ); + EXCHG( m_Orient, item->m_Orient ); - -void SCH_TEXT::Place( SCH_EDIT_FRAME* frame, wxDC* DC ) -{ - if( !IsNew() ) - { - // For existing (not new texts: save in undo list the old text: - ClearFlags(); - PICKED_ITEMS_LIST pickList; - ITEM_PICKER picker( this, UR_CHANGED); //UR_EXCHANGE_T ); - SCH_ITEM* undoItem = frame->GetUndoItem(); - - wxCHECK_RET( undoItem != NULL && undoItem->Type() == Type(), - wxT( "Invalid text undo item." ) ); - - undoItem->ClearFlags(); - picker.SetLink( undoItem ); - // the owner of undoItem is no more frame, this is picker: - frame->SetUndoItem( NULL ); - - pickList.PushItem( picker ); - frame->SaveCopyInUndoList( pickList, UR_CHANGED ); //UR_EXCHANGE_T ); - } - - SCH_ITEM::Place( frame, DC ); + EXCHG( m_Layer, item->m_Layer ); + EXCHG( m_HJustify, item->m_HJustify ); + EXCHG( m_VJustify, item->m_VJustify ); + EXCHG( m_IsDangling, item->m_IsDangling ); + EXCHG( m_SchematicOrientation, item->m_SchematicOrientation ); } diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index 118419a882..331d679114 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -144,9 +144,7 @@ public: aPoints.clear(); } - void SwapData( SCH_TEXT* copyitem ); - - void Place( SCH_EDIT_FRAME* frame, wxDC* DC ); + virtual void SwapData( SCH_ITEM* aItem ); /** * Function GetBoundingBox @@ -242,6 +240,8 @@ private: virtual bool doHitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const; virtual EDA_ITEM* doClone() const; virtual void doPlot( PLOTTER* aPlotter ); + virtual wxPoint doGetPosition() const { return m_Pos; } + virtual void doSetPosition( const wxPoint& aPosition ) { m_Pos = aPosition; } }; diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index d02aaeb509..2356527a3c 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -1,3 +1,28 @@ +/* + * 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. + * + * 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 + */ + /** * @file schedit.cpp */ @@ -52,7 +77,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_SCH_RESIZE_SHEET: case ID_POPUP_IMPORT_GLABEL: case ID_POPUP_SCH_EDIT_SHEET_PIN: - case ID_POPUP_SCH_MOVE_SHEET_PIN: case ID_POPUP_SCH_DRAG_CMP_REQUEST: case ID_POPUP_SCH_DRAG_WIRE_REQUEST: case ID_POPUP_SCH_EDIT_CMP: @@ -256,11 +280,6 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) EditSheetPin( (SCH_SHEET_PIN*) item, &dc ); break; - case ID_POPUP_SCH_MOVE_SHEET_PIN: - DrawPanel->MoveCursorToCrossHair(); - MoveSheetPin( (SCH_SHEET_PIN*) item, &dc ); - break; - case ID_POPUP_SCH_DRAG_CMP_REQUEST: case ID_POPUP_SCH_DRAG_WIRE_REQUEST: DrawPanel->MoveCursorToCrossHair(); @@ -478,48 +497,39 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent ) INSTALL_UNBUFFERED_DC( dc, DrawPanel ); - DrawPanel->MoveCursorToCrossHair(); - switch( item->Type() ) { + case SCH_LINE_T: + break; + case SCH_JUNCTION_T: - break; - + case SCH_NO_CONNECT_T: case SCH_BUS_ENTRY_T: - StartMoveBusEntry( (SCH_BUS_ENTRY*) item, &dc ); - break; - case SCH_LABEL_T: case SCH_GLOBAL_LABEL_T: case SCH_HIERARCHICAL_LABEL_T: case SCH_TEXT_T: - MoveText( (SCH_TEXT*) item, &dc ); + case SCH_COMPONENT_T: + MoveItem( item, &dc ); break; case SCH_BITMAP_T: MoveImage( (SCH_BITMAP*) item, &dc ); break; - case SCH_COMPONENT_T: - StartMovePart( (SCH_COMPONENT*) item, &dc ); - break; - - case SCH_LINE_T: - break; - case SCH_SHEET_T: StartMoveSheet( (SCH_SHEET*) item, &dc ); break; - case SCH_NO_CONNECT_T: - break; - case SCH_FIELD_T: MoveField( (SCH_FIELD*) item, &dc ); break; - case SCH_MARKER_T: case SCH_SHEET_PIN_T: + MoveSheetPin( (SCH_SHEET_PIN*) item, &dc ); + break; + + case SCH_MARKER_T: default: wxFAIL_MSG( wxString::Format( wxT( "Cannot move item type %s" ), GetChars( item->GetClass() ) ) ); diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index 6990b44e96..f6876ce002 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -1,3 +1,28 @@ +/* + * 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. + * + * 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 + */ + /** * @file schematic_undo_redo.cpp * @brief Eeschema undo and redo functions for schematic editor. @@ -82,118 +107,6 @@ * swap data between Item and its copy, pointed by its .m_Image member * swapped data is data modified by edition, so not all values are swapped */ -void SwapData( EDA_ITEM* aItem, EDA_ITEM* aImage ) -{ - if( aItem == NULL || aImage == NULL ) - { - wxMessageBox( wxT( "SwapData error: NULL pointer" ) ); - return; - } - - switch( aItem->Type() ) - { - case SCH_POLYLINE_T: - #undef SOURCE - #undef DEST - #define SOURCE ( (SCH_POLYLINE*) aItem ) - #define DEST ( (SCH_POLYLINE*) aImage ) - break; - - case SCH_JUNCTION_T: - #undef SOURCE - #undef DEST - #define SOURCE ( (SCH_JUNCTION*) aItem ) - #define DEST ( (SCH_JUNCTION*) aImage ) - EXCHG( SOURCE->m_Pos, DEST->m_Pos ); - break; - - case SCH_LABEL_T: - case SCH_GLOBAL_LABEL_T: - case SCH_HIERARCHICAL_LABEL_T: - case SCH_TEXT_T: - #undef SOURCE - #undef DEST - #define SOURCE ( (SCH_TEXT*) aItem ) - #define DEST ( (SCH_TEXT*) aImage ) - DEST->SwapData( SOURCE ); - break; - - case SCH_COMPONENT_T: - #undef SOURCE - #undef DEST - #define SOURCE ( (SCH_COMPONENT*) aItem ) - #define DEST ( (SCH_COMPONENT*) aImage ) - DEST->SwapData( SOURCE ); - break; - - case SCH_LINE_T: - #undef SOURCE - #undef DEST - #define SOURCE ( (SCH_LINE*) aItem ) - #define DEST ( (SCH_LINE*) aImage ) - EXCHG( SOURCE->m_Start, DEST->m_Start ); - EXCHG( SOURCE->m_End, DEST->m_End ); - break; - - case SCH_BUS_ENTRY_T: - #undef SOURCE - #undef DEST - #define SOURCE ( (SCH_BUS_ENTRY*) aItem ) - #define DEST ( (SCH_BUS_ENTRY*) aImage ) - EXCHG( SOURCE->m_Pos, DEST->m_Pos ); - EXCHG( SOURCE->m_Size, DEST->m_Size ); - break; - - case SCH_SHEET_T: - #undef SOURCE - #undef DEST - #define SOURCE ( (SCH_SHEET*) aItem ) - #define DEST ( (SCH_SHEET*) aImage ) - DEST->SwapData( SOURCE ); - break; - - case SCH_MARKER_T: - #undef SOURCE - #undef DEST - #define SOURCE ( (SCH_MARKER*) aItem ) - #define DEST ( (SCH_MARKER*) aImage ) - EXCHG( SOURCE->m_Pos, DEST->m_Pos ); - break; - - case SCH_SHEET_PIN_T: - #undef SOURCE - #undef DEST - #define SOURCE ( (SCH_SHEET_PIN*) aItem ) - #define DEST ( (SCH_SHEET_PIN*) aImage ) - DEST->SwapData( SOURCE ); - break; - - case SCH_NO_CONNECT_T: - #undef SOURCE - #undef DEST - #define SOURCE ( (SCH_NO_CONNECT*) aItem ) - #define DEST ( (SCH_NO_CONNECT*) aImage ) - EXCHG( SOURCE->m_Pos, DEST->m_Pos ); - break; - - case SCH_BITMAP_T: - #undef SOURCE - #undef DEST - #define SOURCE ( (SCH_BITMAP*) aItem ) - #define DEST ( (SCH_BITMAP*) aImage ) - DEST->SwapData( SOURCE ); - break; - - case SCH_FIELD_T: - break; - - // not directly used in schematic: - default: - wxMessageBox( wxT( "SwapData() error: unexpected type" ) ); - break; - } -} - void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem, UNDO_REDO_T aCommandType, @@ -346,7 +259,7 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed switch( aList->GetPickedItemStatus( ii ) ) { case UR_CHANGED: /* Exchange old and new data for each item */ - SwapData( item, image ); + item->SwapData( image ); break; case UR_NEW: /* new items are deleted */ diff --git a/include/sch_item_struct.h b/include/sch_item_struct.h index 54b8518178..0facba15a0 100644 --- a/include/sch_item_struct.h +++ b/include/sch_item_struct.h @@ -1,3 +1,28 @@ +/* + * 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. + * + * 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 + */ + /** * @file sch_item_struct.h * @brief Base schematic object class definition. @@ -131,7 +156,13 @@ public: int aDrawMode, int aColor = -1 ) = 0; - /* Place function */ + /** + * Function Place + * place the schematic item into the draw list. + *

+ * If the schematic item is a new item or is modified, it is added to undo list. + *

+ */ virtual void Place( SCH_EDIT_FRAME* aFrame, wxDC* aDC ); /** @@ -321,6 +352,20 @@ public: virtual void GetNetListItem( vector& aNetListItems, SCH_SHEET_PATH* aSheetPath ) { } + /** + * Function GetPosition + * @return the schematic item position. + */ + wxPoint GetPosition() const { return doGetPosition(); } + + /** + * Function SetPosition + * set the schematic item position to \a aPosition. + * + * @param aPosition A reference to a wxPoint object containing the new position. + */ + void SetPosition( const wxPoint& aPosition ) { doSetPosition( aPosition ); } + virtual bool operator <( const SCH_ITEM& aItem ) const; /** @@ -343,6 +388,10 @@ private: virtual bool doIsConnected( const wxPoint& aPosition ) const { return false; } virtual void doPlot( PLOTTER* aPlotter ); + + virtual wxPoint doGetPosition() const = 0; + + virtual void doSetPosition( const wxPoint& aPosition ) = 0; }; diff --git a/include/wxEeschemaStruct.h b/include/wxEeschemaStruct.h index 28439b9731..c1fdaff5f9 100644 --- a/include/wxEeschemaStruct.h +++ b/include/wxEeschemaStruct.h @@ -1,3 +1,28 @@ +/* + * 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. + * + * 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 + */ + /** * @file wxEeschemaStruct.h */ @@ -339,6 +364,21 @@ public: */ bool DeleteItemAtCrossHair( wxDC* aDC ); + /** + * Function FindComponentAndItem + * finds a Component in the schematic, and an item in this component. + * @param component_reference The component reference to find. + * @param text_to_find - The text to search for, either in value, reference + * or elsewhere. + * @param Find_in_hierarchy: false => Search is made in current sheet + * true => the whole hierarchy + * @param SearchType: 0 => find component + * 1 => find pin + * 2 => find ref + * 3 => find value + * >= 4 => unused (same as 0) + * @param mouseWarp If true, then move the mouse cursor to the item. + */ SCH_ITEM* FindComponentAndItem( const wxString& component_reference, bool Find_in_hierarchy, int SearchType, @@ -589,7 +629,15 @@ private: void OnFindDialogClose( wxFindDialogEvent& event ); void OnFindDrcMarker( wxFindDialogEvent& event ); void OnFindCompnentInLib( wxFindDialogEvent& event ); - void OnFindSchematicItem( wxFindDialogEvent& event ); + + /** + * Function OnFindSchematicItem + * finds an item in the schematic matching the search criteria in \a aEvent. + * + * @param aEvent - Find dialog event containing the find parameters. + */ + void OnFindSchematicItem( wxFindDialogEvent& aEvent ); + void OnLoadFile( wxCommandEvent& event ); void OnLoadStuffFile( wxCommandEvent& event ); void OnNewProject( wxCommandEvent& event ); @@ -603,7 +651,10 @@ private: void OnSelectItem( wxCommandEvent& aEvent ); - /* edition events functions */ + /** + * Function OnCopySchematicItemRequest + * is the command event handler for duplicating the item at the current location. + */ void OnCopySchematicItemRequest( wxCommandEvent& event ); /* User interface update event handlers. */ @@ -623,7 +674,6 @@ private: SCH_BUS_ENTRY* CreateBusEntry( wxDC* DC, int entry_type ); void SetBusEntryShape( wxDC* DC, SCH_BUS_ENTRY* BusEntry, int entry_type ); int GetBusEntryShape( SCH_BUS_ENTRY* BusEntry ); - void StartMoveBusEntry( SCH_BUS_ENTRY* DrawLibItem, wxDC* DC ); /** * Function AddNoConnect @@ -637,11 +687,19 @@ private: // Junction SCH_JUNCTION* AddJunction( wxDC* aDC, const wxPoint& aPosition, bool aPutInUndoList = FALSE ); + /** + * Function MoveItem + * start moving \a aItem using the mouse. + * + * @param aItem A pointer to an SCH_ITEM to move. + * @param aDC The device context to draw \a aItem. + */ + void MoveItem( SCH_ITEM* aItem, wxDC* aDC ); + // Text, label, glabel SCH_TEXT* CreateNewText( wxDC* aDC, int aType ); void EditSchematicText( SCH_TEXT* TextStruct ); void ChangeTextOrient( SCH_TEXT* aTextItem, wxDC* aDC ); - void MoveText( SCH_TEXT* aTextItem, wxDC* aDC ); /** * Function OnCovertTextType @@ -773,7 +831,6 @@ private: const wxString& libname, wxArrayString& List, bool UseLibBrowser ); - void StartMovePart( SCH_COMPONENT* DrawLibItem, wxDC* DC ); /** * Function EditComponent