Commit ffa9feda authored by Wayne Stambaugh's avatar Wayne Stambaugh

Schematic component library editor rotate item improvements.

* Merge three separate rotate code paths into a single rotate item function.
* Reduce three separate rotate command IDs into a single rotate command ID.
* Move pin rotate code into pin object.
parent bc8f250b
...@@ -166,9 +166,10 @@ enum id_eeschema_frm ...@@ -166,9 +166,10 @@ enum id_eeschema_frm
ID_LIBEDIT_EXPORT_BODY_BUTT, ID_LIBEDIT_EXPORT_BODY_BUTT,
ID_LIBEDIT_DELETE_ITEM_BUTT, ID_LIBEDIT_DELETE_ITEM_BUTT,
ID_LIBEDIT_ROTATE_ITEM,
/* Library editor context menu IDs */ /* Library editor context menu IDs */
ID_LIBEDIT_EDIT_PIN, ID_LIBEDIT_EDIT_PIN,
ID_LIBEDIT_ROTATE_PIN,
ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_ITEM, ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_ITEM,
ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM, ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM,
ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM, ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM,
...@@ -180,9 +181,7 @@ enum id_eeschema_frm ...@@ -180,9 +181,7 @@ enum id_eeschema_frm
ID_POPUP_LIBEDIT_CANCEL_EDITING, ID_POPUP_LIBEDIT_CANCEL_EDITING,
ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST,
ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM, ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM,
ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM,
ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT, ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT,
ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT,
/* Library editor menubar IDs */ /* Library editor menubar IDs */
ID_LIBEDIT_SAVE_CURRENT_LIB_AS, ID_LIBEDIT_SAVE_CURRENT_LIB_AS,
......
...@@ -959,7 +959,8 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -959,7 +959,8 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
break; break;
case HK_EDIT: case HK_EDIT:
m_drawItem = LocateItemUsingCursor( aPosition ); if( itemInEdit )
m_drawItem = LocateItemUsingCursor( aPosition );
if( m_drawItem ) if( m_drawItem )
{ {
...@@ -991,30 +992,13 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -991,30 +992,13 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
break; break;
case HK_ROTATE: case HK_ROTATE:
m_drawItem = LocateItemUsingCursor( aPosition ); if( m_drawItem == NULL )
m_drawItem = LocateItemUsingCursor( aPosition );
if( m_drawItem ) if( m_drawItem )
{ {
switch( m_drawItem->Type() ) cmd.SetId( ID_LIBEDIT_ROTATE_ITEM );
{ GetEventHandler()->ProcessEvent( cmd );
case LIB_PIN_T:
cmd.SetId( ID_LIBEDIT_ROTATE_PIN );
GetEventHandler()->ProcessEvent( cmd );
break;
case LIB_TEXT_T:
cmd.SetId( ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT );
GetEventHandler()->ProcessEvent( cmd );
break;
case LIB_FIELD_T:
cmd.SetId( ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM );
GetEventHandler()->ProcessEvent( cmd );
break;
default:
break;
}
} }
break; break;
...@@ -1024,7 +1008,8 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -1024,7 +1008,8 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
break; break;
case HK_DELETE: case HK_DELETE:
m_drawItem = LocateItemUsingCursor( aPosition ); if( !itemInEdit )
m_drawItem = LocateItemUsingCursor( aPosition );
if( m_drawItem && !m_drawItem->InEditMode() ) if( m_drawItem && !m_drawItem->InEditMode() )
{ {
...@@ -1035,13 +1020,16 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, ...@@ -1035,13 +1020,16 @@ void LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
break; break;
case HK_LIBEDIT_MOVE_GRAPHIC_ITEM: case HK_LIBEDIT_MOVE_GRAPHIC_ITEM:
m_drawItem = LocateItemUsingCursor( aPosition ); if( !itemInEdit )
if( m_drawItem && !m_drawItem->InEditMode() )
{ {
wxCommandEvent evt; m_drawItem = LocateItemUsingCursor( aPosition );
evt.SetId( ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST );
Process_Special_Functions( evt ); if( m_drawItem )
{
wxCommandEvent evt;
evt.SetId( ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST );
Process_Special_Functions( evt );
}
} }
break; break;
......
...@@ -1798,6 +1798,21 @@ int LIB_PIN::GetOrientationCodeIndex( int code ) ...@@ -1798,6 +1798,21 @@ int LIB_PIN::GetOrientationCodeIndex( int code )
} }
void LIB_PIN::Rotate()
{
// Get the actual pin orientation index
int i = GetOrientationCodeIndex( GetOrientation() );
// Compute the next orientation, swap lower two bits for the right order
i = ((i & 2) >> 1) | ((i & 1) << 1);
i = i + 1;
i = ((i & 2) >> 1) | ((i & 1) << 1);
// Set the new orientation
SetOrientation( GetOrientationCode( i ) );
}
wxArrayString LIB_PIN::GetStyleNames( void ) wxArrayString LIB_PIN::GetStyleNames( void )
{ {
wxArrayString tmp; wxArrayString tmp;
......
...@@ -158,12 +158,12 @@ public: ...@@ -158,12 +158,12 @@ public:
wxPoint ReturnPinEndPoint() const; wxPoint ReturnPinEndPoint() const;
/** /**
* Function ReturnPinDrawOrient * Function ReturnPinDrawOrient
* Return the pin real orientation (PIN_UP, PIN_DOWN, PIN_RIGHT, PIN_LEFT), * returns the pin real orientation (PIN_UP, PIN_DOWN, PIN_RIGHT, PIN_LEFT),
* according to its orientation and the matrix transform (rot, mirror) \a aTransform * according to its orientation and the matrix transform (rot, mirror) \a aTransform
* @param aTransform = transform matrix * @param aTransform = transform matrix
*/ */
int ReturnPinDrawOrient( const TRANSFORM& aTransform ); int ReturnPinDrawOrient( const TRANSFORM& aTransform );
/** /**
...@@ -189,7 +189,7 @@ public: ...@@ -189,7 +189,7 @@ public:
*/ */
static wxString ReturnPinStringNum( long aPinNum ); static wxString ReturnPinStringNum( long aPinNum );
void SetPinNumFromString( wxString& aBuffer ); void SetPinNumFromString( wxString& aBuffer );
wxString GetName() const { return m_name; } wxString GetName() const { return m_name; }
...@@ -243,6 +243,8 @@ public: ...@@ -243,6 +243,8 @@ public:
*/ */
void SetOrientation( int aOrientation ); void SetOrientation( int aOrientation );
void Rotate();
int GetShape() const { return m_shape; } int GetShape() const { return m_shape; }
/** /**
......
...@@ -83,7 +83,9 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) ...@@ -83,7 +83,9 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
break; break;
case ID_LIBEDIT_DELETE_ITEM_BUTT: case ID_LIBEDIT_DELETE_ITEM_BUTT:
if( LocateItemUsingCursor( aPosition ) ) m_drawItem = LocateItemUsingCursor( aPosition );
if( m_drawItem )
deleteItem( DC ); deleteItem( DC );
else else
DisplayCmpDoc(); DisplayCmpDoc();
......
...@@ -151,7 +151,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -151,7 +151,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, msg, edit_text_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_BODY_EDIT_ITEM, msg, edit_text_xpm );
msg = AddHotkeyName( _( "Rotate Text" ), s_Libedit_Hokeys_Descr, HK_ROTATE ); msg = AddHotkeyName( _( "Rotate Text" ), s_Libedit_Hokeys_Descr, HK_ROTATE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT, msg, edit_text_xpm ); ADD_MENUITEM( PopMenu, ID_LIBEDIT_ROTATE_ITEM, msg, edit_text_xpm );
if( DrawEntry->m_Flags == 0 ) if( DrawEntry->m_Flags == 0 )
{ {
...@@ -203,7 +203,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) ...@@ -203,7 +203,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, msg, move_field_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_MOVE_ITEM_REQUEST, msg, move_field_xpm );
} }
msg = AddHotkeyName( _( "Field Rotate" ), s_Libedit_Hokeys_Descr, HK_ROTATE ); msg = AddHotkeyName( _( "Field Rotate" ), s_Libedit_Hokeys_Descr, HK_ROTATE );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM, msg, rotate_field_xpm ); ADD_MENUITEM( PopMenu, ID_LIBEDIT_ROTATE_ITEM, msg, rotate_field_xpm );
msg = AddHotkeyName( _( "Field Edit" ), s_Libedit_Hokeys_Descr, HK_EDIT ); msg = AddHotkeyName( _( "Field Edit" ), s_Libedit_Hokeys_Descr, HK_EDIT );
ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM, msg, edit_text_xpm ); ADD_MENUITEM( PopMenu, ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM, msg, edit_text_xpm );
break; break;
...@@ -240,7 +240,7 @@ void AddMenusForPin( wxMenu* PopMenu, LIB_PIN* Pin, LIB_EDIT_FRAME* frame ) ...@@ -240,7 +240,7 @@ void AddMenusForPin( wxMenu* PopMenu, LIB_PIN* Pin, LIB_EDIT_FRAME* frame )
ADD_MENUITEM( PopMenu, ID_LIBEDIT_EDIT_PIN, msg, edit_xpm ); ADD_MENUITEM( PopMenu, ID_LIBEDIT_EDIT_PIN, msg, edit_xpm );
msg = AddHotkeyName( _( "Rotate Pin " ), s_Libedit_Hokeys_Descr, HK_ROTATE ); msg = AddHotkeyName( _( "Rotate Pin " ), s_Libedit_Hokeys_Descr, HK_ROTATE );
ADD_MENUITEM( PopMenu, ID_LIBEDIT_ROTATE_PIN, msg, rotate_pin_xpm ); ADD_MENUITEM( PopMenu, ID_LIBEDIT_ROTATE_ITEM, msg, rotate_pin_xpm );
if( not_in_move ) if( not_in_move )
{ {
......
...@@ -128,12 +128,12 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) ...@@ -128,12 +128,12 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, LIB_EDIT_FRAME::SetLanguage ) EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, LIB_EDIT_FRAME::SetLanguage )
/* Context menu events and commands. */ /* Context menu events and commands. */
EVT_MENU( ID_LIBEDIT_EDIT_PIN, LIB_EDIT_FRAME::OnEditPin ) EVT_MENU( ID_LIBEDIT_EDIT_PIN, LIB_EDIT_FRAME::OnEditPin )
EVT_MENU( ID_LIBEDIT_ROTATE_PIN, LIB_EDIT_FRAME::OnRotatePin ) EVT_MENU( ID_LIBEDIT_ROTATE_ITEM, LIB_EDIT_FRAME::OnRotateItem )
EVT_MENU_RANGE( ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_ITEM, EVT_MENU_RANGE( ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_ITEM,
ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT, ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT,
LIB_EDIT_FRAME::Process_Special_Functions ) LIB_EDIT_FRAME::Process_Special_Functions )
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
...@@ -618,7 +618,6 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -618,7 +618,6 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_LIBEDIT_END_CREATE_ITEM: case ID_POPUP_LIBEDIT_END_CREATE_ITEM:
case ID_LIBEDIT_EDIT_PIN: case ID_LIBEDIT_EDIT_PIN:
case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM: case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM:
case ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM:
case ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM: case ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM:
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM: case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM:
case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM: case ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM:
...@@ -630,7 +629,6 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -630,7 +629,6 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_MIRROR_Y_BLOCK: case ID_POPUP_MIRROR_Y_BLOCK:
case ID_POPUP_PLACE_BLOCK: case ID_POPUP_PLACE_BLOCK:
case ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT: case ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT:
case ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT:
break; break;
case ID_POPUP_LIBEDIT_CANCEL_EDITING: case ID_POPUP_LIBEDIT_CANCEL_EDITING:
...@@ -752,37 +750,6 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -752,37 +750,6 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_LIBEDIT_ROTATE_GRAPHIC_TEXT:
if( m_drawItem == NULL && m_drawItem->Type() != LIB_TEXT_T )
break;
DrawPanel->MoveCursorToCrossHair();
if( !m_drawItem->InEditMode() )
{
SaveCopyInUndoList( m_component );
m_drawItem->SetUnit( m_unit );
}
m_drawItem->Rotate();
DrawPanel->Refresh();
break;
case ID_POPUP_LIBEDIT_FIELD_ROTATE_ITEM:
{
if( m_drawItem == NULL || ( m_drawItem->Type() != LIB_FIELD_T ) )
break;
DrawPanel->MoveCursorToCrossHair();
if( !m_drawItem->InEditMode() )
{
SaveCopyInUndoList( m_component );
m_drawItem->SetUnit( m_unit );
}
m_drawItem->Rotate();
DrawPanel->Refresh();
break;
}
case ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM: case ID_POPUP_LIBEDIT_FIELD_EDIT_ITEM:
if( m_drawItem == NULL ) if( m_drawItem == NULL )
break; break;
...@@ -854,7 +821,6 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -854,7 +821,6 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( GetToolId() == ID_NO_TOOL_SELECTED ) if( GetToolId() == ID_NO_TOOL_SELECTED )
m_lastDrawItem = NULL; m_lastDrawItem = NULL;
} }
...@@ -1093,6 +1059,43 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) ...@@ -1093,6 +1059,43 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
} }
void LIB_EDIT_FRAME::OnRotateItem( wxCommandEvent& aEvent )
{
if( m_drawItem == NULL )
return;
if( !m_drawItem->InEditMode() )
{
SaveCopyInUndoList( m_component );
m_drawItem->SetUnit( m_unit );
}
m_drawItem->Rotate();
OnModify();
DrawPanel->Refresh();
if( GetToolId() == ID_NO_TOOL_SELECTED )
m_lastDrawItem = NULL;
}
LIB_DRAW_ITEM* LIB_EDIT_FRAME::LocateItemUsingCursor( const wxPoint& aPosition )
{
if( m_component == NULL )
return NULL;
LIB_DRAW_ITEM* item = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT,
aPosition );
wxPoint pos = GetScreen()->GetNearestGridPosition( aPosition );
if( item == NULL && aPosition != pos )
item = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT, pos );
return item;
}
void LIB_EDIT_FRAME::deleteItem( wxDC* aDC ) void LIB_EDIT_FRAME::deleteItem( wxDC* aDC )
{ {
wxCHECK_RET( m_drawItem != NULL, wxT( "No drawing item selected to delete." ) ); wxCHECK_RET( m_drawItem != NULL, wxT( "No drawing item selected to delete." ) );
......
...@@ -74,7 +74,6 @@ public: ...@@ -74,7 +74,6 @@ public:
void OnCheckComponent( wxCommandEvent& event ); void OnCheckComponent( wxCommandEvent& event );
void OnSelectBodyStyle( wxCommandEvent& event ); void OnSelectBodyStyle( wxCommandEvent& event );
void OnEditPin( wxCommandEvent& event ); void OnEditPin( wxCommandEvent& event );
void OnRotatePin( wxCommandEvent& event );
void OnUpdateSelectTool( wxUpdateUIEvent& aEvent ); void OnUpdateSelectTool( wxUpdateUIEvent& aEvent );
void OnUpdateEditingPart( wxUpdateUIEvent& event ); void OnUpdateEditingPart( wxUpdateUIEvent& event );
...@@ -225,6 +224,12 @@ private: ...@@ -225,6 +224,12 @@ private:
void DisplayCmpDoc(); void DisplayCmpDoc();
/**
* Function OnRotateItem
* rotates the current item.
*/
void OnRotateItem( wxCommandEvent& aEvent );
/** /**
* Function deleteItem * Function deleteItem
* deletes the currently selected draw item. * deletes the currently selected draw item.
......
...@@ -152,22 +152,3 @@ this component?" ), ...@@ -152,22 +152,3 @@ this component?" ),
OnModify(); OnModify();
UpdateAliasSelectList(); UpdateAliasSelectList();
} }
LIB_DRAW_ITEM* LIB_EDIT_FRAME::LocateItemUsingCursor( const wxPoint& aPosition )
{
if( m_component == NULL )
return NULL;
if( ( m_drawItem == NULL ) || ( m_drawItem->m_Flags == 0 ) )
{
m_drawItem = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT, aPosition );
wxPoint pos = GetScreen()->GetNearestGridPosition( aPosition );
if( m_drawItem == NULL && aPosition != pos )
m_drawItem = m_component->LocateDrawItem( m_unit, m_convert, TYPE_NOT_INIT, pos );
}
return m_drawItem;
}
...@@ -38,42 +38,6 @@ static bool LastPinCommonUnit = false; ...@@ -38,42 +38,6 @@ static bool LastPinCommonUnit = false;
static bool LastPinVisible = true; static bool LastPinVisible = true;
void LIB_EDIT_FRAME::OnRotatePin( wxCommandEvent& event )
{
// Check, if the item is a pin, else return
if( m_drawItem == NULL || m_drawItem->Type() != LIB_PIN_T )
return;
// save flags to restore them after rotating
int item_flags = m_drawItem->m_Flags;
LIB_PIN* pin = (LIB_PIN*) m_drawItem;
// Save old pin orientation
LastPinOrient = pin->GetOrientation();
if( !pin->InEditMode() )
SaveCopyInUndoList( pin->GetParent() );
// Get the actual pin orientation index
int orientationIndex = pin->GetOrientationCodeIndex( pin->GetOrientation() );
// Compute the next orientation, swap lower two bits for the right order
orientationIndex = ((orientationIndex & 2) >> 1) | ((orientationIndex & 1) << 1);
orientationIndex = orientationIndex + 1;
orientationIndex = ((orientationIndex & 2) >> 1) | ((orientationIndex & 1) << 1);
// Set the new orientation
pin->SetOrientation( pin->GetOrientationCode( orientationIndex ) );
OnModify( );
pin->DisplayInfo( this );
DrawPanel->Refresh();
// Restore pin flags
pin->m_Flags = item_flags;
}
void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event ) void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
{ {
if( m_drawItem == NULL || m_drawItem->Type() != LIB_PIN_T ) if( m_drawItem == NULL || m_drawItem->Type() != LIB_PIN_T )
...@@ -129,12 +93,8 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event ) ...@@ -129,12 +93,8 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
} }
/* Save the pin properties to use for the next new pin. */ /* Save the pin properties to use for the next new pin. */
LastPinNameSize = ReturnValueFromString( g_UserUnit, LastPinNameSize = ReturnValueFromString( g_UserUnit, dlg.GetNameTextSize(), m_InternalUnits );
dlg.GetNameTextSize(), LastPinNumSize = ReturnValueFromString( g_UserUnit, dlg.GetNumberTextSize(), m_InternalUnits );
m_InternalUnits );
LastPinNumSize = ReturnValueFromString( g_UserUnit,
dlg.GetNumberTextSize(),
m_InternalUnits );
LastPinOrient = LIB_PIN::GetOrientationCode( dlg.GetOrientation() ); LastPinOrient = LIB_PIN::GetOrientationCode( dlg.GetOrientation() );
LastPinLength = ReturnValueFromString( g_UserUnit, dlg.GetLength(), m_InternalUnits ); LastPinLength = ReturnValueFromString( g_UserUnit, dlg.GetLength(), m_InternalUnits );
LastPinShape = LIB_PIN::GetStyleCode( dlg.GetStyle() ); LastPinShape = LIB_PIN::GetStyleCode( dlg.GetStyle() );
...@@ -220,7 +180,7 @@ void LIB_EDIT_FRAME::PlacePin( wxDC* DC ) ...@@ -220,7 +180,7 @@ void LIB_EDIT_FRAME::PlacePin( wxDC* DC )
newpos = GetScreen()->GetCrossHairPosition( true ); newpos = GetScreen()->GetCrossHairPosition( true );
// Tst for an other pin in same new position: // Test for an other pin in same new position:
for( Pin = m_component->GetNextPin(); Pin != NULL; Pin = m_component->GetNextPin( Pin ) ) for( Pin = m_component->GetNextPin(); Pin != NULL; Pin = m_component->GetNextPin( Pin ) )
{ {
if( Pin == CurrentPin || newpos != Pin->GetPosition() || Pin->m_Flags ) if( Pin == CurrentPin || newpos != Pin->GetPosition() || Pin->m_Flags )
...@@ -302,11 +262,14 @@ void LIB_EDIT_FRAME::StartMovePin( wxDC* DC ) ...@@ -302,11 +262,14 @@ void LIB_EDIT_FRAME::StartMovePin( wxDC* DC )
/* Mark pins for moving. */ /* Mark pins for moving. */
Pin = m_component->GetNextPin(); Pin = m_component->GetNextPin();
for( ; Pin != NULL; Pin = m_component->GetNextPin( Pin ) ) for( ; Pin != NULL; Pin = m_component->GetNextPin( Pin ) )
{ {
Pin->m_Flags = 0; Pin->m_Flags = 0;
if( Pin == CurrentPin ) if( Pin == CurrentPin )
continue; continue;
if( ( Pin->GetPosition() == CurrentPin->GetPosition() ) if( ( Pin->GetPosition() == CurrentPin->GetPosition() )
&& ( Pin->GetOrientation() == CurrentPin->GetOrientation() ) && ( Pin->GetOrientation() == CurrentPin->GetOrientation() )
&& ( g_EditPinByPinIsOn == false ) ) && ( g_EditPinByPinIsOn == false ) )
...@@ -483,7 +446,7 @@ static void CreateImagePins( LIB_PIN* Pin, int unit, int convert, bool asDeMorga ...@@ -483,7 +446,7 @@ static void CreateImagePins( LIB_PIN* Pin, int unit, int convert, bool asDeMorga
/* Depending on "id": /* Depending on "id":
* - Change pin text size (name or num) (range 10 .. 1000 mil) * - Change pin text size (name or num) (range 10 .. 1000 mil)
* - Change pin lenght. * - Change pin length.
* *
* If Pin is selected ( .m_flag == IS_SELECTED ) only the other selected * If Pin is selected ( .m_flag == IS_SELECTED ) only the other selected
* pins are modified * pins are modified
...@@ -531,8 +494,8 @@ void LIB_EDIT_FRAME::GlobalSetPins( wxDC* DC, LIB_PIN* MasterPin, int id ) ...@@ -531,8 +494,8 @@ void LIB_EDIT_FRAME::GlobalSetPins( wxDC* DC, LIB_PIN* MasterPin, int id )
break; break;
} }
( ( LIB_DRAW_ITEM* )Pin )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, GR_DEFAULT_DRAWMODE, Pin->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, GR_DEFAULT_DRAWMODE, &showPinText,
&showPinText, DefaultTransform ); DefaultTransform );
} }
} }
...@@ -690,7 +653,7 @@ void LIB_EDIT_FRAME::OnCheckComponent( wxCommandEvent& event ) ...@@ -690,7 +653,7 @@ void LIB_EDIT_FRAME::OnCheckComponent( wxCommandEvent& event )
( (Pin->GetPosition().y % MIN_GRID_SIZE) == 0 ) ) ( (Pin->GetPosition().y % MIN_GRID_SIZE) == 0 ) )
continue; continue;
// A pin is foun here off grid // A pin is found here off grid
offgrid_error++; offgrid_error++;
wxString stringPinNum; wxString stringPinNum;
Pin->ReturnPinStringNum( stringPinNum ); Pin->ReturnPinStringNum( stringPinNum );
......
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