Commit 56059efd authored by charras's avatar charras

Netclasses work continued

Fixed problems in libedit and crashes when no component loaded
parent b4fe26a3
......@@ -8,7 +8,7 @@
#include "appl_wxstruct.h"
#define BUILD_VERSION "(20091001-unstable)"
#define BUILD_VERSION "(20091010-unstable)"
#ifdef HAVE_SVN_VERSION
......
......@@ -19,6 +19,7 @@ set(CVPCB_SRCS
dialog_cvpcb_config_fbp.cpp
dialog_display_options.cpp
displayframe.cpp
dummy_functions.cpp
genequiv.cpp
init.cpp
listboxes.cpp
......
/* dummy_functions.cpp
*
* There are functions used in some classes.
* they are useful in pcbnew, but have no meaning or are never used
* in cvpcb or gerbview.
* but they must exist because they appear in some classes, and here, no nothing.
*/
#include "fctsys.h"
#include "common.h"
#include "pcbnew.h"
TRACK* Marque_Une_Piste( BOARD* aPcb,
TRACK* aStartSegm,
int* aSegmCount,
int* aTrackLen,
bool aReorder )
{
return NULL;
}
......@@ -101,6 +101,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_DRAG: /* Drag */
case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */
if ( m_component )
ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate,
m_unit, m_convert,
g_EditPinByPinIsOn );
......@@ -125,11 +126,13 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
break;
case BLOCK_DELETE: /* Delete */
if ( m_component )
ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate,
m_unit, m_convert,
g_EditPinByPinIsOn );
if( ItemCount )
SaveCopyInUndoList( m_component );
if ( m_component )
m_component->DeleteSelectedItems();
break;
......@@ -142,6 +145,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_MIRROR_Y:
if ( m_component )
ItemCount = m_component->SelectItems( GetScreen()->m_BlockLocate,
m_unit, m_convert,
g_EditPinByPinIsOn );
......@@ -149,6 +153,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
SaveCopyInUndoList( m_component );
pt = GetScreen()->m_BlockLocate.Centre();
pt.y *= -1;
if ( m_component )
m_component->MirrorSelectedItemsH( pt );
break;
......@@ -166,6 +171,7 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
if( MustDoPlace <= 0 )
{
if( GetScreen()->m_BlockLocate.m_Command != BLOCK_SELECT_ITEMS_ONLY )
if ( m_component )
m_component->ClearSelectedItems();
GetScreen()->m_BlockLocate.m_Flags = 0;
......@@ -213,18 +219,22 @@ void WinEDA_LibeditFrame::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;
......@@ -233,9 +243,11 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
break;
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 )
m_component->MirrorSelectedItemsH( pt );
break;
......
......@@ -599,8 +599,8 @@ bool LIB_COMPONENT::Load( FILE* file, char* line, int* lineNum,
return false;
}
m_DrawPinNum = (drawnum == 'N') ? FALSE : TRUE;
m_DrawPinName = (drawname == 'N') ? FALSE : TRUE;
m_DrawPinNum = (drawnum == 'N') ? FALSE : true;
m_DrawPinName = (drawname == 'N') ? FALSE : true;
/* Copy part name and prefix. */
strupper( name );
......@@ -622,7 +622,7 @@ bool LIB_COMPONENT::Load( FILE* file, char* line, int* lineNum,
// Copy optional infos
if( ( p = strtok( NULL, " \t\n" ) ) != NULL && *p == 'L' )
m_UnitSelectionLocked = TRUE;
m_UnitSelectionLocked = true;
if( ( p = strtok( NULL, " \t\n" ) ) != NULL && *p == 'P' )
m_Options = ENTRY_POWER;
......@@ -862,10 +862,10 @@ void LIB_COMPONENT::SetFields( const std::vector <LIB_FIELD> aFields )
{
bool create = FALSE;
if( !aFields[ii].m_Text.IsEmpty() )
create = TRUE;
create = true;
if( !aFields[ii].m_Name.IsEmpty()
&& ( aFields[ii].m_Name != ReturnDefaultFieldName( ii ) ) )
create = TRUE;
create = true;
if( create )
{
LIB_FIELD*Field = new LIB_FIELD( this, ii );
......@@ -1302,7 +1302,7 @@ void LIB_COMPONENT::SetConversion( bool asConvert )
{
if( asConvert == HasConversion() )
return;
// Duplicate items to create the converted shape
if( asConvert )
{
......@@ -1321,6 +1321,7 @@ void LIB_COMPONENT::SetConversion( bool asConvert )
}
else
{
// Delete converted shape items becuase the converted shape does not exist
LIB_DRAW_ITEM_LIST::iterator i = m_Drawings.begin();
while( i != m_Drawings.end() )
......
......@@ -31,18 +31,21 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_OptionsBoxSizer->Add( m_AsConvertButt, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_ShowPinNumButt = new wxCheckBox( m_PanelBasic, wxID_ANY, _("Show Pin Num"), wxDefaultPosition, wxDefaultSize, 0 );
m_ShowPinNumButt->SetValue(true);
m_ShowPinNumButt->SetToolTip( _("Show or hide pin numbers") );
m_OptionsBoxSizer->Add( m_ShowPinNumButt, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_ShowPinNameButt = new wxCheckBox( m_PanelBasic, wxID_ANY, _("Show Pin Name"), wxDefaultPosition, wxDefaultSize, 0 );
m_ShowPinNameButt->SetValue(true);
m_ShowPinNameButt->SetToolTip( _("Show or hide pin names") );
m_OptionsBoxSizer->Add( m_ShowPinNameButt, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_PinsNameInsideButt = new wxCheckBox( m_PanelBasic, wxID_ANY, _("Pin Name Inside"), wxDefaultPosition, wxDefaultSize, 0 );
m_PinsNameInsideButt->SetValue(true);
m_PinsNameInsideButt->SetToolTip( _("Check this option to have pin names inside the body and pin number outside.\nIf not checked pins names and pins numbers are outside.") );
......@@ -63,7 +66,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_staticTextNbUnits->Wrap( -1 );
bSizernbunits->Add( m_staticTextNbUnits, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_SelNumberOfUnits = new wxSpinCtrl( m_PanelBasic, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 16, 1 );
m_SelNumberOfUnits = new wxSpinCtrl( m_PanelBasic, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 16, 1 );
bSizernbunits->Add( m_SelNumberOfUnits, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
bSizerMidBasicPanel->Add( bSizernbunits, 1, wxEXPAND, 5 );
......@@ -75,7 +78,7 @@ DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE::DIALOG_EDIT_COMPONENT_IN_LIBRARY_BASE( wx
m_staticTextskew->Wrap( -1 );
bSizer17->Add( m_staticTextskew, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_SetSkew = new wxSpinCtrl( m_PanelBasic, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 100, 0 );
m_SetSkew = new wxSpinCtrl( m_PanelBasic, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 100, 0 );
bSizer17->Add( m_SetSkew, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerMidBasicPanel->Add( bSizer17, 1, wxEXPAND, 5 );
......
......@@ -246,7 +246,7 @@
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="bg"></property>
<property name="checked">0</property>
<property name="checked">1</property>
<property name="context_help"></property>
<property name="enabled">1</property>
<property name="fg"></property>
......@@ -298,7 +298,7 @@
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="bg"></property>
<property name="checked">0</property>
<property name="checked">1</property>
<property name="context_help"></property>
<property name="enabled">1</property>
<property name="fg"></property>
......@@ -350,7 +350,7 @@
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="bg"></property>
<property name="checked">0</property>
<property name="checked">1</property>
<property name="context_help"></property>
<property name="enabled">1</property>
<property name="fg"></property>
......@@ -531,7 +531,7 @@
<property name="initial">1</property>
<property name="max">16</property>
<property name="maximum_size"></property>
<property name="min">0</property>
<property name="min">1</property>
<property name="minimum_size"></property>
<property name="name">m_SelNumberOfUnits</property>
<property name="permission">protected</property>
......@@ -648,7 +648,7 @@
<property name="initial">0</property>
<property name="max">100</property>
<property name="maximum_size"></property>
<property name="min">0</property>
<property name="min">1</property>
<property name="minimum_size"></property>
<property name="name">m_SetSkew</property>
<property name="permission">protected</property>
......
......@@ -522,7 +522,7 @@
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="initial">0</property>
<property name="max">40</property>
<property name="max">26</property>
<property name="maximum_size"></property>
<property name="min">1</property>
<property name="minimum_size"></property>
......@@ -754,7 +754,7 @@
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Prevent drawing items from being &amp;moved</property>
<property name="label">Parts in package locked (cannot be swapped)</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_checkLockItems</property>
......@@ -949,9 +949,9 @@
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="initial">40</property>
<property name="max">10000</property>
<property name="max">100</property>
<property name="maximum_size"></property>
<property name="min">0</property>
<property name="min">1</property>
<property name="minimum_size"></property>
<property name="name">m_spinPinTextPosition</property>
<property name="permission">protected</property>
......@@ -1190,6 +1190,79 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer121</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">3</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">12</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">3</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="bg"></property>
<property name="checked">1</property>
<property name="context_help"></property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Pin name &amp;inside</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_checkShowPinNameInside</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCheckBox"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">10</property>
<property name="flag">wxALL|wxEXPAND</property>
......
......@@ -62,6 +62,12 @@ public:
m_checkShowPinName->SetValue( show );
}
bool GetShowPinName( void ) { return m_checkShowPinName->GetValue(); }
void SetPinNameInside( bool show )
{
m_checkShowPinNameInside->SetValue( show );
}
bool GetPinNameInside( void ) { return m_checkShowPinNameInside->GetValue(); }
};
#endif // __dialog_lib_new_component__
......@@ -80,7 +80,7 @@ DIALOG_LIB_NEW_COMPONENT_BASE::DIALOG_LIB_NEW_COMPONENT_BASE( wxWindow* parent,
bSizer4->Add( 0, 0, 1, wxEXPAND, 3 );
m_spinPartCount = new wxSpinCtrl( this, wxID_ANY, wxT("1"), wxDefaultPosition, wxSize( 100,-1 ), wxSP_ARROW_KEYS, 1, 40, 0 );
m_spinPartCount = new wxSpinCtrl( this, wxID_ANY, wxT("1"), wxDefaultPosition, wxSize( 100,-1 ), wxSP_ARROW_KEYS, 1, 26, 0 );
bSizer4->Add( m_spinPartCount, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
......@@ -118,7 +118,7 @@ DIALOG_LIB_NEW_COMPONENT_BASE::DIALOG_LIB_NEW_COMPONENT_BASE( wxWindow* parent,
bSizer9->Add( 12, 0, 0, wxEXPAND, 3 );
m_checkLockItems = new wxCheckBox( this, wxID_ANY, _("Prevent drawing items from being &moved"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkLockItems = new wxCheckBox( this, wxID_ANY, _("Parts in package locked (cannot be swapped)"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer9->Add( m_checkLockItems, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
......@@ -146,7 +146,7 @@ DIALOG_LIB_NEW_COMPONENT_BASE::DIALOG_LIB_NEW_COMPONENT_BASE( wxWindow* parent,
bSizer6->Add( 0, 0, 1, wxEXPAND, 3 );
m_spinPinTextPosition = new wxSpinCtrl( this, wxID_ANY, wxT("40"), wxDefaultPosition, wxSize( 100,-1 ), wxSP_ARROW_KEYS, 0, 10000, 40 );
m_spinPinTextPosition = new wxSpinCtrl( this, wxID_ANY, wxT("40"), wxDefaultPosition, wxSize( 100,-1 ), wxSP_ARROW_KEYS, 1, 100, 40 );
bSizer6->Add( m_spinPinTextPosition, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
m_staticText5 = new wxStaticText( this, wxID_ANY, _("mils"), wxDefaultPosition, wxSize( 30,-1 ), 0 );
......@@ -181,6 +181,19 @@ DIALOG_LIB_NEW_COMPONENT_BASE::DIALOG_LIB_NEW_COMPONENT_BASE( wxWindow* parent,
bSizer5->Add( bSizer12, 0, wxALL|wxEXPAND, 0 );
wxBoxSizer* bSizer121;
bSizer121 = new wxBoxSizer( wxHORIZONTAL );
bSizer121->Add( 12, 0, 0, wxEXPAND, 3 );
m_checkShowPinNameInside = new wxCheckBox( this, wxID_ANY, _("Pin name &inside"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkShowPinNameInside->SetValue(true);
bSizer121->Add( m_checkShowPinNameInside, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
bSizer5->Add( bSizer121, 1, wxEXPAND, 5 );
bSizer5->Add( 0, 5, 0, wxALL|wxEXPAND, 10 );
......
......@@ -67,6 +67,8 @@ class DIALOG_LIB_NEW_COMPONENT_BASE : public wxDialog
wxCheckBox* m_checkShowPinName;
wxCheckBox* m_checkShowPinNameInside;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
......
......@@ -5,6 +5,7 @@
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "common.h"
#include "class_drawpanel.h"
#include "confirm.h"
#include "gestfich.h"
......@@ -31,13 +32,12 @@
void WinEDA_LibeditFrame::OnEditComponentProperties( wxCommandEvent& event )
{
EditComponentProperties();
DrawPanel->Refresh();
}
void WinEDA_LibeditFrame::EditComponentProperties()
{
wxASSERT( m_component != NULL && m_library != NULL );
DIALOG_EDIT_COMPONENT_IN_LIBRARY dlg( this );
if( dlg.ShowModal() == wxID_CANCEL )
......@@ -120,15 +120,21 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
/* Update the doc, keyword and doc filename strings */
size_t i;
int index;
CMP_LIB_ENTRY* entry;
CMP_LIB_ENTRY* entry = NULL;
LIB_COMPONENT* component = m_Parent->GetComponent();
if( component == NULL )
{
EndModal( wxID_CANCEL );
return;
}
CMP_LIBRARY* library = m_Parent->GetLibrary();
if( m_Parent->GetAliasName().IsEmpty() )
{
entry = (CMP_LIB_ENTRY*) component;
}
else
else if ( library )
{
entry = library->FindEntry( m_Parent->GetAliasName() );
}
......@@ -213,21 +219,26 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::OnOkClick( wxCommandEvent& event )
component->m_DrawPinNum = m_ShowPinNumButt->GetValue() ? 1 : 0;
component->m_DrawPinName = m_ShowPinNameButt->GetValue() ? 1 : 0;
if( m_PinsNameInsideButt->GetValue() == FALSE )
component->m_TextInside = 0;
if( m_PinsNameInsideButt->GetValue() == false )
component->m_TextInside = 0; // pin text outside the body (name is on the pin)
else
{
component->m_TextInside = m_SetSkew->GetValue();
// Ensure component->m_TextInside != 0, because the meaning is "text outside".
if( component->m_TextInside == 0 )
component->m_TextInside = 20; // give a reasonnable value
}
if( m_OptionPower->GetValue() == TRUE )
if( m_OptionPower->GetValue() == true )
component->m_Options = ENTRY_POWER;
else
component->m_Options = ENTRY_NORMAL;
/* Set the option "Units locked".
* Obviously, cannot be TRUE if there is only one part */
* Obviously, cannot be true if there is only one part */
component->m_UnitSelectionLocked = m_OptionPartsLocked->GetValue();
if( component->GetPartCount() <= 1 )
component->m_UnitSelectionLocked = FALSE;
component->m_UnitSelectionLocked = false;
/* Update the footprint filter list */
component->m_FootprintList.Clear();
......@@ -273,8 +284,8 @@ edited!" ),
if( IsOK( this, _( "Remove all aliases from list?" ) ) )
{
m_PartAliasList->Clear();
m_ButtonDeleteAllAlias->Enable( FALSE );
m_ButtonDeleteOneAlias->Enable( FALSE );
m_ButtonDeleteAllAlias->Enable( false );
m_ButtonDeleteOneAlias->Enable( false );
}
}
......@@ -316,8 +327,8 @@ library <%s>." ),
m_PartAliasList->Append( aliasname );
if( m_Parent->GetAliasName().IsEmpty() )
m_ButtonDeleteAllAlias->Enable( TRUE );
m_ButtonDeleteOneAlias->Enable( TRUE );
m_ButtonDeleteAllAlias->Enable( true );
m_ButtonDeleteOneAlias->Enable( true );
}
......@@ -342,8 +353,8 @@ edited!" ),
if( m_PartAliasList->IsEmpty() )
{
m_ButtonDeleteAllAlias->Enable( FALSE );
m_ButtonDeleteOneAlias->Enable( FALSE );
m_ButtonDeleteAllAlias->Enable( false );
m_ButtonDeleteOneAlias->Enable( false );
}
}
......@@ -379,21 +390,21 @@ bool DIALOG_EDIT_COMPONENT_IN_LIBRARY::SetUnsetConvert()
|| ( m_Parent->GetShowDeMorgan() == component->HasConversion() ) )
return false;
if( m_Parent->GetShowDeMorgan()
&& !IsOK( this, _( "Add new pins for alternate body style \
( DeMorgan ) to component?" ) ) )
if( m_Parent->GetShowDeMorgan() )
{
m_Parent->SetShowDeMorgan( false );
if( !IsOK( this, _( "Add new pins for alternate body style \
( DeMorgan ) to component?" ) ) )
return false;
}
if( !m_Parent->GetShowDeMorgan()
&& !IsOK( this, _( "Delete alternate body style (DeMorgan) draw \
items from component?" ) ) )
else if( component->HasConversion() )
{
if( !IsOK( this, _( "Delete alternate body style (DeMorgan) draw items from component?" ) ) )
{
m_Parent->SetShowDeMorgan( true );
return false;
}
}
component->SetConversion( m_Parent->GetShowDeMorgan() );
m_Parent->GetScreen()->SetModify();
......@@ -419,7 +430,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile( wxCommandEvent& e
mask, /* Masque d'affichage */
this,
wxFD_OPEN,
TRUE
true
);
if( FullFileName.IsEmpty() )
return;
......@@ -446,8 +457,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteAllFootprintFilter(
if( IsOK( this, _( "Ok to Delete FootprintFilter LIST" ) ) )
{
m_FootprintFilterListBox->Clear();
m_ButtonDeleteAllFootprintFilter->Enable( FALSE );
m_ButtonDeleteOneFootprintFilter->Enable( FALSE );
m_ButtonDeleteAllFootprintFilter->Enable( false );
m_ButtonDeleteOneFootprintFilter->Enable( false );
}
}
......@@ -486,8 +497,8 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::AddFootprintFilter( wxCommandEvent& WXUNU
}
m_FootprintFilterListBox->Append( Line );
m_ButtonDeleteAllFootprintFilter->Enable( TRUE );
m_ButtonDeleteOneFootprintFilter->Enable( TRUE );
m_ButtonDeleteAllFootprintFilter->Enable( true );
m_ButtonDeleteOneFootprintFilter->Enable( true );
}
......@@ -503,7 +514,7 @@ void DIALOG_EDIT_COMPONENT_IN_LIBRARY::DeleteOneFootprintFilter(
if( !component || (m_FootprintFilterListBox->GetCount() == 0) )
{
m_ButtonDeleteAllFootprintFilter->Enable( FALSE );
m_ButtonDeleteOneFootprintFilter->Enable( FALSE );
m_ButtonDeleteAllFootprintFilter->Enable( false );
m_ButtonDeleteOneFootprintFilter->Enable( false );
}
}
......@@ -113,6 +113,7 @@ library \"%s\"." ),
GetScreen()->ClearUndoRedoList();
Zoom_Automatique( false );
DrawPanel->Refresh();
SetShowDeMorgan(m_component->HasConversion() );
}
......@@ -506,7 +507,10 @@ lost!\n\nClear the current component from the screen?" ) ) )
return;
if( dlg.GetName().IsEmpty() )
{
wxMessageBox(_("This new component has no name and cannot be created. Aborted"));
return;
}
name = dlg.GetName().MakeUpper();
name.Replace( wxT( " " ), wxT( "_" ) );
......@@ -525,12 +529,25 @@ lost!\n\nClear the current component from the screen?" ) ) )
LIB_COMPONENT* component = new LIB_COMPONENT( name );
component->m_Prefix.m_Text = dlg.GetReference();
component->SetPartCount( dlg.GetPartCount() );
// Initialize component->m_TextInside member:
// if 0, pin text is outside the body (on the pin)
// if > 0, pin text is inside the body
component->SetConversion( dlg.GetAlternateBodyStyle() );
SetShowDeMorgan( dlg.GetAlternateBodyStyle() );
if( dlg.GetPinNameInside( ) )
{
component->m_TextInside = dlg.GetPinTextPosition();
component->m_Options = ( dlg.GetPowerSymbol() ) ? ENTRY_POWER :
ENTRY_NORMAL;
if( component->m_TextInside == 0 )
component->m_TextInside = 1;
}
else
component->m_TextInside = 0;
component->m_Options = ( dlg.GetPowerSymbol() ) ? ENTRY_POWER : ENTRY_NORMAL;
component->m_DrawPinNum = dlg.GetShowPinNumber();
component->m_DrawPinName = dlg.GetShowPinName();
component->m_UnitSelectionLocked = dlg.GetLockItems();
if( dlg.GetPartCount() < 2 )
component->m_UnitSelectionLocked = false;
if( m_component )
{
......
......@@ -20,8 +20,8 @@ class LIB_DRAW_ITEM;
class WinEDA_LibeditFrame : public WinEDA_DrawFrame
{
public:
WinEDAChoiceBox* m_SelpartBox;
WinEDAChoiceBox* m_SelAliasBox;
WinEDAChoiceBox* m_SelpartBox; // a Box to select a part to edit (if any)
WinEDAChoiceBox* m_SelAliasBox; // a box to select the alias to edit (if any)
public:
WinEDA_LibeditFrame( wxWindow* father,
......@@ -93,6 +93,7 @@ public:
m_unit = unit;
}
int GetConvert( void ) { return m_convert; }
void SetConvert( int convert )
......@@ -101,6 +102,7 @@ public:
m_convert = convert;
}
LIB_DRAW_ITEM* GetLastDrawItem( void ) { return m_lastDrawItem; }
void SetLastDrawItem( LIB_DRAW_ITEM* drawItem )
......@@ -108,6 +110,7 @@ public:
m_lastDrawItem = drawItem;
}
LIB_DRAW_ITEM* GetDrawItem( void ) { return m_drawItem; }
void SetDrawItem( LIB_DRAW_ITEM* drawItem );
......@@ -135,8 +138,8 @@ public:
int flag_type_command = 0 );
private:
void GetComponentFromUndoList(wxCommandEvent& event);
void GetComponentFromRedoList(wxCommandEvent& event);
void GetComponentFromUndoList( wxCommandEvent& event );
void GetComponentFromRedoList( wxCommandEvent& event );
// Edition des Pins:
void CreatePin( wxDC* DC );
......@@ -184,14 +187,19 @@ protected:
wxString m_LastLibImportPath;
wxString m_LastLibExportPath;
static LIB_COMPONENT* m_component;
static CMP_LIBRARY* m_library;
static LIB_COMPONENT* m_component; // The current edited component (NULL if no component)
static CMP_LIBRARY* m_library; // The current active libary (NULL if none)
static LIB_DRAW_ITEM* m_lastDrawItem;
static LIB_DRAW_ITEM* m_drawItem;
static wxString m_aliasName;
static int m_unit;
static int m_convert;
static bool m_showDeMorgan;
static int m_unit; // The unit number to edit and show
static int m_convert; // Show the normal shape ( m_convert <= 1 )
// or the converted shape ( m_convert > 1 )
static bool m_showDeMorgan; // true to force DeMorgan/normal tools selection enabled
// They are enabled when the loaded component has
// Graphic items for converted shape
// But under some circumstances (New component created)
// these tools must left enable
static wxSize m_clientSize;
DECLARE_EVENT_TABLE()
......
......@@ -154,6 +154,7 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father,
m_Draw_Axis = true; // true pour avoir les axes dessines
m_Draw_Grid = true; // true pour avoir la axes dessinee
m_ConfigPath = wxT( "LibraryEditor" );
SetShowDeMorgan( false );
// Give an icon
SetIcon( wxIcon( libedit_xpm ) );
......@@ -440,8 +441,7 @@ void WinEDA_LibeditFrame::OnUpdatePartNumber( wxUpdateUIEvent& event )
/* Using the typical event.Enable() call doesn't seem to work with wxGTK
* so use the pointer to alias combobox to directly enable or disable.
*/
m_SelpartBox->Enable( m_component != NULL
&& m_component->GetPartCount() > 1 );
m_SelpartBox->Enable( m_component && m_component->GetPartCount() > 1 );
}
......@@ -450,8 +450,8 @@ void WinEDA_LibeditFrame::OnUpdateDeMorganNormal( wxUpdateUIEvent& event )
if( m_HToolBar == NULL )
return;
event.Enable( m_component != NULL
&& m_component->HasConversion() );
event.Enable( GetShowDeMorgan() ||
(m_component && m_component->HasConversion()) );
m_HToolBar->ToggleTool( event.GetId(), m_convert <= 1 );
}
......@@ -461,8 +461,8 @@ void WinEDA_LibeditFrame::OnUpdateDeMorganConvert( wxUpdateUIEvent& event )
if( m_HToolBar == NULL )
return;
event.Enable( m_component != NULL
&& m_component->HasConversion() );
event.Enable( GetShowDeMorgan() ||
(m_component && m_component->HasConversion()) );
m_HToolBar->ToggleTool( event.GetId(), m_convert > 1 );
}
......
......@@ -796,7 +796,7 @@ static void FindAllsInstancesOfComponent( SCH_COMPONENT* Component_in,
for( pin = Entry->GetNextPin(); pin != NULL;
pin = Entry->GetNextPin( pin ) )
{
wxASSERT( pin->Type() != COMPONENT_PIN_DRAW_TYPE );
wxASSERT( pin->Type() == COMPONENT_PIN_DRAW_TYPE );
if( pin->m_Unit
&& ( pin->m_Unit != Component2->GetUnitSelection( sheet ) ) )
......
......@@ -12,6 +12,7 @@ set(GERBVIEW_SRCS
controle.cpp
dcode.cpp
deltrack.cpp
dummy_functions.cpp
edit.cpp
export_to_pcbnew.cpp
files.cpp
......
/* dummy_functions.cpp
*
* There are functions used in some classes.
* they are useful in pcbnew, but have no meaning or are never used
* in cvpcb or gerbview.
* but they must exist because they appear in some classes, and here, no nothing.
*/
#include "fctsys.h"
#include "common.h"
#include "pcbnew.h"
TRACK* Marque_Une_Piste( BOARD* aPcb,
TRACK* aStartSegm,
int* aSegmCount,
int* aTrackLen,
bool aReorder )
{
return NULL;
}
......@@ -457,9 +457,10 @@ public:
* Basic routine used by other routines when editing tracks or vias
* @param aTrackItem = the track segment or via to modify
* @param aItemsListPicker = the list picker to use for an undo command (can be NULL)
* @param aUseNetclassValue = true to use NetClass value, false to use g_DesignSettings value
* @return true if done, false if no not change (because DRC error)
*/
bool SetTrackSegmentWidth( TRACK* aTrackItem, PICKED_ITEMS_LIST* aItemsListPicker );
bool SetTrackSegmentWidth( TRACK* aTrackItem, PICKED_ITEMS_LIST* aItemsListPicker, bool aUseNetclassValue );
// zone handling
......
No preview for this file type
This diff is collapsed.
......@@ -97,6 +97,7 @@ set(PCBNEW_SRCS
librairi.cpp
loadcmp.cpp
locate.cpp
magnetic_tracks_functions.cpp
menubarmodedit.cpp
menubarpcb.cpp
mirepcb.cpp
......
......@@ -46,7 +46,8 @@ void WinEDA_PcbFrame::Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On )
return;
DrawPanel->CursorOff( DC ); // Erase cursor shape
Track = Marque_Une_Piste( this, DC, track, &nb_segm, GR_OR | GR_SURBRILL );
Track = Marque_Une_Piste( GetBoard(), track, &nb_segm, NULL, true );
Trace_Une_Piste( DrawPanel, DC, Track, nb_segm, GR_OR | GR_SURBRILL );
for( ; (Track != NULL) && (nb_segm > 0); nb_segm-- )
{
......
......@@ -208,7 +208,7 @@ public:
return m_NetClassName;
}
#if 0
#if 1
/**
* Function GetTrackWidth
* returns the width of tracks used to route this net.
......@@ -220,16 +220,18 @@ public:
}
#if 0
/**
* Function GetTrackWidth
* Function GetTrackMinWidth
* returns the Minimum value for tracks thickness (used in DRC)
*/
int GetTrackWidth()
int GetTrackMinWidth()
{
wxASSERT( m_NetClass );
return m_NetClass->GetTrackMinWidth();
// wxASSERT( m_NetClass );
// return m_NetClass->GetTrackMinWidth();
return g_DesignSettings.m_TrackMinWidth;
}
#endif
/**
* Function GetViaSize
......@@ -238,7 +240,17 @@ public:
int GetViaSize()
{
wxASSERT( m_NetClass );
return m_NetClass->GetViaSize();
return m_NetClass->GetViaDiameter();
}
/**
* Function GetMicroViaSize
* returns the size of vias used to route this net
*/
int GetMicroViaSize()
{
wxASSERT( m_NetClass );
return m_NetClass->GetuViaDiameter();
}
......@@ -249,10 +261,22 @@ public:
int GetViaDrillSize()
{
wxASSERT( m_NetClass );
return m_NetClass->GetViaDrillSize();
return m_NetClass->GetViaDrill();
}
/**
* Function GetViaDrillSize
* returns the size of via drills used to route this net
*/
int GetMicroViaDrillSize()
{
wxASSERT( m_NetClass );
return m_NetClass->GetuViaDrill();
}
#if 0
/**
* Function GetViaMinSize
* returns the Minimum value for via sizes (used in DRC)
......@@ -262,7 +286,7 @@ public:
wxASSERT( m_NetClass );
return m_NetClass->GetViaMinSize();
}
#endif
/**
* Function GetClearance
......
......@@ -14,32 +14,6 @@
#include "protos.h"
// #define RATSNET_DEBUG
#ifdef RATSNET_DEBUG
/**************************************/
void DbgDisplayTrackInfos( TRACK* track )
/**************************************/
/* Only for ratsnest debug
*/
{
wxString msg;
msg << wxT( "Netcode " ) << track->GetNet();
msg << wxT( " - " ) << track->GetSubNet();
msg << wxT( "\nptrS " ) << (unsigned) track->start;
msg << wxT( " ptrE " ) << (unsigned) track->end;
msg << wxT( " this " ) << (unsigned) track;
wxMessageBox( msg );
}
#endif
/**
* Function ShowClearance
* tests to see if the clearance border is drawn on the given track.
......@@ -151,17 +125,27 @@ int TRACK::GetDrillValue() const
return g_DesignSettings.m_ViaDrill;
}
/**
* Function GetLength
* returns the position of this object.
* @return the length of the track segment (0 for a via).
*/
double TRACK::GetLength()
{
wxPoint delta = m_End - m_Start;
return sqrt( (double)delta.x*delta.x + (double)delta.y*delta.y );
}
/***********************/
bool TRACK::IsNull()
/***********************/
// return TRUE if segment length = 0
// return true if segment length = 0
{
if( ( Type() != TYPE_VIA ) && ( m_Start == m_End ) )
return TRUE;
return true;
else
return FALSE;
return false;
}
......@@ -272,24 +256,26 @@ EDA_Rect TRACK::GetBoundingBox()
return ret;
}
/**
* Function Rotate
* Rotate this object.
* @param const wxPoint& aRotCentre - the rotation point.
* @param aAngle - the rotation angle in 0.1 degree.
*/
void TRACK::Rotate(const wxPoint& aRotCentre, int aAngle)
void TRACK::Rotate( const wxPoint& aRotCentre, int aAngle )
{
RotatePoint( &m_Start, aRotCentre, aAngle );
RotatePoint( &m_End, aRotCentre, aAngle );
}
/**
* Function Flip
* Flip this object, i.e. change the board side for this object
* @param const wxPoint& aCentre - the rotation point.
*/
void TRACK::Flip(const wxPoint& aCentre )
void TRACK::Flip( const wxPoint& aCentre )
{
m_Start.y = aCentre.y - (m_Start.y - aCentre.y);
m_End.y = aCentre.y - (m_End.y - aCentre.y);
......@@ -712,8 +698,8 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
angle = 900; // angle is in 0.1 degree
if( panel->GetScreen()->Scale( tsize ) >= 6 )
{
if( !(!IsOnLayer( curr_layer )&& DisplayOpt.ContrastModeDisplay)){
if( !(!IsOnLayer( curr_layer )&& DisplayOpt.ContrastModeDisplay) )
{
tsize = (tsize * 8) / 10; // small reduction to give a better look
DrawGraphicText( panel, DC, tpos,
WHITE, net->GetShortNetname(), angle, wxSize( tsize, tsize ),
......@@ -736,6 +722,7 @@ void SEGVIA::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoi
int fillvia = 0;
WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) panel->m_Parent;
PCB_SCREEN* screen = frame->GetScreen();
if( frame->m_DisplayViaFill == FILLED )
fillvia = 1;
......@@ -907,7 +894,7 @@ void SEGVIA::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoi
DrawGraphicText( panel, DC, m_Start,
WHITE, net->GetShortNetname(), 0, wxSize( tsize, tsize ),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7,
false, false);
false, false );
}
}
}
......@@ -917,12 +904,7 @@ void SEGVIA::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoi
void TRACK::DisplayInfo( WinEDA_DrawFrame* frame )
{
wxString msg;
int text_pos;
BOARD* board = ( (WinEDA_BasePcbFrame*)frame)->GetBoard();
#ifdef RATSNET_DEBUG
DbgDisplayTrackInfos( this );
#endif
BOARD* board = ( (WinEDA_BasePcbFrame*) frame )->GetBoard();
frame->MsgPanel->EraseMsgBox();
......@@ -943,18 +925,11 @@ void TRACK::DisplayInfo( WinEDA_DrawFrame* frame )
msg = wxT( "????" ); break;
}
text_pos = 1;
Affiche_1_Parametre( frame, text_pos, _( "Type" ), msg, DARKCYAN );
text_pos += 10;
frame->MsgPanel->AppendMessage( _( "Type" ), msg, DARKCYAN );
if( Type() == TYPE_TRACK
|| Type() == TYPE_ZONE
|| Type() == TYPE_VIA )
// Display Net Name (in pcbnew)
if( frame->m_Ident == PCB_FRAME )
{
/* Display NetName pour les segments de piste type cuivre */
NETINFO_ITEM* net = board->FindNet( GetNet() );
if( net )
......@@ -962,31 +937,18 @@ void TRACK::DisplayInfo( WinEDA_DrawFrame* frame )
else
msg = wxT( "<noname>" );
Affiche_1_Parametre( frame, text_pos, _( "NetName" ), msg, RED );
text_pos += 20;
frame->MsgPanel->AppendMessage( _( "NetName" ), msg, RED );
/* Display net code : (usefull in test or debug) */
msg.Printf( wxT( "%d .%d" ), GetNet(), GetSubNet() );
Affiche_1_Parametre( frame, text_pos, _( "NetCode" ), msg, RED );
text_pos += 8;
}
else
{
Affiche_1_Parametre( frame, text_pos, _( "Segment" ), wxEmptyString, RED );
if( m_Shape == S_CIRCLE )
Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Circle" ), RED );
else
Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Standard" ), RED );
text_pos += 8;
frame->MsgPanel->AppendMessage( _( "NetCode" ), msg, RED );
}
#if defined(DEBUG)
/* Display the flags */
msg.Printf( wxT( "0x%08X" ), m_Flags );
Affiche_1_Parametre( frame, text_pos, _( "Flags" ), msg, BLUE );
text_pos += 8;
frame->MsgPanel->AppendMessage( _( "Flags" ), msg, BLUE );
#endif
......@@ -998,8 +960,7 @@ void TRACK::DisplayInfo( WinEDA_DrawFrame* frame )
if( GetState( SEGM_AR ) )
msg[2] = 'A';
Affiche_1_Parametre( frame, text_pos, _( "Stat" ), msg, MAGENTA );
text_pos += 6;
frame->MsgPanel->AppendMessage( _( "Stat" ), msg, MAGENTA );
/* Display layer or layer pair) */
if( Type() == TYPE_VIA )
......@@ -1014,8 +975,7 @@ void TRACK::DisplayInfo( WinEDA_DrawFrame* frame )
else
msg = board->GetLayerName( m_Layer );
Affiche_1_Parametre( frame, text_pos, _( "Layer" ), msg, BROWN );
text_pos += 15;
frame->MsgPanel->AppendMessage( _( "Layer" ), msg, BROWN );
/* Display width */
valeur_param( (unsigned) m_Width, msg );
......@@ -1023,8 +983,7 @@ void TRACK::DisplayInfo( WinEDA_DrawFrame* frame )
if( Type() == TYPE_VIA ) // Display Diam and Drill values
{
// Display diameter value:
Affiche_1_Parametre( frame, text_pos, _( "Diam" ), msg, DARKCYAN );
text_pos += 8;
frame->MsgPanel->AppendMessage( _( "Diam" ), msg, DARKCYAN );
// Display drill value
int drill_value = GetDrillValue();
......@@ -1032,24 +991,41 @@ void TRACK::DisplayInfo( WinEDA_DrawFrame* frame )
valeur_param( (unsigned) drill_value, msg );
wxString title = _( "Drill" );
title += wxT(" ");
title += wxT( " " );
if( m_Drill >= 0 )
title += _( "(Specific)" );
else
title += _( "(Default)" );
Affiche_1_Parametre( frame, text_pos, title, msg, RED );
frame->MsgPanel->AppendMessage( title, msg, RED );
}
else
Affiche_1_Parametre( frame, text_pos, _( "Width" ), msg, DARKCYAN );
{
frame->MsgPanel->AppendMessage( _( "Width" ), msg, DARKCYAN );
}
NETCLASS* netclass = GetNetClass();
if( netclass )
{
msg = netclass->GetName();
text_pos += 10;
Affiche_1_Parametre( frame, text_pos, _( "Net Class" ), msg, DARKCYAN );
frame->MsgPanel->AppendMessage( _( "Net Class" ), msg, DARKCYAN );
}
// Display segment length
if( Type() != TYPE_VIA ) // Display Diam and Drill values
{
valeur_param( wxRound( GetLength() ), msg );
frame->MsgPanel->AppendMessage( _( "Seg Len" ), msg, DARKCYAN );
}
// Display full track length (in pcbnew)
if( frame->m_Ident == PCB_FRAME )
{
int trackLen;
Marque_Une_Piste( board, this, NULL, &trackLen, false );
valeur_param( trackLen, msg );
frame->MsgPanel->AppendMessage( _( "Track Len" ), msg, DARKCYAN );
}
}
......
......@@ -96,6 +96,13 @@ public:
return m_Start; // it had to be start or end.
}
/**
* Function GetLength
* returns the position of this object.
* @return the length of the track segment (0 for a via).
*/
double GetLength();
EDA_Rect GetBoundingBox();
......
......@@ -10,11 +10,13 @@
#include "pcbnew.h"
#include "wxPcbStruct.h"
#include "protos.h"
#include "pcbnew_id.h"
#include "collectors.h"
#include "bitmaps.h"
//external funtions used here:
extern bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
int aCurrentTool, wxSize grid, wxPoint on_grid, wxPoint* curpos );
/*************************************************************************************/
static BOARD_ITEM* AllAreModulesAndReturnSmallestIfSo( GENERAL_COLLECTOR* aCollector )
......@@ -220,265 +222,6 @@ BOARD_ITEM* WinEDA_BasePcbFrame::PcbGeneralLocateAndDisplay( int aHotKeyCode )
}
/**
* Function Join
* finds the point where line segment (b1,b0) intersects with segment (a1,a0).
* If that point would be outside of (a0,a1), the respective endpoint is used.
* Join returns the point in "res" and "true" if a suitable point was found,
* "false" if both lines are parallel or if the length of either segment is zero.
*/
static bool Join( wxPoint* res, wxPoint a0, wxPoint a1, wxPoint b0, wxPoint b1 )
{
/* References:
http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/
http://www.gekkou.co.uk/blogs/monologues/2007/12/13/1197586800000.html
*/
double denom;
double t;
// if either segment is zero length
if( a1.x==a0.x && a1.y==a0.y )
return false;
if( b1.x==b0.x && b1.y==b0.y )
return false;
a1 -= a0;
b1 -= b0;
b0 -= a0;
denom = (double) b1.y * a1.x - (double) b1.x * a1.y;
if( !denom )
{
return false; // parallel
}
t = ((double) b1.y * b0.x - (double) b1.x * b0.y ) / denom;
t = min( max( t, 0.0 ), 1.0 );
res->x = wxRound( a0.x + t * a1.x );
res->y = wxRound( a0.y + t * a1.y );
return true;
}
/*
* "Project" finds the projection of a grid point on a track. This is the point
* from where we want to draw new orthogonal tracks when starting on a track.
*/
bool Project( wxPoint* res, wxPoint on_grid, const TRACK* track )
{
if( track->m_Start == track->m_End )
return false;
wxPoint vec = track->m_End - track->m_Start;
double t = double( on_grid.x - track->m_Start.x ) * vec.x +
double( on_grid.y - track->m_Start.y ) * vec.y;
t /= (double) vec.x * vec.x + (double) vec.y * vec.y;
t = min( max( t, 0.0 ), 1.0 );
res->x = wxRound( track->m_Start.x + t * vec.x );
res->y = wxRound( track->m_Start.y + t * vec.y );
return true;
}
/**
* Function Magnetize
* tests to see if there are any magnetic items within near reach of the given
* "curpos". If yes, then curpos is adjusted appropriately according to that
* near magnetic item and true is returned.
* @param curpos The initial position, and what to adjust if a change is needed.
* @return bool - true if the position was adjusted magnetically, else false.
*/
static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
int aCurrentTool, wxSize grid, wxPoint on_grid, wxPoint* curpos )
{
bool doCheckNet = g_MagneticPadOption != capture_always && Drc_On;
bool doTrack = false;
bool doPad = false;
bool amMovingVia = false;
TRACK* currTrack = g_CurrentTrackSegment;
BOARD_ITEM* currItem = frame->GetCurItem();
// D( printf( "currTrack=%p currItem=%p currTrack->Type()=%d currItem->Type()=%d\n", currTrack, currItem, currTrack ? currTrack->Type() : 0, currItem ? currItem->Type() : 0 ); )
if( !currTrack && currItem && currItem->Type()==TYPE_VIA && currItem->m_Flags )
{
// moving a VIA
currTrack = (TRACK*) currItem;
amMovingVia = true;
return false; // comment this return out and play with it.
}
else if( currItem != currTrack )
{
currTrack = NULL;
}
if( g_MagneticPadOption == capture_always )
doPad = true;
if( g_MagneticTrackOption == capture_always )
doTrack = true;
if( aCurrentTool == ID_TRACK_BUTT || amMovingVia )
{
int q = capture_cursor_in_track_tool;
if( g_MagneticPadOption == q )
doPad = true;
if( g_MagneticTrackOption == q )
doTrack = true;
}
// D(printf("doPad=%d doTrack=%d aCurrentTool=%d amMovingVia=%d\n", doPad, doTrack, aCurrentTool, amMovingVia );)
// The search precedence order is pads, then tracks/vias
if( doPad )
{
D_PAD* pad = Locate_Any_Pad( m_Pcb, CURSEUR_OFF_GRILLE, TRUE );
if( pad )
{
if( doCheckNet && currTrack && currTrack->GetNet() != pad->GetNet() )
return false;
*curpos = pad->m_Pos;
return true;
}
}
// after pads, only track & via tests remain, skip them if not desired
if( doTrack )
{
int layer = ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer;
for( TRACK* via = m_Pcb->m_Track;
via && (via = Locate_Via_Area( via, *curpos, layer )) != NULL;
via = via->Next() )
{
if( via != currTrack ) // a via cannot influence itself
{
if( !doCheckNet || !currTrack || currTrack->GetNet() == via->GetNet() )
{
*curpos = via->m_Start;
// D(printf("via hit\n");)
return true;
}
}
else
{
//D( printf( "skipping self\n" ); )
}
}
if( !currTrack )
{
int layer_mask = g_TabOneLayerMask[layer];
TRACK* track = Locate_Pistes( m_Pcb->m_Track, layer_mask, CURSEUR_OFF_GRILLE );
if( !track || track->Type() != TYPE_TRACK )
{
// D(printf("!currTrack and track=%p not found, layer_mask=0x%X\n", track, layer_mask );)
return false;
}
// D( printf( "Project\n" ); )
return Project( curpos, on_grid, track );
}
/*
* In two segment mode, ignore the final segment if it's inside a grid
* square.
*/
if( !amMovingVia && currTrack && g_TwoSegmentTrackBuild && currTrack->Back()
&& currTrack->m_Start.x - grid.x < currTrack->m_End.x
&& currTrack->m_Start.x + grid.x > currTrack->m_End.x
&& currTrack->m_Start.y - grid.y < currTrack->m_End.y
&& currTrack->m_Start.y + grid.y > currTrack->m_End.y )
{
currTrack = currTrack->Back();
}
for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() )
{
if( track->Type() != TYPE_TRACK )
continue;
if( doCheckNet && currTrack && currTrack->GetNet() != track->GetNet() )
continue;
if( g_DesignSettings.IsLayerVisible( track->GetLayer() ) == false )
continue;
// omit the layer check if moving a via
if( !amMovingVia && !track->IsOnLayer( layer ) )
continue;
if( !track->HitTest( *curpos ) )
continue;
D(printf( "have track prospect\n");)
if( Join( curpos, track->m_Start, track->m_End, currTrack->m_Start, currTrack->m_End ) )
{
// D(printf( "join currTrack->Type()=%d\n", currTrack->Type() );)
return true;
}
if( aCurrentTool == ID_TRACK_BUTT || amMovingVia )
{
// At this point we have a drawing mouse on a track, we are drawing
// a new track and that new track is parallel to the track the
// mouse is on. Find the nearest end point of the track under mouse
// to the mouse and return that.
double distStart = hypot( double( curpos->x - track->m_Start.x ),
double( curpos->y - track->m_Start.y ));
double distEnd = hypot( double( curpos->x - track->m_End.x ),
double( curpos->y - track->m_End.y ));
// if track not via, or if its a via dragging but not with its adjacent track
if( currTrack->Type() != TYPE_VIA
|| ( currTrack->m_Start != track->m_Start && currTrack->m_Start != track->m_End ))
{
if( distStart <= currTrack->m_Width/2 )
{
// D(printf("nearest end is start\n");)
*curpos = track->m_Start;
return true;
}
if( distEnd <= currTrack->m_Width/2 )
{
// D(printf("nearest end is end\n");)
*curpos = track->m_End;
return true;
}
// @todo otherwise confine curpos such that it stays centered
// within "track"
}
}
}
}
return false;
}
/****************************************************************/
void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse )
/*****************************************************************/
......
......@@ -192,7 +192,7 @@ void WinEDA_PcbFrame::Remove_One_Track( wxDC* DC, TRACK* pt_segm )
if( pt_segm == NULL )
return;
TRACK* trackList = Marque_Une_Piste( this, DC, pt_segm, &segments_to_delete_count, 0 );
TRACK* trackList = Marque_Une_Piste( GetBoard(), pt_segm, &segments_to_delete_count, NULL, true );
if( segments_to_delete_count == 0 )
return;
......
......@@ -73,7 +73,7 @@ DIALOG_TRACKS_OPTIONS_BASE::DIALOG_TRACKS_OPTIONS_BASE( wxWindow* parent, wxWind
wxStaticBoxSizer* sbMiddleLeftSizer;
sbMiddleLeftSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Vias Options:") ), wxVERTICAL );
wxString m_OptViaTypeChoices[] = { _("Through Via"), _("Blind or Buried Via") };
wxString m_OptViaTypeChoices[] = { _("Through via"), _("Blind or buried via") };
int m_OptViaTypeNChoices = sizeof( m_OptViaTypeChoices ) / sizeof( wxString );
m_OptViaType = new wxRadioBox( this, wxID_ANY, _("Default Via Type"), wxDefaultPosition, wxDefaultSize, m_OptViaTypeNChoices, m_OptViaTypeChoices, 1, wxRA_SPECIFY_COLS );
m_OptViaType->SetSelection( 0 );
......@@ -84,7 +84,7 @@ DIALOG_TRACKS_OPTIONS_BASE::DIALOG_TRACKS_OPTIONS_BASE( wxWindow* parent, wxWind
sbMiddleLeftSizer->Add( 10, 10, 0, 0, 5 );
wxString m_AllowMicroViaCtrlChoices[] = { _("Do Not Allow Micro Vias"), _("Allow Micro Vias") };
wxString m_AllowMicroViaCtrlChoices[] = { _("Do not allow micro vias"), _("Allow micro vias") };
int m_AllowMicroViaCtrlNChoices = sizeof( m_AllowMicroViaCtrlChoices ) / sizeof( wxString );
m_AllowMicroViaCtrl = new wxRadioBox( this, wxID_ALLOW_MICROVIA, _("Micro Vias:"), wxDefaultPosition, wxDefaultSize, m_AllowMicroViaCtrlNChoices, m_AllowMicroViaCtrlChoices, 1, wxRA_SPECIFY_COLS );
m_AllowMicroViaCtrl->SetSelection( 0 );
......
......@@ -509,7 +509,7 @@
<property name="proportion">0</property>
<object class="wxRadioBox" expanded="1">
<property name="bg"></property>
<property name="choices">&quot;Through Via&quot; &quot;Blind or Buried Via&quot;</property>
<property name="choices">&quot;Through via&quot; &quot;Blind or buried via&quot;</property>
<property name="context_help"></property>
<property name="enabled">1</property>
<property name="fg"></property>
......@@ -573,7 +573,7 @@
<property name="proportion">0</property>
<object class="wxRadioBox" expanded="1">
<property name="bg"></property>
<property name="choices">&quot;Do Not Allow Micro Vias&quot; &quot;Allow Micro Vias&quot;</property>
<property name="choices">&quot;Do not allow micro vias&quot; &quot;Allow micro vias&quot;</property>
<property name="context_help"></property>
<property name="enabled">1</property>
<property name="fg"></property>
......
/***************************************************************/
/* Edition des pistes: Routines de modification de dimensions: */
/* Modif de largeurs de segment, piste, net , zone et diam Via */
/***************************************************************/
/***************************************************************
* Tracks and Vias size edition:
* Functions to modify sizes of segment, track, net , all vias and/or all tracks
***************************************************************/
#include "fctsys.h"
#include "common.h"
......@@ -13,29 +13,46 @@
#include "protos.h"
/** Function SetTrackSegmentWidth
* Modify one track segment width or one via diameter (using DRC control).
* Basic routine used by other routines when editing tracks or vias
* @param aTrackItem = the track segment or via to modify
* @param aItemsListPicker = the list picker to use for an undo command (can be NULL)
* @param aUseNetclassValue = true to use NetClass value, false to use g_DesignSettings value
* @return true if done, false if no not change (because DRC error)
*/
bool WinEDA_PcbFrame::SetTrackSegmentWidth( TRACK* aTrackItem,
PICKED_ITEMS_LIST* aItemsListPicker )
PICKED_ITEMS_LIST* aItemsListPicker,
bool aUseNetclassValue )
{
int initial_width, new_width;
bool change_ok = false;
NETINFO_ITEM* net = NULL;
if( aUseNetclassValue )
net = GetBoard()->FindNet( aTrackItem->GetNet() );
initial_width = aTrackItem->m_Width;
new_width = aTrackItem->m_Width = g_DesignSettings.m_CurrentTrackWidth;
if( net )
new_width = net->GetTrackWidth();
else
new_width = g_DesignSettings.m_CurrentTrackWidth;
if( aTrackItem->Type() == TYPE_VIA )
{
if( net )
new_width = net->GetViaSize();
else
new_width = aTrackItem->m_Width = g_DesignSettings.m_CurrentViaSize;
if( aTrackItem->m_Shape == VIA_MICROVIA )
{
if( net )
new_width = net->GetViaSize();
else
new_width = aTrackItem->m_Width = g_DesignSettings.m_CurrentMicroViaSize;
}
}
aTrackItem->m_Width = new_width;
if( initial_width < new_width ) /* make a DRC test because the new size is bigger than the old size */
{
int diagdrc = OK_DRC;
......@@ -46,6 +63,7 @@ bool WinEDA_PcbFrame::SetTrackSegmentWidth( TRACK* aTrackItem,
}
else if( initial_width > new_width )
change_ok = true;
// if new width == initial_width: do nothing
if( change_ok )
......@@ -75,7 +93,7 @@ bool WinEDA_PcbFrame::SetTrackSegmentWidth( TRACK* aTrackItem,
void WinEDA_PcbFrame::Edit_TrackSegm_Width( wxDC* DC, TRACK* aTrackItem )
{
PICKED_ITEMS_LIST itemsListPicker;
bool change = SetTrackSegmentWidth( aTrackItem, &itemsListPicker );
bool change = SetTrackSegmentWidth( aTrackItem, &itemsListPicker, false );
if( change == 0 || aTrackItem->m_Flags )
return; // No change
......@@ -84,7 +102,7 @@ void WinEDA_PcbFrame::Edit_TrackSegm_Width( wxDC* DC, TRACK* aTrackItem )
if( DC )
{
TRACK* oldsegm = (TRACK*) itemsListPicker.GetPickedItemLink( 0 );
wxASSERT(oldsegm);
wxASSERT( oldsegm );
DrawPanel->CursorOff( DC ); // Erase cursor shape
oldsegm->Draw( DrawPanel, DC, GR_XOR ); // Erase old track shape
aTrackItem->Draw( DrawPanel, DC, GR_OR ); // Display new track shape
......@@ -93,6 +111,7 @@ void WinEDA_PcbFrame::Edit_TrackSegm_Width( wxDC* DC, TRACK* aTrackItem )
SaveCopyInUndoList( itemsListPicker, UR_CHANGED );
}
/** Function Edit_Track_Width
* Modify a full track width (using DRC control).
* a full track is the set of track segments between 2 ends: pads or a point that has more than 2 segments ends connected
......@@ -108,14 +127,14 @@ void WinEDA_PcbFrame::Edit_Track_Width( wxDC* DC, TRACK* aTrackSegment )
if( aTrackSegment == NULL )
return;
pt_track = Marque_Une_Piste( this, DC, aTrackSegment, &nb_segm, 0 );
pt_track = Marque_Une_Piste( GetBoard(), aTrackSegment, &nb_segm, NULL, true );
PICKED_ITEMS_LIST itemsListPicker;
bool change = false;
for( int ii = 0; ii < nb_segm; ii++, pt_track = pt_track->Next() )
{
pt_track->SetState( BUSY, OFF );
if( SetTrackSegmentWidth( pt_track, &itemsListPicker ) )
if( SetTrackSegmentWidth( pt_track, &itemsListPicker, false ) )
change = true;
}
......@@ -142,26 +161,36 @@ void WinEDA_PcbFrame::Edit_Track_Width( wxDC* DC, TRACK* aTrackSegment )
/***********************************************************/
void WinEDA_PcbFrame::Edit_Net_Width( wxDC* DC, int Netcode )
void WinEDA_PcbFrame::Edit_Net_Width( wxDC* DC, int aNetcode )
/***********************************************************/
{
TRACK* pt_segm;
if( Netcode <= 0 )
if( aNetcode <= 0 )
return;
if( !IsOK( this, _( "Change track width (entire NET) ?" ) ) )
NETINFO_ITEM* net = GetBoard()->FindNet( aNetcode );
wxASSERT( net );
wxString netName = net->GetNetname();
wxString msg;
NETCLASS* netClass = net->GetNetClass();
wxASSERT( netClass );
wxString netClassName = netClass->GetName();
msg.Printf( _(
"Set tracks and vias sizes to the Netclass \"%s\"default value (entire NET \"%s\") ?" ),
netClassName.c_str(), netName.c_str() );
if( !IsOK( this, msg ) )
return;
/* balayage des segments */
/* Examine segments */
PICKED_ITEMS_LIST itemsListPicker;
bool change = false;
for( pt_segm = GetBoard()->m_Track; pt_segm != NULL; pt_segm = pt_segm->Next() )
{
if( Netcode != pt_segm->GetNet() ) /* mauvaise piste */
if( aNetcode != pt_segm->GetNet() ) /* not in net */
continue;
/* piste d'un net trouvee */
if( SetTrackSegmentWidth( pt_segm, &itemsListPicker ) )
/* we have found a item member of the net */
if( SetTrackSegmentWidth( pt_segm, &itemsListPicker, true ) )
change = true;
}
......@@ -200,17 +229,17 @@ bool WinEDA_PcbFrame::Resize_Pistes_Vias( wxDC* DC, bool Track, bool Via )
if( Track && Via )
{
if( !IsOK( this, _( "Edit All Tracks and Vias Sizes" ) ) )
if( !IsOK( this, _( "Set All Tracks and Vias to Netclass value" ) ) )
return FALSE;
}
else if( Via )
{
if( !IsOK( this, _( "Edit All Via Sizes" ) ) )
if( !IsOK( this, _( "Set All Via to Netclass value" ) ) )
return FALSE;
}
else if( Track )
{
if( !IsOK( this, _( "Edit All Track Sizes" ) ) )
if( !IsOK( this, _( "Set All Track to Netclass value" ) ) )
return FALSE;
}
......@@ -221,16 +250,17 @@ bool WinEDA_PcbFrame::Resize_Pistes_Vias( wxDC* DC, bool Track, bool Via )
{
if( (pt_segm->Type() == TYPE_VIA ) && Via )
{
if( SetTrackSegmentWidth( pt_segm, &itemsListPicker ) )
if( SetTrackSegmentWidth( pt_segm, &itemsListPicker, true ) )
change = true;
}
}
if( (pt_segm->Type() == TYPE_TRACK ) && Track )
{
if( SetTrackSegmentWidth( pt_segm, &itemsListPicker ) )
if( SetTrackSegmentWidth( pt_segm, &itemsListPicker, true ) )
change = true;;
}
}
if( !change )
return false;
......
......@@ -73,7 +73,8 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC )
l1 = Route_Layer_TOP; l2 = Route_Layer_BOTTOM;
pt_track = Marque_Une_Piste( this, DC, pt_segm, &nb_segm, GR_XOR );
pt_track = Marque_Une_Piste( GetBoard(), pt_segm, &nb_segm, NULL, true );
Trace_Une_Piste( DrawPanel, DC, pt_track, nb_segm, GR_XOR );
/* effacement du flag BUSY et sauvegarde en membre .param de la couche
* initiale */
......
/********************************************************/
/* magnetic_tracks_functions.cpp */
/********************************************************/
/* functions used to controle the cursor position, when creating a track
* and when the "magnetic tracks" option is on
* (the current created track is kept near existing tracks
* the distance is the clearance between tracks)
*/
#include "fctsys.h"
#include "common.h"
#include "pcbnew.h"
#include "wxPcbStruct.h"
#include "protos.h"
#include "pcbnew_id.h"
/**
* Function Join
* finds the point where line segment (b1,b0) intersects with segment (a1,a0).
* If that point would be outside of (a0,a1), the respective endpoint is used.
* Join returns the point in "res" and "true" if a suitable point was found,
* "false" if both lines are parallel or if the length of either segment is zero.
*/
static bool Join( wxPoint* res, wxPoint a0, wxPoint a1, wxPoint b0, wxPoint b1 )
{
/* References:
http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/
http://www.gekkou.co.uk/blogs/monologues/2007/12/13/1197586800000.html
*/
double denom;
double t;
// if either segment is zero length
if( a1.x==a0.x && a1.y==a0.y )
return false;
if( b1.x==b0.x && b1.y==b0.y )
return false;
a1 -= a0;
b1 -= b0;
b0 -= a0;
denom = (double) b1.y * a1.x - (double) b1.x * a1.y;
if( !denom )
{
return false; // parallel
}
t = ((double) b1.y * b0.x - (double) b1.x * b0.y ) / denom;
t = min( max( t, 0.0 ), 1.0 );
res->x = wxRound( a0.x + t * a1.x );
res->y = wxRound( a0.y + t * a1.y );
return true;
}
/*
* "Project" finds the projection of a grid point on a track. This is the point
* from where we want to draw new orthogonal tracks when starting on a track.
*/
bool Project( wxPoint* res, wxPoint on_grid, const TRACK* track )
{
if( track->m_Start == track->m_End )
return false;
wxPoint vec = track->m_End - track->m_Start;
double t = double( on_grid.x - track->m_Start.x ) * vec.x +
double( on_grid.y - track->m_Start.y ) * vec.y;
t /= (double) vec.x * vec.x + (double) vec.y * vec.y;
t = min( max( t, 0.0 ), 1.0 );
res->x = wxRound( track->m_Start.x + t * vec.x );
res->y = wxRound( track->m_Start.y + t * vec.y );
return true;
}
/**
* Function Magnetize
* tests to see if there are any magnetic items within near reach of the given
* "curpos". If yes, then curpos is adjusted appropriately according to that
* near magnetic item and true is returned.
* @param curpos The initial position, and what to adjust if a change is needed.
* @return bool - true if the position was adjusted magnetically, else false.
*/
bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
int aCurrentTool, wxSize grid, wxPoint on_grid, wxPoint* curpos )
{
bool doCheckNet = g_MagneticPadOption != capture_always && Drc_On;
bool doTrack = false;
bool doPad = false;
bool amMovingVia = false;
TRACK* currTrack = g_CurrentTrackSegment;
BOARD_ITEM* currItem = frame->GetCurItem();
// D( printf( "currTrack=%p currItem=%p currTrack->Type()=%d currItem->Type()=%d\n", currTrack, currItem, currTrack ? currTrack->Type() : 0, currItem ? currItem->Type() : 0 ); )
if( !currTrack && currItem && currItem->Type()==TYPE_VIA && currItem->m_Flags )
{
// moving a VIA
currTrack = (TRACK*) currItem;
amMovingVia = true;
return false; // comment this return out and play with it.
}
else if( currItem != currTrack )
{
currTrack = NULL;
}
if( g_MagneticPadOption == capture_always )
doPad = true;
if( g_MagneticTrackOption == capture_always )
doTrack = true;
if( aCurrentTool == ID_TRACK_BUTT || amMovingVia )
{
int q = capture_cursor_in_track_tool;
if( g_MagneticPadOption == q )
doPad = true;
if( g_MagneticTrackOption == q )
doTrack = true;
}
// D(printf("doPad=%d doTrack=%d aCurrentTool=%d amMovingVia=%d\n", doPad, doTrack, aCurrentTool, amMovingVia );)
// The search precedence order is pads, then tracks/vias
if( doPad )
{
D_PAD* pad = Locate_Any_Pad( m_Pcb, CURSEUR_OFF_GRILLE, TRUE );
if( pad )
{
if( doCheckNet && currTrack && currTrack->GetNet() != pad->GetNet() )
return false;
*curpos = pad->m_Pos;
return true;
}
}
// after pads, only track & via tests remain, skip them if not desired
if( doTrack )
{
int layer = ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer;
for( TRACK* via = m_Pcb->m_Track;
via && (via = Locate_Via_Area( via, *curpos, layer )) != NULL;
via = via->Next() )
{
if( via != currTrack ) // a via cannot influence itself
{
if( !doCheckNet || !currTrack || currTrack->GetNet() == via->GetNet() )
{
*curpos = via->m_Start;
// D(printf("via hit\n");)
return true;
}
}
else
{
//D( printf( "skipping self\n" ); )
}
}
if( !currTrack )
{
int layer_mask = g_TabOneLayerMask[layer];
TRACK* track = Locate_Pistes( m_Pcb->m_Track, layer_mask, CURSEUR_OFF_GRILLE );
if( !track || track->Type() != TYPE_TRACK )
{
// D(printf("!currTrack and track=%p not found, layer_mask=0x%X\n", track, layer_mask );)
return false;
}
// D( printf( "Project\n" ); )
return Project( curpos, on_grid, track );
}
/*
* In two segment mode, ignore the final segment if it's inside a grid
* square.
*/
if( !amMovingVia && currTrack && g_TwoSegmentTrackBuild && currTrack->Back()
&& currTrack->m_Start.x - grid.x < currTrack->m_End.x
&& currTrack->m_Start.x + grid.x > currTrack->m_End.x
&& currTrack->m_Start.y - grid.y < currTrack->m_End.y
&& currTrack->m_Start.y + grid.y > currTrack->m_End.y )
{
currTrack = currTrack->Back();
}
for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() )
{
if( track->Type() != TYPE_TRACK )
continue;
if( doCheckNet && currTrack && currTrack->GetNet() != track->GetNet() )
continue;
if( g_DesignSettings.IsLayerVisible( track->GetLayer() ) == false )
continue;
// omit the layer check if moving a via
if( !amMovingVia && !track->IsOnLayer( layer ) )
continue;
if( !track->HitTest( *curpos ) )
continue;
D(printf( "have track prospect\n");)
if( Join( curpos, track->m_Start, track->m_End, currTrack->m_Start, currTrack->m_End ) )
{
// D(printf( "join currTrack->Type()=%d\n", currTrack->Type() );)
return true;
}
if( aCurrentTool == ID_TRACK_BUTT || amMovingVia )
{
// At this point we have a drawing mouse on a track, we are drawing
// a new track and that new track is parallel to the track the
// mouse is on. Find the nearest end point of the track under mouse
// to the mouse and return that.
double distStart = hypot( double( curpos->x - track->m_Start.x ),
double( curpos->y - track->m_Start.y ));
double distEnd = hypot( double( curpos->x - track->m_End.x ),
double( curpos->y - track->m_End.y ));
// if track not via, or if its a via dragging but not with its adjacent track
if( currTrack->Type() != TYPE_VIA
|| ( currTrack->m_Start != track->m_Start && currTrack->m_Start != track->m_End ))
{
if( distStart <= currTrack->m_Width/2 )
{
// D(printf("nearest end is start\n");)
*curpos = track->m_Start;
return true;
}
if( distEnd <= currTrack->m_Width/2 )
{
// D(printf("nearest end is end\n");)
*curpos = track->m_End;
return true;
}
// @todo otherwise confine curpos such that it stays centered
// within "track"
}
}
}
}
return false;
}
......@@ -506,7 +506,7 @@ void WinEDA_PcbFrame::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu )
track_mnu = new wxMenu;
ADD_MENUITEM_WITH_SUBMENU( PopMenu, track_mnu,
ID_POPUP_PCB_EDIT_TRACK_MNU, _(
"Change Width" ), width_track_xpm );
"Change Tracks and Vias Sizes" ), width_track_xpm );
ADD_MENUITEM( track_mnu, ID_POPUP_PCB_EDIT_TRACKSEG,
Track->Type()==TYPE_VIA ? _( "Change Via Size" ) : _(
"Change Segment Width" ), width_segment_xpm );
......@@ -514,13 +514,13 @@ void WinEDA_PcbFrame::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu )
ADD_MENUITEM( track_mnu, ID_POPUP_PCB_EDIT_TRACK,
_( "Change Track Width" ), width_track_xpm );
ADD_MENUITEM( track_mnu, ID_POPUP_PCB_EDIT_NET,
_( "Change Net" ), width_net_xpm );
_( "Set Net to NetClass values" ), width_net_xpm );
ADD_MENUITEM( track_mnu, ID_POPUP_PCB_EDIT_ALL_VIAS_AND_TRACK_SIZE,
_( "Change ALL Tracks and Vias" ), width_track_via_xpm );
_( "Set ALL Tracks and Vias to NetClass Values" ), width_track_via_xpm );
ADD_MENUITEM( track_mnu, ID_POPUP_PCB_EDIT_ALL_VIAS_SIZE,
_( "Change ALL Vias (No Track)" ), width_vias_xpm );
_( "Set ALL Vias (No Track)to NetClass Values" ), width_vias_xpm );
ADD_MENUITEM( track_mnu, ID_POPUP_PCB_EDIT_ALL_TRACK_SIZE,
_( "Change ALL Tracks (No Via)" ), width_track_xpm );
_( "Set ALL Tracks (No Via)to NetClass Values" ), width_track_xpm );
}
// Delete control:
......
......@@ -262,17 +262,24 @@ void Calcule_Coord_Extremite_45( int ox, int oy, int* fx, int* fy );
/*****************/
/* TRACK.CPP : */
/*****************/
TRACK* Marque_Une_Piste( WinEDA_BasePcbFrame* frame, wxDC* DC,
TRACK* pt_segm, int* nb_segm, int flagcolor );
/* Routine de Marquage de 1 piste, a partir du segment pointe par pt_segm.
* le segment pointe est marque puis les segments adjacents
* jusqu'a un pad ou un point de jonction de plus de 2 segments
* le marquage est la mise a 1 du bit BUSY du parametre .status
* Les segments sont ensuite reclasses pour etre contigus en memoire
* Retourne:
* adresse du 1er segment de la chaine creee
* nombre de segments */
/**
* Function Marque_Une_Piste
* marks a chain of track segments, connected to aTrackList.
* Each segment is marked by setting the BUSY bit into m_Flags. Electrical continuity
* is detected by walking each segment, and finally the segments are rearranged
* into a contiguous chain within the given list.
* @param aPcb = the board to analyse
* @param aStartSegm The first interesting segment within a list of track segment of aPcb
* @param aSegmCount = a pointer to an integer where to return the number of interesting segments
* @param aTrackLen = a pointer to an integer where to return the lenght of the track
* @param aReorder =
* true for reorder the interesting segments (useful for track edition/deletion)
* in this case the flag BUSY is set (the user is responsible of flag clearing)
* false for no reorder : useful when we want just calculate the track lenght
* in this case, flags are reset
* @return TRACK* the first in the chain of interesting segments.
*/
TRACK* Marque_Une_Piste( BOARD * aPcb, TRACK* aStartSegm, int* aSegmCount, int * aTrackLen, bool aReorder );
int ReturnEndsTrack( TRACK* RefTrack, int NbSegm,
TRACK** StartTrack, TRACK** EndTrack );
......
......@@ -49,7 +49,7 @@ int WinEDA_PcbFrame::EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewT
if( aNewTrack->Type() == TYPE_VIA && (aNewTrackSegmentsCount > 1 ) )
aNewTrack = aNewTrack->Next();
aNewTrack = Marque_Une_Piste( this, aDC, aNewTrack, &aNewTrackSegmentsCount, 0 );
aNewTrack = Marque_Une_Piste( GetBoard(), aNewTrack, &aNewTrackSegmentsCount, NULL, true );
wxASSERT( aNewTrack );
#if 0 && defined(DEBUG)
......@@ -204,7 +204,7 @@ int WinEDA_PcbFrame::EraseRedundantTrack( wxDC* aDC, TRACK* aNewTrack, int aNewT
nbconnect--;
pt_del->SetState( CHAIN, OFF );
pt_del = Marque_Une_Piste( this, aDC, pt_del, &nb_segm, 0 );
pt_del = Marque_Une_Piste( GetBoard(), pt_del, &nb_segm, NULL, true );
/* Test si La piste marquee est redondante, c'est a dire si l'un des
* segments marques est connecte au point de depart de la piste nouvelle
......
This diff is collapsed.
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