Fix schematic library pin editing bug. Fixes lp:809506

* Change edit pin per part flag to only have effect when editing
  component with multiple parts or alternate body styles.
* Move global edit pin pert part variable into library editor frame
  object.
* Note that this only fixes the bug when the component does not have
  multiple parts or alternate body styles.
This commit is contained in:
Wayne Stambaugh 2011-10-28 09:43:37 -04:00
parent 858636fd27
commit a834c47be5
7 changed files with 286 additions and 70 deletions

View File

@ -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 <stambaughw@verizon.net>
* 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 block_libedit.cpp * @file block_libedit.cpp
*/ */
@ -99,7 +124,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
if ( m_component ) if ( m_component )
ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate, ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate,
m_unit, m_convert, m_unit, m_convert,
g_EditPinByPinIsOn ); m_editPinsPerPartOrConvert );
if( ItemCount ) if( ItemCount )
{ {
nextCmd = true; nextCmd = true;
@ -126,9 +151,10 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
if ( m_component ) if ( m_component )
ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate, ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate,
m_unit, m_convert, m_unit, m_convert,
g_EditPinByPinIsOn ); m_editPinsPerPartOrConvert );
if( ItemCount ) if( ItemCount )
SaveCopyInUndoList( m_component ); SaveCopyInUndoList( m_component );
if ( m_component ) if ( m_component )
{ {
m_component->DeleteSelectedItems(); m_component->DeleteSelectedItems();
@ -148,15 +174,18 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
if ( m_component ) if ( m_component )
ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate, ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate,
m_unit, m_convert, m_unit, m_convert,
g_EditPinByPinIsOn ); m_editPinsPerPartOrConvert );
if( ItemCount ) if( ItemCount )
SaveCopyInUndoList( m_component ); SaveCopyInUndoList( m_component );
pt = GetScreen()->m_BlockLocate.Centre(); pt = GetScreen()->m_BlockLocate.Centre();
pt.y *= -1; pt.y *= -1;
if ( m_component ) if ( m_component )
{ {
OnModify(); OnModify();
int block_cmd = GetScreen()->m_BlockLocate.m_Command; int block_cmd = GetScreen()->m_BlockLocate.m_Command;
if( block_cmd == BLOCK_MIRROR_Y) if( block_cmd == BLOCK_MIRROR_Y)
m_component->MirrorSelectedItemsH( pt ); m_component->MirrorSelectedItemsH( pt );
else if( block_cmd == BLOCK_MIRROR_X) else if( block_cmd == BLOCK_MIRROR_X)
@ -164,6 +193,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
else if( block_cmd == BLOCK_ROTATE) else if( block_cmd == BLOCK_ROTATE)
m_component->RotateSelectedItems( pt ); m_component->RotateSelectedItems( pt );
} }
break; break;
case BLOCK_ZOOM: /* Window Zoom */ case BLOCK_ZOOM: /* Window Zoom */
@ -221,23 +251,31 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
case BLOCK_MOVE: /* Move */ case BLOCK_MOVE: /* Move */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
GetScreen()->m_BlockLocate.ClearItemsList(); GetScreen()->m_BlockLocate.ClearItemsList();
if ( m_component ) if ( m_component )
SaveCopyInUndoList( m_component ); SaveCopyInUndoList( m_component );
pt = GetScreen()->m_BlockLocate.m_MoveVector; pt = GetScreen()->m_BlockLocate.m_MoveVector;
pt.y *= -1; pt.y *= -1;
if ( m_component ) if ( m_component )
m_component->MoveSelectedItems( pt ); m_component->MoveSelectedItems( pt );
DrawPanel->Refresh( true ); DrawPanel->Refresh( true );
break; break;
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
GetScreen()->m_BlockLocate.ClearItemsList(); GetScreen()->m_BlockLocate.ClearItemsList();
if ( m_component ) if ( m_component )
SaveCopyInUndoList( m_component ); SaveCopyInUndoList( m_component );
pt = GetScreen()->m_BlockLocate.m_MoveVector; pt = GetScreen()->m_BlockLocate.m_MoveVector;
pt.y *= -1; pt.y *= -1;
if ( m_component ) if ( m_component )
m_component->CopySelectedItems( pt ); m_component->CopySelectedItems( pt );
break; break;
case BLOCK_PASTE: /* Paste (recopy the last block saved) */ case BLOCK_PASTE: /* Paste (recopy the last block saved) */
@ -249,11 +287,14 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
case BLOCK_MIRROR_Y: // Invert by popup menu, from block move case BLOCK_MIRROR_Y: // Invert by popup menu, from block move
if ( m_component ) if ( m_component )
SaveCopyInUndoList( m_component ); SaveCopyInUndoList( m_component );
pt = GetScreen()->m_BlockLocate.Centre(); pt = GetScreen()->m_BlockLocate.Centre();
pt.y *= -1; pt.y *= -1;
if ( m_component ) if ( m_component )
{ {
int block_cmd = GetScreen()->m_BlockLocate.m_Command; int block_cmd = GetScreen()->m_BlockLocate.m_Command;
if( block_cmd == BLOCK_MIRROR_Y) if( block_cmd == BLOCK_MIRROR_Y)
m_component->MirrorSelectedItemsH( pt ); m_component->MirrorSelectedItemsH( pt );
else if( block_cmd == BLOCK_MIRROR_X) else if( block_cmd == BLOCK_MIRROR_X)
@ -261,6 +302,7 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
else if( block_cmd == BLOCK_ROTATE ) else if( block_cmd == BLOCK_ROTATE )
m_component->RotateSelectedItems( pt ); m_component->RotateSelectedItems( pt );
} }
break; break;
case BLOCK_ZOOM: // Handled by HandleBlockEnd case BLOCK_ZOOM: // Handled by HandleBlockEnd

View File

@ -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 <stambaughw@verizon.net>
* 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.cpp * @file eeschema.cpp
*/ */
@ -46,10 +71,6 @@ const wxString CompLibFileWildcard( wxT( "KiCad component library file (*.lib)|*
LayerStruct g_LayerDescr; /* layer colors. */ LayerStruct g_LayerDescr; /* layer colors. */
bool g_EditPinByPinIsOn = false; /* true to do not synchronize pins
* edition when they are at the
* same location */
int g_DrawDefaultLineThickness = 6; /* Default line thickness in int g_DrawDefaultLineThickness = 6; /* Default line thickness in
* Eeschema units used to * Eeschema units used to
* draw/plot items having a * draw/plot items having a

View File

@ -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 <stambaughw@verizon.net>
* 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 libedit.cpp * @file libedit.cpp
* @brief Eeschema component library editor. * @brief Eeschema component library editor.
@ -74,8 +99,7 @@ bool LIB_EDIT_FRAME::LoadComponentFromCurrentLib( LIB_ALIAS* aLibEntry )
if( !LoadOneLibraryPartAux( aLibEntry, m_library ) ) if( !LoadOneLibraryPartAux( aLibEntry, m_library ) )
return false; return false;
g_EditPinByPinIsOn = m_component->UnitsLocked() ? true : false; m_editPinsPerPartOrConvert = m_component->UnitsLocked() ? true : false;
m_HToolBar->ToggleTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn );
GetScreen()->ClearUndoRedoList(); GetScreen()->ClearUndoRedoList();
Zoom_Automatique( false ); Zoom_Automatique( false );
@ -539,8 +563,7 @@ lost!\n\nClear the current component from the screen?" ) ) )
DisplayCmpDoc(); DisplayCmpDoc();
UpdateAliasSelectList(); UpdateAliasSelectList();
UpdatePartSelectList(); UpdatePartSelectList();
g_EditPinByPinIsOn = m_component->UnitsLocked() ? true : false; m_editPinsPerPartOrConvert = m_component->UnitsLocked() ? true : false;
m_HToolBar->ToggleTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn );
m_lastDrawItem = NULL; m_lastDrawItem = NULL;
GetScreen()->ClearUndoRedoList(); GetScreen()->ClearUndoRedoList();
OnModify(); OnModify();

View File

@ -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 <stambaughw@verizon.net>
* 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 libeditframe.cpp * @file libeditframe.cpp
* @brief LIB_EDIT_FRAME class is the component library editor frame. * @brief LIB_EDIT_FRAME class is the component library editor frame.
@ -66,9 +91,6 @@ int LIB_EDIT_FRAME:: m_drawLineWidth = 0;
FILL_T LIB_EDIT_FRAME:: m_drawFillStyle = NO_FILL; FILL_T LIB_EDIT_FRAME:: m_drawFillStyle = NO_FILL;
/************************/
/* class LIB_EDIT_FRAME */
/************************/
BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_CLOSE( LIB_EDIT_FRAME::OnCloseWindow ) EVT_CLOSE( LIB_EDIT_FRAME::OnCloseWindow )
EVT_SIZE( LIB_EDIT_FRAME::OnSize ) EVT_SIZE( LIB_EDIT_FRAME::OnSize )
@ -120,7 +142,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_MENU( ID_COLORS_SETUP, LIB_EDIT_FRAME::Process_Config ) EVT_MENU( ID_COLORS_SETUP, LIB_EDIT_FRAME::Process_Config )
EVT_MENU( ID_LIBEDIT_DIMENSIONS, LIB_EDIT_FRAME::InstallDimensionsDialog ) EVT_MENU( ID_LIBEDIT_DIMENSIONS, LIB_EDIT_FRAME::InstallDimensionsDialog )
// Multple item selection context menu commands. // Multiple item selection context menu commands.
EVT_MENU_RANGE( ID_SELECT_ITEM_START, ID_SELECT_ITEM_END, LIB_EDIT_FRAME::OnSelectItem ) EVT_MENU_RANGE( ID_SELECT_ITEM_START, ID_SELECT_ITEM_END, LIB_EDIT_FRAME::OnSelectItem )
EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END, EVT_MENU_RANGE( ID_PREFERENCES_HOTKEY_START, ID_PREFERENCES_HOTKEY_END,
@ -179,6 +201,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent,
m_drawSpecificUnit = false; m_drawSpecificUnit = false;
m_tempCopyComponent = NULL; m_tempCopyComponent = NULL;
m_HotkeysZoomAndGridList = s_Libedit_Hokeys_Descr; m_HotkeysZoomAndGridList = s_Libedit_Hokeys_Descr;
m_editPinsPerPartOrConvert = false;
wxIcon icon; wxIcon icon;
@ -192,7 +215,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent,
LoadSettings(); LoadSettings();
// Initilialize grid id to a default value if not found in config or bad: // Initialize grid id to a default value if not found in config or bad:
if( (m_LastGridSizeId <= 0) if( (m_LastGridSizeId <= 0)
|| ( m_LastGridSizeId < (ID_POPUP_GRID_USER - ID_POPUP_GRID_LEVEL_1000) ) ) || ( m_LastGridSizeId < (ID_POPUP_GRID_USER - ID_POPUP_GRID_LEVEL_1000) ) )
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000; m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;
@ -215,7 +238,6 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent,
m_auimgr.SetManagedWindow( this ); m_auimgr.SetManagedWindow( this );
EDA_PANEINFO horiz; EDA_PANEINFO horiz;
horiz.HorizontalToolbarPane(); horiz.HorizontalToolbarPane();
@ -225,8 +247,6 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent,
EDA_PANEINFO mesg; EDA_PANEINFO mesg;
mesg.MessageToolbarPane(); mesg.MessageToolbarPane();
m_auimgr.AddPane( m_HToolBar, m_auimgr.AddPane( m_HToolBar,
wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top().Row( 0 ) ); wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top().Row( 0 ) );
@ -310,8 +330,10 @@ void LIB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
return; return;
} }
else else
{
GetScreen()->ClrModify(); GetScreen()->ClrModify();
} }
}
BOOST_FOREACH( const CMP_LIBRARY &lib, CMP_LIBRARY::GetLibraryList() ) BOOST_FOREACH( const CMP_LIBRARY &lib, CMP_LIBRARY::GetLibraryList() )
{ {
@ -351,8 +373,7 @@ double LIB_EDIT_FRAME::BestZoom()
BoundaryBox = m_component->GetBoundingBox( m_unit, m_convert ); BoundaryBox = m_component->GetBoundingBox( m_unit, m_convert );
dx = BoundaryBox.GetWidth(); dx = BoundaryBox.GetWidth();
dy = BoundaryBox.GetHeight(); dy = BoundaryBox.GetHeight();
GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) );
);
} }
else else
{ {
@ -483,7 +504,7 @@ void LIB_EDIT_FRAME::OnUpdatePinByPin( wxUpdateUIEvent& event )
event.Enable( ( m_component != NULL ) event.Enable( ( m_component != NULL )
&& ( ( m_component->GetPartCount() > 1 ) || m_showDeMorgan ) ); && ( ( m_component->GetPartCount() > 1 ) || m_showDeMorgan ) );
event.Check( g_EditPinByPinIsOn ); event.Check( m_editPinsPerPartOrConvert );
} }
@ -653,7 +674,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_LIBEDIT_EDIT_PIN_BY_PIN: case ID_LIBEDIT_EDIT_PIN_BY_PIN:
g_EditPinByPinIsOn = m_HToolBar->GetToolState( ID_LIBEDIT_EDIT_PIN_BY_PIN ); m_editPinsPerPartOrConvert = m_HToolBar->GetToolState( ID_LIBEDIT_EDIT_PIN_BY_PIN );
break; break;
case ID_POPUP_LIBEDIT_END_CREATE_ITEM: case ID_POPUP_LIBEDIT_END_CREATE_ITEM:
@ -848,6 +869,7 @@ void LIB_EDIT_FRAME::EnsureActiveLibExists()
return; return;
bool exists = CMP_LIBRARY::LibraryExists( m_library ); bool exists = CMP_LIBRARY::LibraryExists( m_library );
if( exists ) if( exists )
return; return;
else else
@ -936,8 +958,9 @@ void LIB_EDIT_FRAME::OnEditComponentProperties( wxCommandEvent& event )
if( partLocked != GetComponent()->UnitsLocked() ) if( partLocked != GetComponent()->UnitsLocked() )
{ {
// g_EditPinByPinIsOn is set to the better value, if m_UnitSelectionLocked has changed // m_editPinsPerPartOrConvert is set to the better value, if m_UnitSelectionLocked
g_EditPinByPinIsOn = GetComponent()->UnitsLocked() ? true : false; // has changed
m_editPinsPerPartOrConvert = GetComponent()->UnitsLocked() ? true : false;
} }
UpdateAliasSelectList(); UpdateAliasSelectList();
@ -959,7 +982,7 @@ void LIB_EDIT_FRAME::InstallDimensionsDialog( wxCommandEvent& event )
void LIB_EDIT_FRAME::OnCreateNewPartFromExisting( wxCommandEvent& event ) void LIB_EDIT_FRAME::OnCreateNewPartFromExisting( wxCommandEvent& event )
{ {
wxCHECK_RET( m_component != NULL, wxCHECK_RET( m_component != NULL,
wxT( "Cannot create new part from non-existant current part." ) ); wxT( "Cannot create new part from non-existent current part." ) );
INSTALL_UNBUFFERED_DC( dc, DrawPanel ); INSTALL_UNBUFFERED_DC( dc, DrawPanel );
DrawPanel->CrossHairOff( &dc ); DrawPanel->CrossHairOff( &dc );
@ -1167,7 +1190,7 @@ void LIB_EDIT_FRAME::deleteItem( wxDC* aDC )
m_component->RemoveDrawItem( (LIB_ITEM*) pin, DrawPanel, aDC ); m_component->RemoveDrawItem( (LIB_ITEM*) pin, DrawPanel, aDC );
if( g_EditPinByPinIsOn == false ) if( SynchronizePins() )
{ {
LIB_PIN* tmp = m_component->GetNextPin(); LIB_PIN* tmp = m_component->GetNextPin();
@ -1182,13 +1205,20 @@ void LIB_EDIT_FRAME::deleteItem( wxDC* aDC )
m_component->RemoveDrawItem( (LIB_ITEM*) pin ); m_component->RemoveDrawItem( (LIB_ITEM*) pin );
} }
} }
DrawPanel->Refresh();
} }
else else
{ {
if( DrawPanel->IsMouseCaptured() ) if( DrawPanel->IsMouseCaptured() )
{
DrawPanel->m_endMouseCaptureCallback( DrawPanel, aDC ); DrawPanel->m_endMouseCaptureCallback( DrawPanel, aDC );
}
else else
{
m_component->RemoveDrawItem( m_drawItem, DrawPanel, aDC ); m_component->RemoveDrawItem( m_drawItem, DrawPanel, aDC );
DrawPanel->Refresh();
}
} }
m_drawItem = NULL; m_drawItem = NULL;
@ -1211,3 +1241,10 @@ void LIB_EDIT_FRAME::OnSelectItem( wxCommandEvent& aEvent )
m_drawItem = item; m_drawItem = item;
} }
} }
bool LIB_EDIT_FRAME::SynchronizePins() const
{
return !m_editPinsPerPartOrConvert && ( m_component && ( m_component->HasConversion() ||
m_component->IsMulti()) );
}

View File

@ -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 <stambaughw@verizon.net>
* 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 libeditframe.h * @file libeditframe.h
* @brief Definition of class LIB_EDIT_FRAME * @brief Definition of class LIB_EDIT_FRAME
@ -62,6 +87,14 @@ public:
void OnColorConfig( wxCommandEvent& aEvent ); void OnColorConfig( wxCommandEvent& aEvent );
void Process_Config( wxCommandEvent& event ); void Process_Config( wxCommandEvent& event );
/**
* Function SycnronizePins
* @return True if the edit pins per part or convert is false and the current
* component has multiple parts or body styles. Otherwise false is
* returned.
*/
bool SynchronizePins() const;
/** /**
* Function OnPlotCurrentComponent * Function OnPlotCurrentComponent
* plot the current component in SVG or PNG format. * plot the current component in SVG or PNG format.
@ -371,6 +404,19 @@ private:
void CreatePin( wxDC* DC ); void CreatePin( wxDC* DC );
void StartMovePin( wxDC* DC ); void StartMovePin( wxDC* DC );
/**
* Function CreateImagePins
* adds copies of \a aPin for \a aUnit in components with multiple parts and
* \a aConvert for components that have multiple body styles.
*
* @param aPin The pin to copy.
* @param aUnit The unit to add a copy of \a aPin to.
* @param aConvert The alternate body style to add a copy of \a aPin to.
* @param aDeMorgan Flag to indicate if \a aPin should be created for the
* alternate body style.
*/
void CreateImagePins( LIB_PIN* aPin, int aUnit, int aConvert, bool aDeMorgan );
/** /**
* Function PlaceAnchor * Function PlaceAnchor
* places an anchor reference coordinate for the current component. * places an anchor reference coordinate for the current component.
@ -450,6 +496,15 @@ protected:
*/ */
bool m_drawSpecificUnit; bool m_drawSpecificUnit;
/**
* Set to true to not synchronize pins at the same position when editing
* components with multiple parts or multiple body styles. Setting this
* to false allows editing each pin per part or body style individually.
* This requires the user to open each part or body style to make changes
* to the pin at the same location.
*/
bool m_editPinsPerPartOrConvert;
/** The current draw or edit graphic item fill style. */ /** The current draw or edit graphic item fill style. */
static FILL_T m_drawFillStyle; static FILL_T m_drawFillStyle;
@ -493,7 +548,7 @@ protected:
* Function CreatePNGorJPEGFile * Function CreatePNGorJPEGFile
* creates an image (screenshot) of the current component in PNG or JPEG format. * creates an image (screenshot) of the current component in PNG or JPEG format.
* @param aFileName = the full filename * @param aFileName = the full filename
* @param aFmt_jpeg = true to use JPEG ffile format, false to use PNG file format * @param aFmt_jpeg = true to use JPEG file format, false to use PNG file format
*/ */
void CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_jpeg ); void CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_jpeg );

View File

@ -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 <stambaughw@verizon.net>
* 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 pinedit.cpp * @file pinedit.cpp
* @brief Eeschema pin edit code. * @brief Eeschema pin edit code.
@ -23,7 +48,6 @@
extern void IncrementLabelMember( wxString& name ); extern void IncrementLabelMember( wxString& name );
static void CreateImagePins( LIB_PIN* Pin, int unit, int convert, bool asDeMorgan );
static void AbortPinMove( EDA_DRAW_PANEL* Panel, wxDC* DC ); static void AbortPinMove( EDA_DRAW_PANEL* Panel, wxDC* DC );
static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPositon, bool aErase ); static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPositon, bool aErase );
@ -108,7 +132,7 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
LastPinCommonUnit = dlg.GetAddToAllParts(); LastPinCommonUnit = dlg.GetAddToAllParts();
LastPinVisible = dlg.GetVisible(); LastPinVisible = dlg.GetVisible();
pin->EnableEditMode( true, g_EditPinByPinIsOn ); pin->EnableEditMode( true, m_editPinsPerPartOrConvert );
pin->SetName( dlg.GetName() ); pin->SetName( dlg.GetName() );
pin->SetNameTextSize( LastPinNameSize ); pin->SetNameTextSize( LastPinNameSize );
pin->SetNumber( dlg.GetPadName() ); pin->SetNumber( dlg.GetPadName() );
@ -131,7 +155,7 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
DrawPanel->Refresh(); DrawPanel->Refresh();
} }
pin->EnableEditMode( false, g_EditPinByPinIsOn ); pin->EnableEditMode( false, m_editPinsPerPartOrConvert );
// Restore pin flags, that can be changed by the dialog editor // Restore pin flags, that can be changed by the dialog editor
pin->m_Flags = item_flags; pin->m_Flags = item_flags;
@ -193,7 +217,7 @@ void LIB_EDIT_FRAME::PlacePin( wxDC* DC )
if( Pin == CurrentPin || newpos != Pin->GetPosition() || Pin->m_Flags ) if( Pin == CurrentPin || newpos != Pin->GetPosition() || Pin->m_Flags )
continue; continue;
if( ask_for_pin && !g_EditPinByPinIsOn ) if( ask_for_pin && SynchronizePins() )
{ {
DrawPanel->m_IgnoreMouseEvents = true; DrawPanel->m_IgnoreMouseEvents = true;
status = status =
@ -226,7 +250,7 @@ another pin. Continue?" ) );
LastPinType = CurrentPin->GetType(); LastPinType = CurrentPin->GetType();
LastPinShape = CurrentPin->GetShape(); LastPinShape = CurrentPin->GetShape();
if( !g_EditPinByPinIsOn ) if( SynchronizePins() )
CreateImagePins( CurrentPin, m_unit, m_convert, m_showDeMorgan ); CreateImagePins( CurrentPin, m_unit, m_convert, m_showDeMorgan );
m_lastDrawItem = CurrentPin; m_lastDrawItem = CurrentPin;
@ -279,7 +303,7 @@ void LIB_EDIT_FRAME::StartMovePin( wxDC* DC )
if( ( Pin->GetPosition() == CurrentPin->GetPosition() ) if( ( Pin->GetPosition() == CurrentPin->GetPosition() )
&& ( Pin->GetOrientation() == CurrentPin->GetOrientation() ) && ( Pin->GetOrientation() == CurrentPin->GetOrientation() )
&& ( g_EditPinByPinIsOn == false ) ) && SynchronizePins() )
Pin->m_Flags |= IS_LINKED | IS_MOVED; Pin->m_Flags |= IS_LINKED | IS_MOVED;
} }
@ -359,7 +383,7 @@ void LIB_EDIT_FRAME::CreatePin( wxDC* DC )
pin->SetConvert( m_convert ); pin->SetConvert( m_convert );
/* Flag pins to consider */ /* Flag pins to consider */
if( g_EditPinByPinIsOn == false ) if( SynchronizePins() )
pin->m_Flags |= IS_LINKED; pin->m_Flags |= IS_LINKED;
pin->SetPosition( GetScreen()->GetCrossHairPosition( true ) ); pin->SetPosition( GetScreen()->GetCrossHairPosition( true ) );
@ -372,8 +396,6 @@ void LIB_EDIT_FRAME::CreatePin( wxDC* DC )
pin->SetConvert( LastPinCommonConvert ? 0 : m_convert ); pin->SetConvert( LastPinCommonConvert ? 0 : m_convert );
pin->SetUnit( LastPinCommonUnit ? 0 : m_unit ); pin->SetUnit( LastPinCommonUnit ? 0 : m_unit );
pin->SetVisible( LastPinVisible ); pin->SetVisible( LastPinVisible );
//PlacePin( DC );
//m_drawItem = pin;
PinPreviousPos = pin->GetPosition(); PinPreviousPos = pin->GetPosition();
DrawPanel->m_IgnoreMouseEvents = true; DrawPanel->m_IgnoreMouseEvents = true;
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
@ -399,55 +421,50 @@ void LIB_EDIT_FRAME::CreatePin( wxDC* DC )
} }
static void CreateImagePins( LIB_PIN* Pin, int unit, int convert, bool asDeMorgan ) void LIB_EDIT_FRAME::CreateImagePins( LIB_PIN* aPin, int aUnit, int aConvert, bool aDeMorgan )
{ {
int ii; int ii;
LIB_PIN* NewPin; LIB_PIN* NewPin;
bool CreateConv = false;
if( !SynchronizePins() )
if( g_EditPinByPinIsOn )
return; return;
if( asDeMorgan && ( Pin->GetConvert() != 0 ) )
CreateConv = true;
/* Create "convert" pin at the current position. */ /* Create "convert" pin at the current position. */
if( CreateConv == true ) if( aDeMorgan && ( aPin->GetConvert() != 0 ) )
{ {
NewPin = (LIB_PIN*) Pin->Clone(); NewPin = (LIB_PIN*) aPin->Clone();
if( Pin->GetConvert() > 1 ) if( aPin->GetConvert() > 1 )
NewPin->SetConvert( 1 ); NewPin->SetConvert( 1 );
else else
NewPin->SetConvert( 2 ); NewPin->SetConvert( 2 );
Pin->GetParent()->AddDrawItem( NewPin ); aPin->GetParent()->AddDrawItem( NewPin );
} }
for( ii = 1; ii <= Pin->GetParent()->GetPartCount(); ii++ ) for( ii = 1; ii <= aPin->GetParent()->GetPartCount(); ii++ )
{ {
if( ii == unit || Pin->GetUnit() == 0 ) if( ii == aUnit || aPin->GetUnit() == 0 )
continue; /* Pin common to all units. */ continue; /* Pin common to all units. */
NewPin = (LIB_PIN*) Pin->Clone(); NewPin = (LIB_PIN*) aPin->Clone();
if( convert != 0 ) if( aConvert != 0 )
NewPin->SetConvert( 1 ); NewPin->SetConvert( 1 );
NewPin->SetUnit( ii ); NewPin->SetUnit( ii );
Pin->GetParent()->AddDrawItem( NewPin ); aPin->GetParent()->AddDrawItem( NewPin );
if( CreateConv == false ) if( !( aDeMorgan && ( aPin->GetConvert() != 0 ) ) )
continue; continue;
NewPin = (LIB_PIN*) Pin->Clone(); NewPin = (LIB_PIN*) aPin->Clone();
NewPin->SetConvert( 2 ); NewPin->SetConvert( 2 );
if( Pin->GetUnit() != 0 ) if( aPin->GetUnit() != 0 )
NewPin->SetUnit( ii ); NewPin->SetUnit( ii );
Pin->GetParent()->AddDrawItem( NewPin ); aPin->GetParent()->AddDrawItem( NewPin );
} }
} }
@ -530,7 +547,7 @@ void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin )
m_drawItem = Pin; m_drawItem = Pin;
if( g_EditPinByPinIsOn == false ) if( SynchronizePins() )
Pin->m_Flags |= IS_LINKED; Pin->m_Flags |= IS_LINKED;
wxPoint savepos = GetScreen()->GetCrossHairPosition(); wxPoint savepos = GetScreen()->GetCrossHairPosition();

View File

@ -1,6 +1,31 @@
/******************/ /*
/* tool_lib.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 <stambaughw@verizon.net>
* 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 tool_lib.cpp
*/
#include "fctsys.h" #include "fctsys.h"
#include "hotkeys.h" #include "hotkeys.h"
@ -130,7 +155,7 @@ void LIB_EDIT_FRAME::ReCreateHToolbar()
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
m_HToolBar->AddTool( ID_LIBEDIT_CHECK_PART, wxEmptyString, KiBitmap( erc_xpm ), m_HToolBar->AddTool( ID_LIBEDIT_CHECK_PART, wxEmptyString, KiBitmap( erc_xpm ),
_( "Test for duplicate pins and off grid pins" ) ); _( "Test for duplicate and off grid pins" ) );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
msg = AddHotkeyName( HELP_ZOOM_IN, s_Libedit_Hokeys_Descr, HK_ZOOM_IN, IS_COMMENT ); msg = AddHotkeyName( HELP_ZOOM_IN, s_Libedit_Hokeys_Descr, HK_ZOOM_IN, IS_COMMENT );
@ -173,11 +198,7 @@ void LIB_EDIT_FRAME::ReCreateHToolbar()
m_HToolBar->AddControl( m_SelAliasBox ); m_HToolBar->AddControl( m_SelAliasBox );
m_HToolBar->AddSeparator(); m_HToolBar->AddSeparator();
msg = _( "Edit pins part per part ( Use carefully!)" ); msg = _( "Edit pins per part or body style (Use carefully!)" );
msg << wxT("\n");
msg += _("Usual option = OFF when parts are not locked");
msg << wxT("\n");
msg += _("Usual option = ON when parts are locked");
m_HToolBar->AddTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, wxEmptyString, KiBitmap( pin2pin_xpm ), m_HToolBar->AddTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, wxEmptyString, KiBitmap( pin2pin_xpm ),
msg, wxITEM_CHECK ); msg, wxITEM_CHECK );