From 0dc3be880618e32dec4f4a978b77f2f9091fc0a8 Mon Sep 17 00:00:00 2001 From: lifekidyeaa Date: Tue, 4 Mar 2008 05:40:15 +0000 Subject: [PATCH] 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.(?) --- include/wxPcbStruct.h | 1 + pcbnew/controle.cpp | 44 +-- pcbnew/dialog_general_options.cpp | 94 +++--- pcbnew/dialog_general_options.h | 14 +- pcbnew/dialog_general_options.pjd | 474 +++++++++++++++++++++++++----- pcbnew/hotkeys.cpp | 3 - pcbnew/move_or_drag_track.cpp | 70 ++++- pcbnew/pcbframe.cpp | 2 + pcbnew/pcbnew.h | 7 +- 9 files changed, 565 insertions(+), 144 deletions(-) diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 98dc609d7f..cdbd972cd8 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -489,6 +489,7 @@ public: void Attribut_net( wxDC* DC, int net_code, bool Flag_On ); void Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int command ); bool PlaceDraggedTrackSegment( TRACK* Track, wxDC* DC ); + bool MergeCollinearTracks( TRACK* track, wxDC* DC, int end ); void Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC ); void SwitchLayer( wxDC* DC, int layer ); int Add_45_degrees_Segment( wxDC* DC, TRACK* pt_segm ); diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index fda09cf0a1..3a95b9f043 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -307,23 +307,29 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, curr = NULL; } - switch( g_MagneticPadOption ) - { - case capture_cursor_in_track_tool: - if( aCurrentTool != ID_TRACK_BUTT ) - return false; - break; - - case capture_always: - break; - - case no_effect: - default: - return false; - } + bool pad_ok = false; + if( g_MagneticPadOption == capture_always ) + pad_ok = true; + + + bool track_ok = false; + if( g_MagneticTrackOption == capture_always ) + track_ok = true; + + if( aCurrentTool == ID_TRACK_BUTT ) + { + int q = capture_cursor_in_track_tool; + 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 ); - if( pad ) + if( pad && pad_ok) { if( doCheckNet && curr && curr->GetNet() != pad->GetNet() ) return false; @@ -335,7 +341,7 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, layer = ( (PCB_SCREEN*) ActiveScreen )->m_Active_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() ) return false; @@ -346,7 +352,7 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, layer_mask = g_TabOneLayerMask[layer]; - if( !curr ) + if( !curr && track_ok) { track = Locate_Pistes( m_Pcb->m_Track, layer_mask, CURSEUR_OFF_GRILLE ); if( !track || track->Type() != TYPETRACK ) @@ -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 * 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.y - grid.y < curr->m_End.y @@ -368,7 +374,7 @@ static bool Magnetize( BOARD* m_Pcb, WinEDA_PcbFrame* frame, 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 ) continue; diff --git a/pcbnew/dialog_general_options.cpp b/pcbnew/dialog_general_options.cpp index 6b73e96270..b15d0c0d69 100644 --- a/pcbnew/dialog_general_options.cpp +++ b/pcbnew/dialog_general_options.cpp @@ -227,15 +227,18 @@ bool WinEDA_PcbGeneralOptionsFrame::Create( wxWindow* parent, wxWindowID id, con m_AutoPANOpt = NULL; m_Track_DoubleSegm_Ctrl = NULL; m_MagneticPadOptCtrl = NULL; + m_MagneticTrackOptCtrl = NULL; ////@end WinEDA_PcbGeneralOptionsFrame member initialisation ////@begin WinEDA_PcbGeneralOptionsFrame creation - SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); + SetExtraStyle(wxWS_EX_BLOCK_EVENTS); wxDialog::Create( parent, id, caption, pos, size, style ); CreateControls(); - GetSizer()->Fit(this); - GetSizer()->SetSizeHints(this); + if (GetSizer()) + { + GetSizer()->SetSizeHints(this); + } Centre(); ////@end WinEDA_PcbGeneralOptionsFrame creation SetFont(*g_DialogFont); @@ -249,7 +252,7 @@ bool WinEDA_PcbGeneralOptionsFrame::Create( wxWindow* parent, wxWindowID id, con void WinEDA_PcbGeneralOptionsFrame::CreateControls() { ////@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; @@ -259,30 +262,25 @@ void WinEDA_PcbGeneralOptionsFrame::CreateControls() wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5); - static const wxString m_PolarDisplayStrings[] = { - _("No Display"), - _("Display") - }; - - m_PolarDisplay = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("Display Polar Coord"), wxDefaultPosition, wxDefaultSize, 2, m_PolarDisplayStrings, 1, wxRA_SPECIFY_COLS ); + wxArrayString m_PolarDisplayStrings; + m_PolarDisplayStrings.Add(_("No 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); itemBoxSizer3->Add(m_PolarDisplay, 0, wxALIGN_LEFT|wxALL, 5); - static const wxString m_BoxUnitsStrings[] = { - _("Inches"), - _("millimeters") - }; - - m_BoxUnits = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Units"), wxDefaultPosition, - wxDefaultSize, 2, m_BoxUnitsStrings, 1,wxRA_SPECIFY_COLS ); + wxArrayString m_BoxUnitsStrings; + m_BoxUnitsStrings.Add(_("Inches")); + m_BoxUnitsStrings.Add(_("millimeters")); + m_BoxUnits = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("Units"), wxDefaultPosition, wxDefaultSize, m_BoxUnitsStrings, 1, wxRA_SPECIFY_COLS ); + m_BoxUnits->SetSelection(0); itemBoxSizer3->Add(m_BoxUnits, 0, wxALIGN_LEFT|wxALL, 5); - static const wxString m_CursorShapeStrings[] = { - _("Small"), - _("Big") - }; - - m_CursorShape = new wxRadioBox( itemDialog1, ID_RADIOBOX2, _("Cursor"), wxDefaultPosition, wxDefaultSize, 2, - m_CursorShapeStrings, 1, wxRA_SPECIFY_COLS ); + wxArrayString m_CursorShapeStrings; + m_CursorShapeStrings.Add(_("Small")); + m_CursorShapeStrings.Add(_("Big")); + m_CursorShape = new wxRadioBox( itemDialog1, ID_RADIOBOX2, _("Cursor"), wxDefaultPosition, wxDefaultSize, m_CursorShapeStrings, 1, wxRA_SPECIFY_COLS ); + m_CursorShape->SetSelection(0); itemBoxSizer3->Add(m_CursorShape, 0, wxALIGN_LEFT|wxALL, 5); wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxVERTICAL); @@ -292,14 +290,14 @@ void WinEDA_PcbGeneralOptionsFrame::CreateControls() wxStaticBoxSizer* itemStaticBoxSizer8 = new wxStaticBoxSizer(itemStaticBoxSizer8Static, wxVERTICAL); 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); wxStaticBox* itemStaticBoxSizer10Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Max Links:")); wxStaticBoxSizer* itemStaticBoxSizer10 = new wxStaticBoxSizer(itemStaticBoxSizer10Static, wxVERTICAL); 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); wxStaticBox* itemStaticBoxSizer12Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Auto Save (minuts):")); @@ -351,30 +349,40 @@ void WinEDA_PcbGeneralOptionsFrame::CreateControls() m_Track_DoubleSegm_Ctrl->SetForegroundColour(wxColour(0, 144, 0)); itemStaticBoxSizer15->Add(m_Track_DoubleSegm_Ctrl, 0, wxALIGN_LEFT|wxALL, 5); - static const wxString m_MagneticPadOptCtrlStrings[] = { - _("Never"), - _("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()) + wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxVERTICAL); + itemBoxSizer2->Add(itemBoxSizer24, 0, wxALIGN_TOP|wxALL, 5); + + wxArrayString m_MagneticPadOptCtrlStrings; + m_MagneticPadOptCtrlStrings.Add(_("Never")); + m_MagneticPadOptCtrlStrings.Add(_("When creating tracks")); + m_MagneticPadOptCtrlStrings.Add(_("Always")); + m_MagneticPadOptCtrl = new wxRadioBox( itemDialog1, ID_RADIOBOX4, _("Magnetic Pads"), wxDefaultPosition, wxDefaultSize, m_MagneticPadOptCtrlStrings, 1, wxRA_SPECIFY_COLS ); + m_MagneticPadOptCtrl->SetSelection(0); + if (WinEDA_PcbGeneralOptionsFrame::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); + itemBoxSizer24->Add(m_MagneticPadOptCtrl, 0, wxGROW|wxALL, 5); - wxBoxSizer* itemBoxSizer25 = new wxBoxSizer(wxVERTICAL); - itemBoxSizer2->Add(itemBoxSizer25, 0, wxALIGN_CENTER_VERTICAL|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* itemButton26 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); - itemButton26->SetForegroundColour(wxColour(221, 0, 0)); - itemBoxSizer25->Add(itemButton26, 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* itemButton27 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); - itemButton27->SetForegroundColour(wxColour(0, 0, 255)); - itemBoxSizer25->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 m_MagneticPadOptCtrl->SetValidator( wxGenericValidator(& g_MagneticPadOption) ); + m_MagneticTrackOptCtrl->SetValidator( wxGenericValidator(& g_MagneticTrackOption) ); ////@end WinEDA_PcbGeneralOptionsFrame content construction } diff --git a/pcbnew/dialog_general_options.h b/pcbnew/dialog_general_options.h index ef448006b7..e88905d93d 100644 --- a/pcbnew/dialog_general_options.h +++ b/pcbnew/dialog_general_options.h @@ -40,11 +40,6 @@ class wxSpinCtrl; */ ////@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_RADIOBOX1 10002 #define ID_RADIOBOX2 10003 @@ -59,7 +54,13 @@ class wxSpinCtrl; #define ID_CHECKBOX5 10012 #define ID_CHECKBOX6 10013 #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 /*! @@ -131,6 +132,7 @@ public: wxCheckBox* m_AutoPANOpt; wxCheckBox* m_Track_DoubleSegm_Ctrl; wxRadioBox* m_MagneticPadOptCtrl; + wxRadioBox* m_MagneticTrackOptCtrl; ////@end WinEDA_PcbGeneralOptionsFrame member variables WinEDA_PcbFrame * m_Parent; wxDC * m_DC; diff --git a/pcbnew/dialog_general_options.pjd b/pcbnew/dialog_general_options.pjd index 7655bc860b..612123afac 100644 --- a/pcbnew/dialog_general_options.pjd +++ b/pcbnew/dialog_general_options.pjd @@ -1,4 +1,4 @@ - +
0 @@ -6,18 +6,20 @@ "" "" "" - 35 "" 0 0 0 + 1 1 1 + 1 0 "jean-pierre Charras" "License GNU" "" 0 + 0 "<All platforms>" "<Any>" "///////////////////////////////////////////////////////////////////////////// @@ -43,12 +45,6 @@ // Licence: ///////////////////////////////////////////////////////////////////////////// -" - " -/*! - * %BODY% - */ - " "///////////////////////////////////////////////////////////////////////////// // Name: %SYMBOLS-FILENAME% @@ -82,6 +78,14 @@ #include "wx/wx.h" #endif +" + " /// %BODY% +" + " +/*! + * %BODY% + */ + " "app_resources.h" "app_resources.cpp" @@ -93,11 +97,23 @@ "" "<None>" "<System>" + "utf-8" "<System>" "" + 0 + 0 + 4 + " " + "" 0 + 0 + 1 + 0 1 1 + 0 + 1 + 0
@@ -120,6 +136,7 @@ 0 "" 1 + 0 "" "Debug" "ANSI" @@ -161,6 +178,8 @@ "%AUTO%" "%AUTO%" "%AUTO%" + 0 + 1 "GCC Release" "gcc-config-data-document" @@ -172,6 +191,7 @@ 0 "GCC" 1 + 0 "GCC" "Release" "ANSI" @@ -185,6 +205,7 @@ "No" "Yes" "No" + "No" "%WXVERSION%" "%EXECUTABLE%" "" @@ -215,7 +236,13 @@ "%AUTO%" "%AUTO%" "%AUTO%" + 0 + 1 "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" + "%AUTO%" @@ -230,7 +257,7 @@ 1 1 0 - 0 + 1 "Windows" "html-document" @@ -254,7 +281,10 @@ 10000 0 "" + 0 + "" 0 + 0 "wxID_CANCEL" 5101 "WinEDA_PcbGeneralOptionsFrame" @@ -275,10 +305,16 @@ 0 1 "<Any platform>" + "" + "" + "" + "" + "" + "" + "Tiled" 0 1 0 - 0 1 0 0 @@ -293,7 +329,9 @@ 0 0 0 - 0 + 0 + 0 + 0 0 0 1 @@ -305,6 +343,7 @@ -1 400 300 + 0 "" "wxBoxSizer H" @@ -360,10 +399,18 @@ "wbRadioBoxProxy" "ID_RADIOBOX" 10001 + "" "wxRadioBox" + "wxRadioBox" + 1 + 0 + "" + "" "m_PolarDisplay" "Display Polar Coord" 1 + "No Display|Display" + 0 "" "" "" @@ -374,10 +421,16 @@ "<Any platform>" "" "" + "" + "" + "" + "" + "" 0 1 - "No Display|Display" 0 + 0 + 0 "" -1 -1 @@ -410,10 +463,18 @@ "wbRadioBoxProxy" "ID_RADIOBOX1" 10002 + "" "wxRadioBox" + "wxRadioBox" + 1 + 0 + "" + "" "m_BoxUnits" "Units" 1 + "Inches|millimeters" + 0 "" "" "" @@ -424,10 +485,16 @@ "<Any platform>" "" "" + "" + "" + "" + "" + "" 0 1 - "Inches|millimeters" 0 + 0 + 0 "" -1 -1 @@ -460,10 +527,18 @@ "wbRadioBoxProxy" "ID_RADIOBOX2" 10003 + "" "wxRadioBox" + "wxRadioBox" + 1 + 0 + "" + "" "m_CursorShape" "Cursor" 1 + "Small|Big" + 0 "" "" "" @@ -474,10 +549,16 @@ "<Any platform>" "" "" + "" + "" + "" + "" + "" 0 1 - "Small|Big" 0 + 0 + 0 "" -1 -1 @@ -537,13 +618,14 @@ "wxID_ANY" -1 "Number of Layers:" + "" "" "" "" 0 1 + "wxStaticBox" "Vertical" - "" "Centre" "Centre" 0 @@ -569,7 +651,13 @@ "wbSpinCtrlProxy" "ID_SPINCTRL1" 10005 + "" "wxSpinCtrl" + "wxSpinCtrl" + 1 + 0 + "" + "" "m_LayerNumber" 1 16 @@ -584,6 +672,11 @@ "<Any platform>" "" "" + "" + "" + "" + "" + "" 1 0 0 @@ -593,6 +686,8 @@ 0 0 0 + 0 + 0 "" -1 -1 @@ -627,13 +722,14 @@ "wxID_ANY" -1 "Max Links:" + "" "" "" "" 0 1 + "wxStaticBox" "Vertical" - "" "Centre" "Centre" 0 @@ -659,7 +755,13 @@ "wbSpinCtrlProxy" "ID_SPINCTRL2" 10006 + "" "wxSpinCtrl" + "wxSpinCtrl" + 1 + 0 + "" + "" "m_MaxShowLinks" 1 5 @@ -674,6 +776,11 @@ "<Any platform>" "" "" + "" + "" + "" + "" + "" 1 0 0 @@ -683,6 +790,8 @@ 0 0 0 + 0 + 0 "" -1 -1 @@ -717,13 +826,14 @@ "wxID_ANY" -1 "Auto Save (minuts):" + "" "" "" "" 0 1 + "wxStaticBox" "Vertical" - "" "Centre" "Centre" 0 @@ -749,7 +859,13 @@ "wbSpinCtrlProxy" "ID_SPINCTRL3" 10004 + "" "wxSpinCtrl" + "wxSpinCtrl" + 1 + 0 + "" + "" "m_SaveTime" 0 60 @@ -764,6 +880,11 @@ "<Any platform>" "" "" + "" + "" + "" + "" + "" 1 0 0 @@ -773,6 +894,8 @@ 0 0 0 + 0 + 0 "" -1 -1 @@ -833,13 +956,14 @@ "wxID_ANY" -1 "Options:" + "" "" "" "" 0 1 + "wxStaticBox" "Vertical" - "" "Centre" "Centre" 0 @@ -865,7 +989,13 @@ "wbCheckBoxProxy" "ID_CHECKBOX" 10007 + "" "wxCheckBox" + "wxCheckBox" + 1 + 0 + "" + "" "m_DrcOn" "Drc ON" 0 @@ -873,6 +1003,11 @@ "" "" "" + "" + "" + "" + "" + "" "" "C60000" "" @@ -884,6 +1019,8 @@ 0 0 0 + 0 + 0 "" -1 -1 @@ -916,7 +1053,13 @@ "wbCheckBoxProxy" "ID_CHECKBOX1" 10008 + "" "wxCheckBox" + "wxCheckBox" + 1 + 0 + "" + "" "m_ShowGlobalRatsnest" "Show Ratsnest" 0 @@ -924,6 +1067,11 @@ "" "" "" + "" + "" + "" + "" + "" "" "" "" @@ -935,6 +1083,8 @@ 0 0 0 + 0 + 0 "" -1 -1 @@ -967,7 +1117,13 @@ "wbCheckBoxProxy" "ID_CHECKBOX2" 10009 + "" "wxCheckBox" + "wxCheckBox" + 1 + 0 + "" + "" "m_ShowModuleRatsnest" "Show Mod Ratsnest" 0 @@ -975,6 +1131,11 @@ "" "" "" + "" + "" + "" + "" + "" "" "" "" @@ -986,6 +1147,8 @@ 0 0 0 + 0 + 0 "" -1 -1 @@ -1018,7 +1181,13 @@ "wbCheckBoxProxy" "ID_CHECKBOX3" 10010 + "" "wxCheckBox" + "wxCheckBox" + 1 + 0 + "" + "" "m_TrackAutodel" "Tracks Auto Del" 0 @@ -1026,6 +1195,11 @@ "" "" "" + "" + "" + "" + "" + "" "" "" "" @@ -1037,6 +1211,8 @@ 0 0 0 + 0 + 0 "" -1 -1 @@ -1069,7 +1245,13 @@ "wbCheckBoxProxy" "ID_CHECKBOX4" 10011 + "" "wxCheckBox" + "wxCheckBox" + 1 + 0 + "" + "" "m_Track_45_Only_Ctrl" "Track 45 Only" 0 @@ -1077,6 +1259,11 @@ "" "" "" + "" + "" + "" + "" + "" "" "" "" @@ -1088,6 +1275,8 @@ 0 0 0 + 0 + 0 "" -1 -1 @@ -1120,7 +1309,13 @@ "wbCheckBoxProxy" "ID_CHECKBOX5" 10012 + "" "wxCheckBox" + "wxCheckBox" + 1 + 0 + "" + "" "m_Segments_45_Only_Ctrl" "Segments 45 Only" 0 @@ -1128,6 +1323,11 @@ "" "" "" + "" + "" + "" + "" + "" "" "" "" @@ -1139,6 +1339,8 @@ 0 0 0 + 0 + 0 "" -1 -1 @@ -1171,7 +1373,13 @@ "wbCheckBoxProxy" "ID_CHECKBOX6" 10013 + "" "wxCheckBox" + "wxCheckBox" + 1 + 0 + "" + "" "m_AutoPANOpt" "Auto PAN" 0 @@ -1179,6 +1387,11 @@ "" "" "" + "" + "" + "" + "" + "" "" "0000FF" "" @@ -1190,6 +1403,8 @@ 0 0 0 + 0 + 0 "" -1 -1 @@ -1222,7 +1437,13 @@ "wbCheckBoxProxy" "ID_CHECKBOX7" 10014 + "" "wxCheckBox" + "wxCheckBox" + 1 + 0 + "" + "" "m_Track_DoubleSegm_Ctrl" "Double Segm Track" 0 @@ -1230,6 +1451,11 @@ "" "" "" + "" + "" + "" + "" + "" "" "009000" "" @@ -1241,6 +1467,8 @@ 0 0 0 + 0 + 0 "" -1 -1 @@ -1260,56 +1488,6 @@ "" "" - - "wxRadioBox: ID_MAGNETIC_PAD_CTRL" - "dialog-control-document" - "" - "radiobox" - 0 - 1 - 0 - 0 - "13/6/2006" - "wbRadioBoxProxy" - "ID_MAGNETIC_PAD_CTRL" - 10000 - "wxRadioBox" - "m_MagneticPadOptCtrl" - "Magnetic Pads" - 1 - "" - "control the capture of the pcb cursor when the mouse cursor enters a pad area" - "" - "" - "" - 0 - 1 - "<Any platform>" - "g_MagneticPadOption" - "wxGenericValidator(& %VARIABLE%)" - 0 - 1 - "Never|When creating tracks|Always" - 0 - "" - -1 - -1 - -1 - -1 - "Expand" - "Centre" - 0 - 5 - 1 - 1 - 1 - 1 - 0 - 0 - 0 - "" - "" - @@ -1326,7 +1504,7 @@ "Vertical" "" "Centre" - "Centre" + "Top" 0 5 1 @@ -1337,6 +1515,134 @@ 0 0 "<Any platform>" + + "wxRadioBox: ID_RADIOBOX4" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "3/3/2008" + "wbRadioBoxProxy" + "ID_RADIOBOX4" + 10016 + "" + "wxRadioBox" + "wxRadioBox" + 1 + 0 + "" + "" + "m_MagneticPadOptCtrl" + "Magnetic Pads" + 1 + "Never|When creating tracks|Always" + 0 + "" + "control the capture of the pcb cursor when the mouse cursor enters a pad area" + "" + "" + "" + 0 + 1 + "<Any platform>" + "g_MagneticPadOption" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + "" + "" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + + + "wxRadioBox: ID_RADIOBOX3" + "dialog-control-document" + "" + "radiobox" + 0 + 1 + 0 + 0 + "3/3/2008" + "wbRadioBoxProxy" + "ID_RADIOBOX3" + 10015 + "" + "wxRadioBox" + "wxRadioBox" + 1 + 0 + "" + "" + "m_MagneticTrackOptCtrl" + "Magnetic Tracks" + 1 + "Never|When creating tracks|Always" + 0 + "" + "control the capture of the pcb cursor when the mouse cursor enters a track" + "" + "" + "" + 0 + 1 + "<Any platform>" + "g_MagneticTrackOption" + "wxGenericValidator(& %VARIABLE%)" + "" + "" + "" + "" + "" + 0 + 1 + 0 + 0 + 0 + "" + -1 + -1 + -1 + -1 + "Expand" + "Centre" + 0 + 5 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + "" + "" + "wxButton: wxID_OK" "dialog-control-document" @@ -1351,12 +1657,25 @@ "wxEVT_COMMAND_BUTTON_CLICKED|OnOkClick" "wxID_OK" 5100 + "" "wxButton" + "wxButton" + 1 + 0 + "" + "" "" "&OK" 0 "" "" + "" + "" + "" + "" + "" + "" + "" "" "DD0000" "" @@ -1370,6 +1689,8 @@ 0 0 0 + 0 + 0 "" -1 -1 @@ -1403,12 +1724,25 @@ "wxEVT_COMMAND_BUTTON_CLICKED|OnCancelClick" "wxID_CANCEL" 5101 + "" "wxButton" + "wxButton" + 1 + 0 + "" + "" "" "&Cancel" 0 "" "" + "" + "" + "" + "" + "" + "" + "" "" "0000FF" "" @@ -1422,6 +1756,8 @@ 0 0 0 + 0 + 0 "" -1 -1 diff --git a/pcbnew/hotkeys.cpp b/pcbnew/hotkeys.cpp index e18337b8d2..3e480d6d5f 100644 --- a/pcbnew/hotkeys.cpp +++ b/pcbnew/hotkeys.cpp @@ -310,13 +310,10 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, if( ItemFree ) { // 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: use PcbGeneralLocateAndDisplay() everywhere in this source file. DrawStruct = PcbGeneralLocateAndDisplay(); - // don't let backspace delete modules!! if( DrawStruct && (DrawStruct->Type() == TYPETRACK || DrawStruct->Type() == TYPEVIA) ) diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index 457d37ffe6..b9abef6a32 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -464,6 +464,8 @@ bool InitialiseDragParameters() 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_EndPointVertical = false; @@ -610,7 +612,7 @@ void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int co NbPtNewTrack = 0; 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_HightLigth_NetCode = g_HightLigth_NetCode; if( g_HightLigt_Status ) @@ -670,8 +672,67 @@ void WinEDA_PcbFrame::Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int co DrawHightLight( DC, g_HightLigth_NetCode ); 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 ) /***********************************************************************************/ @@ -682,6 +743,9 @@ void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC if( !track ) return; + + while(MergeCollinearTracks(track, DC, START)){}; + while(MergeCollinearTracks(track, DC, END)){}; s_StartSegmentPresent = s_EndSegmentPresent = TRUE; diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 1943da15e5..eb5d48b81e 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -231,6 +231,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father, WinEDA_App* parent, GridSize.y = SizeY; } m_Parent->m_EDA_Config->Read( wxT( "PcbMagPadOpt" ), &g_MagneticPadOption ); + m_Parent->m_EDA_Config->Read( wxT( "PcbMagTrackOpt" ), &g_MagneticTrackOption ); } GetScreen()->SetGrid( GridSize ); @@ -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_Y" ), (long) GridSize.y ); m_Parent->m_EDA_Config->Write( wxT( "PcbMagPadOpt" ), (long) g_MagneticPadOption ); + m_Parent->m_EDA_Config->Write( wxT( "PcbMagTrackOpt" ), (long) g_MagneticTrackOption ); } Destroy(); } diff --git a/pcbnew/pcbnew.h b/pcbnew/pcbnew.h index 62bd03f5fa..18d4c462dd 100644 --- a/pcbnew/pcbnew.h +++ b/pcbnew/pcbnew.h @@ -256,7 +256,7 @@ eda_global bool g_TwoSegmentTrackBuild // FALSE = 1 segment build, TRUE = 2 45 #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 { no_effect, capture_cursor_in_track_tool, @@ -268,6 +268,11 @@ eda_global int g_MagneticPadOption = capture_cursor_in_track_tool #endif ; +eda_global int g_MagneticTrackOption +#ifdef MAIN += capture_cursor_in_track_tool +#endif +; /* Variables to handle hightlight nets */ eda_global bool g_HightLigt_Status; eda_global int g_HightLigth_NetCode