Commit aac3de4a authored by Mikhail Karpenko's avatar Mikhail Karpenko
Browse files

Add teardrops to all vias, add undo/redo

parent 4e114e1a
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -36,7 +36,7 @@ void TEARDROP::GetCoordinates(std::vector<VECTOR2I> &points)
bool TEARDROP::SetVector(TRACK &aTrack, const VIA & aVia, VECTOR2I &startPoint, VECTOR2I &endPoint)
bool TEARDROP::SetVector(TRACK &aTrack, const VIA & aVia, VECTOR2I &startPoint, VECTOR2I &endPoint)
{
{
    // Decide which end of the track is inside via and set this point as end of vector
    // Decide which end of the track is inside via and set this point as end of vector
    STATUS_FLAGS status = aTrack.IsPointOnEnds(wxPoint(aVia.GetPosition().x, aVia.GetPosition().y), aVia.GetWidth() / 2);
    STATUS_FLAGS status = aTrack.IsPointOnEnds(aVia.GetPosition(), aVia.GetWidth() / 2);
    if (status == STARTPOINT) {
    if (status == STARTPOINT) {
        startPoint = aTrack.GetEnd();
        startPoint = aTrack.GetEnd();
        endPoint = aTrack.GetStart();
        endPoint = aTrack.GetStart();
@@ -105,7 +105,7 @@ bool TEARDROP::StraightSegments(TRACK &aTrack, const VIA &aVia, std::vector<VECT


    // Check that the track is not too short
    // Check that the track is not too short
    double segOutsideVia = aTrack.GetLength() - (aVia.GetWidth() / 2);
    double segOutsideVia = aTrack.GetLength() - (aVia.GetWidth() / 2);
    double minLength = (distance * aVia.GetWidth()) / 100;
    double minLength = (distance * aVia.GetWidth() / 2) / 100;
    if (segOutsideVia < minLength) {
    if (segOutsideVia < minLength) {
        return false;
        return false;
    }
    }
+13 −11
Original line number Original line Diff line number Diff line
@@ -38,12 +38,8 @@ void DIALOG_TEARDROPS::InitDialogSettings()
    if (m_scopeTracks->IsChecked() == true) {
    if (m_scopeTracks->IsChecked() == true) {
        m_settings->m_scope = static_cast<TEARDROPS_SCOPE>(m_settings->m_scope | TEARDROPS_SCOPE_TRACKS);
        m_settings->m_scope = static_cast<TEARDROPS_SCOPE>(m_settings->m_scope | TEARDROPS_SCOPE_TRACKS);
    }
    }
    if (m_checkClear->IsChecked() == true) {
    m_settings->m_clearSelection = m_checkClear->IsChecked();
        m_settings->m_clearSelection = true;
    m_settings->m_ignoreDrc = m_checkIgnore->IsChecked();
    }
    else {
        m_settings->m_clearSelection = false;
    }
}
}


void DIALOG_TEARDROPS::OnModeAdd(wxCommandEvent &event)
void DIALOG_TEARDROPS::OnModeAdd(wxCommandEvent &event)
@@ -106,10 +102,16 @@ void DIALOG_TEARDROPS::OnStyleChanged(wxCommandEvent &event)


void DIALOG_TEARDROPS::OnClearSelection(wxCommandEvent &event)
void DIALOG_TEARDROPS::OnClearSelection(wxCommandEvent &event)
{
{
    if (m_checkClear->IsChecked() == true) {
    event.Skip();
        m_settings->m_clearSelection = true;
    if (m_settings != NULL) {
        m_settings->m_clearSelection = m_checkClear->IsChecked();
    }
    }
    else {
}
        m_settings->m_clearSelection = false;

void DIALOG_TEARDROPS::OnIgnoreDrc(wxCommandEvent &event)
{
    event.Skip();
    if (m_settings != NULL) {
        m_settings->m_ignoreDrc = m_checkIgnore->IsChecked();
    }
    }
}
}
+2 −0
Original line number Original line Diff line number Diff line
@@ -33,6 +33,7 @@ public:
        TEARDROPS_SCOPE m_scope;
        TEARDROPS_SCOPE m_scope;
        TEARDROPS_TYPE m_type;
        TEARDROPS_TYPE m_type;
        bool m_clearSelection;
        bool m_clearSelection;
        bool m_ignoreDrc;
    } TEARDROPS_SETTINGS;
    } TEARDROPS_SETTINGS;
    DIALOG_TEARDROPS(PCB_EDIT_FRAME *aParent, TEARDROPS_SETTINGS *settings);
    DIALOG_TEARDROPS(PCB_EDIT_FRAME *aParent, TEARDROPS_SETTINGS *settings);


@@ -42,6 +43,7 @@ public:
    void OnTracksSelected(wxCommandEvent &event);
    void OnTracksSelected(wxCommandEvent &event);
    void OnStyleChanged(wxCommandEvent &event);
    void OnStyleChanged(wxCommandEvent &event);
    void OnClearSelection(wxCommandEvent &event);
    void OnClearSelection(wxCommandEvent &event);
    void OnIgnoreDrc(wxCommandEvent &event);
    void OnScopeVias(wxCommandEvent &event);
    void OnScopeVias(wxCommandEvent &event);


private:
private:
+3 −1
Original line number Original line Diff line number Diff line
@@ -49,7 +49,7 @@ DIALOG_TEARDROPS_BASE::DIALOG_TEARDROPS_BASE( wxWindow* parent, wxWindowID id, c
	
	
	m_checkIgnore = new wxCheckBox( this, wxID_ANY, wxT("Ignore DRC"), wxDefaultPosition, wxDefaultSize, 0 );
	m_checkIgnore = new wxCheckBox( this, wxID_ANY, wxT("Ignore DRC"), wxDefaultPosition, wxDefaultSize, 0 );
	m_checkIgnore->SetValue(true); 
	m_checkIgnore->SetValue(true); 
	m_checkIgnore->Hide();
	m_checkIgnore->Enable( false );
	
	
	m_optionsSizer->Add( m_checkIgnore, 0, 0, 5 );
	m_optionsSizer->Add( m_checkIgnore, 0, 0, 5 );
	
	
@@ -127,6 +127,7 @@ DIALOG_TEARDROPS_BASE::DIALOG_TEARDROPS_BASE( wxWindow* parent, wxWindowID id, c
	m_modeRemove->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnModeRemove ), NULL, this );
	m_modeRemove->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnModeRemove ), NULL, this );
	m_tracksAll->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnTracksAll ), NULL, this );
	m_tracksAll->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnTracksAll ), NULL, this );
	m_tracksSelected->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnTracksSelected ), NULL, this );
	m_tracksSelected->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnTracksSelected ), NULL, this );
	m_checkIgnore->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnIgnoreDrc ), NULL, this );
	m_checkClear->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnClearSelection ), NULL, this );
	m_checkClear->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnClearSelection ), NULL, this );
	m_choiceStyle->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnStyleChanged ), NULL, this );
	m_choiceStyle->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnStyleChanged ), NULL, this );
	m_scopeVias->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnScopeVias ), NULL, this );
	m_scopeVias->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnScopeVias ), NULL, this );
@@ -139,6 +140,7 @@ DIALOG_TEARDROPS_BASE::~DIALOG_TEARDROPS_BASE()
	m_modeRemove->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnModeRemove ), NULL, this );
	m_modeRemove->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnModeRemove ), NULL, this );
	m_tracksAll->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnTracksAll ), NULL, this );
	m_tracksAll->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnTracksAll ), NULL, this );
	m_tracksSelected->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnTracksSelected ), NULL, this );
	m_tracksSelected->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnTracksSelected ), NULL, this );
	m_checkIgnore->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnIgnoreDrc ), NULL, this );
	m_checkClear->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnClearSelection ), NULL, this );
	m_checkClear->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnClearSelection ), NULL, this );
	m_choiceStyle->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnStyleChanged ), NULL, this );
	m_choiceStyle->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnStyleChanged ), NULL, this );
	m_scopeVias->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnScopeVias ), NULL, this );
	m_scopeVias->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_TEARDROPS_BASE::OnScopeVias ), NULL, this );
+3 −3
Original line number Original line Diff line number Diff line
@@ -370,10 +370,10 @@
                                                <property name="bg"></property>
                                                <property name="bg"></property>
                                                <property name="checked">1</property>
                                                <property name="checked">1</property>
                                                <property name="context_help"></property>
                                                <property name="context_help"></property>
                                                <property name="enabled">1</property>
                                                <property name="enabled">0</property>
                                                <property name="fg"></property>
                                                <property name="fg"></property>
                                                <property name="font"></property>
                                                <property name="font"></property>
                                                <property name="hidden">1</property>
                                                <property name="hidden">0</property>
                                                <property name="id">wxID_ANY</property>
                                                <property name="id">wxID_ANY</property>
                                                <property name="label">Ignore DRC</property>
                                                <property name="label">Ignore DRC</property>
                                                <property name="maximum_size"></property>
                                                <property name="maximum_size"></property>
@@ -393,7 +393,7 @@
                                                <property name="window_name"></property>
                                                <property name="window_name"></property>
                                                <property name="window_style"></property>
                                                <property name="window_style"></property>
                                                <event name="OnChar"></event>
                                                <event name="OnChar"></event>
                                                <event name="OnCheckBox"></event>
                                                <event name="OnCheckBox">OnIgnoreDrc</event>
                                                <event name="OnEnterWindow"></event>
                                                <event name="OnEnterWindow"></event>
                                                <event name="OnEraseBackground"></event>
                                                <event name="OnEraseBackground"></event>
                                                <event name="OnKeyDown"></event>
                                                <event name="OnKeyDown"></event>
Loading