Commit 0dc3be88 authored by lifekidyeaa's avatar lifekidyeaa
Browse files

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
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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 );
+25 −19
Original line number Diff line number Diff line
@@ -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;
	bool pad_ok = false; 
	if( g_MagneticPadOption == capture_always )
		pad_ok = true; 
	
    case capture_always:
        break;
	
    case no_effect:
    default:
        return false;
	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;
+54 −46
Original line number Diff line number Diff line
@@ -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);
    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")
    };
    wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxVERTICAL);
    itemBoxSizer2->Add(itemBoxSizer24, 0, wxALIGN_TOP|wxALL, 5);

    m_MagneticPadOptCtrl = new wxRadioBox( itemDialog1, ID_MAGNETIC_PAD_CTRL, _("Magnetic Pads"), wxDefaultPosition, wxDefaultSize, 3, m_MagneticPadOptCtrlStrings, 1, wxRA_SPECIFY_COLS );
    if (ShowToolTips())
    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);

    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 );
    itemButton26->SetForegroundColour(wxColour(221, 0, 0));
    itemBoxSizer25->Add(itemButton26, 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);
    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
    m_MagneticPadOptCtrl->SetValidator( wxGenericValidator(& g_MagneticPadOption) );
    m_MagneticTrackOptCtrl->SetValidator( wxGenericValidator(& g_MagneticTrackOption) );
////@end WinEDA_PcbGeneralOptionsFrame content construction
}

+8 −6
Original line number Diff line number Diff line
@@ -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;
+405 −69

File changed.

Preview size limit exceeded, changes collapsed.

Loading