← Back to team overview

kicad-developers team mailing list archive

Indroducrion and small patch

 

Hi,

My Name is Bastian Neumann from Germany. I am working with KiCad for some
time now.
It is a great piece of software and beeing free and open source is what me
brought me to it in 2008.

I am an EE and usually using KiCad for PCB design.
Writing software is usually some embedded C or stuff like that. But I
wanted to have the functionality to change vias. So here is my patch to use
the dropdown menues from the properies dialog.

I hope I am doing this correctly. This is my first time contributing to a
project of that size.

Have a nice day.
From 5963be743e3d5cdb13552b76b358f544105951de Mon Sep 17 00:00:00 2001
From: Bastian Neumann <neumann.bastian@xxxxxxxxx>
Date: Thu, 17 Aug 2017 21:04:36 +0200
Subject: [PATCH] Changing via type and start/end layer is now possible in the
 properties dialog

---
 pcbnew/dialogs/dialog_track_via_properties.cpp     | 51 ++++++++++++++++++++++
 .../dialogs/dialog_track_via_properties_base.cpp   |  2 +-
 .../dialogs/dialog_track_via_properties_base.fbp   |  2 +-
 3 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/pcbnew/dialogs/dialog_track_via_properties.cpp b/pcbnew/dialogs/dialog_track_via_properties.cpp
index 4a2c69a..2dc12ca 100644
--- a/pcbnew/dialogs/dialog_track_via_properties.cpp
+++ b/pcbnew/dialogs/dialog_track_via_properties.cpp
@@ -57,6 +57,9 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
     boost::optional<int> viaY = boost::make_optional<int>( false, 0 );
     boost::optional<int> viaDiameter = boost::make_optional<int>( false, 0 );
     boost::optional<int> viaDrill = boost::make_optional<int>( false, 0 );
+    boost::optional<PCB_LAYER_ID> viaStartLayer = boost::make_optional<PCB_LAYER_ID>( false, (PCB_LAYER_ID) 0 );
+    boost::optional<PCB_LAYER_ID> viaEndLayer = boost::make_optional<PCB_LAYER_ID>( false, (PCB_LAYER_ID) 0 );
+    boost::optional<int> viaType = boost::make_optional<int>( false, 0 );
 
     m_haveUniqueNet = true;
     int prevNet = -1;
@@ -150,6 +153,12 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
                     viaY = v->GetPosition().y;
                     viaDiameter = v->GetWidth();
                     viaDrill = v->GetDrillValue();
+                    PCB_LAYER_ID layerStart;
+                    PCB_LAYER_ID layerEnd;
+                    v->LayerPair(&layerStart, &layerEnd);
+                    viaStartLayer = layerStart;
+                    viaEndLayer = layerEnd;
+                    viaType = v->GetViaType();
                     m_vias = true;
                 }
                 else        // check if values are the same for every selected via
@@ -165,6 +174,17 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
 
                     if( viaDrill && ( *viaDrill != v->GetDrillValue() ) )
                         viaDrill = boost::none;
+
+                    PCB_LAYER_ID layerStart;
+                    PCB_LAYER_ID layerEnd;
+                    v->LayerPair(&layerStart, &layerEnd);
+                    if( viaStartLayer && ( viaStartLayer != layerStart ) )
+                        viaStartLayer = boost::none;
+                    if( viaEndLayer && ( viaEndLayer != layerEnd ) )
+                        viaEndLayer = boost::none;
+
+                    if( viaType && ( *viaType != v->GetViaType() ) )
+                        viaType = boost::none;
                 }
 
                 if( v->IsLocked() )
@@ -189,7 +209,29 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
         setCommonVal( viaY, m_ViaYCtrl, m_viaY );
         setCommonVal( viaDiameter, m_ViaDiameterCtrl, m_viaDiameter );
         setCommonVal( viaDrill, m_ViaDrillCtrl, m_viaDrill );
+
+        m_ViaTypeChoice->SetSelection(*viaType);
+        m_ViaTypeChoice->Enable();
+
+        m_ViaStartLayer->SetLayersHotkeys( false );
+        m_ViaStartLayer->SetLayerSet( LSET::AllNonCuMask() );
+        m_ViaStartLayer->SetBoardFrame( aParent );
+        m_ViaStartLayer->Resync();
+
+        if( viaStartLayer )
+            m_ViaStartLayer->SetLayerSelection( *viaStartLayer );
+
+        m_ViaEndLayer->SetLayersHotkeys( false );
+        m_ViaEndLayer->SetLayerSet( LSET::AllNonCuMask() );
+        m_ViaEndLayer->SetBoardFrame( aParent );
+        m_ViaEndLayer->Resync();
+
+        if( viaEndLayer )
+            m_ViaEndLayer->SetLayerSelection( *viaEndLayer );
+
         m_ViaDiameterCtrl->SetFocus();
+
+
     }
     else
     {
@@ -367,6 +409,15 @@ bool DIALOG_TRACK_VIA_PROPERTIES::Apply( COMMIT& aCommit )
                     v->SetNetCode( m_NetComboBox->GetSelectedNet() );
                 }
 
+                LAYER_NUM startLayer = m_ViaStartLayer->GetLayerSelection();
+                LAYER_NUM endLayer = m_ViaEndLayer->GetLayerSelection();
+
+                if( startLayer != UNDEFINED_LAYER && endLayer != UNDEFINED_LAYER)
+                    v->SetLayerPair( (PCB_LAYER_ID)startLayer, (PCB_LAYER_ID)endLayer );
+
+                if( m_ViaTypeChoice->GetSelection() != VIA_NOT_DEFINED )
+                    v->SetViaType( (VIATYPE_T)m_ViaTypeChoice->GetSelection() );
+
                 if( changeLock )
                     v->SetLocked( setLock );
 
diff --git a/pcbnew/dialogs/dialog_track_via_properties_base.cpp b/pcbnew/dialogs/dialog_track_via_properties_base.cpp
index 7cc9c2e..2c303a4 100644
--- a/pcbnew/dialogs/dialog_track_via_properties_base.cpp
+++ b/pcbnew/dialogs/dialog_track_via_properties_base.cpp
@@ -226,7 +226,7 @@ DIALOG_TRACK_VIA_PROPERTIES_BASE::DIALOG_TRACK_VIA_PROPERTIES_BASE( wxWindow* pa
 	m_ViaTypeLabel->Wrap( -1 );
 	fgViaRightSizer->Add( m_ViaTypeLabel, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
 	
-	wxString m_ViaTypeChoiceChoices[] = { _("Through"), _("Micro"), _("Blind/buried"), wxEmptyString };
+	wxString m_ViaTypeChoiceChoices[] = { wxEmptyString, _("Micro"), _("Blind/buried"), _("Through") };
 	int m_ViaTypeChoiceNChoices = sizeof( m_ViaTypeChoiceChoices ) / sizeof( wxString );
 	m_ViaTypeChoice = new wxChoice( m_sbViaSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_ViaTypeChoiceNChoices, m_ViaTypeChoiceChoices, 0 );
 	m_ViaTypeChoice->SetSelection( 0 );
diff --git a/pcbnew/dialogs/dialog_track_via_properties_base.fbp b/pcbnew/dialogs/dialog_track_via_properties_base.fbp
index a886bb7..198092c 100644
--- a/pcbnew/dialogs/dialog_track_via_properties_base.fbp
+++ b/pcbnew/dialogs/dialog_track_via_properties_base.fbp
@@ -3450,7 +3450,7 @@
                                         <property name="caption"></property>
                                         <property name="caption_visible">1</property>
                                         <property name="center_pane">0</property>
-                                        <property name="choices">&quot;Through&quot; &quot;Micro&quot; &quot;Blind/buried&quot; &quot;&quot;</property>
+                                        <property name="choices">&quot;&quot; &quot;Micro&quot; &quot;Blind/buried&quot; &quot;Through&quot;</property>
                                         <property name="close_button">1</property>
                                         <property name="context_help"></property>
                                         <property name="context_menu">1</property>
-- 
2.7.4