Commit a834c47b authored by Wayne Stambaugh's avatar Wayne Stambaugh

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.
parent 858636fd
/*
* 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
*/
......@@ -31,7 +56,7 @@ int LIB_EDIT_FRAME::ReturnBlockCommand( int key )
cmd = key & 0x255;
break;
case - 1:
case -1:
cmd = BLOCK_PRESELECT_MOVE;
break;
......@@ -99,7 +124,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
if ( m_component )
ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate,
m_unit, m_convert,
g_EditPinByPinIsOn );
m_editPinsPerPartOrConvert );
if( ItemCount )
{
nextCmd = true;
......@@ -126,9 +151,10 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
if ( m_component )
ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate,
m_unit, m_convert,
g_EditPinByPinIsOn );
m_editPinsPerPartOrConvert );
if( ItemCount )
SaveCopyInUndoList( m_component );
if ( m_component )
{
m_component->DeleteSelectedItems();
......@@ -148,15 +174,18 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
if ( m_component )
ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate,
m_unit, m_convert,
g_EditPinByPinIsOn );
m_editPinsPerPartOrConvert );
if( ItemCount )
SaveCopyInUndoList( m_component );
pt = GetScreen()->m_BlockLocate.Centre();
pt.y *= -1;
if ( m_component )
{
OnModify();
int block_cmd = GetScreen()->m_BlockLocate.m_Command;
if( block_cmd == BLOCK_MIRROR_Y)
m_component->MirrorSelectedItemsH( pt );
else if( block_cmd == BLOCK_MIRROR_X)
......@@ -164,6 +193,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
else if( block_cmd == BLOCK_ROTATE)
m_component->RotateSelectedItems( pt );
}
break;
case BLOCK_ZOOM: /* Window Zoom */
......@@ -221,23 +251,31 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
case BLOCK_MOVE: /* Move */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
GetScreen()->m_BlockLocate.ClearItemsList();
if ( m_component )
SaveCopyInUndoList( m_component );
pt = GetScreen()->m_BlockLocate.m_MoveVector;
pt.y *= -1;
if ( m_component )
m_component->MoveSelectedItems( pt );
DrawPanel->Refresh( true );
break;
case BLOCK_COPY: /* Copy */
GetScreen()->m_BlockLocate.ClearItemsList();
if ( m_component )
SaveCopyInUndoList( m_component );
pt = GetScreen()->m_BlockLocate.m_MoveVector;
pt.y *= -1;
if ( m_component )
m_component->CopySelectedItems( pt );
break;
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
if ( m_component )
SaveCopyInUndoList( m_component );
pt = GetScreen()->m_BlockLocate.Centre();
pt.y *= -1;
if ( m_component )
{
int block_cmd = GetScreen()->m_BlockLocate.m_Command;
if( block_cmd == BLOCK_MIRROR_Y)
m_component->MirrorSelectedItemsH( pt );
else if( block_cmd == BLOCK_MIRROR_X)
......@@ -261,6 +302,7 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
else if( block_cmd == BLOCK_ROTATE )
m_component->RotateSelectedItems( pt );
}
break;
case BLOCK_ZOOM: // Handled by HandleBlockEnd
......
/*
* 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
*/
......@@ -46,10 +71,6 @@ const wxString CompLibFileWildcard( wxT( "KiCad component library file (*.lib)|*
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
* Eeschema units used to
* draw/plot items having a
......
/*
* 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
* @brief Eeschema component library editor.
......@@ -74,8 +99,7 @@ bool LIB_EDIT_FRAME::LoadComponentFromCurrentLib( LIB_ALIAS* aLibEntry )
if( !LoadOneLibraryPartAux( aLibEntry, m_library ) )
return false;
g_EditPinByPinIsOn = m_component->UnitsLocked() ? true : false;
m_HToolBar->ToggleTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn );
m_editPinsPerPartOrConvert = m_component->UnitsLocked() ? true : false;
GetScreen()->ClearUndoRedoList();
Zoom_Automatique( false );
......@@ -539,8 +563,7 @@ lost!\n\nClear the current component from the screen?" ) ) )
DisplayCmpDoc();
UpdateAliasSelectList();
UpdatePartSelectList();
g_EditPinByPinIsOn = m_component->UnitsLocked() ? true : false;
m_HToolBar->ToggleTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, g_EditPinByPinIsOn );
m_editPinsPerPartOrConvert = m_component->UnitsLocked() ? true : false;
m_lastDrawItem = NULL;
GetScreen()->ClearUndoRedoList();
OnModify();
......
/*
* 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
* @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;
/************************/
/* class LIB_EDIT_FRAME */
/************************/
BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_CLOSE( LIB_EDIT_FRAME::OnCloseWindow )
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_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_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_tempCopyComponent = NULL;
m_HotkeysZoomAndGridList = s_Libedit_Hokeys_Descr;
m_editPinsPerPartOrConvert = false;
wxIcon icon;
......@@ -192,7 +215,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent,
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)
|| ( m_LastGridSizeId < (ID_POPUP_GRID_USER - 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 );
EDA_PANEINFO horiz;
horiz.HorizontalToolbarPane();
......@@ -225,8 +247,6 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( SCH_EDIT_FRAME* aParent,
EDA_PANEINFO mesg;
mesg.MessageToolbarPane();
m_auimgr.AddPane( m_HToolBar,
wxAuiPaneInfo( horiz ).Name( wxT( "m_HToolBar" ) ).Top().Row( 0 ) );
......@@ -310,8 +330,10 @@ void LIB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
return;
}
else
{
GetScreen()->ClrModify();
}
}
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 );
dx = BoundaryBox.GetWidth();
dy = BoundaryBox.GetHeight();
GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 )
);
GetScreen()->SetScrollCenterPosition( wxPoint( 0, 0 ) );
}
else
{
......@@ -365,7 +386,7 @@ double LIB_EDIT_FRAME::BestZoom()
// Reserve a 10% margin around component bounding box.
double margin_scale_factor = 0.8;
double zx =(double) dx / (margin_scale_factor * (double)size.x );
double zx =(double) dx / ( margin_scale_factor * (double)size.x );
double zy = (double) dy / ( margin_scale_factor * (double)size.y );
double bestzoom = MAX( zx, zy );
......@@ -483,7 +504,7 @@ void LIB_EDIT_FRAME::OnUpdatePinByPin( wxUpdateUIEvent& event )
event.Enable( ( m_component != NULL )
&& ( ( 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;
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;
case ID_POPUP_LIBEDIT_END_CREATE_ITEM:
......@@ -848,6 +869,7 @@ void LIB_EDIT_FRAME::EnsureActiveLibExists()
return;
bool exists = CMP_LIBRARY::LibraryExists( m_library );
if( exists )
return;
else
......@@ -936,8 +958,9 @@ void LIB_EDIT_FRAME::OnEditComponentProperties( wxCommandEvent& event )
if( partLocked != GetComponent()->UnitsLocked() )
{
// g_EditPinByPinIsOn is set to the better value, if m_UnitSelectionLocked has changed
g_EditPinByPinIsOn = GetComponent()->UnitsLocked() ? true : false;
// m_editPinsPerPartOrConvert is set to the better value, if m_UnitSelectionLocked
// has changed
m_editPinsPerPartOrConvert = GetComponent()->UnitsLocked() ? true : false;
}
UpdateAliasSelectList();
......@@ -959,7 +982,7 @@ void LIB_EDIT_FRAME::InstallDimensionsDialog( wxCommandEvent& event )
void LIB_EDIT_FRAME::OnCreateNewPartFromExisting( wxCommandEvent& event )
{
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 );
DrawPanel->CrossHairOff( &dc );
......@@ -1167,7 +1190,7 @@ void LIB_EDIT_FRAME::deleteItem( wxDC* aDC )
m_component->RemoveDrawItem( (LIB_ITEM*) pin, DrawPanel, aDC );
if( g_EditPinByPinIsOn == false )
if( SynchronizePins() )
{
LIB_PIN* tmp = m_component->GetNextPin();
......@@ -1182,13 +1205,20 @@ void LIB_EDIT_FRAME::deleteItem( wxDC* aDC )
m_component->RemoveDrawItem( (LIB_ITEM*) pin );
}
}
DrawPanel->Refresh();
}
else
{
if( DrawPanel->IsMouseCaptured() )
{
DrawPanel->m_endMouseCaptureCallback( DrawPanel, aDC );
}
else
{
m_component->RemoveDrawItem( m_drawItem, DrawPanel, aDC );
DrawPanel->Refresh();
}
}
m_drawItem = NULL;
......@@ -1211,3 +1241,10 @@ void LIB_EDIT_FRAME::OnSelectItem( wxCommandEvent& aEvent )
m_drawItem = item;
}
}
bool LIB_EDIT_FRAME::SynchronizePins() const
{
return !m_editPinsPerPartOrConvert && ( m_component && ( m_component->HasConversion() ||
m_component->IsMulti()) );
}
/*
* 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
* @brief Definition of class LIB_EDIT_FRAME
......@@ -62,6 +87,14 @@ public:
void OnColorConfig( wxCommandEvent& aEvent );
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
* plot the current component in SVG or PNG format.
......@@ -371,6 +404,19 @@ private:
void CreatePin( 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
* places an anchor reference coordinate for the current component.
......@@ -450,6 +496,15 @@ protected:
*/
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. */
static FILL_T m_drawFillStyle;
......@@ -493,7 +548,7 @@ protected:
* Function CreatePNGorJPEGFile
* creates an image (screenshot) of the current component in PNG or JPEG format.
* @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 );
......
/*
* 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
* @brief Eeschema pin edit code.
......@@ -23,7 +48,6 @@
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 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();
LastPinVisible = dlg.GetVisible();
pin->EnableEditMode( true, g_EditPinByPinIsOn );
pin->EnableEditMode( true, m_editPinsPerPartOrConvert );
pin->SetName( dlg.GetName() );
pin->SetNameTextSize( LastPinNameSize );
pin->SetNumber( dlg.GetPadName() );
......@@ -131,7 +155,7 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
DrawPanel->Refresh();
}
pin->EnableEditMode( false, g_EditPinByPinIsOn );
pin->EnableEditMode( false, m_editPinsPerPartOrConvert );
// Restore pin flags, that can be changed by the dialog editor
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 )
continue;
if( ask_for_pin && !g_EditPinByPinIsOn )
if( ask_for_pin && SynchronizePins() )
{
DrawPanel->m_IgnoreMouseEvents = true;
status =
......@@ -226,7 +250,7 @@ another pin. Continue?" ) );
LastPinType = CurrentPin->GetType();
LastPinShape = CurrentPin->GetShape();
if( !g_EditPinByPinIsOn )
if( SynchronizePins() )
CreateImagePins( CurrentPin, m_unit, m_convert, m_showDeMorgan );
m_lastDrawItem = CurrentPin;
......@@ -279,7 +303,7 @@ void LIB_EDIT_FRAME::StartMovePin( wxDC* DC )
if( ( Pin->GetPosition() == CurrentPin->GetPosition() )
&& ( Pin->GetOrientation() == CurrentPin->GetOrientation() )
&& ( g_EditPinByPinIsOn == false ) )
&& SynchronizePins() )
Pin->m_Flags |= IS_LINKED | IS_MOVED;
}
......@@ -359,7 +383,7 @@ void LIB_EDIT_FRAME::CreatePin( wxDC* DC )
pin->SetConvert( m_convert );
/* Flag pins to consider */
if( g_EditPinByPinIsOn == false )
if( SynchronizePins() )
pin->m_Flags |= IS_LINKED;
pin->SetPosition( GetScreen()->GetCrossHairPosition( true ) );
......@@ -372,8 +396,6 @@ void LIB_EDIT_FRAME::CreatePin( wxDC* DC )
pin->SetConvert( LastPinCommonConvert ? 0 : m_convert );
pin->SetUnit( LastPinCommonUnit ? 0 : m_unit );
pin->SetVisible( LastPinVisible );
//PlacePin( DC );
//m_drawItem = pin;
PinPreviousPos = pin->GetPosition();
DrawPanel->m_IgnoreMouseEvents = true;
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;
LIB_PIN* NewPin;
bool CreateConv = false;
if( g_EditPinByPinIsOn )
if( !SynchronizePins() )
return;
if( asDeMorgan && ( Pin->GetConvert() != 0 ) )
CreateConv = true;
/* 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 );
else
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. */
NewPin = (LIB_PIN*) Pin->Clone();
NewPin = (LIB_PIN*) aPin->Clone();
if( convert != 0 )
if( aConvert != 0 )
NewPin->SetConvert( 1 );
NewPin->SetUnit( ii );
Pin->GetParent()->AddDrawItem( NewPin );
aPin->GetParent()->AddDrawItem( NewPin );
if( CreateConv == false )
if( !( aDeMorgan && ( aPin->GetConvert() != 0 ) ) )
continue;
NewPin = (LIB_PIN*) Pin->Clone();
NewPin = (LIB_PIN*) aPin->Clone();
NewPin->SetConvert( 2 );
if( Pin->GetUnit() != 0 )
if( aPin->GetUnit() != 0 )
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;
if( g_EditPinByPinIsOn == false )
if( SynchronizePins() )
Pin->m_Flags |= IS_LINKED;
wxPoint savepos = GetScreen()->GetCrossHairPosition();
......
/******************/
/* 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 "hotkeys.h"
......@@ -130,7 +155,7 @@ void LIB_EDIT_FRAME::ReCreateHToolbar()
m_HToolBar->AddSeparator();
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();
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->AddSeparator();
msg = _( "Edit pins part per part ( 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");
msg = _( "Edit pins per part or body style (Use carefully!)" );
m_HToolBar->AddTool( ID_LIBEDIT_EDIT_PIN_BY_PIN, wxEmptyString, KiBitmap( pin2pin_xpm ),
msg, wxITEM_CHECK );
......
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