Commit 78377058 authored by Wayne Stambaugh's avatar Wayne Stambaugh

More Eeschema schematic item move code unification.

* Tweak move item to support moving schematic sheet pin objects.
* Change schematic sheet pin set position to constrain position within
  the parent sheet.
* Schematic sheet pin moving now handled by unified move code.
* Remove old schematic sheet pin move code.
* Add custom client data object for passing hot key information to
  command event handlers.
* Fix a bug that prevented changes to schematic sheet pin objects from
  being undone.
parent 4c063574
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 Kicad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -97,7 +97,7 @@ void SCH_ITEM::Place( SCH_EDIT_FRAME* aFrame, wxDC* aDC ) ...@@ -97,7 +97,7 @@ void SCH_ITEM::Place( SCH_EDIT_FRAME* aFrame, wxDC* aDC )
m_Flags = 0; m_Flags = 0;
screen->SetModify(); screen->SetModify();
screen->SetCurItem( NULL ); screen->SetCurItem( NULL );
aFrame->DrawPanel->SetMouseCapture( NULL, NULL ); aFrame->DrawPanel->EndMouseCapture();
if( aDC ) if( aDC )
{ {
......
...@@ -496,19 +496,32 @@ static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) ...@@ -496,19 +496,32 @@ static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
delete item; delete item;
item = NULL; item = NULL;
} }
else // Move command on an existing text item, restore the values of the original. else
{ {
SCH_ITEM* olditem = parent->GetUndoItem(); SCH_ITEM* oldItem = parent->GetUndoItem();
screen->SetCurItem( item );
SCH_ITEM* currentItem;
// Items that are children of other objects are undone by swapping the contents
// of the parent items.
if( item->Type() == SCH_SHEET_PIN_T )
{
currentItem = (SCH_ITEM*) item->GetParent();
}
else
{
currentItem = item;
}
wxCHECK_RET( olditem != NULL && item->Type() == olditem->Type(), screen->SetCurItem( currentItem );
wxCHECK_RET( oldItem != NULL && currentItem->Type() == oldItem->Type(),
wxT( "Cannot restore undefined or bad last schematic item." ) ); wxT( "Cannot restore undefined or bad last schematic item." ) );
// Never delete existing item, because it can be referenced by an undo/redo command // Never delete existing item, because it can be referenced by an undo/redo command
// Just restore its data // Just restore its data
currentItem->SwapData( oldItem );
item->SwapData( olditem ); currentItem->ClearFlags();
item->ClearFlags();
} }
aPanel->Refresh(); aPanel->Refresh();
...@@ -546,12 +559,20 @@ void SCH_EDIT_FRAME::MoveItem( SCH_ITEM* aItem, wxDC* aDC ) ...@@ -546,12 +559,20 @@ void SCH_EDIT_FRAME::MoveItem( SCH_ITEM* aItem, wxDC* aDC )
m_itemToRepeat = NULL; m_itemToRepeat = NULL;
if( !aItem->IsNew() ) if( !aItem->IsNew() )
SetUndoItem( aItem ); {
if( (aItem->Type() == SCH_SHEET_PIN_T) )
SetUndoItem( (SCH_ITEM*) aItem->GetParent() );
else
SetUndoItem( aItem );
}
aItem->SetFlags( IS_MOVED ); aItem->SetFlags( IS_MOVED );
DrawPanel->CrossHairOff( aDC ); DrawPanel->CrossHairOff( aDC );
GetScreen()->SetCrossHairPosition( aItem->GetPosition() );
if( (aItem->Type() != SCH_SHEET_PIN_T) )
GetScreen()->SetCrossHairPosition( aItem->GetPosition() );
DrawPanel->MoveCursorToCrossHair(); DrawPanel->MoveCursorToCrossHair();
OnModify(); OnModify();
......
...@@ -572,7 +572,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -572,7 +572,7 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
case HK_ROTATE: // Component or other schematic item rotation case HK_ROTATE: // Component or other schematic item rotation
if ( screen->m_BlockLocate.m_State != STATE_NO_BLOCK )//allows bloc operation on hotkey if ( screen->m_BlockLocate.m_State != STATE_NO_BLOCK )//allows bloc operation on hotkey
{ {
HandleBlockEndByPopUp(BLOCK_ROTATE, aDC ); HandleBlockEndByPopUp( BLOCK_ROTATE, aDC );
break; break;
} }
...@@ -731,18 +731,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -731,18 +731,8 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
break; break;
case HK_MOVE_COMPONENT_OR_ITEM: // Start move schematic item. case HK_MOVE_COMPONENT_OR_ITEM: // Start move schematic item.
if( itemInEdit ) cmd.SetInt( aHotKey );
break; cmd.SetClientData( new EDA_HOTKEY_CLIENT_DATA( aPosition ) );
if( aItem == NULL )
{
aItem = LocateAndShowItem( aPosition, SCH_COLLECTOR::MovableItems,
hotKey->m_Idcommand );
if( aItem == NULL )
break;
}
cmd.SetId( hotKey->m_IdMenuEvent ); cmd.SetId( hotKey->m_IdMenuEvent );
wxPostEvent( this, cmd ); wxPostEvent( this, cmd );
break; break;
......
...@@ -920,7 +920,7 @@ void SCH_SHEET::Resize( const wxSize& aSize ) ...@@ -920,7 +920,7 @@ void SCH_SHEET::Resize( const wxSize& aSize )
/* Move the sheet labels according to the new sheet size. */ /* Move the sheet labels according to the new sheet size. */
BOOST_FOREACH( SCH_SHEET_PIN& label, m_pins ) BOOST_FOREACH( SCH_SHEET_PIN& label, m_pins )
{ {
label.ConstraintOnEdge( label.m_Pos ); label.ConstrainOnEdge( label.m_Pos );
} }
} }
......
...@@ -132,11 +132,11 @@ public: ...@@ -132,11 +132,11 @@ public:
int GetEdge() const; int GetEdge() const;
/** /**
* Function ConstraintOnEdge * Function ConstrainOnEdge
* is used to adjust label position to edge based on proximity to vertical / horizontal edge * is used to adjust label position to edge based on proximity to vertical / horizontal edge
* of the parent sheet. * of the parent sheet.
*/ */
void ConstraintOnEdge( wxPoint Pos ); void ConstrainOnEdge( wxPoint Pos );
/** /**
* Get the parent sheet object of this sheet pin. * Get the parent sheet object of this sheet pin.
...@@ -221,6 +221,12 @@ public: ...@@ -221,6 +221,12 @@ public:
virtual wxString GetSelectMenuText() const; virtual wxString GetSelectMenuText() const;
virtual BITMAP_DEF GetMenuImage() const { return add_hierar_pin_xpm; } virtual BITMAP_DEF GetMenuImage() const { return add_hierar_pin_xpm; }
private:
virtual void doSetPosition( const wxPoint& aPosition )
{
ConstrainOnEdge( aPosition );
}
}; };
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 Kicad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -43,14 +43,14 @@ ...@@ -43,14 +43,14 @@
#include "kicad_string.h" #include "kicad_string.h"
/* m_Edge define on which edge the pin is positionned: /* m_Edge define on which edge the pin is positioned:
* *
* 0: pin on left side * 0: pin on left side
* 1: pin on right side * 1: pin on right side
* 2: pin on top side * 2: pin on top side
* 3: pin on bottom side * 3: pin on bottom side
* for compatibility reasons, this does not follow same values as text * for compatibility reasons, this does not follow same values as text
* ortientation. * orientation.
*/ */
SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxString& text ) : SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxString& text ) :
...@@ -60,10 +60,12 @@ SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxStr ...@@ -60,10 +60,12 @@ SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxStr
wxASSERT( parent ); wxASSERT( parent );
m_Layer = LAYER_SHEETLABEL; m_Layer = LAYER_SHEETLABEL;
m_Pos = pos; m_Pos = pos;
if( parent->IsVerticalOrientation() ) if( parent->IsVerticalOrientation() )
SetEdge( 2 ); SetEdge( 2 );
else else
SetEdge( 0 ); SetEdge( 0 );
m_Shape = NET_INPUT; m_Shape = NET_INPUT;
m_IsDangling = true; m_IsDangling = true;
m_Number = 2; m_Number = 2;
...@@ -141,26 +143,20 @@ void SCH_SHEET_PIN::Place( SCH_EDIT_FRAME* aFrame, wxDC* aDC ) ...@@ -141,26 +143,20 @@ void SCH_SHEET_PIN::Place( SCH_EDIT_FRAME* aFrame, wxDC* aDC )
wxCHECK_RET( (sheet != NULL) && (sheet->Type() == SCH_SHEET_T), wxCHECK_RET( (sheet != NULL) && (sheet->Type() == SCH_SHEET_T),
wxT( "Cannot place sheet pin in invalid schematic sheet object." ) ); wxT( "Cannot place sheet pin in invalid schematic sheet object." ) );
int flags = m_Flags; if( IsNew() )
m_Flags = 0;
if( flags & IS_NEW )
{ {
aFrame->SaveCopyInUndoList( sheet, UR_CHANGED ); aFrame->SaveCopyInUndoList( sheet, UR_CHANGED );
sheet->AddPin( this ); sheet->AddPin( this );
} }
else // pin sheet was existing and only moved else // Sheet pin already existed and was only moved.
{ {
wxPoint tmp = m_Pos; aFrame->SaveUndoItemInUndoList( sheet );
m_Pos = aFrame->GetLastSheetPinPosition();
SetEdge( aFrame->GetLastSheetPinEdge() );
aFrame->SaveCopyInUndoList( sheet, UR_CHANGED );
m_Pos = tmp;
} }
ConstraintOnEdge( aFrame->GetScreen()->GetCrossHairPosition() ); ClearFlags();
sheet->Draw( aFrame->DrawPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE ); sheet->Draw( aFrame->DrawPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
// Make sure we don't call the abort move function.
aFrame->DrawPanel->SetMouseCapture( NULL, NULL ); aFrame->DrawPanel->SetMouseCapture( NULL, NULL );
aFrame->DrawPanel->EndMouseCapture(); aFrame->DrawPanel->EndMouseCapture();
} }
...@@ -205,7 +201,7 @@ int SCH_SHEET_PIN::GetEdge() const ...@@ -205,7 +201,7 @@ int SCH_SHEET_PIN::GetEdge() const
} }
void SCH_SHEET_PIN::ConstraintOnEdge( wxPoint Pos ) void SCH_SHEET_PIN::ConstrainOnEdge( wxPoint Pos )
{ {
SCH_SHEET* Sheet = (SCH_SHEET*) GetParent(); SCH_SHEET* Sheet = (SCH_SHEET*) GetParent();
...@@ -224,8 +220,10 @@ void SCH_SHEET_PIN::ConstraintOnEdge( wxPoint Pos ) ...@@ -224,8 +220,10 @@ void SCH_SHEET_PIN::ConstraintOnEdge( wxPoint Pos )
} }
m_Pos.y = Pos.y; m_Pos.y = Pos.y;
if( m_Pos.y < Sheet->m_Pos.y ) if( m_Pos.y < Sheet->m_Pos.y )
m_Pos.y = Sheet->m_Pos.y; m_Pos.y = Sheet->m_Pos.y;
if( m_Pos.y > (Sheet->m_Pos.y + Sheet->m_Size.y) ) if( m_Pos.y > (Sheet->m_Pos.y + Sheet->m_Size.y) )
m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y; m_Pos.y = Sheet->m_Pos.y + Sheet->m_Size.y;
} }
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "eda_doc.h" #include "eda_doc.h"
#include "wxEeschemaStruct.h" #include "wxEeschemaStruct.h"
#include "kicad_device_context.h" #include "kicad_device_context.h"
#include "hotkeys_basic.h"
#include "general.h" #include "general.h"
#include "eeschema_id.h" #include "eeschema_id.h"
...@@ -492,8 +493,28 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent ) ...@@ -492,8 +493,28 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
SCH_SCREEN* screen = GetScreen(); SCH_SCREEN* screen = GetScreen();
SCH_ITEM* item = screen->GetCurItem(); SCH_ITEM* item = screen->GetCurItem();
wxLogDebug( wxT( "Command member m_commandInt = %d." ), aEvent.GetInt() );
if( item == NULL ) if( item == NULL )
return; {
// If we didn't get here by a hot key, then something has gone wrong.
if( aEvent.GetInt() == 0 )
return;
EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientData();
wxCHECK_RET( data != NULL, wxT( "Invalid hot key client data." ) );
item = LocateAndShowItem( data->GetPosition(), SCH_COLLECTOR::MovableItems,
aEvent.GetInt() );
aEvent.SetClientData( NULL );
delete data;
// Exit if no item found at the current location or the item is already being edited.
if( (item == NULL) || (item->GetFlags() != 0) )
return;
}
INSTALL_UNBUFFERED_DC( dc, DrawPanel ); INSTALL_UNBUFFERED_DC( dc, DrawPanel );
...@@ -510,6 +531,7 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent ) ...@@ -510,6 +531,7 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
case SCH_HIERARCHICAL_LABEL_T: case SCH_HIERARCHICAL_LABEL_T:
case SCH_TEXT_T: case SCH_TEXT_T:
case SCH_COMPONENT_T: case SCH_COMPONENT_T:
case SCH_SHEET_PIN_T:
MoveItem( item, &dc ); MoveItem( item, &dc );
break; break;
...@@ -525,10 +547,6 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent ) ...@@ -525,10 +547,6 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
MoveField( (SCH_FIELD*) item, &dc ); MoveField( (SCH_FIELD*) item, &dc );
break; break;
case SCH_SHEET_PIN_T:
MoveSheetPin( (SCH_SHEET_PIN*) item, &dc );
break;
case SCH_MARKER_T: case SCH_MARKER_T:
default: default:
wxFAIL_MSG( wxString::Format( wxT( "Cannot move item type %s" ), wxFAIL_MSG( wxString::Format( wxT( "Cannot move item type %s" ),
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* 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 sheetlab.cpp * @file sheetlab.cpp
* @brief Create and edit the SCH_SHEET_PIN items. * @brief Create and edit the SCH_SHEET_PIN items.
...@@ -21,71 +46,6 @@ ...@@ -21,71 +46,6 @@
int SCH_EDIT_FRAME::m_lastSheetPinType = NET_INPUT; int SCH_EDIT_FRAME::m_lastSheetPinType = NET_INPUT;
wxSize SCH_EDIT_FRAME::m_lastSheetPinTextSize( DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT ); wxSize SCH_EDIT_FRAME::m_lastSheetPinTextSize( DEFAULT_SIZE_TEXT, DEFAULT_SIZE_TEXT );
wxPoint SCH_EDIT_FRAME::m_lastSheetPinPosition; wxPoint SCH_EDIT_FRAME::m_lastSheetPinPosition;
int SCH_EDIT_FRAME::m_lastSheetPinEdge;
/* Called when aborting a move pinsheet label
* delete a new pin sheet label, or restire its old position
*/
static void abortSheetPinMove( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
{
wxCHECK_RET( (aPanel != NULL) && (aDC != NULL), wxT( "Invalid panel or device context." ) );
SCH_EDIT_FRAME* frame = (SCH_EDIT_FRAME*) aPanel->GetParent();
SCH_SHEET_PIN* sheetPin = (SCH_SHEET_PIN*) aPanel->GetScreen()->GetCurItem();
wxCHECK_RET( (frame != NULL) && (sheetPin != NULL) && (sheetPin->Type() == SCH_SHEET_PIN_T),
wxT( "Invalid frame or sheet pin." ) );
sheetPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
if( sheetPin->IsNew() )
{
SAFE_DELETE( sheetPin );
}
else
{
// Restore edge position:
sheetPin->m_Pos = frame->GetLastSheetPinPosition();
sheetPin->SetEdge( frame->GetLastSheetPinEdge() );
sheetPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
sheetPin->ClearFlags();
}
aPanel->GetScreen()->SetCurItem( NULL );
}
static void moveSheetPin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase )
{
SCH_SHEET_PIN* sheetPin = (SCH_SHEET_PIN*) aPanel->GetScreen()->GetCurItem();
if( sheetPin == NULL || sheetPin->Type() != SCH_SHEET_PIN_T )
return;
if( aErase )
sheetPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
sheetPin->ConstraintOnEdge( aPanel->GetScreen()->GetCrossHairPosition() );
sheetPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
}
void SCH_EDIT_FRAME::MoveSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC )
{
wxCHECK_RET( (aSheetPin != NULL) && (aSheetPin->Type() == SCH_SHEET_PIN_T),
wxT( "Cannot move invalid schematic sheet pin object." ) );
m_lastSheetPinTextSize = aSheetPin->m_Size;
m_lastSheetPinType = aSheetPin->m_Shape;
m_lastSheetPinPosition = aSheetPin->m_Pos;
m_lastSheetPinEdge = aSheetPin->GetEdge();
aSheetPin->SetFlags( IS_MOVED );
DrawPanel->SetMouseCapture( moveSheetPin, abortSheetPinMove );
moveSheetPin( DrawPanel, aDC, wxDefaultPosition, true );
}
int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC ) int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC )
...@@ -117,6 +77,12 @@ int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC ) ...@@ -117,6 +77,12 @@ int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC )
if( aDC ) if( aDC )
aSheetPin->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); aSheetPin->Draw( DrawPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
if( !aSheetPin->IsNew() )
{
SaveCopyInUndoList( (SCH_ITEM*) aSheetPin->GetParent(), UR_CHANGED );
GetScreen()->SetCurItem( NULL );
}
aSheetPin->m_Text = dlg.GetLabelName(); aSheetPin->m_Text = dlg.GetLabelName();
aSheetPin->m_Size.y = ReturnValueFromString( g_UserUnit, dlg.GetTextHeight(), m_InternalUnits ); aSheetPin->m_Size.y = ReturnValueFromString( g_UserUnit, dlg.GetTextHeight(), m_InternalUnits );
aSheetPin->m_Size.x = ReturnValueFromString( g_UserUnit, dlg.GetTextWidth(), m_InternalUnits ); aSheetPin->m_Size.x = ReturnValueFromString( g_UserUnit, dlg.GetTextWidth(), m_InternalUnits );
...@@ -147,12 +113,10 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, wxDC* aDC ) ...@@ -147,12 +113,10 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, wxDC* aDC )
return NULL; return NULL;
} }
GetScreen()->SetCurItem( sheetPin );
m_lastSheetPinType = sheetPin->m_Shape; m_lastSheetPinType = sheetPin->m_Shape;
m_lastSheetPinTextSize = sheetPin->m_Size; m_lastSheetPinTextSize = sheetPin->m_Size;
DrawPanel->SetMouseCapture( moveSheetPin, abortSheetPinMove ); MoveItem( (SCH_ITEM*) sheetPin, aDC );
moveSheetPin( DrawPanel, aDC, wxDefaultPosition, false );
OnModify(); OnModify();
return sheetPin; return sheetPin;
...@@ -190,17 +154,12 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::ImportSheetPin( SCH_SHEET* aSheet, wxDC* aDC ) ...@@ -190,17 +154,12 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::ImportSheetPin( SCH_SHEET* aSheet, wxDC* aDC )
return NULL; return NULL;
} }
OnModify();
SaveCopyInUndoList( aSheet, UR_CHANGED );
sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), label->m_Text ); sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), label->m_Text );
sheetPin->SetFlags( IS_NEW ); sheetPin->SetFlags( IS_NEW );
sheetPin->m_Size = m_lastSheetPinTextSize; sheetPin->m_Size = m_lastSheetPinTextSize;
m_lastSheetPinType = sheetPin->m_Shape = label->m_Shape; m_lastSheetPinType = sheetPin->m_Shape = label->m_Shape;
GetScreen()->SetCurItem( sheetPin ); MoveItem( (SCH_ITEM*) sheetPin, aDC );
DrawPanel->SetMouseCapture( moveSheetPin, abortSheetPinMove );
moveSheetPin( DrawPanel, aDC, wxDefaultPosition, false );
return sheetPin; return sheetPin;
} }
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* 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 hotkeys_basic.h * @file hotkeys_basic.h
* @brief Some functions to handle hotkeys in KiCad * @brief Some functions to handle hotkeys in KiCad
...@@ -12,8 +35,20 @@ ...@@ -12,8 +35,20 @@
class EDA_DRAW_FRAME; class EDA_DRAW_FRAME;
/* Class to handle hotkey commands. hotkeys have a default value /* Identifiers (tags) in key code configuration file (or section names)
* This class allows the real key code changed by user(from a key code list file) * .m_SectionTag member of a EDA_HOTKEY_CONFIG
*/
extern wxString g_CommonSectionTag;
extern wxString g_SchematicSectionTag;
extern wxString g_LibEditSectionTag;
extern wxString g_BoardEditorSectionTag;
extern wxString g_ModuleEditSectionTag;
/**
* class EDA_HOTKEY
* is a class to handle hot key commands. Hot keys have a default value.
* This class allows the real key code changed by user(from a key code list file)
*/ */
class EDA_HOTKEY class EDA_HOTKEY
{ {
...@@ -49,31 +84,42 @@ public: ...@@ -49,31 +84,42 @@ public:
const wchar_t* m_Comment; // Will be printed in the config file only. const wchar_t* m_Comment; // Will be printed in the config file only.
}; };
/* Identifiers (tags) in key code configuration file (or section names)
* .m_SectionTag member of a EDA_HOTKEY_CONFIG /**
* Class EDA_HOTKEY_CLIENT_DATA
* provides client data member for hotkeys to include in command events generated
* by the hot key.
*/ */
extern wxString g_CommonSectionTag; class EDA_HOTKEY_CLIENT_DATA : public wxClientData
extern wxString g_SchematicSectionTag; {
extern wxString g_LibEditSectionTag; //< Logical position of the mouse cursor when the hot key was pressed.
extern wxString g_BoardEditorSectionTag; wxPoint m_position;
extern wxString g_ModuleEditSectionTag;
public:
EDA_HOTKEY_CLIENT_DATA( const wxPoint& aPosition = wxDefaultPosition ) :
m_position( aPosition ) {}
void SetPosition( const wxPoint& aPosition ) { m_position = aPosition; }
wxPoint GetPosition() { return m_position; }
};
/* Functions: /* Functions:
*/ */
void AddHotkeyConfigMenu( wxMenu* menu ); void AddHotkeyConfigMenu( wxMenu* menu );
void HandleHotkeyConfigMenuSelection( EDA_DRAW_FRAME* frame, int id ); void HandleHotkeyConfigMenuSelection( EDA_DRAW_FRAME* frame, int id );
/** /**
* Function ReturnKeyNameFromKeyCode * Function ReturnKeyNameFromKeyCode
* return the key name from the key code * return the key name from the key code
* Only some wxWidgets key values are handled for function key ( see * * Only some wxWidgets key values are handled for function key ( see
* s_Hotkey_Name_List[] ) * s_Hotkey_Name_List[] )
* @param aKeycode = key code (ascii value, or wxWidgets value for function keys) * @param aKeycode = key code (ascii value, or wxWidgets value for function keys)
* @param aIsFound = a pointer to a bool to return true if found, or false. an be NULL default) * @param aIsFound = a pointer to a bool to return true if found, or false. an be NULL default)
* @return the key name in a wxString * @return the key name in a wxString
*/ */
wxString ReturnKeyNameFromKeyCode( int aKeycode, bool * aIsFound = NULL ); wxString ReturnKeyNameFromKeyCode( int aKeycode, bool * aIsFound = NULL );
/** /**
* Function ReturnKeyNameFromCommandId * Function ReturnKeyNameFromCommandId
...@@ -82,9 +128,10 @@ wxString ReturnKeyNameFromKeyCode( int aKeycode, bool * aIsFound = NULL ) ...@@ -82,9 +128,10 @@ wxString ReturnKeyNameFromKeyCode( int aKeycode, bool * aIsFound = NULL )
* @param aCommandId = Command Id value * @param aCommandId = Command Id value
* @return the key name in a wxString * @return the key name in a wxString
*/ */
wxString ReturnKeyNameFromCommandId( EDA_HOTKEY** aList, int aCommandId ); wxString ReturnKeyNameFromCommandId( EDA_HOTKEY** aList, int aCommandId );
/** /**
* Function ReturnKeyCodeFromKeyName * Function ReturnKeyCodeFromKeyName
* return the key code from its key name * return the key code from its key name
* Only some wxWidgets key values are handled for function key * Only some wxWidgets key values are handled for function key
......
...@@ -146,7 +146,6 @@ private: ...@@ -146,7 +146,6 @@ private:
static int m_lastSheetPinType; ///< Last sheet pin type. static int m_lastSheetPinType; ///< Last sheet pin type.
static wxSize m_lastSheetPinTextSize; ///< Last sheet pin text size. static wxSize m_lastSheetPinTextSize; ///< Last sheet pin text size.
static wxPoint m_lastSheetPinPosition; ///< Last sheet pin position. static wxPoint m_lastSheetPinPosition; ///< Last sheet pin position.
static int m_lastSheetPinEdge; ///< Last sheet edge a sheet pin was placed.
protected: protected:
TEMPLATES m_TemplateFieldNames; TEMPLATES m_TemplateFieldNames;
...@@ -773,8 +772,6 @@ public: ...@@ -773,8 +772,6 @@ public:
wxPoint GetLastSheetPinPosition() const { return m_lastSheetPinPosition; } wxPoint GetLastSheetPinPosition() const { return m_lastSheetPinPosition; }
int GetLastSheetPinEdge() const { return m_lastSheetPinEdge; }
private: private:
void StartMoveSheet( SCH_SHEET* sheet, wxDC* DC ); void StartMoveSheet( SCH_SHEET* sheet, wxDC* DC );
...@@ -796,14 +793,6 @@ private: ...@@ -796,14 +793,6 @@ private:
*/ */
int EditSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC ); int EditSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC );
/**
* Function MoveSheetPin
* moves \a aSheetPin within it's parent sheet object.
* @param aSheetPin The sheet pin item to move.
* @param aDC The device context to draw on.
*/
void MoveSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC );
/** /**
* Function ImportSheetPin * Function ImportSheetPin
* automatically creates a sheet pin from the hierarchical labels in the schematic * automatically creates a sheet pin from the hierarchical labels in the schematic
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment