Commit 0dc3be88 authored by lifekidyeaa's avatar lifekidyeaa

added an option to enable/disable magnetic tracks in the general options...

added an option to enable/disable magnetic tracks in the general options dialog of PCBnew (same as the magnetic 
pads option.)  Haven't fixed the via issue 
(since I don't quite understand why it is doing this, nor does it occur in 100% of the cases), but now you can just 
turn 
off magnetic tracks when I desire to move vias by small increments.  Magnetic tracks are on by default.  Original 
via complaint here: 
http://tech.groups.yahoo.com/group/kicad-devel/message/1155

Also mostly gotten rid of the annoying "Unable to drag this segment: two collinear segments" error.  Now, if two 
(or more) segments are collinear, they are merged into one equivalent segment when you try to drag them while 
maintaining slope.  I can't imagine any cases where this would be a bad thing (and I have plenty of experience where 
the error was not desired!).  Note I say *mostly* because there still seem to be some length=1 (e.g. 0.003mm) segments 
at the end of valid-length segments.  I do not want to remove them because this would change the board layout, though 
in a basically imperceptible way.  We could maybe have an option to clean & remove these minimal-length segments, but 
I worry that they serve to connect things slightly off grid & those things on-grid; also, removal may cause DRC 
errors. It would be good if we could avoid their creation.(?)

parent 35b7973b
...@@ -489,6 +489,7 @@ public: ...@@ -489,6 +489,7 @@ public:
void Attribut_net( wxDC* DC, int net_code, bool Flag_On ); void Attribut_net( wxDC* DC, int net_code, bool Flag_On );
void Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int command ); void Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int command );
bool PlaceDraggedTrackSegment( TRACK* Track, wxDC* DC ); bool PlaceDraggedTrackSegment( TRACK* Track, wxDC* DC );
bool MergeCollinearTracks( TRACK* track, wxDC* DC, int end );
void Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC ); void Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC );
void SwitchLayer( wxDC* DC, int layer ); void SwitchLayer( wxDC* DC, int layer );
int Add_45_degrees_Segment( wxDC* DC, TRACK* pt_segm ); int Add_45_degrees_Segment( wxDC* DC, TRACK* pt_segm );
......
...@@ -307,23 +307,29 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, ...@@ -307,23 +307,29 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
curr = NULL; curr = NULL;
} }
switch( g_MagneticPadOption ) bool pad_ok = false;
{ if( g_MagneticPadOption == capture_always )
case capture_cursor_in_track_tool: pad_ok = true;
if( aCurrentTool != ID_TRACK_BUTT )
return false;
break; bool track_ok = false;
if( g_MagneticTrackOption == capture_always )
case capture_always: track_ok = true;
break;
if( aCurrentTool == ID_TRACK_BUTT )
case no_effect: {
default: int q = capture_cursor_in_track_tool;
return false; if( g_MagneticPadOption == q )
} pad_ok = true;
if( g_MagneticTrackOption == q )
track_ok = true;
}
if(!pad_ok && !track_ok) //then nothing magnetic to do
return false;
pad = Locate_Any_Pad( m_Pcb, CURSEUR_OFF_GRILLE, TRUE ); pad = Locate_Any_Pad( m_Pcb, CURSEUR_OFF_GRILLE, TRUE );
if( pad ) if( pad && pad_ok)
{ {
if( doCheckNet && curr && curr->GetNet() != pad->GetNet() ) if( doCheckNet && curr && curr->GetNet() != pad->GetNet() )
return false; return false;
...@@ -335,7 +341,7 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, ...@@ -335,7 +341,7 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
layer = ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer; layer = ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer;
via = Locate_Via_Area( m_Pcb, *curpos, layer ); via = Locate_Via_Area( m_Pcb, *curpos, layer );
if( via ) if( via && track_ok) //vias are part of tracks...?
{ {
if( doCheckNet && curr && curr->GetNet() != via->GetNet() ) if( doCheckNet && curr && curr->GetNet() != via->GetNet() )
return false; return false;
...@@ -346,7 +352,7 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, ...@@ -346,7 +352,7 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
layer_mask = g_TabOneLayerMask[layer]; layer_mask = g_TabOneLayerMask[layer];
if( !curr ) if( !curr && track_ok)
{ {
track = Locate_Pistes( m_Pcb->m_Track, layer_mask, CURSEUR_OFF_GRILLE ); track = Locate_Pistes( m_Pcb->m_Track, layer_mask, CURSEUR_OFF_GRILLE );
if( !track || track->Type() != TYPETRACK ) if( !track || track->Type() != TYPETRACK )
...@@ -359,7 +365,7 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, ...@@ -359,7 +365,7 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
* In two segment mode, ignore the final segment if it's inside a grid * In two segment mode, ignore the final segment if it's inside a grid
* square. * square.
*/ */
if( g_TwoSegmentTrackBuild && curr->Back() if( curr && g_TwoSegmentTrackBuild && curr->Back()
&& curr->m_Start.x - grid.x < curr->m_End.x && curr->m_Start.x - grid.x < curr->m_End.x
&& curr->m_Start.x + grid.x > curr->m_End.x && curr->m_Start.x + grid.x > curr->m_End.x
&& curr->m_Start.y - grid.y < curr->m_End.y && curr->m_Start.y - grid.y < curr->m_End.y
...@@ -368,7 +374,7 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, ...@@ -368,7 +374,7 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame,
curr = curr->Back(); curr = curr->Back();
} }
for( track = m_Pcb->m_Track; track; track = track->Next() ) for( track = m_Pcb->m_Track; track && track_ok; track = track->Next() )
{ {
if( track->Type() != TYPETRACK ) if( track->Type() != TYPETRACK )
continue; continue;
......
...@@ -227,15 +227,18 @@ bool WinEDA_PcbGeneralOptionsFrame::Create( wxWindow* parent, wxWindowID id, con ...@@ -227,15 +227,18 @@ bool WinEDA_PcbGeneralOptionsFrame::Create( wxWindow* parent, wxWindowID id, con
m_AutoPANOpt = NULL; m_AutoPANOpt = NULL;
m_Track_DoubleSegm_Ctrl = NULL; m_Track_DoubleSegm_Ctrl = NULL;
m_MagneticPadOptCtrl = NULL; m_MagneticPadOptCtrl = NULL;
m_MagneticTrackOptCtrl = NULL;
////@end WinEDA_PcbGeneralOptionsFrame member initialisation ////@end WinEDA_PcbGeneralOptionsFrame member initialisation
////@begin WinEDA_PcbGeneralOptionsFrame creation ////@begin WinEDA_PcbGeneralOptionsFrame creation
SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
wxDialog::Create( parent, id, caption, pos, size, style ); wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls(); CreateControls();
GetSizer()->Fit(this); if (GetSizer())
GetSizer()->SetSizeHints(this); {
GetSizer()->SetSizeHints(this);
}
Centre(); Centre();
////@end WinEDA_PcbGeneralOptionsFrame creation ////@end WinEDA_PcbGeneralOptionsFrame creation
SetFont(*g_DialogFont); SetFont(*g_DialogFont);
...@@ -249,7 +252,7 @@ bool WinEDA_PcbGeneralOptionsFrame::Create( wxWindow* parent, wxWindowID id, con ...@@ -249,7 +252,7 @@ bool WinEDA_PcbGeneralOptionsFrame::Create( wxWindow* parent, wxWindowID id, con
void WinEDA_PcbGeneralOptionsFrame::CreateControls() void WinEDA_PcbGeneralOptionsFrame::CreateControls()
{ {
////@begin WinEDA_PcbGeneralOptionsFrame content construction ////@begin WinEDA_PcbGeneralOptionsFrame content construction
// Generated by DialogBlocks, 13/04/2006 22:32:02 (unregistered) // Generated by DialogBlocks, Mon 03 Mar 2008 04:27:22 PM EST (unregistered)
WinEDA_PcbGeneralOptionsFrame* itemDialog1 = this; WinEDA_PcbGeneralOptionsFrame* itemDialog1 = this;
...@@ -259,30 +262,25 @@ void WinEDA_PcbGeneralOptionsFrame::CreateControls() ...@@ -259,30 +262,25 @@ void WinEDA_PcbGeneralOptionsFrame::CreateControls()
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5); itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5);
static const wxString m_PolarDisplayStrings[] = { wxArrayString m_PolarDisplayStrings;
_("No Display"), m_PolarDisplayStrings.Add(_("No Display"));
_("Display") m_PolarDisplayStrings.Add(_("Display"));
}; m_PolarDisplay = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Display Polar Coord"), wxDefaultPosition, wxDefaultSize, m_PolarDisplayStrings, 1, wxRA_SPECIFY_COLS );
m_PolarDisplay->SetSelection(0);
m_PolarDisplay = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Display Polar Coord"), wxDefaultPosition, wxDefaultSize, 2, m_PolarDisplayStrings, 1, wxRA_SPECIFY_COLS );
itemBoxSizer3->Add(m_PolarDisplay, 0, wxALIGN_LEFT|wxALL, 5); itemBoxSizer3->Add(m_PolarDisplay, 0, wxALIGN_LEFT|wxALL, 5);
static const wxString m_BoxUnitsStrings[] = { wxArrayString m_BoxUnitsStrings;
_("Inches"), m_BoxUnitsStrings.Add(_("Inches"));
_("millimeters") m_BoxUnitsStrings.Add(_("millimeters"));
}; m_BoxUnits = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Units"), wxDefaultPosition, wxDefaultSize, m_BoxUnitsStrings, 1, wxRA_SPECIFY_COLS );
m_BoxUnits->SetSelection(0);
m_BoxUnits = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Units"), wxDefaultPosition,
wxDefaultSize, 2, m_BoxUnitsStrings, 1,wxRA_SPECIFY_COLS );
itemBoxSizer3->Add(m_BoxUnits, 0, wxALIGN_LEFT|wxALL, 5); itemBoxSizer3->Add(m_BoxUnits, 0, wxALIGN_LEFT|wxALL, 5);
static const wxString m_CursorShapeStrings[] = { wxArrayString m_CursorShapeStrings;
_("Small"), m_CursorShapeStrings.Add(_("Small"));
_("Big") m_CursorShapeStrings.Add(_("Big"));
}; m_CursorShape = new wxRadioBox( itemDialog1, ID_RADIOBOX2, _("Cursor"), wxDefaultPosition, wxDefaultSize, m_CursorShapeStrings, 1, wxRA_SPECIFY_COLS );
m_CursorShape->SetSelection(0);
m_CursorShape = new wxRadioBox( itemDialog1, ID_RADIOBOX2, _("Cursor"), wxDefaultPosition, wxDefaultSize, 2,
m_CursorShapeStrings, 1, wxRA_SPECIFY_COLS );
itemBoxSizer3->Add(m_CursorShape, 0, wxALIGN_LEFT|wxALL, 5); itemBoxSizer3->Add(m_CursorShape, 0, wxALIGN_LEFT|wxALL, 5);
wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxVERTICAL); wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxVERTICAL);
...@@ -292,14 +290,14 @@ void WinEDA_PcbGeneralOptionsFrame::CreateControls() ...@@ -292,14 +290,14 @@ void WinEDA_PcbGeneralOptionsFrame::CreateControls()
wxStaticBoxSizer* itemStaticBoxSizer8 = new wxStaticBoxSizer(itemStaticBoxSizer8Static, wxVERTICAL); wxStaticBoxSizer* itemStaticBoxSizer8 = new wxStaticBoxSizer(itemStaticBoxSizer8Static, wxVERTICAL);
itemBoxSizer7->Add(itemStaticBoxSizer8, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); itemBoxSizer7->Add(itemStaticBoxSizer8, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
m_LayerNumber = new wxSpinCtrl( itemDialog1, ID_SPINCTRL1, _T("0"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 16, 0 ); m_LayerNumber = new wxSpinCtrl( itemDialog1, ID_SPINCTRL1, _T("1"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 16, 1 );
itemStaticBoxSizer8->Add(m_LayerNumber, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); itemStaticBoxSizer8->Add(m_LayerNumber, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
wxStaticBox* itemStaticBoxSizer10Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Max Links:")); wxStaticBox* itemStaticBoxSizer10Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Max Links:"));
wxStaticBoxSizer* itemStaticBoxSizer10 = new wxStaticBoxSizer(itemStaticBoxSizer10Static, wxVERTICAL); wxStaticBoxSizer* itemStaticBoxSizer10 = new wxStaticBoxSizer(itemStaticBoxSizer10Static, wxVERTICAL);
itemBoxSizer7->Add(itemStaticBoxSizer10, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); itemBoxSizer7->Add(itemStaticBoxSizer10, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
m_MaxShowLinks = new wxSpinCtrl( itemDialog1, ID_SPINCTRL2, _T("0"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 5, 0 ); m_MaxShowLinks = new wxSpinCtrl( itemDialog1, ID_SPINCTRL2, _T("1"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 5, 1 );
itemStaticBoxSizer10->Add(m_MaxShowLinks, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); itemStaticBoxSizer10->Add(m_MaxShowLinks, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
wxStaticBox* itemStaticBoxSizer12Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Auto Save (minuts):")); wxStaticBox* itemStaticBoxSizer12Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Auto Save (minuts):"));
...@@ -351,30 +349,40 @@ void WinEDA_PcbGeneralOptionsFrame::CreateControls() ...@@ -351,30 +349,40 @@ void WinEDA_PcbGeneralOptionsFrame::CreateControls()
m_Track_DoubleSegm_Ctrl->SetForegroundColour(wxColour(0, 144, 0)); m_Track_DoubleSegm_Ctrl->SetForegroundColour(wxColour(0, 144, 0));
itemStaticBoxSizer15->Add(m_Track_DoubleSegm_Ctrl, 0, wxALIGN_LEFT|wxALL, 5); itemStaticBoxSizer15->Add(m_Track_DoubleSegm_Ctrl, 0, wxALIGN_LEFT|wxALL, 5);
static const wxString m_MagneticPadOptCtrlStrings[] = { wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxVERTICAL);
_("Never"), itemBoxSizer2->Add(itemBoxSizer24, 0, wxALIGN_TOP|wxALL, 5);
_("When creating tracks"),
_("Always")
};
m_MagneticPadOptCtrl = new wxRadioBox( itemDialog1, ID_MAGNETIC_PAD_CTRL, _("Magnetic Pads"), wxDefaultPosition, wxDefaultSize, 3, m_MagneticPadOptCtrlStrings, 1, wxRA_SPECIFY_COLS );
if (ShowToolTips())
m_MagneticPadOptCtrl->SetToolTip(_("control the capture of the pcb cursor when the mouse cursor enters a pad area"));
itemStaticBoxSizer15->Add(m_MagneticPadOptCtrl, 0, wxGROW|wxALL, 5);
wxBoxSizer* itemBoxSizer25 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer2->Add(itemBoxSizer25, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* itemButton26 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); wxArrayString m_MagneticPadOptCtrlStrings;
itemButton26->SetForegroundColour(wxColour(221, 0, 0)); m_MagneticPadOptCtrlStrings.Add(_("Never"));
itemBoxSizer25->Add(itemButton26, 0, wxGROW|wxALL, 5); m_MagneticPadOptCtrlStrings.Add(_("When creating tracks"));
m_MagneticPadOptCtrlStrings.Add(_("Always"));
wxButton* itemButton27 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); m_MagneticPadOptCtrl = new wxRadioBox( itemDialog1, ID_RADIOBOX4, _("Magnetic Pads"), wxDefaultPosition, wxDefaultSize, m_MagneticPadOptCtrlStrings, 1, wxRA_SPECIFY_COLS );
itemButton27->SetForegroundColour(wxColour(0, 0, 255)); m_MagneticPadOptCtrl->SetSelection(0);
itemBoxSizer25->Add(itemButton27, 0, wxGROW|wxALL, 5); if (WinEDA_PcbGeneralOptionsFrame::ShowToolTips())
m_MagneticPadOptCtrl->SetToolTip(_("control the capture of the pcb cursor when the mouse cursor enters a pad area"));
itemBoxSizer24->Add(m_MagneticPadOptCtrl, 0, wxGROW|wxALL, 5);
wxArrayString m_MagneticTrackOptCtrlStrings;
m_MagneticTrackOptCtrlStrings.Add(_("Never"));
m_MagneticTrackOptCtrlStrings.Add(_("When creating tracks"));
m_MagneticTrackOptCtrlStrings.Add(_("Always"));
m_MagneticTrackOptCtrl = new wxRadioBox( itemDialog1, ID_RADIOBOX3, _("Magnetic Tracks"), wxDefaultPosition, wxDefaultSize, m_MagneticTrackOptCtrlStrings, 1, wxRA_SPECIFY_COLS );
m_MagneticTrackOptCtrl->SetSelection(0);
if (WinEDA_PcbGeneralOptionsFrame::ShowToolTips())
m_MagneticTrackOptCtrl->SetToolTip(_("control the capture of the pcb cursor when the mouse cursor enters a track"));
itemBoxSizer24->Add(m_MagneticTrackOptCtrl, 0, wxGROW|wxALL, 5);
wxButton* itemButton27 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton27->SetForegroundColour(wxColour(221, 0, 0));
itemBoxSizer24->Add(itemButton27, 0, wxGROW|wxALL, 5);
wxButton* itemButton28 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton28->SetForegroundColour(wxColour(0, 0, 255));
itemBoxSizer24->Add(itemButton28, 0, wxGROW|wxALL, 5);
// Set validators // Set validators
m_MagneticPadOptCtrl->SetValidator( wxGenericValidator(& g_MagneticPadOption) ); m_MagneticPadOptCtrl->SetValidator( wxGenericValidator(& g_MagneticPadOption) );
m_MagneticTrackOptCtrl->SetValidator( wxGenericValidator(& g_MagneticTrackOption) );
////@end WinEDA_PcbGeneralOptionsFrame content construction ////@end WinEDA_PcbGeneralOptionsFrame content construction
} }
......
...@@ -40,11 +40,6 @@ class wxSpinCtrl; ...@@ -40,11 +40,6 @@ class wxSpinCtrl;
*/ */
////@begin control identifiers ////@begin control identifiers
#define SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_STYLE wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX|MAYBE_RESIZE_BORDER
#define SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_TITLE _("General Options")
#define SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_IDNAME wxID_CANCEL
#define SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_SIZE wxSize(400, 300)
#define SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_POSITION wxDefaultPosition
#define ID_RADIOBOX 10001 #define ID_RADIOBOX 10001
#define ID_RADIOBOX1 10002 #define ID_RADIOBOX1 10002
#define ID_RADIOBOX2 10003 #define ID_RADIOBOX2 10003
...@@ -59,7 +54,13 @@ class wxSpinCtrl; ...@@ -59,7 +54,13 @@ class wxSpinCtrl;
#define ID_CHECKBOX5 10012 #define ID_CHECKBOX5 10012
#define ID_CHECKBOX6 10013 #define ID_CHECKBOX6 10013
#define ID_CHECKBOX7 10014 #define ID_CHECKBOX7 10014
#define ID_MAGNETIC_PAD_CTRL 10000 #define ID_RADIOBOX4 10016
#define ID_RADIOBOX3 10015
#define SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_STYLE wxCAPTION|wxSYSTEM_MENU|wxCLOSE_BOX|MAYBE_RESIZE_BORDER
#define SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_TITLE _("General Options")
#define SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_IDNAME wxID_CANCEL
#define SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_SIZE wxSize(400, 300)
#define SYMBOL_WINEDA_PCBGENERALOPTIONSFRAME_POSITION wxDefaultPosition
////@end control identifiers ////@end control identifiers
/*! /*!
...@@ -131,6 +132,7 @@ public: ...@@ -131,6 +132,7 @@ public:
wxCheckBox* m_AutoPANOpt; wxCheckBox* m_AutoPANOpt;
wxCheckBox* m_Track_DoubleSegm_Ctrl; wxCheckBox* m_Track_DoubleSegm_Ctrl;
wxRadioBox* m_MagneticPadOptCtrl; wxRadioBox* m_MagneticPadOptCtrl;
wxRadioBox* m_MagneticTrackOptCtrl;
////@end WinEDA_PcbGeneralOptionsFrame member variables ////@end WinEDA_PcbGeneralOptionsFrame member variables
WinEDA_PcbFrame * m_Parent; WinEDA_PcbFrame * m_Parent;
wxDC * m_DC; wxDC * m_DC;
......
This diff is collapsed.
...@@ -310,13 +310,10 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, ...@@ -310,13 +310,10 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey,
if( ItemFree ) if( ItemFree )
{ {
// no track is currently being edited - select a segment and remove it. // no track is currently being edited - select a segment and remove it.
// @todo: possibly? pass the HK command code to PcbGeneralLocateAndDisplay() so it can restrict its search to specific item types. // @todo: possibly? pass the HK command code to PcbGeneralLocateAndDisplay() so it can restrict its search to specific item types.
// @todo: use PcbGeneralLocateAndDisplay() everywhere in this source file. // @todo: use PcbGeneralLocateAndDisplay() everywhere in this source file.
DrawStruct = PcbGeneralLocateAndDisplay(); DrawStruct = PcbGeneralLocateAndDisplay();
// don't let backspace delete modules!! // don't let backspace delete modules!!
if( DrawStruct && (DrawStruct->Type() == TYPETRACK if( DrawStruct && (DrawStruct->Type() == TYPETRACK
|| DrawStruct->Type() == TYPEVIA) ) || DrawStruct->Type() == TYPEVIA) )
......
...@@ -464,6 +464,8 @@ bool InitialiseDragParameters() ...@@ -464,6 +464,8 @@ bool InitialiseDragParameters()
tSegmentToStart = TrackSegWrapper->m_Segm; // Get the segment connected to the start point tSegmentToStart = TrackSegWrapper->m_Segm; // Get the segment connected to the start point
} }
} }
//would be nice to eliminate collinear segments here, so we don't
//have to deal with that annoying "Unable to drag this segment: two collinear segments"
s_StartPointVertical = false; s_StartPointVertical = false;
s_EndPointVertical = false; s_EndPointVertical = false;
...@@ -610,7 +612,7 @@ void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int co ...@@ -610,7 +612,7 @@ void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int co
NbPtNewTrack = 0; NbPtNewTrack = 0;
EraseDragListe(); EraseDragListe();
/* Change hight light net: the new one will be hightlighted */ /* Change highlighted net: the new one will be hightlighted */
Old_HightLigt_Status = g_HightLigt_Status; Old_HightLigt_Status = g_HightLigt_Status;
Old_HightLigth_NetCode = g_HightLigth_NetCode; Old_HightLigth_NetCode = g_HightLigth_NetCode;
if( g_HightLigt_Status ) if( g_HightLigt_Status )
...@@ -670,8 +672,67 @@ void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int co ...@@ -670,8 +672,67 @@ void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int co
DrawHightLight( DC, g_HightLigth_NetCode ); DrawHightLight( DC, g_HightLigth_NetCode );
DrawPanel->ManageCurseur( DrawPanel, DC, TRUE ); DrawPanel->ManageCurseur( DrawPanel, DC, TRUE );
} }
void SortTrackEndPoints(TRACK* track)
{
//sort the track endpoints -- should not matter in terms of drawing
//or producing the pcb -- but makes doing comparisons easier.
wxPoint tmp;
int dx = track->m_End.x - track->m_Start.x;
if(dx){
if( track->m_Start.x > track->m_End.x ){
tmp = track->m_Start;
track->m_Start = track->m_End;
track->m_End = tmp;
}
}else{
if( track->m_Start.y > track->m_End.y ){
tmp = track->m_Start;
track->m_Start = track->m_End;
track->m_End = tmp;
}
}
}
/***********************************************************************************/
bool WinEDA_PcbFrame::MergeCollinearTracks( TRACK* track, wxDC* DC, int end )
/***********************************************************************************/
{
TRACK* testtrack = NULL;
testtrack = (TRACK*) Locate_Piste_Connectee( track, m_Pcb->m_Track, NULL, end );
if( testtrack )
{
SortTrackEndPoints(track);
SortTrackEndPoints(testtrack);
int dx = track->m_End.x - track->m_Start.x;
int dy = track->m_End.y - track->m_Start.y;
int tdx = testtrack->m_End.x - testtrack->m_Start.x;
int tdy = testtrack->m_End.y - testtrack->m_Start.y;
if( (dy * tdx == dx * tdy && dy != 0 && dx != 0 && tdy != 0 && tdx != 0) /*angle, same slope*/
|| (dy == 0 && tdy == 0 && dx*tdx )/*horizontal*/
|| (dx == 0 && tdx == 0 && dy*tdy )/*vertical*/ ) {
if(track->m_Start == testtrack->m_Start || track->m_End == testtrack->m_Start){
if( ( dx*tdx && testtrack->m_End.x > track->m_End.x )
||( dy*tdy && testtrack->m_End.y > track->m_End.y )){
track->m_End = testtrack->m_End;
Delete_Segment( DC, testtrack );
return true;
}
}
if(track->m_Start == testtrack->m_End || track->m_End == testtrack->m_End){
if( ( dx*tdx && testtrack->m_Start.x < track->m_Start.x )
||( dy*tdy && testtrack->m_Start.y < track->m_Start.y )){
track->m_Start = testtrack->m_Start;
Delete_Segment( DC, testtrack );
return true;
}
}
}
}
return false;
}
/***********************************************************************************/ /***********************************************************************************/
void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC ) void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC )
/***********************************************************************************/ /***********************************************************************************/
...@@ -682,6 +743,9 @@ void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC ...@@ -682,6 +743,9 @@ void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
if( !track ) if( !track )
return; return;
while(MergeCollinearTracks(track, DC, START)){};
while(MergeCollinearTracks(track, DC, END)){};
s_StartSegmentPresent = s_EndSegmentPresent = TRUE; s_StartSegmentPresent = s_EndSegmentPresent = TRUE;
......
...@@ -231,6 +231,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, WinEDA_App* parent, ...@@ -231,6 +231,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, WinEDA_App* parent,
GridSize.y = SizeY; GridSize.y = SizeY;
} }
m_Parent->m_EDA_Config->Read( wxT( "PcbMagPadOpt" ), &g_MagneticPadOption ); m_Parent->m_EDA_Config->Read( wxT( "PcbMagPadOpt" ), &g_MagneticPadOption );
m_Parent->m_EDA_Config->Read( wxT( "PcbMagTrackOpt" ), &g_MagneticTrackOption );
} }
GetScreen()->SetGrid( GridSize ); GetScreen()->SetGrid( GridSize );
...@@ -311,6 +312,7 @@ void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event ) ...@@ -311,6 +312,7 @@ void WinEDA_PcbFrame::OnCloseWindow( wxCloseEvent& Event )
m_Parent->m_EDA_Config->Write( wxT( "PcbEditGrid_X" ), (long) GridSize.x ); m_Parent->m_EDA_Config->Write( wxT( "PcbEditGrid_X" ), (long) GridSize.x );
m_Parent->m_EDA_Config->Write( wxT( "PcbEditGrid_Y" ), (long) GridSize.y ); m_Parent->m_EDA_Config->Write( wxT( "PcbEditGrid_Y" ), (long) GridSize.y );
m_Parent->m_EDA_Config->Write( wxT( "PcbMagPadOpt" ), (long) g_MagneticPadOption ); m_Parent->m_EDA_Config->Write( wxT( "PcbMagPadOpt" ), (long) g_MagneticPadOption );
m_Parent->m_EDA_Config->Write( wxT( "PcbMagTrackOpt" ), (long) g_MagneticTrackOption );
} }
Destroy(); Destroy();
} }
......
...@@ -256,7 +256,7 @@ eda_global bool g_TwoSegmentTrackBuild // FALSE = 1 segment build, TRUE = 2 45 ...@@ -256,7 +256,7 @@ eda_global bool g_TwoSegmentTrackBuild // FALSE = 1 segment build, TRUE = 2 45
#endif #endif
; ;
/* How to handle magnetic pads: feature to move the pcb cursor on a pad center */ /* How to handle magnetic pads & tracks: feature to move the pcb cursor on a pad center / track length */
enum MagneticPadOptionValues { enum MagneticPadOptionValues {
no_effect, no_effect,
capture_cursor_in_track_tool, capture_cursor_in_track_tool,
...@@ -268,6 +268,11 @@ eda_global int g_MagneticPadOption ...@@ -268,6 +268,11 @@ eda_global int g_MagneticPadOption
= capture_cursor_in_track_tool = capture_cursor_in_track_tool
#endif #endif
; ;
eda_global int g_MagneticTrackOption
#ifdef MAIN
= capture_cursor_in_track_tool
#endif
;
/* Variables to handle hightlight nets */ /* Variables to handle hightlight nets */
eda_global bool g_HightLigt_Status; eda_global bool g_HightLigt_Status;
eda_global int g_HightLigth_NetCode eda_global int g_HightLigth_NetCode
......
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