From 80adf9d85b58807a2557b498eff849338a21622f Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Fri, 14 Nov 2014 19:15:58 +0100 Subject: [PATCH 01/10] router: multiple changes - re-worked PNS_LINE_PLACER and PNS_ROUTER classes a bit, removing duplicate class members - cleaned up Andrew's blind/buried via fixes - fixed 'custom via width' dialog bug updating the width even when closed/cancelled - fixed incorrect radius of drawn microvias --- pcbnew/dialogs/dialog_track_via_size.cpp | 22 +- pcbnew/dialogs/dialog_track_via_size.h | 8 +- pcbnew/dialogs/dialog_track_via_size_base.cpp | 38 ++-- pcbnew/dialogs/dialog_track_via_size_base.fbp | 211 +++--------------- pcbnew/dialogs/dialog_track_via_size_base.h | 15 +- pcbnew/pcb_painter.cpp | 3 +- pcbnew/router/CMakeLists.txt | 1 + pcbnew/router/pns_dragger.cpp | 2 +- pcbnew/router/pns_itemset.cpp | 52 ++--- pcbnew/router/pns_itemset.h | 84 +++++-- pcbnew/router/pns_joint.h | 62 ++--- pcbnew/router/pns_layerset.h | 2 +- pcbnew/router/pns_line_placer.cpp | 194 ++++++++-------- pcbnew/router/pns_line_placer.h | 40 ++-- pcbnew/router/pns_router.cpp | 191 ++++------------ pcbnew/router/pns_router.h | 38 +--- pcbnew/router/pns_routing_settings.h | 33 +-- pcbnew/router/pns_sizes_settings.cpp | 159 +++++++++++++ pcbnew/router/pns_sizes_settings.h | 95 ++++++++ pcbnew/router/pns_via.h | 2 +- pcbnew/router/router_preview_item.cpp | 1 + pcbnew/router/router_tool.cpp | 190 +++++++++++----- pcbnew/router/router_tool.h | 5 +- 23 files changed, 744 insertions(+), 704 deletions(-) create mode 100644 pcbnew/router/pns_sizes_settings.cpp create mode 100644 pcbnew/router/pns_sizes_settings.h diff --git a/pcbnew/dialogs/dialog_track_via_size.cpp b/pcbnew/dialogs/dialog_track_via_size.cpp index a7522aba70..ab9e1cac37 100644 --- a/pcbnew/dialogs/dialog_track_via_size.cpp +++ b/pcbnew/dialogs/dialog_track_via_size.cpp @@ -23,22 +23,22 @@ */ #include "dialog_track_via_size.h" -#include #include #include #include -DIALOG_TRACK_VIA_SIZE::DIALOG_TRACK_VIA_SIZE( wxWindow* aParent, PNS_ROUTING_SETTINGS& aSettings ) : +#include "class_board_design_settings.h" + +DIALOG_TRACK_VIA_SIZE::DIALOG_TRACK_VIA_SIZE( wxWindow* aParent, BOARD_DESIGN_SETTINGS& aSettings ) : DIALOG_TRACK_VIA_SIZE_BASE( aParent ), m_settings( aSettings ) { // Load router settings to dialog fields - m_trackWidth->SetValue( To_User_Unit( m_trackWidth->GetUnits(), m_settings.GetTrackWidth() ) ); - m_viaDiameter->SetValue( To_User_Unit( m_viaDiameter->GetUnits(), m_settings.GetViaDiameter() ) ); - m_viaDrill->SetValue( To_User_Unit( m_viaDrill->GetUnits(), m_settings.GetViaDrill() ) ); + m_trackWidth->SetValue( To_User_Unit( m_trackWidth->GetUnits(), m_settings.GetCustomTrackWidth() ) ); + m_viaDiameter->SetValue( To_User_Unit( m_viaDiameter->GetUnits(), m_settings.GetCustomViaSize() ) ); + m_viaDrill->SetValue( To_User_Unit( m_viaDrill->GetUnits(), m_settings.GetCustomViaDrill() ) ); m_trackWidth->SetFocus(); - GetSizer()->SetSizeHints( this ); // Pressing ENTER when any of the text input fields is active applies changes #if wxCHECK_VERSION( 3, 0, 0 ) @@ -46,6 +46,8 @@ DIALOG_TRACK_VIA_SIZE::DIALOG_TRACK_VIA_SIZE( wxWindow* aParent, PNS_ROUTING_SET #else Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE::onOkClick ), NULL, this ); #endif + + Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_TRACK_VIA_SIZE::onClose ) ); } @@ -56,7 +58,7 @@ bool DIALOG_TRACK_VIA_SIZE::check() return false; // Via drill should be smaller than via diameter - if( *m_viaDrill->GetValue() >= m_viaDiameter->GetValue() ) + if( m_viaDrill->GetValue() >= m_viaDiameter->GetValue() ) return false; return true; @@ -74,9 +76,9 @@ void DIALOG_TRACK_VIA_SIZE::onOkClick( wxCommandEvent& aEvent ) if( check() ) { // Store dialog values to the router settings - m_settings.SetTrackWidth( From_User_Unit( m_trackWidth->GetUnits(), *m_trackWidth->GetValue() ) ); - m_settings.SetViaDiameter( From_User_Unit( m_viaDiameter->GetUnits(), *m_viaDiameter->GetValue() ) ); - m_settings.SetViaDrill( From_User_Unit( m_viaDrill->GetUnits(), *m_viaDrill->GetValue() ) ); + m_settings.SetCustomTrackWidth( From_User_Unit( m_trackWidth->GetUnits(), *m_trackWidth->GetValue() ) ); + m_settings.SetCustomViaSize( From_User_Unit( m_viaDiameter->GetUnits(), *m_viaDiameter->GetValue() ) ); + m_settings.SetCustomViaDrill( From_User_Unit( m_viaDrill->GetUnits(), *m_viaDrill->GetValue() ) ); EndModal( 1 ); } else diff --git a/pcbnew/dialogs/dialog_track_via_size.h b/pcbnew/dialogs/dialog_track_via_size.h index 92a03e8ec6..5db003d7de 100644 --- a/pcbnew/dialogs/dialog_track_via_size.h +++ b/pcbnew/dialogs/dialog_track_via_size.h @@ -19,7 +19,7 @@ */ /** - * Push and Shove router track width and via size dialog. + * Custom track width and via size dialog. */ #ifndef __dialog_track_via_size__ @@ -27,18 +27,18 @@ #include "dialog_track_via_size_base.h" -class PNS_ROUTING_SETTINGS; +class BOARD_DESIGN_SETTINGS; /** Implementing DIALOG_TRACK_VIA_SIZE_BASE */ class DIALOG_TRACK_VIA_SIZE : public DIALOG_TRACK_VIA_SIZE_BASE { public: /** Constructor */ - DIALOG_TRACK_VIA_SIZE( wxWindow* aParent, PNS_ROUTING_SETTINGS& aSettings ); + DIALOG_TRACK_VIA_SIZE( wxWindow* aParent, BOARD_DESIGN_SETTINGS& aSettings ); protected: // Routings settings that are modified by the dialog. - PNS_ROUTING_SETTINGS& m_settings; + BOARD_DESIGN_SETTINGS& m_settings; ///> Checks if values given in the dialog are sensible. bool check(); diff --git a/pcbnew/dialogs/dialog_track_via_size_base.cpp b/pcbnew/dialogs/dialog_track_via_size_base.cpp index 0331d8f204..a1bfad0ce4 100644 --- a/pcbnew/dialogs/dialog_track_via_size_base.cpp +++ b/pcbnew/dialogs/dialog_track_via_size_base.cpp @@ -1,61 +1,57 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 6 2013) +// C++ code generated with wxFormBuilder (version Jun 6 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#include "dialog_shim.h" - #include "dialog_track_via_size_base.h" /////////////////////////////////////////////////////////////////////////// DIALOG_TRACK_VIA_SIZE_BASE::DIALOG_TRACK_VIA_SIZE_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) { - this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + this->SetSizeHints( wxSize( 280,240 ), wxDefaultSize ); wxBoxSizer* bSizes; bSizes = new wxBoxSizer( wxVERTICAL ); m_trackWidth = new WX_UNIT_TEXT( this, _("Track width:") ); - bSizes->Add( m_trackWidth, 0, wxALL, 5 ); + bSizes->Add( m_trackWidth, 0, wxALL|wxEXPAND, 5 ); m_viaDiameter = new WX_UNIT_TEXT( this, _("Via diameter:") ); - bSizes->Add( m_viaDiameter, 0, wxALL, 5 ); + bSizes->Add( m_viaDiameter, 0, wxALL|wxEXPAND, 5 ); m_viaDrill = new WX_UNIT_TEXT( this, _("Via drill:") ); - bSizes->Add( m_viaDrill, 0, wxALL, 5 ); + bSizes->Add( m_viaDrill, 0, wxALL|wxEXPAND, 5 ); - wxBoxSizer* bButtons; - bButtons = new wxBoxSizer( wxHORIZONTAL ); + m_stdButtons = new wxStdDialogButtonSizer(); + m_stdButtonsOK = new wxButton( this, wxID_OK ); + m_stdButtons->AddButton( m_stdButtonsOK ); + m_stdButtonsCancel = new wxButton( this, wxID_CANCEL ); + m_stdButtons->AddButton( m_stdButtonsCancel ); + m_stdButtons->Realize(); - m_ok = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 ); - bButtons->Add( m_ok, 1, wxALL, 5 ); - - m_cancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); - bButtons->Add( m_cancel, 1, wxALL, 5 ); - - - bSizes->Add( bButtons, 0, wxEXPAND, 5 ); + bSizes->Add( m_stdButtons, 0, wxEXPAND|wxALL, 5 ); this->SetSizer( bSizes ); this->Layout(); + bSizes->Fit( this ); this->Centre( wxBOTH ); // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onClose ) ); - m_ok->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onOkClick ), NULL, this ); - m_cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onCancelClick ), NULL, this ); + m_stdButtonsCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onCancelClick ), NULL, this ); + m_stdButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onOkClick ), NULL, this ); } DIALOG_TRACK_VIA_SIZE_BASE::~DIALOG_TRACK_VIA_SIZE_BASE() { // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onClose ) ); - m_ok->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onOkClick ), NULL, this ); - m_cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onCancelClick ), NULL, this ); + m_stdButtonsCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onCancelClick ), NULL, this ); + m_stdButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_TRACK_VIA_SIZE_BASE::onOkClick ), NULL, this ); } diff --git a/pcbnew/dialogs/dialog_track_via_size_base.fbp b/pcbnew/dialogs/dialog_track_via_size_base.fbp index f442938f09..c2e3325af7 100644 --- a/pcbnew/dialogs/dialog_track_via_size_base.fbp +++ b/pcbnew/dialogs/dialog_track_via_size_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -41,11 +41,11 @@ 0 wxID_ANY - + 280,240 DIALOG_TRACK_VIA_SIZE_BASE - 388,162 - wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + -1,-1 + wxDEFAULT_DIALOG_STYLE Track width and via size @@ -147,7 +147,7 @@ 1 - DIALOG_SHIM; dialog_shim.h + 0 @@ -350,189 +350,28 @@ 5 - wxEXPAND + wxEXPAND|wxALL 0 - + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 - bButtons - wxHORIZONTAL - none - - 5 - wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_OK - OK - - 0 - - - 0 - - 1 - m_ok - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onOkClick - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_CANCEL - Cancel - - 0 - - - 0 - - 1 - m_cancel - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - onCancelClick - - - - - - - - - - - - - - - - - - - - - - - - - + m_stdButtons + protected + + onCancelClick + + + + onOkClick + + diff --git a/pcbnew/dialogs/dialog_track_via_size_base.h b/pcbnew/dialogs/dialog_track_via_size_base.h index 0446af107e..3f62c01588 100644 --- a/pcbnew/dialogs/dialog_track_via_size_base.h +++ b/pcbnew/dialogs/dialog_track_via_size_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 6 2013) +// C++ code generated with wxFormBuilder (version Jun 6 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -11,16 +11,14 @@ #include #include #include -class DIALOG_SHIM; - #include #include #include #include #include #include -#include #include +#include #include /////////////////////////////////////////////////////////////////////////// @@ -37,18 +35,19 @@ class DIALOG_TRACK_VIA_SIZE_BASE : public wxDialog WX_UNIT_TEXT* m_trackWidth; WX_UNIT_TEXT* m_viaDiameter; WX_UNIT_TEXT* m_viaDrill; - wxButton* m_ok; - wxButton* m_cancel; + wxStdDialogButtonSizer* m_stdButtons; + wxButton* m_stdButtonsOK; + wxButton* m_stdButtonsCancel; // Virtual event handlers, overide them in your derived class virtual void onClose( wxCloseEvent& event ) { event.Skip(); } - virtual void onOkClick( wxCommandEvent& event ) { event.Skip(); } virtual void onCancelClick( wxCommandEvent& event ) { event.Skip(); } + virtual void onOkClick( wxCommandEvent& event ) { event.Skip(); } public: - DIALOG_TRACK_VIA_SIZE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Track width and via size"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 388,162 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_TRACK_VIA_SIZE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Track width and via size"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE ); ~DIALOG_TRACK_VIA_SIZE_BASE(); }; diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 211260e620..d339e0c7b0 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -387,8 +387,7 @@ void PCB_PAINTER::draw( const VIA* aVia, int aLayer ) else { double width = ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0; - radius -= width / 2.0; - + m_gal->SetLineWidth( width ); m_gal->SetIsFill( true ); m_gal->SetIsStroke( false ); diff --git a/pcbnew/router/CMakeLists.txt b/pcbnew/router/CMakeLists.txt index 411216441f..a69b09118f 100644 --- a/pcbnew/router/CMakeLists.txt +++ b/pcbnew/router/CMakeLists.txt @@ -24,6 +24,7 @@ set( PCBNEW_PNS_SRCS pns_router.cpp pns_routing_settings.cpp pns_shove.cpp + pns_sizes_settings.cpp pns_solid.cpp pns_utils.cpp pns_via.cpp diff --git a/pcbnew/router/pns_dragger.cpp b/pcbnew/router/pns_dragger.cpp index bc43858d95..f1fe58c8d9 100644 --- a/pcbnew/router/pns_dragger.cpp +++ b/pcbnew/router/pns_dragger.cpp @@ -188,7 +188,7 @@ void PNS_DRAGGER::dumbDragVia( PNS_VIA* aVia, PNS_NODE* aNode, const VECTOR2I& a draggedLine->DragCorner( aP, 0 ); draggedLine->ClearSegmentLinks(); - m_draggedItems.AddOwned( draggedLine ); + m_draggedItems.Add( draggedLine ); // FIXME: mem leak m_lastNode->Remove( &origLine ); m_lastNode->Add( draggedLine ); diff --git a/pcbnew/router/pns_itemset.cpp b/pcbnew/router/pns_itemset.cpp index 20254b94c0..38165e6ccd 100644 --- a/pcbnew/router/pns_itemset.cpp +++ b/pcbnew/router/pns_itemset.cpp @@ -28,28 +28,9 @@ PNS_ITEMSET::PNS_ITEMSET( PNS_ITEM* aInitialItem ) m_items.push_back(aInitialItem); } - -PNS_ITEMSET::~PNS_ITEMSET() +PNS_ITEMSET& PNS_ITEMSET::FilterLayers( int aStart, int aEnd, bool aInvert ) { - Clear(); -} - - -void PNS_ITEMSET::Clear() -{ - BOOST_FOREACH(PNS_ITEM* item, m_ownedItems) - { - delete item; - } - - m_items.clear(); - m_ownedItems.clear(); -} - - -PNS_ITEMSET& PNS_ITEMSET::FilterLayers( int aStart, int aEnd ) -{ - ITEM_VECTOR newItems; + ITEMS newItems; PNS_LAYERSET l; if( aEnd < 0 ) @@ -59,7 +40,7 @@ PNS_ITEMSET& PNS_ITEMSET::FilterLayers( int aStart, int aEnd ) BOOST_FOREACH( PNS_ITEM* item, m_items ) - if( item->Layers().Overlaps( l ) ) + if( item->Layers().Overlaps( l ) ^ aInvert ) newItems.push_back( item ); m_items = newItems; @@ -68,13 +49,13 @@ PNS_ITEMSET& PNS_ITEMSET::FilterLayers( int aStart, int aEnd ) } -PNS_ITEMSET& PNS_ITEMSET::FilterKinds( int aKindMask ) +PNS_ITEMSET& PNS_ITEMSET::FilterKinds( int aKindMask, bool aInvert ) { - ITEM_VECTOR newItems; + ITEMS newItems; BOOST_FOREACH( PNS_ITEM* item, m_items ) { - if( item->OfKind ( aKindMask ) ) + if( item->OfKind ( aKindMask ) ^ aInvert ) newItems.push_back( item ); } @@ -84,13 +65,28 @@ PNS_ITEMSET& PNS_ITEMSET::FilterKinds( int aKindMask ) } -PNS_ITEMSET& PNS_ITEMSET::FilterNet( int aNet ) +PNS_ITEMSET& PNS_ITEMSET::FilterNet( int aNet, bool aInvert ) { - ITEM_VECTOR newItems; + ITEMS newItems; BOOST_FOREACH( PNS_ITEM* item, m_items ) { - if( item->Net() == aNet ) + if( (item->Net() == aNet) ^ aInvert ) + newItems.push_back( item ); + } + + m_items = newItems; + + return *this; +} + +PNS_ITEMSET& PNS_ITEMSET::ExcludeItem ( const PNS_ITEM *aItem ) +{ + ITEMS newItems; + + BOOST_FOREACH( PNS_ITEM* item, m_items ) + { + if( item != aItem ) newItems.push_back( item ); } diff --git a/pcbnew/router/pns_itemset.h b/pcbnew/router/pns_itemset.h index 44fe9c3c92..ec73f66177 100644 --- a/pcbnew/router/pns_itemset.h +++ b/pcbnew/router/pns_itemset.h @@ -22,6 +22,7 @@ #define __PNS_ITEMSET_H #include +#include #include "pns_item.h" @@ -35,53 +36,96 @@ class PNS_ITEMSET { public: - typedef std::vector ITEM_VECTOR; + typedef std::vector ITEMS; PNS_ITEMSET( PNS_ITEM* aInitialItem = NULL ); PNS_ITEMSET( const PNS_ITEMSET& aOther ) { m_items = aOther.m_items; - m_ownedItems = ITEM_VECTOR(); } const PNS_ITEMSET& operator=( const PNS_ITEMSET& aOther ) { m_items = aOther.m_items; - m_ownedItems = ITEM_VECTOR(); - return *this; } - ~PNS_ITEMSET(); + int Count(int aKindMask = -1) const + { + int n = 0; + BOOST_FOREACH ( PNS_ITEM *item, m_items ) + { + if( item->Kind() & aKindMask ) + n++; + } + return n; + } - ITEM_VECTOR& Items() { return m_items; } - const ITEM_VECTOR& CItems() const { return m_items; } + ITEMS& Items() { return m_items; } + const ITEMS& CItems() const { return m_items; } - PNS_ITEMSET& FilterLayers( int aStart, int aEnd = -1 ); - PNS_ITEMSET& FilterKinds( int aKindMask ); - PNS_ITEMSET& FilterNet( int aNet ); + PNS_ITEMSET& FilterLayers( int aStart, int aEnd = -1, bool aInvert = false ); + PNS_ITEMSET& FilterKinds( int aKindMask, bool aInvert = false ); + PNS_ITEMSET& FilterNet( int aNet, bool aInvert = false ); - int Size() { return m_items.size(); } + PNS_ITEMSET& ExcludeLayers( int aStart, int aEnd = -1 ) + { + return FilterLayers( aStart, aEnd, true ); + } + + PNS_ITEMSET& ExcludeKinds( int aKindMask ) + { + return FilterKinds ( aKindMask, true ); + } + + PNS_ITEMSET& ExcludeNet( int aNet ) + { + return FilterNet ( aNet, true ); + } + + PNS_ITEMSET& ExcludeItem ( const PNS_ITEM *aItem ); + + int Size() const + { + return m_items.size(); + } void Add( PNS_ITEM* aItem ) { - m_items.push_back( aItem ); + m_items.push_back ( aItem ); } - PNS_ITEM* Get( int index ) const { return m_items[index]; } + PNS_ITEM* Get( int index ) const + { + return m_items[index]; + } - void Clear(); - - void AddOwned( PNS_ITEM *aItem ) + PNS_ITEM* operator[] (int index ) const { - m_items.push_back( aItem ); - m_ownedItems.push_back( aItem ); + return m_items[index]; + } + + void Clear() + { + m_items.clear(); + } + + bool Contains ( const PNS_ITEM *aItem ) const + { + return std::find ( m_items.begin(), m_items.end(), aItem ) != m_items.end(); + } + + void Erase ( const PNS_ITEM *aItem ) + { + ITEMS::iterator f = std::find (m_items.begin(), m_items.end(), aItem ); + + if( f != m_items.end() ) + m_items.erase ( f ); } private: - ITEM_VECTOR m_items; - ITEM_VECTOR m_ownedItems; + ITEMS m_items; }; #endif diff --git a/pcbnew/router/pns_joint.h b/pcbnew/router/pns_joint.h index bcac27d356..bb396d0c8c 100644 --- a/pcbnew/router/pns_joint.h +++ b/pcbnew/router/pns_joint.h @@ -28,6 +28,7 @@ #include "pns_item.h" #include "pns_segment.h" +#include "pns_itemset.h" /** * Class PNS_JOINT @@ -81,7 +82,7 @@ public: /// segments of the same net, on the same layer. bool IsLineCorner() const { - if( m_linkedItems.size() != 2 ) + if( m_linkedItems.Size() != 2 ) return false; if( m_linkedItems[0]->Kind() != SEGMENT || m_linkedItems[1]->Kind() != SEGMENT ) @@ -97,24 +98,18 @@ public: ///> Links the joint to a given board item (when it's added to the PNS_NODE) void Link( PNS_ITEM* aItem ) { - LINKED_ITEMS::iterator f = std::find( m_linkedItems.begin(), m_linkedItems.end(), aItem ); - - if( f != m_linkedItems.end() ) + if (m_linkedItems.Contains( aItem )) return; - m_linkedItems.push_back( aItem ); + m_linkedItems.Add ( aItem ); } ///> Unlinks a given board item from the joint (upon its removal from a PNS_NODE) ///> Returns true if the joint became dangling after unlinking. bool Unlink( PNS_ITEM* aItem ) { - LINKED_ITEMS::iterator f = std::find( m_linkedItems.begin(), m_linkedItems.end(), aItem ); - - if( f != m_linkedItems.end() ) - f = m_linkedItems.erase( f ); - - return m_linkedItems.size() == 0; + m_linkedItems.Erase ( aItem ); + return m_linkedItems.Size() == 0; } ///> For trivial joints, returns the segment adjacent to (aCurrent). For non-trival ones, returns @@ -127,16 +122,6 @@ public: return static_cast( m_linkedItems[m_linkedItems[0] == aCurrent ? 1 : 0] ); } - PNS_VIA* Via() - { - for( LINKED_ITEMS::iterator i = m_linkedItems.begin(); i != m_linkedItems.end(); ++i ) - { - if( (*i)->Kind() == PNS_ITEM::VIA ) - return (PNS_VIA*)( *i ); - } - - return NULL; - } /// trivial accessors const HASH_TAG& Tag() const @@ -154,26 +139,27 @@ public: return m_tag.net; } - LINKED_ITEMS& LinkList() + const LINKED_ITEMS& LinkList() const { - return m_linkedItems; + return m_linkedItems.CItems(); + } + + const PNS_ITEMSET& CLinks() const + { + return m_linkedItems; + } + + PNS_ITEMSET Links() const + { + return m_linkedItems; } - ///> Returns the number of linked items of types listed in aMask. int LinkCount( int aMask = -1 ) const { - int n = 0; - - for( LINKED_ITEMS::const_iterator i = m_linkedItems.begin(); - i != m_linkedItems.end(); ++i ) - { - if( (*i)->Kind() & aMask ) - n++; - } - - return n; + return m_linkedItems.Count( aMask ); } + void Dump() const; bool operator==( const PNS_JOINT& rhs ) const @@ -188,11 +174,9 @@ public: m_layers.Merge( aJoint.m_layers ); - // fixme: duplicate links (?) - for( LINKED_ITEMS::const_iterator i = aJoint.m_linkedItems.begin(); - i != aJoint.m_linkedItems.end(); ++i ) + BOOST_FOREACH ( PNS_ITEM *item, aJoint.LinkList() ) { - m_linkedItems.push_back( *i ); + m_linkedItems.Add (item); } } @@ -207,7 +191,7 @@ private: HASH_TAG m_tag; ///> list of items linked to this joint - LINKED_ITEMS m_linkedItems; + PNS_ITEMSET m_linkedItems; }; diff --git a/pcbnew/router/pns_layerset.h b/pcbnew/router/pns_layerset.h index aed8761365..c319ea3969 100644 --- a/pcbnew/router/pns_layerset.h +++ b/pcbnew/router/pns_layerset.h @@ -108,7 +108,7 @@ public: ///> Shortcut for comparisons/overlap tests static PNS_LAYERSET All() { - return PNS_LAYERSET( 0, 64 ); + return PNS_LAYERSET( 0, 256 ); // fixme: use layer IDs header } private: diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index 933be48750..f56b66c793 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -40,10 +40,10 @@ PNS_LINE_PLACER::PNS_LINE_PLACER( PNS_ROUTER* aRouter ) : PNS_ALGO_BASE ( aRouter ) { m_initial_direction = DIRECTION_45::N; - m_iteration = 0; m_world = NULL; m_shove = NULL; m_currentNode = NULL; + m_idle = true; } @@ -59,52 +59,22 @@ void PNS_LINE_PLACER::setWorld ( PNS_NODE* aWorld ) m_world = aWorld; } - -void PNS_LINE_PLACER::AddVia( bool aEnabled, int aDiameter, int aDrill, VIATYPE_T aType ) +const PNS_VIA PNS_LINE_PLACER::makeVia ( const VECTOR2I& aP ) +{ + const PNS_LAYERSET layers( m_sizes.GetLayerTop(), m_sizes.GetLayerBottom() ); + + return PNS_VIA ( aP, layers, m_sizes.ViaDiameter(), m_sizes.ViaDrill(), -1, m_sizes.ViaType() ); +} + + +void PNS_LINE_PLACER::ToggleVia( bool aEnabled ) { - m_viaDiameter = aDiameter; - m_viaDrill = aDrill; m_placingVia = aEnabled; - m_viaType = aType; + if(!m_idle) + Move ( m_currentEnd, NULL ); } -void PNS_LINE_PLACER::startPlacement( const VECTOR2I& aStart, int aNet, int aWidth, int aLayer ) -{ - assert( m_world != NULL ); - - m_direction = m_initial_direction; - TRACE( 1, "world %p, initial-direction %s layer %d\n", - m_world % m_direction.Format().c_str() % aLayer ); - m_head.SetNet( aNet ); - m_tail.SetNet( aNet ); - m_head.SetWidth( aWidth ); - m_tail.SetWidth( aWidth ); - m_head.Line().Clear(); - m_tail.Line().Clear(); - m_head.SetLayer( aLayer ); - m_tail.SetLayer( aLayer ); - m_iteration = 0; - m_p_start = aStart; - - m_lastNode = NULL; - m_currentNode = m_world; - - m_currentMode = Settings().Mode(); - - if( m_shove ) - delete m_shove; - - m_shove = NULL; - - if( m_currentMode == RM_Shove || m_currentMode == RM_Smart ) - { - m_shove = new PNS_SHOVE( m_world->Branch(), Router() ); - } - - m_placingVia = false; -} - void PNS_LINE_PLACER::setInitialDirection( const DIRECTION_45& aDirection ) { @@ -380,8 +350,9 @@ bool PNS_LINE_PLACER::handleViaPlacement( PNS_LINE& aHead ) if( !m_placingVia ) return true; - PNS_LAYERSET layers( Settings().GetLayerTop(), Settings().GetLayerBottom() ); - PNS_VIA v( aHead.CPoint( -1 ), layers, m_viaDiameter, m_viaDrill, aHead.Net(), m_viaType ); + PNS_VIA v ( makeVia ( aHead.CPoint( -1 ) ) ); + v.SetNet ( aHead.Net() ); + VECTOR2I force; VECTOR2I lead = aHead.CPoint( -1 ) - aHead.CPoint( 0 ); @@ -440,9 +411,7 @@ bool PNS_LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, PNS_LINE& aNewHead ) } else if( m_placingVia && viaOk ) { - PNS_LAYERSET layers( Settings().GetLayerTop(), Settings().GetLayerBottom() ); - PNS_VIA v1( walkFull.CPoint( -1 ), layers, m_viaDiameter, m_viaDrill, -1, m_viaType ); - walkFull.AppendVia( v1 ); + walkFull.AppendVia( makeVia ( walkFull.CPoint( -1 ) ) ); } PNS_OPTIMIZER::Optimize( &walkFull, effort, m_currentNode ); @@ -465,9 +434,7 @@ bool PNS_LINE_PLACER::rhMarkObstacles( const VECTOR2I& aP, PNS_LINE& aNewHead ) if( m_placingVia ) { - PNS_LAYERSET layers( Settings().GetLayerTop(), Settings().GetLayerBottom() ); - PNS_VIA v1( m_head.CPoint( -1 ), layers, m_viaDiameter, m_viaDrill, -1, m_viaType ); - m_head.AppendVia( v1 ); + m_head.AppendVia( makeVia ( m_head.CPoint( -1 ) ) ); } aNewHead = m_head; @@ -508,9 +475,8 @@ bool PNS_LINE_PLACER::rhShoveOnly ( const VECTOR2I& aP, PNS_LINE& aNewHead ) if( m_placingVia ) { - PNS_LAYERSET layers( Settings().GetLayerTop(), Settings().GetLayerBottom() ); - PNS_VIA v1( l.CPoint( -1 ), layers, m_viaDiameter, m_viaDrill, -1, m_viaType ); - PNS_VIA v2( l2.CPoint( -1 ), layers, m_viaDiameter, m_viaDrill, -1, m_viaType ); + PNS_VIA v1( makeVia ( l.CPoint( -1 ) ) ); + PNS_VIA v2( makeVia ( l2.CPoint( -1 ) ) ); l.AppendVia( v1 ); l2.AppendVia( v2 ); @@ -759,15 +725,24 @@ void PNS_LINE_PLACER::splitAdjacentSegments( PNS_NODE* aNode, PNS_ITEM* aSeg, co } -void PNS_LINE_PLACER::SetLayer( int aLayer ) +bool PNS_LINE_PLACER::SetLayer( int aLayer ) { - m_currentLayer = aLayer; + if(m_idle) + { + m_currentLayer = aLayer; + return true; + } else if (m_chainedPlacement) { + return false; + } else if (!m_startItem || (m_startItem->OfKind(PNS_ITEM::VIA) && m_startItem->Layers().Overlaps( aLayer ))) { + m_currentLayer = aLayer; + initPlacement ( ); + Move ( m_currentEnd, NULL ); + return true; + } - m_head.SetLayer( aLayer ); - m_tail.SetLayer( aLayer ); + return false; } - void PNS_LINE_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem ) { VECTOR2I p( aP ); @@ -775,10 +750,6 @@ void PNS_LINE_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem ) static int unknowNetIdx = 0; // -10000; int net = -1; - m_lastNode = NULL; - m_placingVia = false; - m_startsOnVia = false; - bool splitSeg = false; if( Router()->SnappingEnabled() ) @@ -789,19 +760,60 @@ void PNS_LINE_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem ) else net = aStartItem->Net(); - m_currentStart = p; - m_originalStart = p; + m_currentStart = p; m_currentEnd = p; m_currentNet = net; + m_startItem = aStartItem; + m_placingVia = false; + m_chainedPlacement = false; - PNS_NODE* rootNode = Router()->GetWorld()->Branch(); - - if( splitSeg ) - splitAdjacentSegments( rootNode, aStartItem, p ); - - setWorld( rootNode ); setInitialDirection( Settings().InitialDirection() ); - startPlacement( p, m_currentNet, m_currentWidth, m_currentLayer ); + + initPlacement( splitSeg ); +} + +void PNS_LINE_PLACER::initPlacement( bool aSplitSeg ) +{ + m_idle = false; + + m_head.Line().Clear(); + m_tail.Line().Clear(); + m_head.SetNet( m_currentNet ); + m_tail.SetNet( m_currentNet ); + m_head.SetLayer( m_currentLayer ); + m_tail.SetLayer( m_currentLayer ); + m_head.SetWidth( m_sizes.TrackWidth() ); + m_tail.SetWidth( m_sizes.TrackWidth() ); + + m_p_start = m_currentStart; + m_direction = m_initial_direction; + + PNS_NODE *world = Router()->GetWorld(); + + world->KillChildren(); + PNS_NODE* rootNode = world->Branch(); + + if( aSplitSeg ) + splitAdjacentSegments( rootNode, m_startItem, m_currentStart ); + + setWorld( rootNode ); + + TRACE( 1, "world %p, intitial-direction %s layer %d\n", + m_world % m_direction.Format().c_str() % aLayer ); + + m_lastNode = NULL; + m_currentNode = m_world; + m_currentMode = Settings().Mode(); + + if( m_shove ) + delete m_shove; + + m_shove = NULL; + + if( m_currentMode == RM_Shove || m_currentMode == RM_Smart ) + { + m_shove = new PNS_SHOVE( m_world->Branch(), Router() ); + } } @@ -902,25 +914,13 @@ bool PNS_LINE_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem ) if( !realEnd ) { setInitialDirection( d_last ); - VECTOR2I p_start = m_placingVia ? p_last : p_pre_last; - - if( m_placingVia ) - { - int layerTop = Router()->Settings().GetLayerTop(); - int layerBottom = Router()->Settings().GetLayerBottom(); - - // Change the current layer to the other side of the board - if( m_currentLayer == layerTop ) - m_currentLayer = layerBottom; - else - m_currentLayer = layerTop; - } - - setWorld( Router()->GetWorld()->Branch() ); - startPlacement( p_start, m_head.Net(), m_head.Width(), m_currentLayer ); - - m_startsOnVia = m_placingVia; + m_currentStart = m_placingVia ? p_last : p_pre_last; + m_startItem = NULL; m_placingVia = false; + m_chainedPlacement = !pl.EndsWithVia(); + initPlacement(); + } else { + m_idle = true; } return realEnd; @@ -995,16 +995,14 @@ void PNS_LINE_PLACER::simplifyNewLine( PNS_NODE* aNode, PNS_SEGMENT* aLatest ) } -void PNS_LINE_PLACER::UpdateSizes( const PNS_ROUTING_SETTINGS& aSettings ) +void PNS_LINE_PLACER::UpdateSizes( const PNS_SIZES_SETTINGS& aSizes ) { - int trackWidth = aSettings.GetTrackWidth(); - - m_head.SetWidth( trackWidth ); - m_tail.SetWidth( trackWidth ); - - m_currentWidth = trackWidth; - m_viaDiameter = aSettings.GetViaDiameter(); - m_viaDrill = aSettings.GetViaDrill(); + m_sizes = aSizes; + if( !m_idle ) + { + initPlacement ( ); + Move ( m_currentEnd, NULL ); + } } diff --git a/pcbnew/router/pns_line_placer.h b/pcbnew/router/pns_line_placer.h index dfbb1bb619..487dd1c99c 100644 --- a/pcbnew/router/pns_line_placer.h +++ b/pcbnew/router/pns_line_placer.h @@ -26,6 +26,7 @@ #include #include +#include "pns_sizes_settings.h" #include "pns_node.h" #include "pns_via.h" #include "pns_line.h" @@ -35,6 +36,9 @@ class PNS_ROUTER; class PNS_SHOVE; class PNS_OPTIMIZER; class PNS_ROUTER_BASE; +class PNS_VIA; +class PNS_SIZES_SETTINGS; + /** * Class PNS_LINE_PLACER @@ -78,29 +82,19 @@ public: bool FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem ); /** - * Function AddVia() + * Function ToggleVia() * * Enables/disables a via at the end of currently routed trace. - * @param aEnabled if true, a via is attached during placement - * @param aDiameter diameter of the via - * @param aDrill drill of the via - * @param aType Type of the via */ - void AddVia( bool aEnabled, int aDiameter, int aDrill, VIATYPE_T aType ); + void ToggleVia( bool aEnabled ); /** * Function SetLayer() * * Sets the current routing layer. */ - void SetLayer( int aLayer ); + bool SetLayer( int aLayer ); - /** - * Function SetWidth() - * - * Sets the current track width. - */ - void SetWidth( int aWidth ); /** * Function Head() @@ -184,8 +178,9 @@ public: * a settings class. Used to dynamically change these parameters as * the track is routed. */ - void UpdateSizes( const PNS_ROUTING_SETTINGS& aSettings ); + void UpdateSizes( const PNS_SIZES_SETTINGS& aSizes ); + bool IsPlacingVia() const { return m_placingVia; } private: /** * Function route() @@ -220,7 +215,7 @@ private: * * Initializes placement of a new line with given parameters. */ - void startPlacement( const VECTOR2I& aStart, int aNet, int aWidth, int aLayer ); + void initPlacement( bool aSplitSeg = false ); /** * Function setInitialDirection() @@ -346,7 +341,9 @@ private: ///> route step, mark obstacles mode bool rhMarkObstacles( const VECTOR2I& aP, PNS_LINE& aNewHead ); - + + const PNS_VIA makeVia ( const VECTOR2I& aP ); + ///> current routing direction DIRECTION_45 m_direction; @@ -378,6 +375,8 @@ private: ///> Postprocessed world state (including marked collisions & removed loops) PNS_NODE* m_lastNode; + PNS_SIZES_SETTINGS m_sizes; + ///> Are we placing a via? bool m_placingVia; @@ -387,9 +386,6 @@ private: ///> current via drill int m_viaDrill; - ///> current via type - VIATYPE_T m_viaType; - ///> current track width int m_currentWidth; @@ -398,10 +394,14 @@ private: bool m_startsOnVia; - VECTOR2I m_originalStart, m_currentEnd, m_currentStart; + VECTOR2I m_currentEnd, m_currentStart; PNS_LINE m_currentTrace; PNS_MODE m_currentMode; + PNS_ITEM *m_startItem; + + bool m_idle; + bool m_chainedPlacement; }; #endif // __PNS_LINE_PLACER_H diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index 4dbde1ebbf..4a0d8be6c5 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -121,7 +121,6 @@ PNS_ITEM* PNS_ROUTER::syncPad( D_PAD* aPad ) switch( aPad->GetAttribute() ) { case PAD_STANDARD: - layers = PNS_LAYERSET( 0, MAX_CU_LAYERS - 1 ); // TODO necessary? it is already initialized break; case PAD_SMD: @@ -249,31 +248,6 @@ void PNS_ROUTER::SetBoard( BOARD* aBoard ) TRACE( 1, "m_board = %p\n", m_board ); } - -int PNS_ROUTER::NextCopperLayer( bool aUp ) -{ - LSET mask = m_board->GetEnabledLayers() & m_board->GetVisibleLayers(); - LAYER_NUM l = m_currentLayer; - - do - { - l += ( aUp ? 1 : -1 ); - - if( l >= MAX_CU_LAYERS ) - l = 0; - - if( l < 0 ) - l = MAX_CU_LAYERS - 1; - - if( mask[l] ) - return l; - } - while( l != m_currentLayer ); - - return l; -} - - void PNS_ROUTER::SyncWorld() { if( !m_board ) @@ -324,10 +298,6 @@ PNS_ROUTER::PNS_ROUTER() m_clearanceFunc = NULL; - m_currentLayer = 1; - m_placingVia = false; - m_startsOnVia = false; - m_currentNet = -1; m_state = IDLE; m_world = NULL; m_placer = NULL; @@ -483,51 +453,21 @@ bool PNS_ROUTER::StartDragging( const VECTOR2I& aP, PNS_ITEM* aStartItem ) return true; } - -bool PNS_ROUTER::StartRouting( const VECTOR2I& aP, PNS_ITEM* aStartItem ) +bool PNS_ROUTER::StartRouting( const VECTOR2I& aP, PNS_ITEM* aStartItem, int aLayer ) { - m_state = ROUTE_TRACK; - m_placer = new PNS_LINE_PLACER( this ); - m_placer->SetLayer( m_currentLayer ); - - const BOARD_DESIGN_SETTINGS& dsnSettings = m_board->GetDesignSettings(); - - if( dsnSettings.UseNetClassTrack() && aStartItem != NULL ) // netclass value - { - m_settings.SetTrackWidth( aStartItem->Parent()->GetNetClass()->GetTrackWidth() ); - } - else - { - m_settings.SetTrackWidth( dsnSettings.GetCurrentTrackWidth() ); - } - - if( dsnSettings.UseNetClassVia() && aStartItem != NULL ) // netclass value - { - m_settings.SetViaDiameter( aStartItem->Parent()->GetNetClass()->GetViaDiameter() ); - m_settings.SetViaDrill( aStartItem->Parent()->GetNetClass()->GetViaDrill() ); - } - else - { - m_settings.SetViaDiameter( dsnSettings.GetCurrentViaSize() ); - m_settings.SetViaDrill( dsnSettings.GetCurrentViaDrill() ); - } - - m_placer->UpdateSizes( m_settings ); + + m_placer->UpdateSizes ( m_sizes ); + m_placer->SetLayer( aLayer ); m_placer->Start( aP, aStartItem ); + m_currentEnd = aP; m_currentEndItem = NULL; + m_state = ROUTE_TRACK; return true; } - -const VECTOR2I PNS_ROUTER::CurrentEnd() const -{ - return m_currentEnd; -} - - void PNS_ROUTER::eraseView() { BOOST_FOREACH( BOARD_ITEM* item, m_hiddenItems ) @@ -689,13 +629,14 @@ void PNS_ROUTER::updateView( PNS_NODE* aNode, PNS_ITEMSET& aCurrent ) } -void PNS_ROUTER::ApplySettings() +void PNS_ROUTER::UpdateSizes ( const PNS_SIZES_SETTINGS& aSizes ) { + m_sizes = aSizes; + // Change track/via size settings if( m_state == ROUTE_TRACK) { - m_placer->UpdateSizes( m_settings ); - m_placer->Move( m_currentEnd, m_currentEndItem ); + m_placer->UpdateSizes( m_sizes ); movePlacing( m_currentEnd, m_currentEndItem ); } } @@ -791,26 +732,6 @@ void PNS_ROUTER::CommitRouting( PNS_NODE* aNode ) } -PNS_VIA* PNS_ROUTER::checkLoneVia( PNS_JOINT* aJoint ) const -{ - PNS_VIA* theVia = NULL; - PNS_LAYERSET l; - - BOOST_FOREACH( PNS_ITEM* item, aJoint->LinkList() ) - { - if( item->Kind() == PNS_ITEM::VIA ) - theVia = static_cast( item ); - - l.Merge( item->Layers() ); - } - - if( l.Start() == l.End() ) - return theVia; - - return NULL; -} - - bool PNS_ROUTER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem ) { bool rv = false; @@ -819,8 +740,6 @@ bool PNS_ROUTER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem ) { case ROUTE_TRACK: rv = m_placer->FixRoute( aP, aEndItem ); - m_startsOnVia = m_placingVia; - m_placingVia = false; break; case DRAG_SEGMENT: @@ -841,7 +760,17 @@ bool PNS_ROUTER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem ) void PNS_ROUTER::StopRouting() { // Update the ratsnest with new changes - m_board->GetRatsnest()->Recalculate( m_currentNet ); + if(m_placer) + { + int n = m_placer->CurrentNet(); + + if( n >= 0) + { + // Update the ratsnest with new changes + m_board->GetRatsnest()->Recalculate( n ); + } + } + if( !RoutingInProgress() ) return; @@ -868,7 +797,7 @@ void PNS_ROUTER::FlipPosture() if( m_state == ROUTE_TRACK ) { m_placer->FlipPosture(); - m_placer->Move( m_currentEnd, m_currentEndItem ); + movePlacing ( m_currentEnd, m_currentEndItem ); } } @@ -877,80 +806,42 @@ void PNS_ROUTER::SwitchLayer( int aLayer ) { switch( m_state ) { - case IDLE: - m_currentLayer = aLayer; - break; - - case ROUTE_TRACK: - if( m_startsOnVia ) - { - m_currentLayer = aLayer; + case ROUTE_TRACK: m_placer->SetLayer( aLayer ); - } - break; - - default: - break; + break; + default: + break; } } -void PNS_ROUTER::ToggleViaPlacement(VIATYPE_T type) +void PNS_ROUTER::ToggleViaPlacement() { - const int layercount = m_board->GetDesignSettings().GetCopperLayerCount(); - - // Cannot place microvias or blind vias if not allowed (obvious) - if( ( type == VIA_BLIND_BURIED ) && ( !m_board->GetDesignSettings().m_BlindBuriedViaAllowed ) ) - return; - if( ( type == VIA_MICROVIA ) && ( !m_board->GetDesignSettings().m_MicroViasAllowed ) ) - return; - - //Can only place through vias on 2-layer boards - if( ( type != VIA_THROUGH ) && ( layercount <= 2 ) ) - return; - - //Can only place microvias if we're on an outer layer, or directly adjacent to one - if( ( type == VIA_MICROVIA ) && ( m_currentLayer > In1_Cu ) && ( m_currentLayer < layercount-2 ) ) - return; - - //Cannot place blind vias with front/back as the layer pair, this doesn't make sense - if( ( type == VIA_BLIND_BURIED ) && ( Settings().GetLayerTop() == F_Cu ) && ( Settings().GetLayerBottom() == B_Cu ) ) - return; - - if( m_state == ROUTE_TRACK ) + if( m_state == ROUTE_TRACK ) { - m_placingVia = !m_placingVia; - m_placer->AddVia( m_placingVia, m_settings.GetViaDiameter(), m_settings.GetViaDrill(), type ); + bool toggle = !m_placer->IsPlacingVia(); + m_placer->ToggleVia( toggle ); } } int PNS_ROUTER::GetCurrentNet() const { - switch( m_state ) - { - case ROUTE_TRACK: - return m_placer->CurrentNet(); - - default: - return m_currentNet; - } + if(m_placer) + return m_placer->CurrentNet(); + return -1; } int PNS_ROUTER::GetCurrentLayer() const { - switch( m_state ) - { - case ROUTE_TRACK: - return m_placer->CurrentLayer(); - - default: - return m_currentLayer; - } + if( m_placer ) + return m_placer->CurrentLayer(); + return -1; } + void PNS_ROUTER::DumpLog() { PNS_LOGGER* logger = NULL; @@ -968,3 +859,11 @@ void PNS_ROUTER::DumpLog() if( logger ) logger->Save( "/tmp/shove.log" ); } + +bool PNS_ROUTER::IsPlacingVia() const +{ + if(!m_placer) + return NULL; + return m_placer->IsPlacingVia(); +} + diff --git a/pcbnew/router/pns_router.h b/pcbnew/router/pns_router.h index dd6c6b9694..0b381d828a 100644 --- a/pcbnew/router/pns_router.h +++ b/pcbnew/router/pns_router.h @@ -30,6 +30,7 @@ #include #include "pns_routing_settings.h" +#include "pns_sizes_settings.h" #include "pns_item.h" #include "pns_itemset.h" #include "pns_node.h" @@ -86,13 +87,12 @@ public: void SetView( KIGFX::VIEW* aView ); bool RoutingInProgress() const; - bool StartRouting( const VECTOR2I& aP, PNS_ITEM* aItem ); + bool StartRouting( const VECTOR2I& aP, PNS_ITEM* aItem, int aLayer ); void Move( const VECTOR2I& aP, PNS_ITEM* aItem ); bool FixRoute( const VECTOR2I& aP, PNS_ITEM* aItem ); void StopRouting(); - const VECTOR2I CurrentEnd() const; int GetClearance( const PNS_ITEM* aA, const PNS_ITEM* aB ) const; @@ -112,7 +112,7 @@ public: void SwitchLayer( int layer ); - void ToggleViaPlacement( VIATYPE_T type = VIA_NOT_DEFINED ); + void ToggleViaPlacement(); int GetCurrentLayer() const; int GetCurrentNet() const; @@ -123,15 +123,7 @@ public: { return m_clearanceFunc; } - - bool IsPlacingVia() const - { - return m_placingVia; - } - - int NextCopperLayer( bool aUp ); - - // typedef boost::optional optHoverItem; + bool IsPlacingVia() const; const PNS_ITEMSET QueryHoverItems( const VECTOR2I& aP ); const VECTOR2I SnapToItem( PNS_ITEM* aItem, VECTOR2I aP, bool& aSplitsSegment ); @@ -175,7 +167,7 @@ public: * Applies stored settings. * @see Settings() */ - void ApplySettings(); + void UpdateSizes( const PNS_SIZES_SETTINGS& aSizes ); /** * Changes routing settings to ones passed in the parameter. @@ -184,8 +176,6 @@ public: void LoadSettings( const PNS_ROUTING_SETTINGS& aSettings ) { m_settings = aSettings; - - ApplySettings(); } void EnableSnapping( bool aEnable ) @@ -198,6 +188,11 @@ public: return m_snappingEnabled; } + PNS_SIZES_SETTINGS& Sizes() + { + return m_sizes; + } + private: void movePlacing( const VECTOR2I& aP, PNS_ITEM* aItem ); void moveDragging( const VECTOR2I& aP, PNS_ITEM* aItem ); @@ -211,7 +206,6 @@ private: PNS_ITEM* pickSingleItem( PNS_ITEMSET& aItems ) const; void splitAdjacentSegments( PNS_NODE* aNode, PNS_ITEM* aSeg, const VECTOR2I& aP ); - PNS_VIA* checkLoneVia( PNS_JOINT* aJoint ) const; PNS_ITEM* syncPad( D_PAD* aPad ); PNS_ITEM* syncTrack( TRACK* aTrack ); @@ -225,9 +219,7 @@ private: void markViolations( PNS_NODE* aNode, PNS_ITEMSET& aCurrent, PNS_NODE::ITEM_VECTOR& aRemoved ); - int m_currentLayer; - int m_currentNet; - + VECTOR2I m_currentEnd; RouterState m_state; BOARD* m_board; @@ -235,9 +227,7 @@ private: PNS_NODE* m_lastNode; PNS_LINE_PLACER* m_placer; PNS_DRAGGER* m_dragger; - PNS_LINE* m_draggedLine; PNS_SHOVE* m_shove; - int m_draggedSegmentIndex; int m_iterLimit; bool m_showInterSteps; int m_snapshotIter; @@ -247,11 +237,6 @@ private: PNS_ITEM* m_currentEndItem; - VECTOR2I m_currentEnd; - VECTOR2I m_currentStart; - VECTOR2I m_originalStart; - bool m_placingVia; - bool m_startsOnVia; bool m_snappingEnabled; bool m_violation; @@ -264,6 +249,7 @@ private: ///> Stores list of modified items in the current operation PICKED_ITEMS_LIST m_undoBuffer; + PNS_SIZES_SETTINGS m_sizes; }; #endif diff --git a/pcbnew/router/pns_routing_settings.h b/pcbnew/router/pns_routing_settings.h index a1261f7155..1a7030be21 100644 --- a/pcbnew/router/pns_routing_settings.h +++ b/pcbnew/router/pns_routing_settings.h @@ -21,6 +21,8 @@ #ifndef __PNS_ROUTING_SETTINGS #define __PNS_ROUTING_SETTINGS +#include + #include "time_limit.h" class DIRECTION_45; @@ -112,13 +114,6 @@ public: bool CanViolateDRC() const { return m_canViolateDRC; } void SetCanViolateDRC( bool aViolate ) { m_canViolateDRC = aViolate; } - void SetTrackWidth( int aWidth ) { m_trackWidth = aWidth; } - int GetTrackWidth() const { return m_trackWidth; } - void SetViaDiameter( int aDiameter ) { m_viaDiameter = aDiameter; } - int GetViaDiameter() const { return m_viaDiameter; } - void SetViaDrill( int aDrill ) { m_viaDrill = aDrill; } - int GetViaDrill() const { return m_viaDrill; } - const DIRECTION_45 InitialDirection() const; int ShoveIterationLimit() const; @@ -127,22 +122,6 @@ public: int WalkaroundIterationLimit() const { return m_walkaroundIterationLimit; }; TIME_LIMIT WalkaroundTimeLimit() const; - void SetLayerPair( int aLayer1, int aLayer2 ) - { - if( aLayer1 < aLayer2 ) - { - m_layerTop = aLayer1; - m_layerBottom = aLayer2; - } - else - { - m_layerBottom = aLayer1; - m_layerTop = aLayer2; - } - } - - int GetLayerTop() const { return m_layerTop; } - int GetLayerBottom() const { return m_layerBottom; } private: bool m_shoveVias; @@ -158,19 +137,11 @@ private: PNS_MODE m_routingMode; PNS_OPTIMIZATION_EFFORT m_optimizerEffort; - int m_trackWidth; - int m_viaDiameter; - int m_viaDrill; - int m_preferredLayer; int m_walkaroundIterationLimit; int m_shoveIterationLimit; TIME_LIMIT m_shoveTimeLimit; TIME_LIMIT m_walkaroundTimeLimit; - - // Routing layers pair - int m_layerTop; - int m_layerBottom; }; #endif diff --git a/pcbnew/router/pns_sizes_settings.cpp b/pcbnew/router/pns_sizes_settings.cpp new file mode 100644 index 0000000000..f2ab01a3be --- /dev/null +++ b/pcbnew/router/pns_sizes_settings.cpp @@ -0,0 +1,159 @@ +/* + * KiRouter - a push-and-(sometimes-)shove PCB router + * + * Copyright (C) 2014 CERN + * Author: Tomasz Wlostowski + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include + +#include "pns_item.h" +#include "pns_via.h" +#include "pns_solid.h" +#include "pns_node.h" +#include "pns_sizes_settings.h" + +int PNS_SIZES_SETTINGS::inheritTrackWidth( PNS_ITEM* aItem ) +{ + VECTOR2I p; + + assert( aItem->Owner() != NULL ); + + switch( aItem->Kind() ) + { + case PNS_ITEM::VIA: + p = static_cast( aItem )->Pos(); + break; + + case PNS_ITEM::SOLID: + p = static_cast( aItem )->Pos(); + break; + + case PNS_ITEM::SEGMENT: + return static_cast( aItem )->Width(); + + default: + return 0; + } + + PNS_JOINT* jt = aItem->Owner()->FindJoint( p, aItem ); + + assert( jt != NULL ); + + int mval = INT_MAX; + + PNS_ITEMSET linkedSegs = jt->Links().ExcludeItem( aItem ).FilterKinds( PNS_ITEM::SEGMENT ); + + BOOST_FOREACH( PNS_ITEM* item, linkedSegs.Items() ) + { + int w = static_cast( item )->Width(); + mval = std::min( w, mval ); + } + + return ( mval == INT_MAX ? 0 : mval ); +} + +void PNS_SIZES_SETTINGS::Init( BOARD* aBoard, PNS_ITEM* aStartItem, int aNet ) +{ + BOARD_DESIGN_SETTINGS &bds = aBoard->GetDesignSettings(); + + NETCLASSPTR netClass; + int net = aNet; + + if( aStartItem ) + net = aStartItem->Net(); + + if( net >= 0 ) + { + NETINFO_ITEM* ni = aBoard->FindNet( net ); + + if( ni ) + { + wxString netClassName = ni->GetClassName(); + netClass = bds.m_NetClasses.Find( netClassName ); + } + } + + if( !netClass ) + netClass = bds.GetDefault(); + + m_trackWidth = 0; + + if( bds.m_UseConnectedTrackWidth && aStartItem != NULL ) + { + m_trackWidth = inheritTrackWidth( aStartItem ); + } + + if( !m_trackWidth && ( bds.UseNetClassTrack() && netClass != NULL ) ) // netclass value + { + m_trackWidth = netClass->GetTrackWidth(); + } + + if( !m_trackWidth ) + { + m_trackWidth = bds.GetCurrentTrackWidth(); + } + + if( bds.UseNetClassVia() && netClass != NULL ) // netclass value + { + m_viaDiameter = netClass->GetViaDiameter(); + m_viaDrill = netClass->GetViaDrill(); + } + else + { + m_viaDiameter = bds.GetCurrentViaSize(); + m_viaDrill = bds.GetCurrentViaDrill(); + } + + m_layerPairs.clear(); +} + +void PNS_SIZES_SETTINGS::ClearLayerPairs() +{ + m_layerPairs.clear(); +} + +void PNS_SIZES_SETTINGS::AddLayerPair( int aL1, int aL2 ) +{ + int top = std::min( aL1, aL2 ); + int bottom = std::max( aL1, aL2 ); + + m_layerPairs[bottom] = top; + m_layerPairs[top] = bottom; +} + +void PNS_SIZES_SETTINGS::ImportCurrent( BOARD_DESIGN_SETTINGS& aSettings ) +{ + m_trackWidth = aSettings.GetCurrentTrackWidth(); + m_viaDiameter = aSettings.GetCurrentViaSize(); + m_viaDrill = aSettings.GetCurrentViaDrill(); +} + +int PNS_SIZES_SETTINGS::GetLayerTop() const +{ + if( m_layerPairs.empty() ) + return F_Cu; + else + return m_layerPairs.begin()->first; +} + +int PNS_SIZES_SETTINGS::GetLayerBottom() const +{ + if( m_layerPairs.empty() ) + return B_Cu; + else + return m_layerPairs.begin()->second; +} diff --git a/pcbnew/router/pns_sizes_settings.h b/pcbnew/router/pns_sizes_settings.h new file mode 100644 index 0000000000..db8d3b3a74 --- /dev/null +++ b/pcbnew/router/pns_sizes_settings.h @@ -0,0 +1,95 @@ +/* + * KiRouter - a push-and-(sometimes-)shove PCB router + * + * Copyright (C) 2014 CERN + * Author: Tomasz Wlostowski + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef __PNS_SIZES_SETTINGS_H +#define __PNS_SIZES_SETTINGS_H + +#include +#include + +#include "../class_track.h" // for VIATYPE_T + +class BOARD; +class BOARD_DESIGN_SETTINGS; +class PNS_ITEM; + +class PNS_SIZES_SETTINGS { + +public: + PNS_SIZES_SETTINGS() : + m_trackWidth( 100000 ), + m_diffPairWidth( 100000 ), + m_diffPairGap( 125000 ), + m_viaDiameter( 500000 ), + m_viaDrill( 200000 ), + m_viaType( VIA_THROUGH ) + {}; + + ~PNS_SIZES_SETTINGS() {}; + + void Init( BOARD* aBoard, PNS_ITEM* aStartItem = NULL, int aNet = -1 ); + void ImportCurrent ( BOARD_DESIGN_SETTINGS& aSettings ); + + void ClearLayerPairs(); + void AddLayerPair( int aL1, int aL2 ); + + int TrackWidth() const { return m_trackWidth; } + void SetTrackWidth( int aWidth ) { m_trackWidth = aWidth; } + + int DiffPairWidth() const { return m_diffPairWidth; } + + int DiffPairGap() const { return m_diffPairGap; } + + int ViaDiameter() const { return m_viaDiameter; } + void SetViaDiameter( int aDiameter) { m_viaDiameter = aDiameter; } + + int ViaDrill() const { return m_viaDrill; } + void SetViaDrill( int aDrill ) { m_viaDrill = aDrill; } + + boost::optional PairedLayer ( int aLayerId ) + { + if( m_layerPairs.find(aLayerId) == m_layerPairs.end() ) + return boost::optional(); + + return m_layerPairs [ aLayerId ]; + } + + int GetLayerTop() const; + int GetLayerBottom() const; + + void SetViaType( VIATYPE_T aViaType ) { m_viaType = aViaType; } + VIATYPE_T ViaType() const { return m_viaType; } + +private: + + int inheritTrackWidth( PNS_ITEM *aItem ); + + int m_trackWidth; + int m_diffPairWidth; + int m_diffPairGap; + int m_viaDiameter; + int m_viaDrill; + + VIATYPE_T m_viaType; + + std::map m_layerPairs; +}; + +#endif // __PNS_SIZES_SETTINGS_H diff --git a/pcbnew/router/pns_via.h b/pcbnew/router/pns_via.h index 86dc2c0503..91bcd79ca9 100644 --- a/pcbnew/router/pns_via.h +++ b/pcbnew/router/pns_via.h @@ -53,7 +53,7 @@ public: if( aViaType == VIA_THROUGH ) { PNS_LAYERSET allLayers( 0, MAX_CU_LAYERS - 1 ); - SetLayers( allLayers); + SetLayers( allLayers ); } } diff --git a/pcbnew/router/router_preview_item.cpp b/pcbnew/router/router_preview_item.cpp index 83e0a2f3a2..e375a8d7e5 100644 --- a/pcbnew/router/router_preview_item.cpp +++ b/pcbnew/router/router_preview_item.cpp @@ -81,6 +81,7 @@ void ROUTER_PREVIEW_ITEM::Update( const PNS_ITEM* aItem ) } case PNS_ITEM::VIA: + m_originLayer = m_layer = ITEM_GAL_LAYER( VIAS_VISIBLE ); m_type = PR_SHAPE; m_width = 0; m_color = COLOR4D( 0.7, 0.7, 0.7, 0.8 ); diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index bbf758be5a..c88ec52d98 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -377,6 +378,9 @@ void ROUTER_TOOL::highlightNet( bool aEnabled, int aNetcode ) void ROUTER_TOOL::handleCommonEvents( TOOL_EVENT& aEvent ) { + PCB_EDIT_FRAME* frame = getEditFrame (); + BOARD *board = getModel (); + #ifdef DEBUG if( aEvent.IsKeyPressed() ) { @@ -392,36 +396,32 @@ void ROUTER_TOOL::handleCommonEvents( TOOL_EVENT& aEvent ) #endif if( aEvent.IsAction( &ACT_RouterOptions ) ) { - DIALOG_PNS_SETTINGS settingsDlg( getEditFrame(), m_router->Settings() ); + DIALOG_PNS_SETTINGS settingsDlg( frame, m_router->Settings() ); if( settingsDlg.ShowModal() ) - m_router->ApplySettings(); + { + // FIXME: do we need an explicit update? + } } else if( aEvent.IsAction( &ACT_CustomTrackWidth ) ) { - DIALOG_TRACK_VIA_SIZE sizeDlg( getEditFrame(), m_router->Settings() ); - BOARD_DESIGN_SETTINGS& bds = getModel()->GetDesignSettings(); + BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings(); + DIALOG_TRACK_VIA_SIZE sizeDlg( frame, bds ); - sizeDlg.ShowModal(); - - // TODO it should be changed, router settings won't keep track & via sizes in the future - bds.SetCustomTrackWidth( m_router->Settings().GetTrackWidth() ); - bds.SetCustomViaSize( m_router->Settings().GetViaDiameter() ); - bds.SetCustomViaDrill( m_router->Settings().GetViaDrill() ); - bds.UseCustomTrackViaSize( true ); - - m_toolMgr->RunAction( COMMON_ACTIONS::trackViaSizeChanged ); + if ( sizeDlg.ShowModal() ) + { + bds.UseCustomTrackViaSize( true ); + m_toolMgr->RunAction( COMMON_ACTIONS::trackViaSizeChanged ); + } } else if( aEvent.IsAction( &COMMON_ACTIONS::trackViaSizeChanged ) ) { - BOARD_DESIGN_SETTINGS& bds = getModel()->GetDesignSettings(); - m_router->Settings().SetTrackWidth( bds.GetCurrentTrackWidth() ); - m_router->Settings().SetViaDiameter( bds.GetCurrentViaSize() ); - m_router->Settings().SetViaDrill( bds.GetCurrentViaDrill() ); - m_router->ApplySettings(); + PNS_SIZES_SETTINGS sizes; + sizes.ImportCurrent ( board->GetDesignSettings() ); + m_router->UpdateSizes ( sizes ); } } @@ -459,10 +459,10 @@ void ROUTER_TOOL::updateStartItem( TOOL_EVENT& aEvent ) ctls->ForceCursorPosition( false ); } - if( startItem->Layers().IsMultilayer() ) - m_startLayer = tl; - else - m_startLayer = startItem->Layers().Start(); +// if( startItem->Layers().IsMultilayer() ) +// m_startLayer = tl; +// else +// m_startLayer = startItem->Layers().Start(); m_startItem = startItem; } @@ -470,7 +470,6 @@ void ROUTER_TOOL::updateStartItem( TOOL_EVENT& aEvent ) { m_startItem = NULL; m_startSnapPoint = cp; - m_startLayer = tl; ctls->ForceCursorPosition( false ); } } @@ -521,25 +520,99 @@ void ROUTER_TOOL::updateEndItem( TOOL_EVENT& aEvent ) TRACE( 0, "%s, layer : %d", m_endItem->KindStr().c_str() % m_endItem->Layers().Start() ); } +int ROUTER_TOOL::getStartLayer( const PNS_ITEM *aItem ) +{ + int tl = getView()->GetTopLayer(); + + if (m_startItem) + { + const PNS_LAYERSET& ls = m_startItem->Layers(); + + if(ls.Overlaps( tl )) + return tl; + else + return ls.Start(); + } + + return tl; +} +void ROUTER_TOOL::switchLayerOnViaPlacement() +{ + PCB_EDIT_FRAME* frame = getEditFrame(); + + int al = frame->GetActiveLayer(); + int cl = m_router->GetCurrentLayer(); + + if( cl != al ) + { + m_router->SwitchLayer( al ); + } + + optional newLayer = m_router->Sizes().PairedLayer( cl ); + + if( newLayer ) + { + m_router->SwitchLayer ( *newLayer ); + frame->SetActiveLayer ( ToLAYER_ID( *newLayer ) ); + } +} + +bool ROUTER_TOOL::onViaCommand( VIATYPE_T aType ) +{ + BOARD *board = getModel (); + BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings(); + PCB_EDIT_FRAME* frame = getEditFrame(); + + const int layerCount = bds.GetCopperLayerCount(); + int currentLayer = m_router->GetCurrentLayer(); + + PNS_SIZES_SETTINGS sizes = m_router->Sizes(); + + sizes.ClearLayerPairs(); + sizes.AddLayerPair( frame->GetScreen()->m_Route_Layer_TOP, + frame->GetScreen()->m_Route_Layer_BOTTOM ); + + if (!m_router->IsPlacingVia()) + { + // Cannot place microvias or blind vias if not allowed (obvious) + if( ( aType == VIA_BLIND_BURIED ) && ( !bds.m_BlindBuriedViaAllowed ) ) + return false; + if( ( aType == VIA_MICROVIA ) && ( !bds.m_MicroViasAllowed ) ) + return false; + + //Can only place through vias on 2-layer boards + if( ( aType != VIA_THROUGH ) && ( layerCount <= 2 ) ) + return false; + + //Can only place microvias if we're on an outer layer, or directly adjacent to one + if( ( aType == VIA_MICROVIA ) && ( currentLayer > In1_Cu ) && ( currentLayer < layerCount-2 ) ) + return false; + + //Cannot place blind vias with front/back as the layer pair, this doesn't make sense + if( ( aType == VIA_BLIND_BURIED ) && ( sizes.GetLayerTop() == F_Cu ) && ( sizes.GetLayerBottom() == B_Cu ) ) + return false; + } + + + sizes.SetViaType ( aType ); + m_router->ToggleViaPlacement( ); + m_router->UpdateSizes( sizes ); + + m_router->Move( m_endSnapPoint, m_endItem ); // refresh + + return false; +} void ROUTER_TOOL::performRouting() { PCB_EDIT_FRAME* frame = getEditFrame(); bool saveUndoBuffer = true; VIEW_CONTROLS* ctls = getViewControls(); + BOARD* board = getModel(); - if( getModel()->GetDesignSettings().m_UseConnectedTrackWidth ) - { - int width = getDefaultWidth( m_startItem ? m_startItem->Net() : -1 ); - - if( m_startItem && m_startItem->OfKind( PNS_ITEM::SEGMENT ) ) - width = static_cast( m_startItem )->Width(); - - m_router->Settings().SetTrackWidth( width ); - } - - m_router->SwitchLayer( m_startLayer ); - frame->SetActiveLayer( ToLAYER_ID( m_startLayer ) ); + int routingLayer = getStartLayer ( m_startItem ); + frame->SetActiveLayer( ToLAYER_ID ( routingLayer ) ); + // fixme: switch on invisible layer if( m_startItem && m_startItem->Net() >= 0 ) { @@ -553,7 +626,13 @@ void ROUTER_TOOL::performRouting() ctls->ForceCursorPosition( false ); ctls->SetAutoPan( true ); - m_router->StartRouting( m_startSnapPoint, m_startItem ); + PNS_SIZES_SETTINGS sizes; + sizes.Init ( board, m_startItem ); + sizes.AddLayerPair ( frame->GetScreen()->m_Route_Layer_TOP, + frame->GetScreen()->m_Route_Layer_BOTTOM ); + m_router->UpdateSizes( sizes ); + + m_router->StartRouting( m_startSnapPoint, m_startItem, routingLayer ); m_endItem = NULL; m_endSnapPoint = m_startSnapPoint; @@ -575,10 +654,16 @@ void ROUTER_TOOL::performRouting() else if( evt->IsClick( BUT_LEFT ) ) { updateEndItem( *evt ); + bool needLayerSwitch = m_router->IsPlacingVia(); if( m_router->FixRoute( m_endSnapPoint, m_endItem ) ) break; + if(needLayerSwitch) + { + switchLayerOnViaPlacement(); + } + // Synchronize the indicated layer frame->SetActiveLayer( ToLAYER_ID( m_router->GetCurrentLayer() ) ); @@ -586,24 +671,15 @@ void ROUTER_TOOL::performRouting() } else if( evt->IsAction( &ACT_PlaceThroughVia ) ) { - m_router->Settings().SetLayerPair( frame->GetScreen()->m_Route_Layer_TOP, - frame->GetScreen()->m_Route_Layer_BOTTOM ); - m_router->ToggleViaPlacement( VIA_THROUGH ); - m_router->Move( m_endSnapPoint, m_endItem ); // refresh + onViaCommand ( VIA_THROUGH ); } else if( evt->IsAction( &ACT_PlaceBlindVia ) ) { - m_router->Settings().SetLayerPair( frame->GetScreen()->m_Route_Layer_TOP, - frame->GetScreen()->m_Route_Layer_BOTTOM ); - m_router->ToggleViaPlacement( VIA_BLIND_BURIED ); - m_router->Move( m_endSnapPoint, m_endItem ); // refresh + onViaCommand ( VIA_BLIND_BURIED ); } else if( evt->IsAction( &ACT_PlaceMicroVia ) ) { - m_router->Settings().SetLayerPair( frame->GetScreen()->m_Route_Layer_TOP, - frame->GetScreen()->m_Route_Layer_BOTTOM ); - m_router->ToggleViaPlacement( VIA_MICROVIA ); - m_router->Move( m_endSnapPoint, m_endItem ); // refresh + onViaCommand ( VIA_MICROVIA ); } else if( evt->IsAction( &ACT_SwitchPosture ) ) { @@ -649,26 +725,19 @@ void ROUTER_TOOL::performRouting() int ROUTER_TOOL::Main( TOOL_EVENT& aEvent ) { VIEW_CONTROLS* ctls = getViewControls(); + PCB_EDIT_FRAME* frame = getEditFrame(); BOARD* board = getModel(); - BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings(); // Deselect all items m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true ); - getEditFrame()->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, - _( "Interactive Router" ) ); + frame->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Interactive Router" ) ); ctls->SetSnapping( true ); ctls->ShowCursor( true ); - // Set current track widths & via size - m_router->Settings().SetTrackWidth( bds.GetCurrentTrackWidth() ); - m_router->Settings().SetViaDiameter( bds.GetCurrentViaSize() ); - m_router->Settings().SetViaDrill( bds.GetCurrentViaDrill() ); - - ROUTER_TOOL_MENU* ctxMenu = new ROUTER_TOOL_MENU( board ); - - SetContextMenu ( ctxMenu ); + std::auto_ptr ctxMenu ( new ROUTER_TOOL_MENU( board ) ); + SetContextMenu ( ctxMenu.get() ); // Main loop: keep receiving events while( OPT_TOOL_EVENT evt = Wait() ) @@ -704,11 +773,10 @@ int ROUTER_TOOL::Main( TOOL_EVENT& aEvent ) // Restore the default settings ctls->SetAutoPan( false ); ctls->ShowCursor( false ); - getEditFrame()->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString ); + frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString ); // Store routing settings till the next invocation m_settings = m_router->Settings(); - delete ctxMenu; return 0; } diff --git a/pcbnew/router/router_tool.h b/pcbnew/router/router_tool.h index 06dc75b7fe..fd98843c01 100644 --- a/pcbnew/router/router_tool.h +++ b/pcbnew/router/router_tool.h @@ -57,9 +57,12 @@ private: void updateEndItem( TOOL_EVENT& aEvent ); void getNetclassDimensions( int aNetCode, int& aWidth, int& aViaDiameter, int& aViaDrill ); - void handleCommonEvents( TOOL_EVENT& evt ); + int getStartLayer( const PNS_ITEM *aItem ); + void switchLayerOnViaPlacement(); + bool onViaCommand( VIATYPE_T aType ); + MSG_PANEL_ITEMS m_panelItems; PNS_ROUTER* m_router; From 4e67de5c15f12b1ba778de8bdbc4c3b470c19280 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Fri, 14 Nov 2014 19:17:01 +0100 Subject: [PATCH 02/10] P&S router bugfixes - fixed walkaround bug causing unwanted overlap/clearance violation when the first segment of trace being laid intersects the obstacle's hull at the same point twice (ie. goes in, turns around and goes out). - fixed placer bug not splitting the start segment after toggling via placement or changing trace width --- common/geometry/shape_line_chain.cpp | 13 ++++++++----- pcbnew/router/pns_line.cpp | 3 +++ pcbnew/router/pns_line_placer.cpp | 11 +++++++---- pcbnew/router/pns_line_placer.h | 1 + pcbnew/router/pns_walkaround.cpp | 12 +++++++++--- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/common/geometry/shape_line_chain.cpp b/common/geometry/shape_line_chain.cpp index e442fcd503..d5b974bb1e 100644 --- a/common/geometry/shape_line_chain.cpp +++ b/common/geometry/shape_line_chain.cpp @@ -150,10 +150,7 @@ int SHAPE_LINE_CHAIN::Split( const VECTOR2I& aP ) int ii = -1; int min_dist = 2; - ii = Find( aP ); - - if( ii >= 0 ) - return ii; + int found_index = Find( aP ); for( int s = 0; s < SegmentCount(); s++ ) { @@ -165,10 +162,16 @@ int SHAPE_LINE_CHAIN::Split( const VECTOR2I& aP ) if( dist < min_dist && seg.A != aP && seg.B != aP ) { min_dist = dist; - ii = s; + if(found_index < 0) + ii = s; + else if(s < found_index) + ii = s; } } + if( ii < 0 ) + ii = found_index; + if( ii >= 0 ) { m_points.insert( m_points.begin() + ii + 1, aP ); diff --git a/pcbnew/router/pns_line.cpp b/pcbnew/router/pns_line.cpp index cbf3a3e68e..d5494dc047 100644 --- a/pcbnew/router/pns_line.cpp +++ b/pcbnew/router/pns_line.cpp @@ -190,6 +190,9 @@ bool PNS_LINE::Walkaround( SHAPE_LINE_CHAIN aObstacle, SHAPE_LINE_CHAIN& aPre, line.Intersect( aObstacle, ips ); + aWalk.Clear(); + aPost.Clear(); + int nearest_dist = INT_MAX; int farthest_dist = 0; diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index f56b66c793..0a57cea3b7 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -735,7 +735,8 @@ bool PNS_LINE_PLACER::SetLayer( int aLayer ) return false; } else if (!m_startItem || (m_startItem->OfKind(PNS_ITEM::VIA) && m_startItem->Layers().Overlaps( aLayer ))) { m_currentLayer = aLayer; - initPlacement ( ); + m_splitSeg = false; + initPlacement ( m_splitSeg ); Move ( m_currentEnd, NULL ); return true; } @@ -766,10 +767,11 @@ void PNS_LINE_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem ) m_startItem = aStartItem; m_placingVia = false; m_chainedPlacement = false; + m_splitSeg = splitSeg; setInitialDirection( Settings().InitialDirection() ); - initPlacement( splitSeg ); + initPlacement( m_splitSeg ); } void PNS_LINE_PLACER::initPlacement( bool aSplitSeg ) @@ -918,7 +920,8 @@ bool PNS_LINE_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem ) m_startItem = NULL; m_placingVia = false; m_chainedPlacement = !pl.EndsWithVia(); - initPlacement(); + m_splitSeg = false; + initPlacement( ); } else { m_idle = true; } @@ -1000,7 +1003,7 @@ void PNS_LINE_PLACER::UpdateSizes( const PNS_SIZES_SETTINGS& aSizes ) m_sizes = aSizes; if( !m_idle ) { - initPlacement ( ); + initPlacement ( m_splitSeg ); Move ( m_currentEnd, NULL ); } } diff --git a/pcbnew/router/pns_line_placer.h b/pcbnew/router/pns_line_placer.h index 487dd1c99c..2c8aa010af 100644 --- a/pcbnew/router/pns_line_placer.h +++ b/pcbnew/router/pns_line_placer.h @@ -402,6 +402,7 @@ private: bool m_idle; bool m_chainedPlacement; + bool m_splitSeg; }; #endif // __PNS_LINE_PLACER_H diff --git a/pcbnew/router/pns_walkaround.cpp b/pcbnew/router/pns_walkaround.cpp index 071f762a32..d472d1ae95 100644 --- a/pcbnew/router/pns_walkaround.cpp +++ b/pcbnew/router/pns_walkaround.cpp @@ -57,7 +57,7 @@ PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::singleStep( PNS_LINE& aPath, VECTOR2I last = aPath.CPoint( -1 ); - if( ( current_obs->m_hull ).PointInside( last ) ) + if( ( current_obs->m_hull ).PointInside( last ) || ( current_obs->m_hull ).PointOnEdge( last ) ) { m_recursiveBlockageCount++; @@ -99,7 +99,10 @@ PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::singleStep( PNS_LINE& aPath, pnew.Append( path_walk[1] ); pnew.Append( path_post[1] ); - current_obs = nearestObstacle( PNS_LINE( aPath, path_post[1] ) ); + if(!path_post[1].PointCount() || !path_walk[1].PointCount()) + current_obs = nearestObstacle( PNS_LINE( aPath, path_pre[1] ) ); + else + current_obs = nearestObstacle( PNS_LINE( aPath, path_post[1] ) ); prev_recursive = false; } else @@ -108,7 +111,10 @@ PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::singleStep( PNS_LINE& aPath, pnew.Append( path_walk[0] ); pnew.Append( path_post[0] ); - current_obs = nearestObstacle( PNS_LINE( aPath, path_walk[0] ) ); + if(!path_post[0].PointCount() || !path_walk[0].PointCount()) + current_obs = nearestObstacle( PNS_LINE( aPath, path_pre[0] ) ); + else + current_obs = nearestObstacle( PNS_LINE( aPath, path_walk[0] ) ); if( !current_obs ) { From 4e280f065f44b37c43912a1f4834b6050c4dcd78 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Fri, 14 Nov 2014 19:17:52 +0100 Subject: [PATCH 03/10] P&S router: fixed shove force propagation incorrect issues causing improper via dragging. --- common/geometry/shape_collisions.cpp | 31 ++++++++++++++++++++-------- pcbnew/router/pns_shove.cpp | 4 ++-- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/common/geometry/shape_collisions.cpp b/common/geometry/shape_collisions.cpp index 677c9e1d6f..806a50244b 100644 --- a/common/geometry/shape_collisions.cpp +++ b/common/geometry/shape_collisions.cpp @@ -175,7 +175,7 @@ static inline bool Collide( const SHAPE_CIRCLE& aA, const SHAPE_SEGMENT& aSeg, i if( col && aNeedMTV ) { - aMTV = pushoutForce( aA, aSeg.GetSeg(), aClearance + aSeg.GetWidth() / 2); + aMTV = -pushoutForce( aA, aSeg.GetSeg(), aClearance + aSeg.GetWidth() / 2); } return col; } @@ -231,16 +231,28 @@ static inline bool Collide( const SHAPE_LINE_CHAIN& aA, const SHAPE_SEGMENT& aB, } -template bool -CollCase( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV ) +template +inline bool CollCase( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV ) { return Collide (*static_cast( aA ), *static_cast( aB ), aClearance, aNeedMTV, aMTV); } -bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV ) +template +inline bool CollCaseReversed ( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV ) { + bool rv = Collide (*static_cast( aB ), + *static_cast( aA ), + aClearance, aNeedMTV, aMTV); + if(rv && aNeedMTV) + aMTV = -aMTV; + return rv; +} + + +bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV ) +{ switch( aA->Type() ) { case SH_RECT: @@ -263,8 +275,8 @@ bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeed switch( aB->Type() ) { case SH_RECT: - return CollCase( aB, aA, aClearance, aNeedMTV, aMTV ); - + return CollCaseReversed( aA, aB, aClearance, aNeedMTV, aMTV ); + case SH_CIRCLE: return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); @@ -272,8 +284,9 @@ bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeed return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); case SH_SEGMENT: - return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); - default: + return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); + + default: break; } @@ -303,7 +316,7 @@ bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeed return CollCase( aB, aA, aClearance, aNeedMTV, aMTV ); case SH_CIRCLE: - return CollCase( aB, aA, aClearance, aNeedMTV, aMTV ); + return CollCaseReversed( aA, aB, aClearance, aNeedMTV, aMTV ); case SH_LINE_CHAIN: return CollCase( aB, aA, aClearance, aNeedMTV, aMTV ); diff --git a/pcbnew/router/pns_shove.cpp b/pcbnew/router/pns_shove.cpp index ed82b947bf..e5f4dfc46f 100644 --- a/pcbnew/router/pns_shove.cpp +++ b/pcbnew/router/pns_shove.cpp @@ -597,7 +597,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingVia (PNS_ITEM* aCurrent, PNS_VIA* { CollideShapes( aObstacleVia->Shape(), aCurrent->Shape(), clearance + PNS_HULL_MARGIN, true, mtvSolid ); - mtv = mtvSolid; + mtv = -mtvSolid; rank = aCurrent->Rank() + 10000; } @@ -924,7 +924,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveLines( const PNS_LINE& aCurrentHead ) if( m_newHead && st == SH_OK ) { st = SH_HEAD_MODIFIED; - Router()->DisplayDebugLine( m_newHead->CLine(), 3, 20000 ); + //Router()->DisplayDebugLine( m_newHead->CLine(), 3, 20000 ); } m_currentNode->RemoveByMarker( MK_HEAD ); From 33f3aca611cf7142c79c2589274e1a5757853cc4 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Fri, 14 Nov 2014 19:18:31 +0100 Subject: [PATCH 04/10] geometry: IsSolid() and Move() methods, segment overlap detection, some improvements in SHAPE_LINE_CHAIN class. --- common/geometry/shape_line_chain.cpp | 7 +++--- include/geometry/seg.h | 34 ++++++++++++++++++++++------ include/geometry/shape.h | 11 +++++++-- include/geometry/shape_circle.h | 9 ++++++++ include/geometry/shape_line_chain.h | 21 +++++++++++++++++ include/geometry/shape_rect.h | 10 ++++++++ include/geometry/shape_segment.h | 11 +++++++++ 7 files changed, 90 insertions(+), 13 deletions(-) diff --git a/common/geometry/shape_line_chain.cpp b/common/geometry/shape_line_chain.cpp index d5b974bb1e..d0437b41e5 100644 --- a/common/geometry/shape_line_chain.cpp +++ b/common/geometry/shape_line_chain.cpp @@ -29,16 +29,15 @@ using boost::optional; bool SHAPE_LINE_CHAIN::Collide( const VECTOR2I& aP, int aClearance ) const { - assert( false ); - - return false; + // fixme: ugly! + SEG s(aP, aP); + return this->Collide(s, aClearance); } bool SHAPE_LINE_CHAIN::Collide( const BOX2I& aBox, int aClearance ) const { assert( false ); - return false; } diff --git a/include/geometry/seg.h b/include/geometry/seg.h index af8161bb80..9c87ff478e 100644 --- a/include/geometry/seg.h +++ b/include/geometry/seg.h @@ -215,14 +215,34 @@ public: */ bool Collinear( const SEG& aSeg ) const { - ecoord qa1 = A.y - B.y; - ecoord qb1 = B.x - A.x; - ecoord qc1 = -qa1 * A.x - qb1 * A.y; - ecoord qa2 = aSeg.A.y - aSeg.B.y; - ecoord qb2 = aSeg.B.x - aSeg.A.x; - ecoord qc2 = -qa2 * aSeg.A.x - qb2 * aSeg.A.y; + ecoord qa = A.y - B.y; + ecoord qb = B.x - A.x; + ecoord qc = -qa * A.x - qb * A.y; - return ( qa1 == qa2 ) && ( qb1 == qb2 ) && ( qc1 == qc2 ); + ecoord d1 = std::abs( aSeg.A.x * qa + aSeg.A.y * qb + qc ); + ecoord d2 = std::abs( aSeg.B.x * qa + aSeg.B.y * qb + qc ); + + return ( d1 <= 1 && d2 <= 1 ); + } + + bool Overlaps ( const SEG& aSeg ) const + { + if( aSeg.A == aSeg.B ) // single point corner case + { + if(A == aSeg.A || B == aSeg.A) + return false; + + return Contains(aSeg.A); + } + + if( !Collinear (aSeg )) + return false; + + if ( Contains (aSeg.A) || Contains(aSeg.B) ) + return true; + if ( aSeg.Contains (A) || aSeg.Contains(B) ) + return true; + return false; } /** diff --git a/include/geometry/shape.h b/include/geometry/shape.h index 7ba77b671b..25f242b054 100644 --- a/include/geometry/shape.h +++ b/include/geometry/shape.h @@ -40,7 +40,10 @@ enum SHAPE_TYPE SH_RECT = 0, ///> axis-aligned rectangle SH_SEGMENT, ///> line segment SH_LINE_CHAIN, ///> line chain (polyline) - SH_CIRCLE ///> circle + SH_CIRCLE, ///> circle + SH_CONVEX, ///> convex polygon + SH_POLYGON, ///> any polygon (with holes, etc.) + SH_COMPOUND ///> compound shape, consisting of multiple simple shapes }; /** @@ -146,7 +149,11 @@ public: return BBox( 0 ).Centre(); // if nothing better is available.... } -private: + virtual void Move ( const VECTOR2I& aVector ) = 0; + + virtual bool IsSolid() const = 0; + +protected: ///> type of our shape SHAPE_TYPE m_type; }; diff --git a/include/geometry/shape_circle.h b/include/geometry/shape_circle.h index e4b668b68c..2408c72ba8 100644 --- a/include/geometry/shape_circle.h +++ b/include/geometry/shape_circle.h @@ -86,6 +86,15 @@ public: return m_center; } + void Move ( const VECTOR2I& aVector ) + { + m_center += aVector; + } + + bool IsSolid() const + { + return true; + } private: int m_radius; VECTOR2I m_center; diff --git a/include/geometry/shape_line_chain.h b/include/geometry/shape_line_chain.h index 8c9c549d98..13ff6cd7c6 100644 --- a/include/geometry/shape_line_chain.h +++ b/include/geometry/shape_line_chain.h @@ -103,6 +103,17 @@ public: m_points[2] = aC; } + SHAPE_LINE_CHAIN( const VECTOR2I& aA, const VECTOR2I& aB, const VECTOR2I& aC, const VECTOR2I& aD ) : + SHAPE( SH_LINE_CHAIN ), m_closed( false ) + { + m_points.resize( 4 ); + m_points[0] = aA; + m_points[1] = aB; + m_points[2] = aC; + m_points[3] = aD; + } + + SHAPE_LINE_CHAIN(const VECTOR2I* aV, int aCount ) : SHAPE( SH_LINE_CHAIN ), m_closed( false ) @@ -553,6 +564,16 @@ public: bool CompareGeometry( const SHAPE_LINE_CHAIN & aOther ) const; + void Move ( const VECTOR2I& aVector ) + { + for(std::vector::iterator i = m_points.begin(); i != m_points.end(); ++i) + (*i) += aVector; + } + + bool IsSolid() const + { + return false; + } private: /// array of vertices std::vector m_points; diff --git a/include/geometry/shape_rect.h b/include/geometry/shape_rect.h index bc3ba44d17..7b16df89e8 100644 --- a/include/geometry/shape_rect.h +++ b/include/geometry/shape_rect.h @@ -159,6 +159,16 @@ public: return m_h; } + void Move ( const VECTOR2I& aVector ) + { + m_p0 += aVector; + } + + bool IsSolid() const + { + return true; + } + private: ///> Top-left corner VECTOR2I m_p0; diff --git a/include/geometry/shape_segment.h b/include/geometry/shape_segment.h index 5f18760bd7..203c8485a2 100644 --- a/include/geometry/shape_segment.h +++ b/include/geometry/shape_segment.h @@ -82,6 +82,17 @@ public: return m_width; } + bool IsSolid() const + { + return true; + } + + void Move ( const VECTOR2I& aVector ) + { + m_seg.A += aVector; + m_seg.B += aVector; + } + private: SEG m_seg; int m_width; From 7721d02afe0c81f01103565dbd61b29d3874a5f4 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Fri, 14 Nov 2014 19:19:08 +0100 Subject: [PATCH 05/10] gal/stroke_font: made text vertical alignment follow the non-GAL renderer. --- common/gal/stroke_font.cpp | 39 +++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/common/gal/stroke_font.cpp b/common/gal/stroke_font.cpp index 31441f5776..380f7e3dd8 100644 --- a/common/gal/stroke_font.cpp +++ b/common/gal/stroke_font.cpp @@ -98,7 +98,8 @@ bool STROKE_FONT::LoadNewStrokeFont( const char* const aNewStrokeFont[], int aNe // Every coordinate description of the Hershey format has an offset, // it has to be subtracted point.x = (double) ( coordinate[0] - 'R' ) * HERSHEY_SCALE - glyphStartX; - point.y = (double) ( coordinate[1] - 'R' ) * HERSHEY_SCALE; + // -10 is here to keep GAL rendering consistent with the legacy gfx stuff + point.y = (double) ( coordinate[1] - 'R' - 10) * HERSHEY_SCALE; pointList.push_back( point ); } @@ -160,28 +161,44 @@ void STROKE_FONT::Draw( const UTF8& aText, const VECTOR2D& aPosition, double aRo m_gal->Rotate( -aRotationAngle ); // Single line height - int lineHeight = getInterline(); - - // The overall height of all lines of text - double textBlockHeight = lineHeight * ( linesCount( aText ) - 1 ); - + int lineHeight = getInterline( ); + int lineCount = linesCount( aText ); + + // align the 1st line of text switch( m_verticalJustify ) { + case GR_TEXT_VJUSTIFY_TOP: + m_gal->Translate( VECTOR2D( 0, m_glyphSize.y ) ); + break; + case GR_TEXT_VJUSTIFY_CENTER: - m_gal->Translate( VECTOR2D( 0, -textBlockHeight / 2.0 ) ); + m_gal->Translate( VECTOR2D( 0, m_glyphSize.y / 2.0 ) ); break; case GR_TEXT_VJUSTIFY_BOTTOM: - m_gal->Translate( VECTOR2D( 0, -textBlockHeight ) ); - break; - - case GR_TEXT_VJUSTIFY_TOP: break; default: break; } + if( lineCount > 1 ) + { + switch( m_verticalJustify ) + { + case GR_TEXT_VJUSTIFY_TOP: + break; + + case GR_TEXT_VJUSTIFY_CENTER: + m_gal->Translate( VECTOR2D(0, -( lineCount - 1 ) * lineHeight / 2) ); + break; + + case GR_TEXT_VJUSTIFY_BOTTOM: + m_gal->Translate( VECTOR2D(0, -( lineCount - 1 ) * lineHeight ) ); + break; + } + } + m_gal->SetIsStroke( true ); m_gal->SetIsFill( false ); From 9245b9039200828a56d3b7540ae48b2fb04581f2 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Fri, 14 Nov 2014 20:19:00 +0100 Subject: [PATCH 06/10] Code formatting. --- common/geometry/shape_line_chain.cpp | 22 ++-- include/geometry/seg.h | 25 +++-- include/geometry/shape.h | 6 +- include/geometry/shape_circle.h | 4 +- include/geometry/shape_line_chain.h | 6 +- include/geometry/shape_rect.h | 6 +- include/geometry/shape_segment.h | 98 ++++++++--------- pcbnew/pcb_painter.cpp | 2 +- pcbnew/router/pns_dragger.cpp | 126 ++++++++++----------- pcbnew/router/pns_itemset.cpp | 10 +- pcbnew/router/pns_itemset.h | 42 +++---- pcbnew/router/pns_joint.h | 41 ++++--- pcbnew/router/pns_line.cpp | 4 +- pcbnew/router/pns_line_placer.cpp | 98 ++++++++--------- pcbnew/router/pns_line_placer.h | 46 ++++---- pcbnew/router/pns_router.cpp | 11 +- pcbnew/router/pns_router.h | 2 +- pcbnew/router/pns_routing_settings.h | 40 +++---- pcbnew/router/pns_shove.cpp | 153 +++++++++++++------------- pcbnew/router/pns_shove.h | 18 +-- pcbnew/router/pns_sizes_settings.h | 2 +- pcbnew/router/pns_via.h | 2 +- pcbnew/router/pns_walkaround.cpp | 10 +- pcbnew/router/pns_walkaround.h | 2 +- pcbnew/router/router_preview_item.cpp | 12 +- pcbnew/router/router_tool.cpp | 42 +++---- pcbnew/router/router_tool.h | 6 +- 27 files changed, 419 insertions(+), 417 deletions(-) diff --git a/common/geometry/shape_line_chain.cpp b/common/geometry/shape_line_chain.cpp index d0437b41e5..70a7939330 100644 --- a/common/geometry/shape_line_chain.cpp +++ b/common/geometry/shape_line_chain.cpp @@ -29,9 +29,9 @@ using boost::optional; bool SHAPE_LINE_CHAIN::Collide( const VECTOR2I& aP, int aClearance ) const { - // fixme: ugly! - SEG s(aP, aP); - return this->Collide(s, aClearance); + // fixme: ugly! + SEG s( aP, aP ); + return this->Collide( s, aClearance ); } @@ -161,9 +161,9 @@ int SHAPE_LINE_CHAIN::Split( const VECTOR2I& aP ) if( dist < min_dist && seg.A != aP && seg.B != aP ) { min_dist = dist; - if(found_index < 0) + if( found_index < 0 ) ii = s; - else if(s < found_index) + else if( s < found_index ) ii = s; } } @@ -521,25 +521,27 @@ const std::string SHAPE_LINE_CHAIN::Format() const bool SHAPE_LINE_CHAIN::CompareGeometry ( const SHAPE_LINE_CHAIN & aOther ) const { - SHAPE_LINE_CHAIN a(*this), b(aOther); + SHAPE_LINE_CHAIN a(*this), b( aOther ); a.Simplify(); b.Simplify(); - if(a.m_points.size() != b.m_points.size()) + if( a.m_points.size() != b.m_points.size() ) return false; - for(int i = 0; i < a.PointCount(); i++) - if(a.CPoint(i) != b.CPoint(i)) + for( int i = 0; i < a.PointCount(); i++) + if( a.CPoint( i ) != b.CPoint( i ) ) return false; return true; } + bool SHAPE_LINE_CHAIN::Intersects( const SHAPE_LINE_CHAIN& aChain ) const { INTERSECTIONS dummy; - return Intersect(aChain, dummy) != 0; + return Intersect( aChain, dummy ) != 0; } + SHAPE* SHAPE_LINE_CHAIN::Clone() const { return new SHAPE_LINE_CHAIN( *this ); diff --git a/include/geometry/seg.h b/include/geometry/seg.h index 9c87ff478e..43ceec3b41 100644 --- a/include/geometry/seg.h +++ b/include/geometry/seg.h @@ -52,7 +52,7 @@ public: /** Default constructor * Creates an empty (0, 0) segment, locally-referenced */ - SEG() + SEG() { m_index = -1; } @@ -61,8 +61,8 @@ public: * Constructor * Creates a segment between (aX1, aY1) and (aX2, aY2), locally referenced */ - SEG( int aX1, int aY1, int aX2, int aY2 ) : - A ( VECTOR2I( aX1, aY1 ) ), + SEG( int aX1, int aY1, int aX2, int aY2 ) : + A ( VECTOR2I( aX1, aY1 ) ), B ( VECTOR2I( aX2, aY2 ) ) { m_index = -1; @@ -84,7 +84,7 @@ public: * @param aB reference to the end point in the parent shape * @param aIndex index of the segment within the parent shape */ - SEG ( const VECTOR2I& aA, const VECTOR2I& aB, int aIndex ) : A( aA ), B( aB ) + SEG( const VECTOR2I& aA, const VECTOR2I& aB, int aIndex ) : A( aA ), B( aB ) { m_index = aIndex; } @@ -92,7 +92,7 @@ public: /** * Copy constructor */ - SEG ( const SEG& aSeg ) : A( aSeg.A ), B( aSeg.B ), m_index ( aSeg.m_index ) + SEG( const SEG& aSeg ) : A( aSeg.A ), B( aSeg.B ), m_index( aSeg.m_index ) { } @@ -101,7 +101,7 @@ public: A = aSeg.A; B = aSeg.B; m_index = aSeg.m_index; - + return *this; } @@ -225,23 +225,24 @@ public: return ( d1 <= 1 && d2 <= 1 ); } - bool Overlaps ( const SEG& aSeg ) const + bool Overlaps( const SEG& aSeg ) const { if( aSeg.A == aSeg.B ) // single point corner case { - if(A == aSeg.A || B == aSeg.A) + if( A == aSeg.A || B == aSeg.A ) return false; - return Contains(aSeg.A); + return Contains( aSeg.A ); } - if( !Collinear (aSeg )) + if( !Collinear( aSeg ) ) return false; - if ( Contains (aSeg.A) || Contains(aSeg.B) ) + if( Contains( aSeg.A ) || Contains( aSeg.B ) ) return true; - if ( aSeg.Contains (A) || aSeg.Contains(B) ) + if( aSeg.Contains( A ) || aSeg.Contains( B ) ) return true; + return false; } diff --git a/include/geometry/shape.h b/include/geometry/shape.h index 25f242b054..2746a178ab 100644 --- a/include/geometry/shape.h +++ b/include/geometry/shape.h @@ -41,7 +41,7 @@ enum SHAPE_TYPE SH_SEGMENT, ///> line segment SH_LINE_CHAIN, ///> line chain (polyline) SH_CIRCLE, ///> circle - SH_CONVEX, ///> convex polygon + SH_CONVEX, ///> convex polygon SH_POLYGON, ///> any polygon (with holes, etc.) SH_COMPOUND ///> compound shape, consisting of multiple simple shapes }; @@ -63,7 +63,7 @@ public: * Creates an empty shape of type aType */ - SHAPE ( SHAPE_TYPE aType ) : m_type( aType ) + SHAPE( SHAPE_TYPE aType ) : m_type( aType ) {} // Destructor @@ -152,7 +152,7 @@ public: virtual void Move ( const VECTOR2I& aVector ) = 0; virtual bool IsSolid() const = 0; - + protected: ///> type of our shape SHAPE_TYPE m_type; diff --git a/include/geometry/shape_circle.h b/include/geometry/shape_circle.h index 2408c72ba8..700f61d860 100644 --- a/include/geometry/shape_circle.h +++ b/include/geometry/shape_circle.h @@ -38,7 +38,7 @@ public: SHAPE( SH_CIRCLE ), m_radius( aRadius ), m_center( aCenter ) {} - SHAPE_CIRCLE ( const SHAPE_CIRCLE& aOther ) : + SHAPE_CIRCLE( const SHAPE_CIRCLE& aOther ) : SHAPE( SH_CIRCLE ), m_radius( aOther.m_radius ), m_center( aOther.m_center ) @@ -86,7 +86,7 @@ public: return m_center; } - void Move ( const VECTOR2I& aVector ) + void Move( const VECTOR2I& aVector ) { m_center += aVector; } diff --git a/include/geometry/shape_line_chain.h b/include/geometry/shape_line_chain.h index 13ff6cd7c6..3224c6487b 100644 --- a/include/geometry/shape_line_chain.h +++ b/include/geometry/shape_line_chain.h @@ -114,7 +114,7 @@ public: } - SHAPE_LINE_CHAIN(const VECTOR2I* aV, int aCount ) : + SHAPE_LINE_CHAIN( const VECTOR2I* aV, int aCount ) : SHAPE( SH_LINE_CHAIN ), m_closed( false ) { @@ -564,9 +564,9 @@ public: bool CompareGeometry( const SHAPE_LINE_CHAIN & aOther ) const; - void Move ( const VECTOR2I& aVector ) + void Move( const VECTOR2I& aVector ) { - for(std::vector::iterator i = m_points.begin(); i != m_points.end(); ++i) + for( std::vector::iterator i = m_points.begin(); i != m_points.end(); ++i ) (*i) += aVector; } diff --git a/include/geometry/shape_rect.h b/include/geometry/shape_rect.h index 7b16df89e8..43bc3c5e01 100644 --- a/include/geometry/shape_rect.h +++ b/include/geometry/shape_rect.h @@ -57,7 +57,7 @@ public: SHAPE( SH_RECT ), m_p0( aP0 ), m_w( aW ), m_h( aH ) {} - SHAPE_RECT ( const SHAPE_RECT& aOther ) : + SHAPE_RECT( const SHAPE_RECT& aOther ) : SHAPE( SH_RECT ), m_p0( aOther.m_p0 ), m_w( aOther.m_w ), @@ -159,7 +159,7 @@ public: return m_h; } - void Move ( const VECTOR2I& aVector ) + void Move( const VECTOR2I& aVector ) { m_p0 += aVector; } @@ -168,7 +168,7 @@ public: { return true; } - + private: ///> Top-left corner VECTOR2I m_p0; diff --git a/include/geometry/shape_segment.h b/include/geometry/shape_segment.h index 203c8485a2..6dc3adea2f 100644 --- a/include/geometry/shape_segment.h +++ b/include/geometry/shape_segment.h @@ -31,71 +31,71 @@ class SHAPE_SEGMENT : public SHAPE { public: - SHAPE_SEGMENT(): - SHAPE( SH_SEGMENT ), m_width( 0 ) {}; - - SHAPE_SEGMENT( const VECTOR2I& aA, const VECTOR2I& aB, int aWidth = 0 ): - SHAPE( SH_SEGMENT ), m_seg( aA, aB ), m_width( aWidth ) {}; + SHAPE_SEGMENT(): + SHAPE( SH_SEGMENT ), m_width( 0 ) {}; - SHAPE_SEGMENT( const SEG& aSeg, int aWidth = 0 ): - SHAPE( SH_SEGMENT ), m_seg( aSeg ), m_width( aWidth ) {}; + SHAPE_SEGMENT( const VECTOR2I& aA, const VECTOR2I& aB, int aWidth = 0 ): + SHAPE( SH_SEGMENT ), m_seg( aA, aB ), m_width( aWidth ) {}; - ~SHAPE_SEGMENT() {}; + SHAPE_SEGMENT( const SEG& aSeg, int aWidth = 0 ): + SHAPE( SH_SEGMENT ), m_seg( aSeg ), m_width( aWidth ) {}; + + ~SHAPE_SEGMENT() {}; SHAPE* Clone() const { return new SHAPE_SEGMENT( m_seg, m_width ); } - const BOX2I BBox( int aClearance = 0 ) const - { - return BOX2I( m_seg.A, m_seg.B - m_seg.A ).Inflate( aClearance + m_width / 2 ); - } + const BOX2I BBox( int aClearance = 0 ) const + { + return BOX2I( m_seg.A, m_seg.B - m_seg.A ).Inflate( aClearance + m_width / 2 ); + } - bool Collide( const SEG& aSeg, int aClearance = 0 ) const - { - return m_seg.Distance( aSeg ) <= m_width / 2 + aClearance; - } + bool Collide( const SEG& aSeg, int aClearance = 0 ) const + { + return m_seg.Distance( aSeg ) <= m_width / 2 + aClearance; + } - bool Collide( const VECTOR2I& aP, int aClearance = 0 ) const - { - return m_seg.Distance( aP ) <= m_width / 2 + aClearance; - } - - void SetSeg ( const SEG& aSeg ) - { - m_seg = aSeg; - } - - const SEG& GetSeg () const - { - return m_seg; - } + bool Collide( const VECTOR2I& aP, int aClearance = 0 ) const + { + return m_seg.Distance( aP ) <= m_width / 2 + aClearance; + } - void SetWidth ( int aWidth ) - { - m_width = aWidth; - } + void SetSeg( const SEG& aSeg ) + { + m_seg = aSeg; + } - int GetWidth() const - { - return m_width; - } + const SEG& GetSeg() const + { + return m_seg; + } - bool IsSolid() const - { - return true; - } + void SetWidth( int aWidth ) + { + m_width = aWidth; + } - void Move ( const VECTOR2I& aVector ) - { - m_seg.A += aVector; - m_seg.B += aVector; - } + int GetWidth() const + { + return m_width; + } + + bool IsSolid() const + { + return true; + } + + void Move( const VECTOR2I& aVector ) + { + m_seg.A += aVector; + m_seg.B += aVector; + } private: - SEG m_seg; - int m_width; + SEG m_seg; + int m_width; }; #endif diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index d339e0c7b0..b83fab28f8 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -387,7 +387,7 @@ void PCB_PAINTER::draw( const VIA* aVia, int aLayer ) else { double width = ( aVia->GetWidth() - aVia->GetDrillValue() ) / 2.0; - + m_gal->SetLineWidth( width ); m_gal->SetIsFill( true ); m_gal->SetIsStroke( false ); diff --git a/pcbnew/router/pns_dragger.cpp b/pcbnew/router/pns_dragger.cpp index f1fe58c8d9..f369686919 100644 --- a/pcbnew/router/pns_dragger.cpp +++ b/pcbnew/router/pns_dragger.cpp @@ -25,7 +25,7 @@ #include "pns_router.h" PNS_DRAGGER::PNS_DRAGGER( PNS_ROUTER* aRouter ) : - PNS_ALGO_BASE ( aRouter ) + PNS_ALGO_BASE( aRouter ) { m_world = NULL; m_shove = NULL; @@ -39,7 +39,7 @@ PNS_DRAGGER::~PNS_DRAGGER() } -void PNS_DRAGGER::SetWorld ( PNS_NODE* aWorld ) +void PNS_DRAGGER::SetWorld( PNS_NODE* aWorld ) { m_world = aWorld; } @@ -49,7 +49,7 @@ bool PNS_DRAGGER::startDragSegment( const VECTOR2D& aP, PNS_SEGMENT* aSeg ) { int w2 = aSeg->Width() / 2; - m_draggedLine = m_world->AssembleLine ( aSeg, &m_draggedSegmentIndex ); + m_draggedLine = m_world->AssembleLine( aSeg, &m_draggedSegmentIndex ); m_shove->SetInitialLine( m_draggedLine ); m_lastValidDraggedLine = *m_draggedLine; m_lastValidDraggedLine.ClearSegmentLinks(); @@ -58,9 +58,9 @@ bool PNS_DRAGGER::startDragSegment( const VECTOR2D& aP, PNS_SEGMENT* aSeg ) m_mode = CORNER; else if( ( aP - aSeg->Seg().B ).EuclideanNorm() <= w2 ) { - m_draggedSegmentIndex ++; + m_draggedSegmentIndex++; m_mode = CORNER; - } else + } else m_mode = SEGMENT; return true; @@ -74,14 +74,14 @@ bool PNS_DRAGGER::startDragVia( const VECTOR2D& aP, PNS_VIA* aVia ) m_mode = VIA; VECTOR2I p0( aVia->Pos() ); - PNS_JOINT *jt = m_world->FindJoint( p0, aVia->Layers().Start(), aVia->Net() ); + PNS_JOINT* jt = m_world->FindJoint( p0, aVia->Layers().Start(), aVia->Net() ); - BOOST_FOREACH(PNS_ITEM *item, jt->LinkList() ) + BOOST_FOREACH( PNS_ITEM* item, jt->LinkList() ) { if( item->OfKind( PNS_ITEM::SEGMENT ) ) { int segIndex; - PNS_SEGMENT* seg = (PNS_SEGMENT*) item; + PNS_SEGMENT* seg = ( PNS_SEGMENT*) item; std::auto_ptr l( m_world->AssembleLine( seg, &segIndex ) ); if( segIndex != 0 ) @@ -97,29 +97,29 @@ bool PNS_DRAGGER::startDragVia( const VECTOR2D& aP, PNS_VIA* aVia ) bool PNS_DRAGGER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem ) { - m_shove = new PNS_SHOVE( m_world, Router() ); + m_shove = new PNS_SHOVE( m_world, Router() ); m_lastNode = NULL; m_draggedItems.Clear(); m_currentMode = Settings().Mode(); TRACE( 2, "StartDragging: item %p [kind %d]", aStartItem % aStartItem->Kind() ); - switch( aStartItem->Kind() ) - { - case PNS_ITEM::SEGMENT: - return startDragSegment ( aP, static_cast( aStartItem ) ); + switch( aStartItem->Kind() ) + { + case PNS_ITEM::SEGMENT: + return startDragSegment( aP, static_cast( aStartItem ) ); - case PNS_ITEM::VIA: - return startDragVia ( aP, static_cast (aStartItem) ); + case PNS_ITEM::VIA: + return startDragVia( aP, static_cast( aStartItem ) ); - default: - return false; - } + default: + return false; + } } bool PNS_DRAGGER::dragMarkObstacles( const VECTOR2I& aP ) -{ +{ if( m_lastNode ) { delete m_lastNode; @@ -133,20 +133,20 @@ bool PNS_DRAGGER::dragMarkObstacles( const VECTOR2I& aP ) { int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine->Width() / 4 : 0; PNS_LINE tmp( *m_draggedLine ); - + if( m_mode == SEGMENT ) - tmp.DragSegment ( aP, m_draggedSegmentIndex, thresh ); + tmp.DragSegment( aP, m_draggedSegmentIndex, thresh ); else - tmp.DragCorner ( aP, m_draggedSegmentIndex, thresh ); - + tmp.DragCorner( aP, m_draggedSegmentIndex, thresh ); + m_lastNode = m_shove->CurrentNode()->Branch(); m_lastValidDraggedLine = tmp; m_lastValidDraggedLine.ClearSegmentLinks(); m_lastValidDraggedLine.Unmark(); - - m_lastNode->Add ( &m_lastValidDraggedLine ); - m_draggedItems = PNS_ITEMSET ( &m_lastValidDraggedLine ); + + m_lastNode->Add( &m_lastValidDraggedLine ); + m_draggedItems = PNS_ITEMSET( &m_lastValidDraggedLine ); break; } @@ -154,7 +154,7 @@ bool PNS_DRAGGER::dragMarkObstacles( const VECTOR2I& aP ) case VIA: // fixme... { m_lastNode = m_shove->CurrentNode()->Branch(); - dumbDragVia ( m_initialVia, m_lastNode, aP ); + dumbDragVia( m_initialVia, m_lastNode, aP ); break; } @@ -164,7 +164,7 @@ bool PNS_DRAGGER::dragMarkObstacles( const VECTOR2I& aP ) m_dragStatus = true; else m_dragStatus = !m_world->CheckColliding( m_draggedItems ); - + return true; } @@ -176,20 +176,20 @@ void PNS_DRAGGER::dumbDragVia( PNS_VIA* aVia, PNS_NODE* aNode, const VECTOR2I& a m_draggedVia->SetPos( aP ); m_draggedItems.Clear(); m_draggedItems.Add( m_draggedVia ); - + m_lastNode->Remove( aVia ); m_lastNode->Add( m_draggedVia ); BOOST_FOREACH( PNS_LINE &l, m_origViaConnections ) { - PNS_LINE origLine (l); + PNS_LINE origLine( l ); PNS_LINE* draggedLine = l.Clone(); - + draggedLine->DragCorner( aP, 0 ); draggedLine->ClearSegmentLinks(); m_draggedItems.Add( draggedLine ); // FIXME: mem leak - + m_lastNode->Remove( &origLine ); m_lastNode->Add( draggedLine ); } @@ -208,43 +208,43 @@ bool PNS_DRAGGER::dragShove( const VECTOR2I& aP ) switch( m_mode ) { - case SEGMENT: - case CORNER: - { - int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine->Width() / 4 : 0; - PNS_LINE tmp( *m_draggedLine ); + case SEGMENT: + case CORNER: + { + int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine->Width() / 4 : 0; + PNS_LINE tmp( *m_draggedLine ); + + if( m_mode == SEGMENT ) + tmp.DragSegment( aP, m_draggedSegmentIndex, thresh ); + else + tmp.DragCorner( aP, m_draggedSegmentIndex, thresh ); - if( m_mode == SEGMENT ) - tmp.DragSegment( aP, m_draggedSegmentIndex, thresh ); - else - tmp.DragCorner( aP, m_draggedSegmentIndex, thresh ); - PNS_SHOVE::SHOVE_STATUS st = m_shove->ShoveLines( tmp ); - + if( st == PNS_SHOVE::SH_OK ) - ok = true; + ok = true; else if( st == PNS_SHOVE::SH_HEAD_MODIFIED ) { tmp = m_shove->NewHead(); ok = true; - } + } m_lastNode = m_shove->CurrentNode()->Branch(); if( ok ) m_lastValidDraggedLine = tmp; - + m_lastValidDraggedLine.ClearSegmentLinks(); m_lastValidDraggedLine.Unmark(); m_lastNode->Add( &m_lastValidDraggedLine ); m_draggedItems = PNS_ITEMSET( &m_lastValidDraggedLine ); break; - } + } case VIA: - { - PNS_VIA *newVia; + { + PNS_VIA* newVia; PNS_SHOVE::SHOVE_STATUS st = m_shove->ShoveDraggingVia( m_draggedVia, aP, &newVia ); if( st == PNS_SHOVE::SH_OK || st == PNS_SHOVE::SH_HEAD_MODIFIED ) @@ -261,7 +261,7 @@ bool PNS_DRAGGER::dragShove( const VECTOR2I& aP ) break; } } - + m_dragStatus = ok; return ok; @@ -274,7 +274,7 @@ bool PNS_DRAGGER::FixRoute() { Router()->CommitRouting( CurrentNode() ); return true; - } + } return false; } @@ -282,23 +282,23 @@ bool PNS_DRAGGER::FixRoute() bool PNS_DRAGGER::Drag( const VECTOR2I& aP ) { - switch( m_currentMode ) - { - case RM_MarkObstacles: - return dragMarkObstacles( aP ); + switch( m_currentMode ) + { + case RM_MarkObstacles: + return dragMarkObstacles( aP ); - case RM_Shove: - case RM_Walkaround: - case RM_Smart: - return dragShove( aP ); + case RM_Shove: + case RM_Walkaround: + case RM_Smart: + return dragShove( aP ); - default: - return false; - } + default: + return false; + } } -PNS_NODE *PNS_DRAGGER::CurrentNode() const +PNS_NODE* PNS_DRAGGER::CurrentNode() const { return m_lastNode; } diff --git a/pcbnew/router/pns_itemset.cpp b/pcbnew/router/pns_itemset.cpp index 38165e6ccd..837f5e4ee5 100644 --- a/pcbnew/router/pns_itemset.cpp +++ b/pcbnew/router/pns_itemset.cpp @@ -24,8 +24,8 @@ PNS_ITEMSET::PNS_ITEMSET( PNS_ITEM* aInitialItem ) { - if(aInitialItem) - m_items.push_back(aInitialItem); + if( aInitialItem ) + m_items.push_back( aInitialItem ); } PNS_ITEMSET& PNS_ITEMSET::FilterLayers( int aStart, int aEnd, bool aInvert ) @@ -55,7 +55,7 @@ PNS_ITEMSET& PNS_ITEMSET::FilterKinds( int aKindMask, bool aInvert ) BOOST_FOREACH( PNS_ITEM* item, m_items ) { - if( item->OfKind ( aKindMask ) ^ aInvert ) + if( item->OfKind( aKindMask ) ^ aInvert ) newItems.push_back( item ); } @@ -71,7 +71,7 @@ PNS_ITEMSET& PNS_ITEMSET::FilterNet( int aNet, bool aInvert ) BOOST_FOREACH( PNS_ITEM* item, m_items ) { - if( (item->Net() == aNet) ^ aInvert ) + if( ( item->Net() == aNet ) ^ aInvert ) newItems.push_back( item ); } @@ -80,7 +80,7 @@ PNS_ITEMSET& PNS_ITEMSET::FilterNet( int aNet, bool aInvert ) return *this; } -PNS_ITEMSET& PNS_ITEMSET::ExcludeItem ( const PNS_ITEM *aItem ) +PNS_ITEMSET& PNS_ITEMSET::ExcludeItem( const PNS_ITEM* aItem ) { ITEMS newItems; diff --git a/pcbnew/router/pns_itemset.h b/pcbnew/router/pns_itemset.h index ec73f66177..d229fc017c 100644 --- a/pcbnew/router/pns_itemset.h +++ b/pcbnew/router/pns_itemset.h @@ -44,17 +44,17 @@ public: { m_items = aOther.m_items; } - + const PNS_ITEMSET& operator=( const PNS_ITEMSET& aOther ) { m_items = aOther.m_items; return *this; } - int Count(int aKindMask = -1) const + int Count( int aKindMask = -1 ) const { int n = 0; - BOOST_FOREACH ( PNS_ITEM *item, m_items ) + BOOST_FOREACH( PNS_ITEM* item, m_items ) { if( item->Kind() & aKindMask ) n++; @@ -76,32 +76,32 @@ public: PNS_ITEMSET& ExcludeKinds( int aKindMask ) { - return FilterKinds ( aKindMask, true ); + return FilterKinds( aKindMask, true ); } PNS_ITEMSET& ExcludeNet( int aNet ) { - return FilterNet ( aNet, true ); + return FilterNet( aNet, true ); } - PNS_ITEMSET& ExcludeItem ( const PNS_ITEM *aItem ); + PNS_ITEMSET& ExcludeItem( const PNS_ITEM* aItem ); - int Size() const - { - return m_items.size(); + int Size() const + { + return m_items.size(); } void Add( PNS_ITEM* aItem ) { - m_items.push_back ( aItem ); + m_items.push_back( aItem ); } - PNS_ITEM* Get( int index ) const - { - return m_items[index]; + PNS_ITEM* Get( int index ) const + { + return m_items[index]; } - PNS_ITEM* operator[] (int index ) const + PNS_ITEM* operator[] ( int index ) const { return m_items[index]; } @@ -111,19 +111,19 @@ public: m_items.clear(); } - bool Contains ( const PNS_ITEM *aItem ) const + bool Contains( const PNS_ITEM* aItem ) const { - return std::find ( m_items.begin(), m_items.end(), aItem ) != m_items.end(); + return std::find( m_items.begin(), m_items.end(), aItem ) != m_items.end(); } - - void Erase ( const PNS_ITEM *aItem ) + + void Erase( const PNS_ITEM* aItem ) { - ITEMS::iterator f = std::find (m_items.begin(), m_items.end(), aItem ); + ITEMS::iterator f = std::find( m_items.begin(), m_items.end(), aItem ); if( f != m_items.end() ) - m_items.erase ( f ); + m_items.erase( f ); } - + private: ITEMS m_items; }; diff --git a/pcbnew/router/pns_joint.h b/pcbnew/router/pns_joint.h index bb396d0c8c..43ca70daf0 100644 --- a/pcbnew/router/pns_joint.h +++ b/pcbnew/router/pns_joint.h @@ -72,7 +72,7 @@ public: m_layers = aB.m_layers; } - PNS_ITEM* Clone ( ) const + PNS_ITEM* Clone( ) const { assert( false ); return NULL; @@ -98,17 +98,17 @@ public: ///> Links the joint to a given board item (when it's added to the PNS_NODE) void Link( PNS_ITEM* aItem ) { - if (m_linkedItems.Contains( aItem )) + if( m_linkedItems.Contains( aItem ) ) return; - m_linkedItems.Add ( aItem ); + m_linkedItems.Add( aItem ); } ///> Unlinks a given board item from the joint (upon its removal from a PNS_NODE) ///> Returns true if the joint became dangling after unlinking. bool Unlink( PNS_ITEM* aItem ) { - m_linkedItems.Erase ( aItem ); + m_linkedItems.Erase( aItem ); return m_linkedItems.Size() == 0; } @@ -124,24 +124,24 @@ public: /// trivial accessors - const HASH_TAG& Tag() const - { - return m_tag; + const HASH_TAG& Tag() const + { + return m_tag; } - - const VECTOR2I& Pos() const - { - return m_tag.pos; + + const VECTOR2I& Pos() const + { + return m_tag.pos; } - - int Net() const - { - return m_tag.net; + + int Net() const + { + return m_tag.net; } - + const LINKED_ITEMS& LinkList() const - { - return m_linkedItems.CItems(); + { + return m_linkedItems.CItems(); } const PNS_ITEMSET& CLinks() const @@ -159,7 +159,6 @@ public: return m_linkedItems.Count( aMask ); } - void Dump() const; bool operator==( const PNS_JOINT& rhs ) const @@ -174,9 +173,9 @@ public: m_layers.Merge( aJoint.m_layers ); - BOOST_FOREACH ( PNS_ITEM *item, aJoint.LinkList() ) + BOOST_FOREACH( PNS_ITEM* item, aJoint.LinkList() ) { - m_linkedItems.Add (item); + m_linkedItems.Add( item ); } } diff --git a/pcbnew/router/pns_line.cpp b/pcbnew/router/pns_line.cpp index d5494dc047..c391f31a9e 100644 --- a/pcbnew/router/pns_line.cpp +++ b/pcbnew/router/pns_line.cpp @@ -123,7 +123,7 @@ int PNS_LINE::Marker()const } -void PNS_LINE::copyLinks( const PNS_LINE *aParent ) +void PNS_LINE::copyLinks( const PNS_LINE* aParent ) { if( aParent->m_segmentRefs == NULL ) { @@ -413,7 +413,7 @@ void PNS_LINE::DragCorner ( const VECTOR2I& aP, int aIndex, int aSnappingThresho if( aIndex == 0 ) path = dragCornerInternal( m_line.Reverse(), snapped ).Reverse(); - else if ( aIndex == m_line.SegmentCount() ) + else if( aIndex == m_line.SegmentCount() ) path = dragCornerInternal( m_line, snapped ); else { diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index 0a57cea3b7..093fbe6218 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -386,12 +386,12 @@ bool PNS_LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, PNS_LINE& aNewHead ) walkaround.SetSolidsOnly( false ); walkaround.SetIterationLimit( Settings().WalkaroundIterationLimit() ); - + PNS_WALKAROUND::WALKAROUND_STATUS wf = walkaround.Route( initTrack, walkFull, false ); switch( Settings().OptimizerEffort() ) { - case OE_LOW: + case OE_LOW: effort = 0; break; @@ -423,7 +423,7 @@ bool PNS_LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, PNS_LINE& aNewHead ) m_head = walkFull; aNewHead = walkFull; - + return rv; } @@ -431,14 +431,14 @@ bool PNS_LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, PNS_LINE& aNewHead ) bool PNS_LINE_PLACER::rhMarkObstacles( const VECTOR2I& aP, PNS_LINE& aNewHead ) { m_head.SetShape( m_direction.BuildInitialTrace( m_p_start, aP ) ); - + if( m_placingVia ) { m_head.AppendVia( makeVia ( m_head.CPoint( -1 ) ) ); } aNewHead = m_head; - + return m_currentNode->CheckColliding( &m_head ); } @@ -482,16 +482,16 @@ bool PNS_LINE_PLACER::rhShoveOnly ( const VECTOR2I& aP, PNS_LINE& aNewHead ) l2.AppendVia( v2 ); } - l.Line().Simplify(); + l.Line().Simplify(); // in certain, uncommon cases there may be loops in the head+tail, In such case, we don't shove to avoid // screwing up the database. if( l.HasLoops() ) { aNewHead = m_head; - return false; + return false; } - + PNS_SHOVE::SHOVE_STATUS status = m_shove->ShoveLines( l ); m_currentNode = m_shove->CurrentNode(); @@ -536,7 +536,7 @@ bool PNS_LINE_PLACER::routeHead( const VECTOR2I& aP, PNS_LINE& aNewHead ) default: break; } - + return false; } @@ -550,14 +550,14 @@ bool PNS_LINE_PLACER::optimizeTailHeadTransition() if( tmp.SegmentCount() < 1 ) return false; - m_head = tmp; + m_head = tmp; m_p_start = tmp.CLine().CPoint( 0 ); m_direction = DIRECTION_45( tmp.CSegment( 0 ) ); m_tail.Line().Clear(); return true; } - + SHAPE_LINE_CHAIN& head = m_head.Line(); SHAPE_LINE_CHAIN& tail = m_tail.Line(); @@ -676,9 +676,9 @@ const PNS_LINE PNS_LINE_PLACER::Trace() const } -const PNS_ITEMSET PNS_LINE_PLACER::Traces() +const PNS_ITEMSET PNS_LINE_PLACER::Traces() { - m_currentTrace = Trace(); + m_currentTrace = Trace(); return PNS_ITEMSET( &m_currentTrace ); } @@ -703,13 +703,13 @@ void PNS_LINE_PLACER::splitAdjacentSegments( PNS_NODE* aNode, PNS_ITEM* aSeg, co { if( aSeg && aSeg->OfKind( PNS_ITEM::SEGMENT ) ) { - PNS_JOINT *jt = aNode->FindJoint( aP, aSeg ); + PNS_JOINT* jt = aNode->FindJoint( aP, aSeg ); if( jt && jt->LinkCount() >= 1 ) return; PNS_SEGMENT* s_old = static_cast( aSeg ); - + PNS_SEGMENT* s_new[2]; s_new[0] = s_old->Clone(); @@ -727,13 +727,13 @@ void PNS_LINE_PLACER::splitAdjacentSegments( PNS_NODE* aNode, PNS_ITEM* aSeg, co bool PNS_LINE_PLACER::SetLayer( int aLayer ) { - if(m_idle) + if( m_idle ) { m_currentLayer = aLayer; return true; - } else if (m_chainedPlacement) { + } else if( m_chainedPlacement ) { return false; - } else if (!m_startItem || (m_startItem->OfKind(PNS_ITEM::VIA) && m_startItem->Layers().Overlaps( aLayer ))) { + } else if( !m_startItem || ( m_startItem->OfKind( PNS_ITEM::VIA ) && m_startItem->Layers().Overlaps( aLayer ) ) ) { m_currentLayer = aLayer; m_splitSeg = false; initPlacement ( m_splitSeg ); @@ -755,7 +755,7 @@ void PNS_LINE_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem ) if( Router()->SnappingEnabled() ) p = Router()->SnapToItem( aStartItem, aP, splitSeg ); - + if( !aStartItem || aStartItem->Net() < 0 ) net = unknowNetIdx--; else @@ -770,8 +770,8 @@ void PNS_LINE_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem ) m_splitSeg = splitSeg; setInitialDirection( Settings().InitialDirection() ); - - initPlacement( m_splitSeg ); + + initPlacement( m_splitSeg ); } void PNS_LINE_PLACER::initPlacement( bool aSplitSeg ) @@ -786,12 +786,12 @@ void PNS_LINE_PLACER::initPlacement( bool aSplitSeg ) m_tail.SetLayer( m_currentLayer ); m_head.SetWidth( m_sizes.TrackWidth() ); m_tail.SetWidth( m_sizes.TrackWidth() ); - + m_p_start = m_currentStart; m_direction = m_initial_direction; - PNS_NODE *world = Router()->GetWorld(); - + PNS_NODE* world = Router()->GetWorld(); + world->KillChildren(); PNS_NODE* rootNode = world->Branch(); @@ -799,23 +799,23 @@ void PNS_LINE_PLACER::initPlacement( bool aSplitSeg ) splitAdjacentSegments( rootNode, m_startItem, m_currentStart ); setWorld( rootNode ); - + TRACE( 1, "world %p, intitial-direction %s layer %d\n", m_world % m_direction.Format().c_str() % aLayer ); - - m_lastNode = NULL; + + m_lastNode = NULL; m_currentNode = m_world; m_currentMode = Settings().Mode(); if( m_shove ) delete m_shove; - + m_shove = NULL; if( m_currentMode == RM_Shove || m_currentMode == RM_Smart ) { m_shove = new PNS_SHOVE( m_world->Branch(), Router() ); - } + } } @@ -824,20 +824,20 @@ void PNS_LINE_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem ) PNS_LINE current; VECTOR2I p = aP; int eiDepth = -1; - + if( aEndItem && aEndItem->Owner() ) eiDepth = aEndItem->Owner()->Depth(); - + if( m_lastNode ) { delete m_lastNode; m_lastNode = NULL; } - + route( p ); current = Trace(); - + if( !current.PointCount() ) m_currentEnd = m_p_start; else @@ -845,14 +845,14 @@ void PNS_LINE_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem ) PNS_NODE* latestNode = m_currentNode; m_lastNode = latestNode->Branch(); - + if( eiDepth >= 0 && aEndItem && latestNode->Depth() > eiDepth && current.SegmentCount() && current.CPoint( -1 ) == aP ) { splitAdjacentSegments( m_lastNode, aEndItem, current.CPoint( -1 ) ); if( Settings().RemoveLoops() ) - removeLoops( m_lastNode, ¤t ); + removeLoops( m_lastNode, ¤t ); } updateLeadingRatLine(); @@ -863,7 +863,7 @@ bool PNS_LINE_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem ) { bool realEnd = false; int lastV; - + PNS_LINE pl = Trace(); if( m_currentMode == RM_MarkObstacles && @@ -908,9 +908,9 @@ bool PNS_LINE_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem ) if( realEnd ) simplifyNewLine( m_lastNode, lastSeg ); - + Router()->CommitRouting( m_lastNode ); - + m_lastNode = NULL; if( !realEnd ) @@ -921,7 +921,7 @@ bool PNS_LINE_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem ) m_placingVia = false; m_chainedPlacement = !pl.EndsWithVia(); m_splitSeg = false; - initPlacement( ); + initPlacement( ); } else { m_idle = true; } @@ -936,10 +936,10 @@ void PNS_LINE_PLACER::removeLoops( PNS_NODE* aNode, PNS_LINE* aLatest ) return; aNode->Add( aLatest, true ); - + for( int s = 0; s < aLatest->SegmentCount(); s++ ) { - PNS_SEGMENT *seg = ( *aLatest->LinkedSegments() )[s]; + PNS_SEGMENT* seg = ( *aLatest->LinkedSegments() )[s]; PNS_LINE* ourLine = aNode->AssembleLine( seg ); PNS_JOINT a, b; std::vector lines; @@ -950,7 +950,7 @@ void PNS_LINE_PLACER::removeLoops( PNS_NODE* aNode, PNS_LINE* aLatest ) { aNode->FindLineEnds( aLatest, a, b); } - + aNode->FindLinesBetweenJoints( a, b, lines ); int removedCount = 0; @@ -976,7 +976,7 @@ void PNS_LINE_PLACER::removeLoops( PNS_NODE* aNode, PNS_LINE* aLatest ) delete ourLine; } - + aNode->Remove( aLatest ); } @@ -991,8 +991,8 @@ void PNS_LINE_PLACER::simplifyNewLine( PNS_NODE* aNode, PNS_SEGMENT* aLatest ) if( simplified.PointCount() != l->PointCount() ) { std::auto_ptr lnew ( l->Clone() ); - aNode -> Remove(l); - lnew->SetShape(simplified); + aNode -> Remove( l ); + lnew->SetShape( simplified ); aNode -> Add( lnew.get() ); } } @@ -1012,21 +1012,21 @@ void PNS_LINE_PLACER::UpdateSizes( const PNS_SIZES_SETTINGS& aSizes ) void PNS_LINE_PLACER::updateLeadingRatLine() { PNS_LINE current = Trace(); - + if( !current.PointCount() ) return; std::auto_ptr tmpNode ( m_lastNode->Branch() ); tmpNode->Add( ¤t ); - PNS_JOINT *jt = tmpNode->FindJoint( current.CPoint( -1 ), + PNS_JOINT* jt = tmpNode->FindJoint( current.CPoint( -1 ), current.Layers().Start(), current.Net() ); if( !jt ) return; - + int anchor; - PNS_ITEM *it = tmpNode->NearestUnconnectedItem( jt, &anchor ); + PNS_ITEM* it = tmpNode->NearestUnconnectedItem( jt, &anchor ); if( it ) { diff --git a/pcbnew/router/pns_line_placer.h b/pcbnew/router/pns_line_placer.h index 2c8aa010af..1d603bd9b6 100644 --- a/pcbnew/router/pns_line_placer.h +++ b/pcbnew/router/pns_line_placer.h @@ -43,7 +43,7 @@ class PNS_SIZES_SETTINGS; /** * Class PNS_LINE_PLACER * - * Single track placement algorithm. Interactively routes a track. + * Single track placement algorithm. Interactively routes a track. * Applies shove and walkaround algorithms when needed. */ @@ -55,7 +55,7 @@ public: /** * Function Start() - * + * * Starts routing a single track at point aP, taking item aStartItem as anchor * (unless NULL). */ @@ -63,8 +63,8 @@ public: /** * Function Move() - * - * Moves the end of the currently routed trace to the point aP, taking + * + * Moves the end of the currently routed trace to the point aP, taking * aEndItem as anchor (if not NULL). * (unless NULL). */ @@ -72,7 +72,7 @@ public: /** * Function FixRoute() - * + * * Commits the currently routed track to the parent node, taking * aP as the final end point and aEndItem as the final anchor (if provided). * @return true, if route has been commited. May return false if the routing @@ -80,10 +80,10 @@ public: * if Settings.CanViolateDRC() is on. */ bool FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem ); - + /** * Function ToggleVia() - * + * * Enables/disables a via at the end of currently routed trace. */ void ToggleVia( bool aEnabled ); @@ -103,7 +103,7 @@ public: * that has not "settled" yet. */ const PNS_LINE& Head() const { return m_head; } - + /** * Function Tail() * @@ -131,7 +131,7 @@ public: * * Returns the current end of the line being placed. It may not be equal * to the cursor position due to collisions. - */ + */ const VECTOR2I& CurrentEnd() const { return m_currentEnd; @@ -141,8 +141,8 @@ public: * Function CurrentNet() * * Returns the net code of currently routed track. - */ - int CurrentNet() const + */ + int CurrentNet() const { return m_currentNet; } @@ -151,8 +151,8 @@ public: * Function CurrentLayer() * * Returns the layer of currently routed track. - */ - int CurrentLayer() const + */ + int CurrentLayer() const { return m_currentLayer; } @@ -163,14 +163,14 @@ public: * Returns the most recent world state. */ PNS_NODE* CurrentNode( bool aLoopsRemoved = false ) const; - + /** * Function FlipPosture() * * Toggles the current posture (straight/diagonal) of the trace head. */ void FlipPosture(); - + /** * Function UpdateSizes() * @@ -198,18 +198,18 @@ private: * Function updateLeadingRatLine() * * Draws the "leading" ratsnest line, which connects the end of currently - * routed track and the nearest yet unrouted item. If the routing for + * routed track and the nearest yet unrouted item. If the routing for * current net is complete, draws nothing. */ void updateLeadingRatLine(); - + /** * Function setWorld() * * Sets the board to route. */ void setWorld( PNS_NODE* aWorld ); - + /** * Function startPlacement() * @@ -245,10 +245,10 @@ private: * Function simplifyNewLine() * * Assembles a line starting from segment aLatest, removes collinear segments - * and redundant vertexes. If a simplification bhas been found, replaces the + * and redundant vertexes. If a simplification bhas been found, replaces the * old line with the simplified one in aNode. */ - void simplifyNewLine( PNS_NODE *aNode, PNS_SEGMENT *aLatest ); + void simplifyNewLine( PNS_NODE* aNode, PNS_SEGMENT* aLatest ); /** * Function handleViaPlacement() @@ -385,7 +385,7 @@ private: ///> current via drill int m_viaDrill; - + ///> current track width int m_currentWidth; @@ -393,12 +393,12 @@ private: int m_currentLayer; bool m_startsOnVia; - + VECTOR2I m_currentEnd, m_currentStart; PNS_LINE m_currentTrace; PNS_MODE m_currentMode; - PNS_ITEM *m_startItem; + PNS_ITEM* m_startItem; bool m_idle; bool m_chainedPlacement; diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index 4a0d8be6c5..a818b922e6 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -456,7 +456,7 @@ bool PNS_ROUTER::StartDragging( const VECTOR2I& aP, PNS_ITEM* aStartItem ) bool PNS_ROUTER::StartRouting( const VECTOR2I& aP, PNS_ITEM* aStartItem, int aLayer ) { m_placer = new PNS_LINE_PLACER( this ); - + m_placer->UpdateSizes ( m_sizes ); m_placer->SetLayer( aLayer ); m_placer->Start( aP, aStartItem ); @@ -504,7 +504,7 @@ void PNS_ROUTER::DisplayItem( const PNS_ITEM* aItem, int aColor, int aClearance void PNS_ROUTER::DisplayItems( const PNS_ITEMSET& aItems ) { - BOOST_FOREACH( const PNS_ITEM *item, aItems.CItems() ) + BOOST_FOREACH( const PNS_ITEM* item, aItems.CItems() ) DisplayItem( item ); } @@ -604,7 +604,7 @@ void PNS_ROUTER::updateView( PNS_NODE* aNode, PNS_ITEMSET& aCurrent ) return; if( Settings().Mode() == RM_MarkObstacles ) - markViolations(aNode, aCurrent, removed); + markViolations( aNode, aCurrent, removed ); aNode->GetUpdatedItems( removed, added ); @@ -760,7 +760,7 @@ bool PNS_ROUTER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem ) void PNS_ROUTER::StopRouting() { // Update the ratsnest with new changes - if(m_placer) + if( m_placer ) { int n = m_placer->CurrentNet(); @@ -827,7 +827,7 @@ void PNS_ROUTER::ToggleViaPlacement() int PNS_ROUTER::GetCurrentNet() const { - if(m_placer) + if( m_placer ) return m_placer->CurrentNet(); return -1; } @@ -841,7 +841,6 @@ int PNS_ROUTER::GetCurrentLayer() const } - void PNS_ROUTER::DumpLog() { PNS_LOGGER* logger = NULL; diff --git a/pcbnew/router/pns_router.h b/pcbnew/router/pns_router.h index 0b381d828a..0969bade68 100644 --- a/pcbnew/router/pns_router.h +++ b/pcbnew/router/pns_router.h @@ -217,7 +217,7 @@ private: void highlightCurrent( bool enabled ); - void markViolations( PNS_NODE* aNode, PNS_ITEMSET& aCurrent, PNS_NODE::ITEM_VECTOR& aRemoved ); + void markViolations( PNS_NODE* aNode, PNS_ITEMSET& aCurrent, PNS_NODE::ITEM_VECTOR& aRemoved ); VECTOR2I m_currentEnd; RouterState m_state; diff --git a/pcbnew/router/pns_routing_settings.h b/pcbnew/router/pns_routing_settings.h index 1a7030be21..1e4e82bdff 100644 --- a/pcbnew/router/pns_routing_settings.h +++ b/pcbnew/router/pns_routing_settings.h @@ -26,7 +26,7 @@ #include "time_limit.h" class DIRECTION_45; - + ///> Routing modes enum PNS_MODE { @@ -37,9 +37,9 @@ enum PNS_MODE }; ///> Optimization effort -enum PNS_OPTIMIZATION_EFFORT +enum PNS_OPTIMIZATION_EFFORT { - OE_LOW = 0, + OE_LOW = 0, OE_MEDIUM = 1, OE_FULL = 2 }; @@ -60,44 +60,44 @@ public: ///> Sets the routing mode. void SetMode( PNS_MODE aMode ) { m_routingMode = aMode; } - + ///> Returns the optimizer effort. Bigger means cleaner traces, but slower routing. PNS_OPTIMIZATION_EFFORT OptimizerEffort() const { return m_optimizerEffort; } - + ///> Sets the optimizer effort. Bigger means cleaner traces, but slower routing. void SetOptimizerEffort( PNS_OPTIMIZATION_EFFORT aEffort ) { m_optimizerEffort = aEffort; } - + ///> Returns true if shoving vias is enbled. bool ShoveVias() const { return m_shoveVias; } ///> Enables/disables shoving vias. void SetShoveVias( bool aShoveVias ) { m_shoveVias = aShoveVias; } - + ///> Returns true if loop (redundant track) removal is on. bool RemoveLoops() const { return m_removeLoops; } ///> Enables/disables loop (redundant track) removal. void SetRemoveLoops( bool aRemoveLoops ) { m_removeLoops = aRemoveLoops; } - + ///> Returns true if suggesting the finish of currently placed track is on. bool SuggestFinish() { return m_suggestFinish; } - + ///> Enables displaying suggestions for finishing the currently placed track. void SetSuggestFinish( bool aSuggestFinish ) { m_suggestFinish = aSuggestFinish; } - + ///> Returns true if Smart Pads (automatic neckdown) is enabled. bool SmartPads () const { return m_smartPads; } ///> Enables/disables Smart Pads (automatic neckdown). void SetSmartPads( bool aSmartPads ) { m_smartPads = aSmartPads; } - + ///> Returns true if follow mouse mode is active (permanently on for the moment). - bool FollowMouse() const - { + bool FollowMouse() const + { return m_followMouse && !( Mode() == RM_MarkObstacles ); } - - ///> Returns true if smoothing segments durign dragging is enabled. + + ///> Returns true if smoothing segments durign dragging is enabled. bool SmoothDraggedSegments() const { return m_smoothDraggedSegments; } ///> Enables/disabled smoothing segments during dragging. @@ -106,11 +106,11 @@ public: ///> Returns true if jumping over unmovable obstacles is on. bool JumpOverObstacles() const { return m_jumpOverObstacles; } - ///> Enables/disables jumping over unmovable obstacles. + ///> Enables/disables jumping over unmovable obstacles. void SetJumpOverObstacles( bool aJumpOverObstacles ) { m_jumpOverObstacles = aJumpOverObstacles; } - - void SetStartDiagonal(bool aStartDiagonal) { m_startDiagonal = aStartDiagonal; } - + + void SetStartDiagonal( bool aStartDiagonal ) { m_startDiagonal = aStartDiagonal; } + bool CanViolateDRC() const { return m_canViolateDRC; } void SetCanViolateDRC( bool aViolate ) { m_canViolateDRC = aViolate; } @@ -136,7 +136,7 @@ private: PNS_MODE m_routingMode; PNS_OPTIMIZATION_EFFORT m_optimizerEffort; - + int m_walkaroundIterationLimit; int m_shoveIterationLimit; diff --git a/pcbnew/router/pns_shove.cpp b/pcbnew/router/pns_shove.cpp index e5f4dfc46f..5c6853a0f8 100644 --- a/pcbnew/router/pns_shove.cpp +++ b/pcbnew/router/pns_shove.cpp @@ -41,7 +41,7 @@ #include -static void sanityCheck( PNS_LINE *aOld, PNS_LINE *aNew ) +static void sanityCheck( PNS_LINE* aOld, PNS_LINE* aNew ) { assert( aOld->CPoint( 0 ) == aNew->CPoint( 0 ) ); assert( aOld->CPoint( -1 ) == aNew->CPoint( -1 ) ); @@ -58,26 +58,26 @@ PNS_SHOVE::PNS_SHOVE( PNS_NODE* aWorld, PNS_ROUTER* aRouter ) : PNS_SHOVE::~PNS_SHOVE() { // free all the stuff we've created during routing/dragging operation. - BOOST_FOREACH( PNS_ITEM *item, m_gcItems ) + BOOST_FOREACH( PNS_ITEM* item, m_gcItems ) delete item; } // garbage-collected line assembling -PNS_LINE* PNS_SHOVE::assembleLine( const PNS_SEGMENT *aSeg, int *aIndex ) +PNS_LINE* PNS_SHOVE::assembleLine( const PNS_SEGMENT* aSeg, int* aIndex ) { PNS_LINE* l = m_currentNode->AssembleLine( const_cast( aSeg ), aIndex ); - m_gcItems.push_back(l); + m_gcItems.push_back( l ); return l; } // garbage-collected line cloning -PNS_LINE *PNS_SHOVE::cloneLine ( const PNS_LINE *aLine ) +PNS_LINE* PNS_SHOVE::cloneLine ( const PNS_LINE* aLine ) { - PNS_LINE *l = aLine->Clone(); + PNS_LINE* l = aLine->Clone(); m_gcItems.push_back( l ); return l; @@ -88,7 +88,7 @@ PNS_LINE *PNS_SHOVE::cloneLine ( const PNS_LINE *aLine ) // visually "outwards" of the line/via applying pressure on it. Unfortunately there's no // mathematical concept of orientation of an open curve, so we use some primitive heuristics: // if the shoved line wraps around the start of the "pusher", it's likely shoved in wrong direction. -bool PNS_SHOVE::checkBumpDirection( PNS_LINE *aCurrent, PNS_LINE *aShoved ) const +bool PNS_SHOVE::checkBumpDirection( PNS_LINE* aCurrent, PNS_LINE* aShoved ) const { const SEG ss = aCurrent->CSegment( 0 ); @@ -98,7 +98,7 @@ bool PNS_SHOVE::checkBumpDirection( PNS_LINE *aCurrent, PNS_LINE *aShoved ) cons dist += aShoved->Width() / 2; const VECTOR2I ps = ss.A - ( ss.B - ss.A ).Resize( dist ); - + return !aShoved->CLine().PointOnEdge( ps ); } @@ -157,7 +157,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::processHullSet( PNS_LINE* aCurrent, PNS_LINE* path.Simplify(); l.SetShape( path ); } - + for( int i = 0; i < std::min ( path.PointCount(), obs.PointCount() ); i++ ) { if( path.CPoint( i ) != obs.CPoint( i ) ) @@ -203,28 +203,28 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::processHullSet( PNS_LINE* aCurrent, PNS_LINE* TRACE( 100, "attempt %d fail self-intersect", attempt ); continue; } - + bool colliding = m_currentNode->CheckColliding( &l, aCurrent ); - + if( ( aCurrent->Marker() & MK_HEAD ) && !colliding ) { PNS_JOINT* jtStart = m_currentNode->FindJoint( aCurrent->CPoint( 0 ), aCurrent ); - + BOOST_FOREACH( PNS_ITEM* item, jtStart->LinkList() ) { if( m_currentNode->CheckColliding( item, &l ) ) colliding = true; } } - + if( colliding ) { TRACE( 100, "attempt %d fail coll-check", attempt ); continue; } - aShoved->SetShape( l.CLine() ); - + aShoved->SetShape( l.CLine() ); + return SH_OK; } @@ -254,7 +254,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::processSingleLine( PNS_LINE* aCurrent, PNS_LI bool viaOnEnd = aCurrent->EndsWithVia(); - if( viaOnEnd && ( !aCurrent->LayersOverlap( aObstacle ) || aCurrent->SegmentCount() == 0 ) ) + if( viaOnEnd && ( !aCurrent->LayersOverlap( aObstacle ) || aCurrent->SegmentCount() == 0 ) ) { rv = walkaroundLoneVia( aCurrent, aObstacle, aShoved ); } @@ -279,7 +279,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::processSingleLine( PNS_LINE* aCurrent, PNS_LI rv = processHullSet ( aCurrent, aObstacle, aShoved, hulls ); } - + if( obstacleIsHead ) aShoved->Mark( aShoved->Marker() | MK_HEAD ); @@ -292,16 +292,16 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSegment( PNS_LINE* aCurrent, PNS_S int segIndex; PNS_LINE* obstacleLine = assembleLine( aObstacleSeg, &segIndex ); PNS_LINE* shovedLine = cloneLine( obstacleLine ); - + SHOVE_STATUS rv = processSingleLine( aCurrent, obstacleLine, shovedLine ); assert ( obstacleLine->LayersOverlap( shovedLine ) ); - + if( rv == SH_OK ) { - if ( shovedLine->Marker() & MK_HEAD ) + if( shovedLine->Marker() & MK_HEAD ) m_newHead = *shovedLine; - + sanityCheck( obstacleLine, shovedLine ); m_currentNode->Replace( obstacleLine, shovedLine ); sanityCheck( obstacleLine, shovedLine ); @@ -324,7 +324,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSegment( PNS_LINE* aCurrent, PNS_S } -PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingLine( PNS_LINE *aCurrent, PNS_LINE *aObstacle ) +PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingLine( PNS_LINE* aCurrent, PNS_LINE* aObstacle ) { PNS_LINE* shovedLine = cloneLine( aObstacle ); @@ -332,13 +332,13 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingLine( PNS_LINE *aCurrent, PNS_LINE if( rv == SH_OK ) { - if ( shovedLine->Marker() & MK_HEAD ) + if( shovedLine->Marker() & MK_HEAD ) m_newHead = *shovedLine; sanityCheck( aObstacle, shovedLine ); m_currentNode->Replace( aObstacle, shovedLine ); sanityCheck( aObstacle, shovedLine ); - + int rank = aObstacle->Rank(); shovedLine->SetRank ( rank ); @@ -360,10 +360,10 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSolid( PNS_LINE* aCurrent, PNS_SOL { PNS_WALKAROUND walkaround( m_currentNode, Router() ); PNS_LINE* walkaroundLine = cloneLine( aCurrent ); - + if( aCurrent->EndsWithVia() ) { - PNS_VIA vh = aCurrent->Via(); + PNS_VIA vh = aCurrent->Via(); PNS_VIA* via = NULL; PNS_JOINT* jtStart = m_currentNode->FindJoint ( vh.Pos(), aCurrent ); @@ -378,14 +378,14 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSolid( PNS_LINE* aCurrent, PNS_SOL break; } } - + if( via && m_currentNode->CheckColliding( via, aObstacleSolid ) ) return onCollidingVia( aObstacleSolid, via ); } walkaround.SetSolidsOnly( true ); walkaround.SetIterationLimit ( 8 ); // fixme: make configurable - + int currentRank = aCurrent->Rank(); int nextRank; @@ -399,7 +399,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSolid( PNS_LINE* aCurrent, PNS_SOL nextRank = currentRank - 1; walkaround.SetSingleDirection( true ); } - + if( walkaround.Route( *aCurrent, *walkaroundLine, false ) != PNS_WALKAROUND::DONE ) return SH_INCOMPLETE; @@ -415,10 +415,10 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSolid( PNS_LINE* aCurrent, PNS_SOL walkaroundLine->Mark( MK_HEAD ); m_newHead = *walkaroundLine; } - + m_currentNode->Replace( aCurrent, walkaroundLine ); walkaroundLine->SetRank ( nextRank ); - + #ifdef DEBUG m_logger.NewGroup( "on-colliding-solid", m_iter ); m_logger.Log( aObstacleSolid, 0, "obstacle-solid" ); @@ -444,7 +444,7 @@ bool PNS_SHOVE::reduceSpringback( const PNS_ITEMSET& aHeadSet ) if( !spTag.m_node->CheckColliding( aHeadSet ) ) { rv = true; - + delete spTag.m_node; m_nodeStack.pop_back(); } @@ -498,9 +498,9 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::pushVia( PNS_VIA* aVia, const VECTOR2I& aForc PNS_SEGMENT* seg = (PNS_SEGMENT*) item; LINE_PAIR lp; int segIndex; - + lp.first = assembleLine( seg, &segIndex ); - + assert( segIndex == 0 || ( segIndex == ( lp.first->SegmentCount() - 1 ) ) ); if( segIndex == 0 ) @@ -526,7 +526,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::pushVia( PNS_VIA* aVia, const VECTOR2I& aForc m_logger.Log ( aVia, 0, "obstacle-via"); m_logger.Log ( pushedVia, 1, "pushed-via"); #endif - + BOOST_FOREACH( LINE_PAIR lp, draggedLines ) { if( lp.first->Marker() & MK_HEAD ) @@ -535,13 +535,13 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::pushVia( PNS_VIA* aVia, const VECTOR2I& aForc m_newHead = *lp.second; } - unwindStack(lp.first); + unwindStack( lp.first ); if( lp.second->SegmentCount() ) { m_currentNode->Replace( lp.first, lp.second ); lp.second->SetRank( aCurrentRank - 1 ); - pushLine( lp.second ); + pushLine( lp.second ); } else m_currentNode->Remove( lp.first ); @@ -556,12 +556,12 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::pushVia( PNS_VIA* aVia, const VECTOR2I& aForc } -PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingVia (PNS_ITEM* aCurrent, PNS_VIA* aObstacleVia ) +PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingVia( PNS_ITEM* aCurrent, PNS_VIA* aObstacleVia ) { int clearance = m_currentNode->GetClearance( aCurrent, aObstacleVia ) ; LINE_PAIR_VEC draggedLines; bool colLine = false, colVia = false; - PNS_LINE *currentLine = NULL; + PNS_LINE* currentLine = NULL; VECTOR2I mtvLine, mtvVia, mtv, mtvSolid; int rank = -1; @@ -573,12 +573,12 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingVia (PNS_ITEM* aCurrent, PNS_VIA* #endif currentLine = (PNS_LINE*) aCurrent; - colLine = CollideShapes( aObstacleVia->Shape(), currentLine->Shape(), - clearance + currentLine->Width() / 2 + PNS_HULL_MARGIN, + colLine = CollideShapes( aObstacleVia->Shape(), currentLine->Shape(), + clearance + currentLine->Width() / 2 + PNS_HULL_MARGIN, true, mtvLine ); if( currentLine->EndsWithVia() ) - colVia = CollideShapes( currentLine->Via().Shape(), aObstacleVia->Shape(), + colVia = CollideShapes( currentLine->Via().Shape(), aObstacleVia->Shape(), clearance + PNS_HULL_MARGIN, true, mtvVia ); if( !colLine && !colVia ) @@ -590,18 +590,18 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingVia (PNS_ITEM* aCurrent, PNS_VIA* mtv = mtvLine; else mtv = mtvVia; - + rank = currentLine->Rank(); } - else if (aCurrent->OfKind(PNS_ITEM::SOLID)) + else if( aCurrent->OfKind( PNS_ITEM::SOLID ) ) { - CollideShapes( aObstacleVia->Shape(), aCurrent->Shape(), + CollideShapes( aObstacleVia->Shape(), aCurrent->Shape(), clearance + PNS_HULL_MARGIN, true, mtvSolid ); mtv = -mtvSolid; rank = aCurrent->Rank() + 10000; } - return pushVia( aObstacleVia, mtv, rank ); + return pushVia( aObstacleVia, mtv, rank ); } @@ -617,19 +617,19 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onReverseCollidingVia( PNS_LINE* aCurrent, PN shoved->ClearSegmentLinks(); cur->RemoveVia(); - unwindStack(aCurrent); + unwindStack( aCurrent ); BOOST_FOREACH( PNS_ITEM* item, jt->LinkList() ) { - if( item->OfKind( PNS_ITEM::SEGMENT ) && item->LayersOverlap( aCurrent ) ) + if( item->OfKind( PNS_ITEM::SEGMENT ) && item->LayersOverlap( aCurrent ) ) { PNS_SEGMENT* seg = (PNS_SEGMENT*) item; PNS_LINE* head = assembleLine( seg ); - + head->AppendVia( *aObstacleVia ); SHOVE_STATUS st = processSingleLine ( head, cur, shoved ); - + if( st != SH_OK ) { #ifdef DEBUG @@ -641,7 +641,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onReverseCollidingVia( PNS_LINE* aCurrent, PN return st; } - + cur->SetShape( shoved->CLine() ); n++; } @@ -654,7 +654,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onReverseCollidingVia( PNS_LINE* aCurrent, PN m_logger.Log( aObstacleVia, 0, "the-via" ); m_logger.Log( aCurrent, 1, "current-line" ); #endif - + PNS_LINE head( *aCurrent ); head.Line().Clear(); head.AppendVia( *aObstacleVia ); @@ -683,7 +683,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onReverseCollidingVia( PNS_LINE* aCurrent, PN pushLine( shoved ); shoved->SetRank( currentRank ); - return SH_OK; + return SH_OK; } @@ -703,7 +703,7 @@ void PNS_SHOVE::unwindStack( PNS_SEGMENT *aSeg ) i = m_optimizerQueue.erase( i ); else i++; - } + } } @@ -715,20 +715,20 @@ void PNS_SHOVE::unwindStack( PNS_ITEM* aItem ) { PNS_LINE* l = static_cast( aItem ); - if ( !l->LinkedSegments() ) + if( !l->LinkedSegments() ) return; BOOST_FOREACH( PNS_SEGMENT* seg, *l->LinkedSegments() ) unwindStack( seg ); } } - + void PNS_SHOVE::pushLine( PNS_LINE* aL ) { if( aL->LinkCount() >= 0 && ( aL->LinkCount() != aL->SegmentCount() ) ) assert( false ); - + m_lineStack.push_back( aL ); m_optimizerQueue.push_back( aL ); } @@ -757,17 +757,17 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter ) PNS_LINE* currentLine = m_lineStack.back(); PNS_NODE::OPT_OBSTACLE nearest; SHOVE_STATUS st; - + PNS_ITEM::PnsKind search_order[] = { PNS_ITEM::SOLID, PNS_ITEM::VIA, PNS_ITEM::SEGMENT }; - + for( int i = 0; i < 3; i++ ) { nearest = m_currentNode->NearestObstacle( currentLine, search_order[i] ); if( nearest ) break; - } - + } + if( !nearest ) { m_lineStack.pop_back(); @@ -786,7 +786,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter ) { PNS_VIA* revVia = (PNS_VIA*) ni; TRACE( 2, "iter %d: reverse-collide-via", aIter ); - + if( currentLine->EndsWithVia() && m_currentNode->CheckColliding( ¤tLine->Via(), revVia ) ) { st = SH_INCOMPLETE; @@ -798,7 +798,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter ) break; } - + case PNS_ITEM::SEGMENT: { PNS_SEGMENT* seg = (PNS_SEGMENT*) ni; @@ -825,15 +825,15 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter ) break; case PNS_ITEM::VIA: - TRACE( 2, "iter %d: shove-via ", aIter ); + TRACE( 2, "iter %d: shove-via ", aIter ); st = onCollidingVia( currentLine, (PNS_VIA*) ni ); break; case PNS_ITEM::SOLID: - TRACE( 2, "iter %d: walk-solid ", aIter ); + TRACE( 2, "iter %d: walk-solid ", aIter ); st = onCollidingSolid( currentLine, (PNS_SOLID*) ni ); break; - + default: break; } @@ -863,7 +863,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveMainLoop() m_iter++; - if( st == SH_INCOMPLETE || timeLimit.Expired() || m_iter >= iterLimit ) + if( st == SH_INCOMPLETE || timeLimit.Expired() || m_iter >= iterLimit ) { st = SH_INCOMPLETE; break; @@ -884,7 +884,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveLines( const PNS_LINE& aCurrentHead ) PNS_LINE* head = cloneLine( &aCurrentHead ); head->ClearSegmentLinks(); - + m_lineStack.clear(); m_optimizerQueue.clear(); m_newHead = OPT_LINE(); @@ -899,7 +899,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveLines( const PNS_LINE& aCurrentHead ) m_currentNode = parent->Branch(); m_currentNode->ClearRanks(); m_currentNode->Add( head ); - + head->Mark( MK_HEAD ); head->SetRank( 100000 ); @@ -921,11 +921,11 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveLines( const PNS_LINE& aCurrentHead ) st = shoveMainLoop(); runOptimizer( m_currentNode, head ); - if( m_newHead && st == SH_OK ) + if( m_newHead && st == SH_OK ) { st = SH_HEAD_MODIFIED; //Router()->DisplayDebugLine( m_newHead->CLine(), 3, 20000 ); - } + } m_currentNode->RemoveByMarker( MK_HEAD ); @@ -939,9 +939,9 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveLines( const PNS_LINE& aCurrentHead ) else { delete m_currentNode; - + m_currentNode = parent; - m_newHead = OPT_LINE(); + m_newHead = OPT_LINE(); } return st; @@ -952,7 +952,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveDraggingVia( PNS_VIA* aVia, const VECTOR PNS_VIA** aNewVia ) { SHOVE_STATUS st = SH_OK; - + m_lineStack.clear(); m_optimizerQueue.clear(); m_newHead = OPT_LINE(); @@ -1031,7 +1031,7 @@ void PNS_SHOVE::runOptimizer( PNS_NODE* aNode, PNS_LINE* aHead ) i != m_optimizerQueue.end(); ++i) { PNS_LINE* line = *i; - + if( !( line -> Marker() & MK_HEAD ) ) { if( effort == OE_MEDIUM || effort == OE_LOW ) @@ -1062,7 +1062,7 @@ void PNS_SHOVE::runOptimizer( PNS_NODE* aNode, PNS_LINE* aHead ) } -const RANGE PNS_SHOVE::findShovedVertexRange( PNS_LINE *aL ) +const RANGE PNS_SHOVE::findShovedVertexRange( PNS_LINE* aL ) { RANGE r; @@ -1116,6 +1116,7 @@ const PNS_LINE PNS_SHOVE::NewHead() const return *m_newHead; } + void PNS_SHOVE::SetInitialLine( PNS_LINE* aInitial ) { m_root = m_root->Branch(); diff --git a/pcbnew/router/pns_shove.h b/pcbnew/router/pns_shove.h index dae355a5f4..2b4f32729f 100644 --- a/pcbnew/router/pns_shove.h +++ b/pcbnew/router/pns_shove.h @@ -37,7 +37,7 @@ class PNS_ROUTER; /** * Class PNS_SHOVE * - * The actual Push and Shove algorithm. + * The actual Push and Shove algorithm. */ class PNS_SHOVE : public PNS_ALGO_BASE @@ -88,11 +88,11 @@ private: SHOVE_STATUS processSingleLine( PNS_LINE* aCurrent, PNS_LINE* aObstacle, PNS_LINE* aShoved ); SHOVE_STATUS processHullSet( PNS_LINE* aCurrent, PNS_LINE* aObstacle, PNS_LINE* aShoved, const HULL_SET& hulls ); - + bool reduceSpringback( const PNS_ITEMSET& aHeadItems ); bool pushSpringback( PNS_NODE* aNode, const PNS_ITEMSET &aHeadItems, const PNS_COST_ESTIMATOR& aCost ); - + SHOVE_STATUS walkaroundLoneVia( PNS_LINE* aCurrent, PNS_LINE* aObstacle, PNS_LINE* aShoved ); bool checkBumpDirection( PNS_LINE* aCurrent, PNS_LINE* aShoved ) const; @@ -104,20 +104,20 @@ private: SHOVE_STATUS pushVia( PNS_VIA* aVia, const VECTOR2I& aForce, int aCurrentRank ); void unwindStack( PNS_SEGMENT* aSeg ); - void unwindStack( PNS_ITEM *aItem ); + void unwindStack( PNS_ITEM* aItem ); void runOptimizer( PNS_NODE* aNode, PNS_LINE* aHead ); - void pushLine( PNS_LINE *aL ); - void popLine(); + void pushLine( PNS_LINE* aL ); + void popLine(); - const RANGE findShovedVertexRange( PNS_LINE *aL ); + const RANGE findShovedVertexRange( PNS_LINE* aL ); PNS_LINE* assembleLine( const PNS_SEGMENT* aSeg, int* aIndex = NULL ); PNS_LINE* cloneLine( const PNS_LINE* aLine ); SHOVE_STATUS shoveIteration( int aIter ); - SHOVE_STATUS shoveMainLoop(); + SHOVE_STATUS shoveMainLoop(); std::vector m_nodeStack; std::vector m_lineStack; @@ -126,7 +126,7 @@ private: PNS_NODE* m_root; PNS_NODE* m_currentNode; - + OPT_LINE m_newHead; PNS_LOGGER m_logger; diff --git a/pcbnew/router/pns_sizes_settings.h b/pcbnew/router/pns_sizes_settings.h index db8d3b3a74..2cd0dae9a1 100644 --- a/pcbnew/router/pns_sizes_settings.h +++ b/pcbnew/router/pns_sizes_settings.h @@ -79,7 +79,7 @@ public: private: - int inheritTrackWidth( PNS_ITEM *aItem ); + int inheritTrackWidth( PNS_ITEM* aItem ); int m_trackWidth; int m_diffPairWidth; diff --git a/pcbnew/router/pns_via.h b/pcbnew/router/pns_via.h index 91bcd79ca9..b7637e9f13 100644 --- a/pcbnew/router/pns_via.h +++ b/pcbnew/router/pns_via.h @@ -48,7 +48,7 @@ public: m_drill = aDrill; m_shape = SHAPE_CIRCLE( aPos, aDiameter / 2 ); m_viaType = aViaType; - + //If we're a through-board via, use all layers regardless of the set passed if( aViaType == VIA_THROUGH ) { diff --git a/pcbnew/router/pns_walkaround.cpp b/pcbnew/router/pns_walkaround.cpp index d472d1ae95..bbe8d2bca3 100644 --- a/pcbnew/router/pns_walkaround.cpp +++ b/pcbnew/router/pns_walkaround.cpp @@ -83,10 +83,10 @@ PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::singleStep( PNS_LINE& aPath, m_logger.Log( ¤t_obs->m_hull, 2, "hull" ); m_logger.Log( current_obs->m_item, 3, "item" ); #endif - + int len_pre = path_walk[0].Length(); int len_alt = path_walk[1].Length(); - + PNS_LINE walk_path( aPath, path_walk[1] ); bool alt_collides = m_world->CheckColliding( &walk_path, m_itemMask ); @@ -158,7 +158,7 @@ PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::Route( const PNS_LINE& aInitia { int len_cw = path_cw.CLine().Length(); int len_ccw = path_ccw.CLine().Length(); - + if( m_forceLongerPath ) aWalkPath = (len_cw > len_ccw ? path_cw : path_ccw); else @@ -179,7 +179,7 @@ PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::Route( const PNS_LINE& aInitia m_iteration++; } - + if( m_iteration == m_iterationLimit ) { int len_cw = path_cw.CLine().Length(); @@ -235,7 +235,7 @@ PNS_WALKAROUND::WALKAROUND_STATUS PNS_WALKAROUND::Route( const PNS_LINE& aInitia if( aWalkPath.CPoint( 0 ) != aInitialPath.CPoint( 0 ) ) return STUCK; - + WALKAROUND_STATUS st = s_ccw == DONE || s_cw == DONE ? DONE : STUCK; if( aOptimize && st == DONE ) diff --git a/pcbnew/router/pns_walkaround.h b/pcbnew/router/pns_walkaround.h index 71b9c1ce2d..95c2079b61 100644 --- a/pcbnew/router/pns_walkaround.h +++ b/pcbnew/router/pns_walkaround.h @@ -34,7 +34,7 @@ class PNS_WALKAROUND : public PNS_ALGO_BASE public: PNS_WALKAROUND( PNS_NODE* aWorld, PNS_ROUTER* aRouter ) : PNS_ALGO_BASE ( aRouter ), - m_world( aWorld ), + m_world( aWorld ), m_iterationLimit( DefaultIterationLimit ) { m_forceSingleDirection = false; diff --git a/pcbnew/router/router_preview_item.cpp b/pcbnew/router/router_preview_item.cpp index e375a8d7e5..58715927bc 100644 --- a/pcbnew/router/router_preview_item.cpp +++ b/pcbnew/router/router_preview_item.cpp @@ -38,7 +38,7 @@ ROUTER_PREVIEW_ITEM::ROUTER_PREVIEW_ITEM( const PNS_ITEM* aItem, VIEW_GROUP* aPa EDA_ITEM( NOT_USED ) { m_parent = aParent; - + m_shape = NULL; m_clearance = -1; m_originLayer = m_layer = ITEM_GAL_LAYER( GP_OVERLAY ); @@ -64,7 +64,7 @@ void ROUTER_PREVIEW_ITEM::Update( const PNS_ITEM* aItem ) m_color.a = 0.8; m_depth = BaseOverlayDepth - aItem->Layers().Start(); m_shape = aItem->Shape()->Clone(); - + switch( aItem->Kind() ) { case PNS_ITEM::LINE: @@ -99,7 +99,7 @@ void ROUTER_PREVIEW_ITEM::Update( const PNS_ITEM* aItem ) if( aItem->Marker() & MK_VIOLATION ) m_color = COLOR4D( 0, 1, 0, 1 ); - + if( aItem->Marker() & MK_HEAD ) m_color.Brighten( 0.7 ); @@ -178,7 +178,7 @@ void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const aGal->SetLineWidth( m_width + 2 * m_clearance ); aGal->DrawLine( s->GetSeg().A, s->GetSeg().B ); } - + break; } @@ -194,7 +194,7 @@ void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const aGal->SetIsStroke( false ); aGal->DrawCircle( c->GetCenter(), c->GetRadius() + m_clearance ); } - + break; } @@ -225,7 +225,7 @@ void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const void ROUTER_PREVIEW_ITEM::Line( const SHAPE_LINE_CHAIN& aLine, int aWidth, int aStyle ) { - m_originLayer = m_layer = 0; + m_originLayer = m_layer = 0; m_width = aWidth; m_color = assignColor( aStyle ); m_type = PR_SHAPE; diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index c88ec52d98..cf7180ba68 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -304,7 +304,7 @@ PNS_ITEM* ROUTER_TOOL::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLa PNS_ITEM* prioritized[4]; - for(int i = 0; i < 4; i++) + for( int i = 0; i < 4; i++ ) prioritized[i] = 0; PNS_ITEMSET candidates = m_router->QueryHoverItems( aWhere ); @@ -379,7 +379,7 @@ void ROUTER_TOOL::highlightNet( bool aEnabled, int aNetcode ) void ROUTER_TOOL::handleCommonEvents( TOOL_EVENT& aEvent ) { PCB_EDIT_FRAME* frame = getEditFrame (); - BOARD *board = getModel (); + BOARD* board = getModel (); #ifdef DEBUG if( aEvent.IsKeyPressed() ) @@ -401,7 +401,7 @@ void ROUTER_TOOL::handleCommonEvents( TOOL_EVENT& aEvent ) if( settingsDlg.ShowModal() ) { // FIXME: do we need an explicit update? - } + } } else if( aEvent.IsAction( &ACT_CustomTrackWidth ) ) @@ -409,7 +409,7 @@ void ROUTER_TOOL::handleCommonEvents( TOOL_EVENT& aEvent ) BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings(); DIALOG_TRACK_VIA_SIZE sizeDlg( frame, bds ); - if ( sizeDlg.ShowModal() ) + if( sizeDlg.ShowModal() ) { bds.UseCustomTrackViaSize( true ); m_toolMgr->RunAction( COMMON_ACTIONS::trackViaSizeChanged ); @@ -437,7 +437,7 @@ void ROUTER_TOOL::updateStartItem( TOOL_EVENT& aEvent ) { VECTOR2I p = aEvent.Position(); startItem = pickSingleItem( p ); - bool snapEnabled = !aEvent.Modifier(MD_SHIFT); + bool snapEnabled = !aEvent.Modifier( MD_SHIFT ); m_router->EnableSnapping ( snapEnabled ); if( !snapEnabled && startItem && !startItem->Layers().Overlaps( tl ) ) @@ -520,20 +520,20 @@ void ROUTER_TOOL::updateEndItem( TOOL_EVENT& aEvent ) TRACE( 0, "%s, layer : %d", m_endItem->KindStr().c_str() % m_endItem->Layers().Start() ); } -int ROUTER_TOOL::getStartLayer( const PNS_ITEM *aItem ) +int ROUTER_TOOL::getStartLayer( const PNS_ITEM* aItem ) { int tl = getView()->GetTopLayer(); - if (m_startItem) + if( m_startItem ) { const PNS_LAYERSET& ls = m_startItem->Layers(); - if(ls.Overlaps( tl )) + if( ls.Overlaps( tl ) ) return tl; else return ls.Start(); } - + return tl; } void ROUTER_TOOL::switchLayerOnViaPlacement() @@ -542,7 +542,7 @@ void ROUTER_TOOL::switchLayerOnViaPlacement() int al = frame->GetActiveLayer(); int cl = m_router->GetCurrentLayer(); - + if( cl != al ) { m_router->SwitchLayer( al ); @@ -559,7 +559,7 @@ void ROUTER_TOOL::switchLayerOnViaPlacement() bool ROUTER_TOOL::onViaCommand( VIATYPE_T aType ) { - BOARD *board = getModel (); + BOARD* board = getModel (); BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings(); PCB_EDIT_FRAME* frame = getEditFrame(); @@ -572,32 +572,32 @@ bool ROUTER_TOOL::onViaCommand( VIATYPE_T aType ) sizes.AddLayerPair( frame->GetScreen()->m_Route_Layer_TOP, frame->GetScreen()->m_Route_Layer_BOTTOM ); - if (!m_router->IsPlacingVia()) + if( !m_router->IsPlacingVia() ) { // Cannot place microvias or blind vias if not allowed (obvious) if( ( aType == VIA_BLIND_BURIED ) && ( !bds.m_BlindBuriedViaAllowed ) ) return false; if( ( aType == VIA_MICROVIA ) && ( !bds.m_MicroViasAllowed ) ) return false; - + //Can only place through vias on 2-layer boards if( ( aType != VIA_THROUGH ) && ( layerCount <= 2 ) ) return false; - + //Can only place microvias if we're on an outer layer, or directly adjacent to one if( ( aType == VIA_MICROVIA ) && ( currentLayer > In1_Cu ) && ( currentLayer < layerCount-2 ) ) return false; - + //Cannot place blind vias with front/back as the layer pair, this doesn't make sense if( ( aType == VIA_BLIND_BURIED ) && ( sizes.GetLayerTop() == F_Cu ) && ( sizes.GetLayerBottom() == B_Cu ) ) return false; } - + sizes.SetViaType ( aType ); m_router->ToggleViaPlacement( ); m_router->UpdateSizes( sizes ); - + m_router->Move( m_endSnapPoint, m_endItem ); // refresh return false; @@ -612,7 +612,7 @@ void ROUTER_TOOL::performRouting() int routingLayer = getStartLayer ( m_startItem ); frame->SetActiveLayer( ToLAYER_ID ( routingLayer ) ); - // fixme: switch on invisible layer + // fixme: switch on invisible layer if( m_startItem && m_startItem->Net() >= 0 ) { @@ -631,7 +631,7 @@ void ROUTER_TOOL::performRouting() sizes.AddLayerPair ( frame->GetScreen()->m_Route_Layer_TOP, frame->GetScreen()->m_Route_Layer_BOTTOM ); m_router->UpdateSizes( sizes ); - + m_router->StartRouting( m_startSnapPoint, m_startItem, routingLayer ); m_endItem = NULL; @@ -659,7 +659,7 @@ void ROUTER_TOOL::performRouting() if( m_router->FixRoute( m_endSnapPoint, m_endItem ) ) break; - if(needLayerSwitch) + if( needLayerSwitch ) { switchLayerOnViaPlacement(); } @@ -764,7 +764,7 @@ int ROUTER_TOOL::Main( TOOL_EVENT& aEvent ) else performRouting(); } - else if ( evt->IsAction( &ACT_Drag ) ) + else if( evt->IsAction( &ACT_Drag ) ) performDragging(); handleCommonEvents( *evt ); diff --git a/pcbnew/router/router_tool.h b/pcbnew/router/router_tool.h index fd98843c01..809bd68871 100644 --- a/pcbnew/router/router_tool.h +++ b/pcbnew/router/router_tool.h @@ -47,10 +47,10 @@ private: PNS_ITEM* pickSingleItem( const VECTOR2I& aWhere, int aNet = -1, int aLayer = -1 ); int getDefaultWidth( int aNetCode ); - + void performRouting(); void performDragging(); - + void highlightNet( bool aEnabled, int aNetcode = -1 ); void updateStartItem( TOOL_EVENT& aEvent ); @@ -59,7 +59,7 @@ private: void getNetclassDimensions( int aNetCode, int& aWidth, int& aViaDiameter, int& aViaDrill ); void handleCommonEvents( TOOL_EVENT& evt ); - int getStartLayer( const PNS_ITEM *aItem ); + int getStartLayer( const PNS_ITEM* aItem ); void switchLayerOnViaPlacement(); bool onViaCommand( VIATYPE_T aType ); From 71e5fb13e6efff36d3d42f053a3cff73606f7a71 Mon Sep 17 00:00:00 2001 From: John Beard Date: Sat, 15 Nov 2014 08:09:59 -0500 Subject: [PATCH 07/10] Segment message panel infromation improvements. * Make "Drawing" string translatable. * Add segment length to message panel. * Add segment angle to message panel. --- pcbnew/class_drawsegment.cpp | 13 ++++++++++++- pcbnew/class_edge_mod.cpp | 8 +++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index b680e9b3d3..9f7e71fc0e 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -317,7 +317,7 @@ void DRAWSEGMENT::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) wxASSERT( m_Parent ); - msg = wxT( "DRAWING" ); + msg = _( "Drawing" ); aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, DARKCYAN ) ); @@ -340,7 +340,18 @@ void DRAWSEGMENT::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) break; default: + { aList.push_back( MSG_PANEL_ITEM( shape, _( "Segment" ), RED ) ); + + msg = ::CoordinateToString( GetLineLength( m_Start, m_End ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Length" ), msg, DARKGREEN ) ); + + // angle counter-clockwise from 3'o-clock + const double deg = RAD2DEG( atan2( m_Start.y - m_End.y, + m_End.x - m_Start.x ) ); + msg.Printf( wxT( "%.1f" ), deg ); + aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) ); + } } wxString start; diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index 6ade01c509..f861798893 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -280,17 +280,15 @@ void EDGE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) if( !board ) return; - aList.push_back( MSG_PANEL_ITEM( _( "Graphic Item" ), wxEmptyString, DARKCYAN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Module" ), module->GetReference(), DARKCYAN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Value" ), module->GetValue(), BLUE ) ); msg.Printf( wxT( "%8.8lX" ), module->GetTimeStamp() ); aList.push_back( MSG_PANEL_ITEM( _( "TimeStamp" ), msg, BROWN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Mod Layer" ), module->GetLayerName(), RED ) ); - aList.push_back( MSG_PANEL_ITEM( _( "Seg Layer" ), - GetLayerName(), RED ) ); - msg = ::CoordinateToString( m_Width ); - aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, BLUE ) ); + + // append the features shared with the base class + DRAWSEGMENT::GetMsgPanelInfo( aList ); } From 5729ee7ea55d00f9678157d10f23f745205cf31d Mon Sep 17 00:00:00 2001 From: Camille Date: Sat, 15 Nov 2014 08:43:23 -0500 Subject: [PATCH 08/10] Compile warning fixes and minor code policy fixes. --- 3d-viewer/vrml_v1_modelparser.cpp | 6 +- 3d-viewer/vrml_v2_modelparser.cpp | 18 +++--- 3d-viewer/x3dmodelparser.cpp | 4 +- include/kiway.h | 2 +- include/wxPcbStruct.h | 2 +- pcbnew/router/direction.h | 2 +- pcbnew/router/pns_shove.cpp | 96 ++++++++++++++--------------- pcbnew/tools/selection_conditions.h | 2 +- utils/idftools/vrml_layer.cpp | 2 +- utils/idftools/vrml_layer.h | 1 - 10 files changed, 67 insertions(+), 68 deletions(-) diff --git a/3d-viewer/vrml_v1_modelparser.cpp b/3d-viewer/vrml_v1_modelparser.cpp index 28579fcb9e..5ada319024 100644 --- a/3d-viewer/vrml_v1_modelparser.cpp +++ b/3d-viewer/vrml_v1_modelparser.cpp @@ -192,7 +192,7 @@ int VRML1_MODEL_PARSER::readMaterial() continue; } - if( ( *text == '}' ) ) + if( *text == '}' ) { return 0; } @@ -240,7 +240,7 @@ int VRML1_MODEL_PARSER::readCoordinate3() continue; } - if( ( *text == '}' ) ) + if( *text == '}' ) { return 0; } @@ -268,7 +268,7 @@ int VRML1_MODEL_PARSER::readIndexedFaceSet() continue; } - if( ( *text == '}' ) ) + if( *text == '}' ) { return 0; } diff --git a/3d-viewer/vrml_v2_modelparser.cpp b/3d-viewer/vrml_v2_modelparser.cpp index 2589c593df..2c21f9bdf3 100644 --- a/3d-viewer/vrml_v2_modelparser.cpp +++ b/3d-viewer/vrml_v2_modelparser.cpp @@ -145,7 +145,7 @@ int VRML2_MODEL_PARSER::read_Transform() continue; } - if( ( *text == '}' ) ) + if( *text == '}' ) { // DBG( printf( " } Exit Transform\n" ) ); break; @@ -265,7 +265,7 @@ int VRML2_MODEL_PARSER::read_DEF() continue; } - if( ( *text == '}' ) ) + if( *text == '}' ) { // DBG( printf( " } Exit DEF\n") ); return 0; @@ -321,7 +321,7 @@ int VRML2_MODEL_PARSER::read_Shape() continue; } - if( ( *text == '}' ) ) + if( *text == '}' ) { // DBG( printf( " } Exit Shape\n") ); return 0; @@ -368,7 +368,7 @@ int VRML2_MODEL_PARSER::read_Appearance() continue; } - if( ( *text == '}' ) ) + if( *text == '}' ) { return 0; } @@ -473,7 +473,7 @@ int VRML2_MODEL_PARSER::read_Material() continue; } - if( ( *text == '}' ) ) + if( *text == '}' ) { return 0; } @@ -566,7 +566,7 @@ int VRML2_MODEL_PARSER::read_IndexedFaceSet() continue; } - if( ( *text == '}' ) ) + if( *text == '}' ) { // DBG( printf( " } Exit IndexedFaceSet\n") ); return 0; @@ -749,7 +749,7 @@ int VRML2_MODEL_PARSER::read_Color() continue; } - if( ( *text == '}' ) ) + if( *text == '}' ) { // DBG( printf( " m_DiffuseColor.size: %ld\n", m_model->m_Materials->m_DiffuseColor.size() ) ); return 0; @@ -779,7 +779,7 @@ int VRML2_MODEL_PARSER::read_Normal() continue; } - if( ( *text == '}' ) ) + if( *text == '}' ) { // DBG( printf( " m_PerFaceNormalsNormalized.size: %lu\n", m_model->m_PerFaceNormalsNormalized.size() ) ); return 0; @@ -817,7 +817,7 @@ int VRML2_MODEL_PARSER::read_Coordinate() continue; } - if( ( *text == '}' ) ) + if( *text == '}' ) { // DBG( printf( " m_Point.size: %lu\n", m_model->m_Point.size() ) ); return 0; diff --git a/3d-viewer/x3dmodelparser.cpp b/3d-viewer/x3dmodelparser.cpp index 176d942c12..d6a1d106f7 100644 --- a/3d-viewer/x3dmodelparser.cpp +++ b/3d-viewer/x3dmodelparser.cpp @@ -384,7 +384,9 @@ bool X3D_MODEL_PARSER::parseDoubleTriplet( const wxString& aData, { wxStringTokenizer tokens( aData ); - double x, y, z; + double x = 0; + double y = 0; + double z = 0; bool ret = tokens.GetNextToken().ToDouble( &x ) && tokens.GetNextToken().ToDouble( &y ) diff --git a/include/kiway.h b/include/kiway.h index 380f300352..cb37c663b4 100644 --- a/include/kiway.h +++ b/include/kiway.h @@ -250,7 +250,7 @@ struct KIFACE */ class KIWAY : public wxEvtHandler { - friend class PGM_SINGLE_TOP; // can use set_kiface() + friend struct PGM_SINGLE_TOP; // can use set_kiface() public: /// Known KIFACE implementations diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 5194cca753..d44bfd89e5 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -75,7 +75,7 @@ namespace PCB { struct IFACE; } // KIFACE_I is in pcbnew.cpp */ class PCB_EDIT_FRAME : public PCB_BASE_EDIT_FRAME { - friend class PCB::IFACE; + friend struct PCB::IFACE; friend class PCB_LAYER_WIDGET; void updateTraceWidthSelectBox(); diff --git a/pcbnew/router/direction.h b/pcbnew/router/direction.h index 90edd1be56..eb37a14988 100644 --- a/pcbnew/router/direction.h +++ b/pcbnew/router/direction.h @@ -65,7 +65,7 @@ public: ANG_UNDEFINED = 0x20 }; - DIRECTION_45( Directions aDir = UNDEFINED ) : m_dir( aDir ) {}; + DIRECTION_45( Directions aDir = UNDEFINED ) : m_dir( aDir ) {} /** * Constructor diff --git a/pcbnew/router/pns_shove.cpp b/pcbnew/router/pns_shove.cpp index 5c6853a0f8..1338557f1a 100644 --- a/pcbnew/router/pns_shove.cpp +++ b/pcbnew/router/pns_shove.cpp @@ -104,7 +104,7 @@ bool PNS_SHOVE::checkBumpDirection( PNS_LINE* aCurrent, PNS_LINE* aShoved ) cons PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::walkaroundLoneVia( PNS_LINE* aCurrent, PNS_LINE* aObstacle, - PNS_LINE* aShoved ) + PNS_LINE* aShoved ) { int clearance = m_currentNode->GetClearance( aCurrent, aObstacle ); const SHAPE_LINE_CHAIN hull = aCurrent->Via().Hull( clearance, aObstacle->Width() ); @@ -313,11 +313,11 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSegment( PNS_LINE* aCurrent, PNS_S } #ifdef DEBUG - m_logger.NewGroup ("on-colliding-segment", m_iter); - m_logger.Log ( aObstacleSeg, 0, "obstacle-segment"); - m_logger.Log ( aCurrent, 1, "current-line"); - m_logger.Log ( obstacleLine, 2, "obstacle-line"); - m_logger.Log ( shovedLine, 3, "shoved-line"); + m_logger.NewGroup( "on-colliding-segment", m_iter ); + m_logger.Log( aObstacleSeg, 0, "obstacle-segment" ); + m_logger.Log( aCurrent, 1, "current-line" ); + m_logger.Log( obstacleLine, 2, "obstacle-line" ); + m_logger.Log( shovedLine, 3, "shoved-line" ); #endif return rv; @@ -365,7 +365,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSolid( PNS_LINE* aCurrent, PNS_SOL { PNS_VIA vh = aCurrent->Via(); PNS_VIA* via = NULL; - PNS_JOINT* jtStart = m_currentNode->FindJoint ( vh.Pos(), aCurrent ); + PNS_JOINT* jtStart = m_currentNode->FindJoint( vh.Pos(), aCurrent ); if( !jtStart ) return SH_INCOMPLETE; @@ -417,7 +417,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSolid( PNS_LINE* aCurrent, PNS_SOL } m_currentNode->Replace( aCurrent, walkaroundLine ); - walkaroundLine->SetRank ( nextRank ); + walkaroundLine->SetRank( nextRank ); #ifdef DEBUG m_logger.NewGroup( "on-colliding-solid", m_iter ); @@ -523,8 +523,8 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::pushVia( PNS_VIA* aVia, const VECTOR2I& aForc pushedVia->SetRank( aCurrentRank - 1 ); #ifdef DEBUG - m_logger.Log ( aVia, 0, "obstacle-via"); - m_logger.Log ( pushedVia, 1, "pushed-via"); + m_logger.Log( aVia, 0, "obstacle-via" ); + m_logger.Log( pushedVia, 1, "pushed-via" ); #endif BOOST_FOREACH( LINE_PAIR lp, draggedLines ) @@ -628,7 +628,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onReverseCollidingVia( PNS_LINE* aCurrent, PN head->AppendVia( *aObstacleVia ); - SHOVE_STATUS st = processSingleLine ( head, cur, shoved ); + SHOVE_STATUS st = processSingleLine( head, cur, shoved ); if( st != SH_OK ) { @@ -665,7 +665,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onReverseCollidingVia( PNS_LINE* aCurrent, PN if( st != SH_OK ) return st; - cur->SetShape ( shoved->CLine() ); + cur->SetShape( shoved->CLine() ); } if( aCurrent->EndsWithVia() ) @@ -678,7 +678,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onReverseCollidingVia( PNS_LINE* aCurrent, PN m_logger.Log( shoved, 3, "shoved-line" ); #endif int currentRank = aCurrent->Rank(); - m_currentNode->Replace ( aCurrent, shoved ); + m_currentNode->Replace( aCurrent, shoved ); pushLine( shoved ); shoved->SetRank( currentRank ); @@ -691,7 +691,7 @@ void PNS_SHOVE::unwindStack( PNS_SEGMENT *aSeg ) { for( std::vector::iterator i = m_lineStack.begin(); i != m_lineStack.end(); ) { - if( (*i)->ContainsSegment ( aSeg ) ) + if( (*i)->ContainsSegment( aSeg ) ) i = m_lineStack.erase( i ); else i++; @@ -756,7 +756,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter ) { PNS_LINE* currentLine = m_lineStack.back(); PNS_NODE::OPT_OBSTACLE nearest; - SHOVE_STATUS st; + SHOVE_STATUS st = SH_NULL; PNS_ITEM::PnsKind search_order[] = { PNS_ITEM::SOLID, PNS_ITEM::VIA, PNS_ITEM::SEGMENT }; @@ -819,23 +819,23 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter ) { // "forward" collisoins switch( ni->Kind() ) { - case PNS_ITEM::SEGMENT: - TRACE( 2, "iter %d: collide-segment ", aIter ); - st = onCollidingSegment( currentLine, (PNS_SEGMENT*) ni ); - break; + case PNS_ITEM::SEGMENT: + TRACE( 2, "iter %d: collide-segment ", aIter ); + st = onCollidingSegment( currentLine, (PNS_SEGMENT*) ni ); + break; - case PNS_ITEM::VIA: - TRACE( 2, "iter %d: shove-via ", aIter ); - st = onCollidingVia( currentLine, (PNS_VIA*) ni ); - break; + case PNS_ITEM::VIA: + TRACE( 2, "iter %d: shove-via ", aIter ); + st = onCollidingVia( currentLine, (PNS_VIA*) ni ); + break; - case PNS_ITEM::SOLID: - TRACE( 2, "iter %d: walk-solid ", aIter ); - st = onCollidingSolid( currentLine, (PNS_SOLID*) ni ); - break; + case PNS_ITEM::SOLID: + TRACE( 2, "iter %d: walk-solid ", aIter ); + st = onCollidingSolid( currentLine, (PNS_SOLID*) ni ); + break; - default: - break; + default: + break; } } @@ -996,25 +996,25 @@ void PNS_SHOVE::runOptimizer( PNS_NODE* aNode, PNS_LINE* aHead ) switch( effort ) { - case OE_LOW: - optFlags = PNS_OPTIMIZER::MERGE_OBTUSE; - n_passes = 1; - extend = 0; - break; + case OE_LOW: + optFlags = PNS_OPTIMIZER::MERGE_OBTUSE; + n_passes = 1; + extend = 0; + break; - case OE_MEDIUM: - optFlags = PNS_OPTIMIZER::MERGE_OBTUSE; - n_passes = 2; - extend = 1; - break; + case OE_MEDIUM: + optFlags = PNS_OPTIMIZER::MERGE_OBTUSE; + n_passes = 2; + extend = 1; + break; - case OE_FULL: - optFlags = PNS_OPTIMIZER::MERGE_SEGMENTS; - n_passes = 2; - break; + case OE_FULL: + optFlags = PNS_OPTIMIZER::MERGE_SEGMENTS; + n_passes = 2; + break; - default: - break; + default: + break; } if( Settings().SmartPads() ) @@ -1028,7 +1028,7 @@ void PNS_SHOVE::runOptimizer( PNS_NODE* aNode, PNS_LINE* aHead ) std::reverse( m_optimizerQueue.begin(), m_optimizerQueue.end() ); for( std::vector::iterator i = m_optimizerQueue.begin(); - i != m_optimizerQueue.end(); ++i) + i != m_optimizerQueue.end(); ++i ) { PNS_LINE* line = *i; @@ -1057,8 +1057,6 @@ void PNS_SHOVE::runOptimizer( PNS_NODE* aNode, PNS_LINE* aHead ) } } } - - } @@ -1120,5 +1118,5 @@ const PNS_LINE PNS_SHOVE::NewHead() const void PNS_SHOVE::SetInitialLine( PNS_LINE* aInitial ) { m_root = m_root->Branch(); - m_root->Remove ( aInitial ); + m_root->Remove( aInitial ); } diff --git a/pcbnew/tools/selection_conditions.h b/pcbnew/tools/selection_conditions.h index 39827b3bd0..99364b5f6e 100644 --- a/pcbnew/tools/selection_conditions.h +++ b/pcbnew/tools/selection_conditions.h @@ -28,7 +28,7 @@ #include #include -class SELECTION; +struct SELECTION; ///> Functor type that checks a specific condition for selected items. typedef boost::function SELECTION_CONDITION; diff --git a/utils/idftools/vrml_layer.cpp b/utils/idftools/vrml_layer.cpp index 65188249f7..54e8cedd90 100644 --- a/utils/idftools/vrml_layer.cpp +++ b/utils/idftools/vrml_layer.cpp @@ -848,7 +848,7 @@ bool VRML_LAYER::Tesselate( VRML_LAYER* holes, bool aHolesOnly ) std::ostringstream ostr; ostr << "Tesselate():FAILED: " << holes->GetError(); error = ostr.str(); - return NULL; + return false; } if( Fault ) diff --git a/utils/idftools/vrml_layer.h b/utils/idftools/vrml_layer.h index 01e4f343cb..2c7511da71 100644 --- a/utils/idftools/vrml_layer.h +++ b/utils/idftools/vrml_layer.h @@ -62,7 +62,6 @@ #define M_PI4 ( M_PI / 4.0 ) #endif -struct GLUtesselator; struct VERTEX_3D { From a95b5693fce635f871c180de0f626d4c1d096208 Mon Sep 17 00:00:00 2001 From: Blair Bonnett Date: Sat, 15 Nov 2014 09:14:01 -0500 Subject: [PATCH 09/10] Fix Linux desktop mime definitions to match FreeDesktop specification. (fixes lp:746710) --- .../linux/mime/applications/bitmap2component.desktop | 9 ++++----- resources/linux/mime/applications/cvpcb.desktop | 9 ++++----- resources/linux/mime/applications/eeschema.desktop | 2 +- resources/linux/mime/applications/gerbview.desktop | 9 ++++----- resources/linux/mime/applications/kicad.desktop | 2 +- resources/linux/mime/applications/pcbcalculator.desktop | 9 ++++----- resources/linux/mime/applications/pcbnew.desktop | 9 ++++----- 7 files changed, 22 insertions(+), 27 deletions(-) diff --git a/resources/linux/mime/applications/bitmap2component.desktop b/resources/linux/mime/applications/bitmap2component.desktop index 09990b1d1f..f2ff02404e 100644 --- a/resources/linux/mime/applications/bitmap2component.desktop +++ b/resources/linux/mime/applications/bitmap2component.desktop @@ -1,11 +1,10 @@ - [Desktop Entry] -Categories=Development;Electronics -Comment=Design a printed circuit board +Categories=Development;Electronics; +Comment=Create a component from a bitmap for use with KiCad Exec=bitmap2component GenericName=EDA Suite Icon=bitmap2component MimeType=application/x-bitmap2component-project; -Name=bitmap2component +Name=Bitmap to Component Converter Type=Application -Name[en_US]=bitmap2component +Name[en_US]=Bitmap to Component Converter diff --git a/resources/linux/mime/applications/cvpcb.desktop b/resources/linux/mime/applications/cvpcb.desktop index 4d2b818aa1..4610839e3d 100644 --- a/resources/linux/mime/applications/cvpcb.desktop +++ b/resources/linux/mime/applications/cvpcb.desktop @@ -1,11 +1,10 @@ - [Desktop Entry] -Categories=Development;Electronics -Comment=Design a printed circuit board +Categories=Development;Electronics; +Comment=Assign footprints to symbols (part of KiCad) Exec=cvpcb GenericName=EDA Suite Icon=cvpcb MimeType=application/x-cvpcb-project; -Name=cvpcb +Name=CvPcb Type=Application -Name[en_US]=cvpcb +Name[en_US]=CvPcb diff --git a/resources/linux/mime/applications/eeschema.desktop b/resources/linux/mime/applications/eeschema.desktop index 0efd102ff5..41b1ba3244 100644 --- a/resources/linux/mime/applications/eeschema.desktop +++ b/resources/linux/mime/applications/eeschema.desktop @@ -1,5 +1,5 @@ [Desktop Entry] -Categories=Development;Electronics +Categories=Development;Electronics; Comment=Design an electronic schematic Comment[fr]=Dessiner des schémas électroniques Exec=eeschema %f diff --git a/resources/linux/mime/applications/gerbview.desktop b/resources/linux/mime/applications/gerbview.desktop index 620f731769..42e3a83643 100644 --- a/resources/linux/mime/applications/gerbview.desktop +++ b/resources/linux/mime/applications/gerbview.desktop @@ -1,11 +1,10 @@ - [Desktop Entry] -Categories=Development;Electronics -Comment=Design a printed circuit board +Categories=Development;Electronics; +Comment=View gerber files Exec=gerbview GenericName=EDA Suite Icon=gerbview MimeType=application/x-gerbview-project; -Name=gerbview +Name=GerbView Type=Application -Name[en_US]=gerbview +Name[en_US]=GerbView diff --git a/resources/linux/mime/applications/kicad.desktop b/resources/linux/mime/applications/kicad.desktop index bf813160f7..e9df0f0aca 100644 --- a/resources/linux/mime/applications/kicad.desktop +++ b/resources/linux/mime/applications/kicad.desktop @@ -1,5 +1,5 @@ [Desktop Entry] -Categories=Development;Electronics +Categories=Development;Electronics; Comment=Design a printed circuit board Comment[fr]=Concevoir un circuit imprimé Exec=kicad %f diff --git a/resources/linux/mime/applications/pcbcalculator.desktop b/resources/linux/mime/applications/pcbcalculator.desktop index 4ae5e3e841..ce37e646c8 100644 --- a/resources/linux/mime/applications/pcbcalculator.desktop +++ b/resources/linux/mime/applications/pcbcalculator.desktop @@ -1,11 +1,10 @@ - [Desktop Entry] -Categories=Development;Electronics -Comment=Design a printed circuit board +Categories=Development;Electronics; +Comment=Calculator for various electronics related computations Exec=pcb_calculator GenericName=EDA Suite Icon=pcbcalculator MimeType=application/x-pcbcalculator-project; -Name=pcbcalculator +Name=Pcb Calculator Type=Application -Name[en_US]=pcbcalculator +Name[en_US]=Pcb Calculator diff --git a/resources/linux/mime/applications/pcbnew.desktop b/resources/linux/mime/applications/pcbnew.desktop index 57551ab8e5..120231edc3 100644 --- a/resources/linux/mime/applications/pcbnew.desktop +++ b/resources/linux/mime/applications/pcbnew.desktop @@ -1,11 +1,10 @@ - [Desktop Entry] -Categories=Development;Electronics -Comment=Design a printed circuit board +Categories=Development;Electronics; +Comment=Layout a printed circuit board Exec=pcbnew %f GenericName=EDA Suite Icon=pcbnew MimeType=application/x-pcbnew-pcb; -Name=pcbnew +Name=Pcbnew Type=Application -Name[en_US]=pcbnew +Name[en_US]=Pcbnew From 1dc51780953d63401df7df5889a9833b041e79c1 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Sat, 15 Nov 2014 14:06:05 -0500 Subject: [PATCH 10/10] Message panel consistency improvements and coding policy fixes. * Make title capitalization consistant. * Replace some instances of module with footprint. * Use angle instead of orientation where appropriate. * Remove abbreviations where it made sense. * Coding policy fixes. --- eeschema/lib_arc.cpp | 4 +- eeschema/lib_bezier.cpp | 4 +- eeschema/lib_circle.cpp | 4 +- eeschema/lib_field.cpp | 4 +- eeschema/lib_polyline.cpp | 4 +- eeschema/lib_rectangle.cpp | 2 +- eeschema/lib_text.cpp | 2 +- eeschema/sch_component.cpp | 2 +- eeschema/sch_marker.cpp | 2 +- eeschema/sch_sheet.cpp | 4 +- eeschema/sch_text.cpp | 8 +- gerbview/class_gerber_draw_item.cpp | 2 +- pcbnew/class_board.cpp | 4 +- pcbnew/class_drawsegment.cpp | 233 ++++++++++++++-------------- pcbnew/class_edge_mod.cpp | 7 +- pcbnew/class_module.cpp | 97 ++++++------ pcbnew/class_netinfo_item.cpp | 2 +- pcbnew/class_pad.cpp | 15 +- pcbnew/class_pcb_text.cpp | 6 +- pcbnew/class_text_mod.cpp | 6 +- pcbnew/class_track.cpp | 12 +- pcbnew/class_zone.cpp | 8 +- 22 files changed, 216 insertions(+), 216 deletions(-) diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index 5876194af2..25b6b706bd 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -557,12 +557,12 @@ void LIB_ARC::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) msg = StringFromValue( g_UserUnit, m_Width, true ); - aList.push_back( MSG_PANEL_ITEM( _( "Line width" ), msg, BLUE ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) ); msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x, bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y ); - aList.push_back( MSG_PANEL_ITEM( _( "Bounding box" ), msg, BROWN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Bounding Box" ), msg, BROWN ) ); } diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index 97c9f1d847..8744ff30b9 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -413,10 +413,10 @@ void LIB_BEZIER::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) msg = StringFromValue( g_UserUnit, m_Width, true ); - aList.push_back( MSG_PANEL_ITEM( _( "Line width" ), msg, BLUE ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) ); msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x, bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y ); - aList.push_back( MSG_PANEL_ITEM( _( "Bounding box" ), msg, BROWN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Bounding Box" ), msg, BROWN ) ); } diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index b6a7719cfd..2a5066e772 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -272,7 +272,7 @@ void LIB_CIRCLE::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) msg = StringFromValue( g_UserUnit, m_Width, true ); - aList.push_back( MSG_PANEL_ITEM( _( "Line width" ), msg, BLUE ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) ); msg = StringFromValue( g_UserUnit, m_Radius, true ); aList.push_back( MSG_PANEL_ITEM( _( "Radius" ), msg, RED ) ); @@ -280,7 +280,7 @@ void LIB_CIRCLE::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x, bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y ); - aList.push_back( MSG_PANEL_ITEM( _( "Bounding box" ), msg, BROWN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Bounding Box" ), msg, BROWN ) ); } diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 6d3f4cc899..814799bdd1 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -753,10 +753,10 @@ void LIB_FIELD::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Style" ), msg, MAGENTA ) ); msg = StringFromValue( g_UserUnit, m_Size.x, true ); - aList.push_back( MSG_PANEL_ITEM( _( "Size X" ), msg, BLUE ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, BLUE ) ); msg = StringFromValue( g_UserUnit, m_Size.y, true ); - aList.push_back( MSG_PANEL_ITEM( _( "Size Y" ), msg, BLUE ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, BLUE ) ); // Display field name (ref, value ...) msg = GetName(); diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index 018a16818d..93efca8863 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -402,12 +402,12 @@ void LIB_POLYLINE::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) msg = StringFromValue( g_UserUnit, m_Width, true ); - aList.push_back( MSG_PANEL_ITEM( _( "Line width" ), msg, BLUE ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) ); msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x, bBox.GetOrigin().y, bBox.GetEnd().x, bBox.GetEnd().y ); - aList.push_back( MSG_PANEL_ITEM( _( "Bounding box" ), msg, BROWN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Bounding Box" ), msg, BROWN ) ); } diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index 13678149e3..b48ee4ceb9 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -252,7 +252,7 @@ void LIB_RECTANGLE::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) msg = StringFromValue( g_UserUnit, m_Width, true ); - aList.push_back( MSG_PANEL_ITEM( _( "Line width" ), msg, BLUE ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) ); } diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index d1ddee602e..d4b2a3f114 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -420,7 +420,7 @@ void LIB_TEXT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) msg = StringFromValue( g_UserUnit, m_Thickness, true ); - aList.push_back( MSG_PANEL_ITEM( _( "Line width" ), msg, BLUE ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) ); } diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index e63913f898..85ca4564b6 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -1516,7 +1516,7 @@ void SCH_COMPONENT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) // Display description of the component, and keywords found in lib aList.push_back( MSG_PANEL_ITEM( _( "Description" ), alias->GetDescription(), DARKCYAN ) ); - aList.push_back( MSG_PANEL_ITEM( _( "Key words" ), alias->GetKeyWords(), DARKCYAN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Key Words" ), alias->GetKeyWords(), DARKCYAN ) ); } } diff --git a/eeschema/sch_marker.cpp b/eeschema/sch_marker.cpp index f7cb4fba8f..d4c0422a1e 100644 --- a/eeschema/sch_marker.cpp +++ b/eeschema/sch_marker.cpp @@ -161,7 +161,7 @@ void SCH_MARKER::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) { wxString msg; - aList.push_back( MSG_PANEL_ITEM( _( "Electronics rule check error" ), + aList.push_back( MSG_PANEL_ITEM( _( "Electronics Rule Check Error" ), GetReporter().GetErrorText(), DARKRED ) ); } diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index a1bbfb2e32..6a732eb1e6 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -825,8 +825,8 @@ wxString SCH_SHEET::GetFileName( void ) const void SCH_SHEET::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) { - aList.push_back( MSG_PANEL_ITEM( _( "Sheet name" ), m_name, CYAN ) ); - aList.push_back( MSG_PANEL_ITEM( _( "File name" ), m_fileName, BROWN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Sheet Name" ), m_name, CYAN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "File Name" ), m_fileName, BROWN ) ); #if 0 // Set to 1 to display the sheet time stamp (mainly for test) wxString msg; diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 9cbf975e06..139520ff93 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -708,7 +708,7 @@ void SCH_TEXT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) switch( Type() ) { case SCH_TEXT_T: - msg = _( "Graphic text" ); + msg = _( "Graphic Text" ); break; case SCH_LABEL_T: @@ -716,11 +716,11 @@ void SCH_TEXT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) break; case SCH_GLOBAL_LABEL_T: - msg = _( "Global label" ); + msg = _( "Global Label" ); break; case SCH_HIERARCHICAL_LABEL_T: - msg = _( "Hierarchical label" ); + msg = _( "Hierarchical Label" ); break; case SCH_SHEET_PIN_T: @@ -767,7 +767,7 @@ void SCH_TEXT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) if( m_Bold ) style += 2; - aList.push_back( MSG_PANEL_ITEM( _("Style"), textStyle[style], BROWN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Style" ), textStyle[style], BROWN ) ); // Display electricat type if it is relevant diff --git a/gerbview/class_gerber_draw_item.cpp b/gerbview/class_gerber_draw_item.cpp index e7e2341f8c..33318b6d43 100644 --- a/gerbview/class_gerber_draw_item.cpp +++ b/gerbview/class_gerber_draw_item.cpp @@ -553,7 +553,7 @@ void GERBER_DRAW_ITEM::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) // Display graphic layer number msg.Printf( wxT( "%d" ), GetLayer() + 1 ); - aList.push_back( MSG_PANEL_ITEM( _( "Graphic layer" ), msg, BROWN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Graphic Layer" ), msg, BROWN ) ); // Display item rotation // The full rotation is Image rotation + m_lyrRotation diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 6bc0154677..0d29750595 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -920,7 +920,7 @@ void BOARD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Vias" ), txt, DARKGREEN ) ); txt.Printf( wxT( "%d" ), trackSegmentsCount ); - aList.push_back( MSG_PANEL_ITEM( _( "trackSegm" ), txt, DARKGREEN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Track Segments" ), txt, DARKGREEN ) ); txt.Printf( wxT( "%d" ), GetNodesCount() ); aList.push_back( MSG_PANEL_ITEM( _( "Nodes" ), txt, DARKCYAN ) ); @@ -937,7 +937,7 @@ void BOARD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Links" ), txt, DARKGREEN ) ); txt.Printf( wxT( "%d" ), GetRatsnestsCount() - GetUnconnectedNetCount() ); - aList.push_back( MSG_PANEL_ITEM( _( "Connect" ), txt, DARKGREEN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Connections" ), txt, DARKGREEN ) ); txt.Printf( wxT( "%d" ), GetUnconnectedNetCount() ); aList.push_back( MSG_PANEL_ITEM( _( "Unconnected" ), txt, BLUE ) ); diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index 9f7e71fc0e..ed043ada0b 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -247,8 +247,9 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, } if( mode == LINE ) + { GRArc( panel->GetClipBox(), DC, ux0, uy0, StAngle, EndAngle, radius, color ); - + } else if( mode == SKETCH ) { GRArc( panel->GetClipBox(), DC, ux0, uy0, StAngle, EndAngle, @@ -264,14 +265,17 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, break; case S_CURVE: - m_BezierPoints = Bezier2Poly(m_Start, m_BezierC1, m_BezierC2, m_End); + m_BezierPoints = Bezier2Poly( m_Start, m_BezierC1, m_BezierC2, m_End ); - for (unsigned int i=1; i < m_BezierPoints.size(); i++) { + for( unsigned int i=1; i < m_BezierPoints.size(); i++ ) + { if( mode == LINE ) + { GRLine( panel->GetClipBox(), DC, m_BezierPoints[i].x, m_BezierPoints[i].y, m_BezierPoints[i-1].x, m_BezierPoints[i-1].y, 0, color ); + } else if( mode == SKETCH ) { GRCSegm( panel->GetClipBox(), DC, @@ -332,7 +336,7 @@ void DRAWSEGMENT::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) case S_ARC: aList.push_back( MSG_PANEL_ITEM( shape, _( "Arc" ), RED ) ); msg.Printf( wxT( "%.1f" ), m_Angle / 10.0 ); - aList.push_back( MSG_PANEL_ITEM( _("Angle"), msg, RED ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, RED ) ); break; case S_CURVE: @@ -384,93 +388,93 @@ const EDA_RECT DRAWSEGMENT::GetBoundingBox() const break; case S_ARC: + { + bbox.Merge( m_End ); + wxPoint end = m_End; + RotatePoint( &end, m_Start, -m_Angle ); + bbox.Merge( end ); + + // Determine the starting quarter + // 0 right-bottom + // 1 left-bottom + // 2 left-top + // 3 right-top + unsigned int quarter = 0; // assume right-bottom + + if( m_End.y < m_Start.y ) // change to left-top + quarter |= 3; + + if( m_End.x < m_Start.x ) // for left side, the LSB is 2nd bit negated + quarter ^= 1; + + int radius = GetRadius(); + int angle = (int) GetArcAngleStart() % 900 + m_Angle; + bool directionCW = ( m_Angle > 0 ); // Is the direction of arc clockwise? + + if( !directionCW ) { - bbox.Merge( m_End ); - wxPoint end = m_End; - RotatePoint( &end, m_Start, -m_Angle ); - bbox.Merge( end ); - - // Determine the starting quarter - // 0 right-bottom - // 1 left-bottom - // 2 left-top - // 3 right-top - unsigned int quarter = 0; // assume right-bottom - - if( m_End.y < m_Start.y ) // change to left-top - quarter |= 3; - - if( m_End.x < m_Start.x ) // for left side, the LSB is 2nd bit negated - quarter ^= 1; - - int radius = GetRadius(); - int angle = (int) GetArcAngleStart() % 900 + m_Angle; - bool directionCW = ( m_Angle > 0 ); // Is the direction of arc clockwise? - - if( !directionCW ) - { - angle = 900 - angle; - quarter = ( quarter + 3 ) % 4; // -1 modulo arithmetic - } - - while( angle > 900 ) - { - switch( quarter ) - { - case 0: - bbox.Merge( wxPoint( m_Start.x, m_Start.y + radius ) ); // down - break; - - case 1: - bbox.Merge( wxPoint( m_Start.x - radius, m_Start.y ) ); // left - break; - - case 2: - bbox.Merge( wxPoint( m_Start.x, m_Start.y - radius ) ); // up - break; - - case 3: - bbox.Merge( wxPoint( m_Start.x + radius, m_Start.y ) ); // right - break; - } - - if( directionCW ) - ++quarter; - else - quarter += 3; // -1 modulo arithmetic - - quarter %= 4; - angle -= 900; - } + angle = 900 - angle; + quarter = ( quarter + 3 ) % 4; // -1 modulo arithmetic } + + while( angle > 900 ) + { + switch( quarter ) + { + case 0: + bbox.Merge( wxPoint( m_Start.x, m_Start.y + radius ) ); // down + break; + + case 1: + bbox.Merge( wxPoint( m_Start.x - radius, m_Start.y ) ); // left + break; + + case 2: + bbox.Merge( wxPoint( m_Start.x, m_Start.y - radius ) ); // up + break; + + case 3: + bbox.Merge( wxPoint( m_Start.x + radius, m_Start.y ) ); // right + break; + } + + if( directionCW ) + ++quarter; + else + quarter += 3; // -1 modulo arithmetic + + quarter %= 4; + angle -= 900; + } + } break; case S_POLYGON: + { + wxPoint p_end; + MODULE* module = GetParentModule(); + + for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ ) { - wxPoint p_end; - MODULE* module = GetParentModule(); + wxPoint pt = m_PolyPoints[ii]; - for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ ) + if( module ) // Transform, if we belong to a module { - wxPoint pt = m_PolyPoints[ii]; - - if( module ) // Transform, if we belong to a module - { - RotatePoint( &pt, module->GetOrientation() ); - pt += module->GetPosition(); - } - - if( ii == 0 ) - p_end = pt; - - bbox.SetX( std::min( bbox.GetX(), pt.x ) ); - bbox.SetY( std::min( bbox.GetY(), pt.y ) ); - p_end.x = std::max( p_end.x, pt.x ); - p_end.y = std::max( p_end.y, pt.y ); + RotatePoint( &pt, module->GetOrientation() ); + pt += module->GetPosition(); } - bbox.SetEnd( p_end ); + if( ii == 0 ) + p_end = pt; + + bbox.SetX( std::min( bbox.GetX(), pt.x ) ); + bbox.SetY( std::min( bbox.GetY(), pt.y ) ); + p_end.x = std::max( p_end.x, pt.x ); + p_end.y = std::max( p_end.y, pt.y ); } + + bbox.SetEnd( p_end ); + } break; default: @@ -490,46 +494,46 @@ bool DRAWSEGMENT::HitTest( const wxPoint& aPosition ) const { case S_CIRCLE: case S_ARC: + { + wxPoint relPos = aPosition - GetCenter(); + int radius = GetRadius(); + int dist = KiROUND( EuclideanNorm( relPos ) ); + + if( abs( radius - dist ) <= ( m_Width / 2 ) ) { - wxPoint relPos = aPosition - GetCenter(); - int radius = GetRadius(); - int dist = KiROUND( EuclideanNorm( relPos ) ); + if( m_Shape == S_CIRCLE ) + return true; - if( abs( radius - dist ) <= ( m_Width / 2 ) ) + // For arcs, the test point angle must be >= arc angle start + // and <= arc angle end + // However angle values > 360 deg are not easy to handle + // so we calculate the relative angle between arc start point and teast point + // this relative arc should be < arc angle if arc angle > 0 (CW arc) + // and > arc angle if arc angle < 0 (CCW arc) + double arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg, in 0.1 deg + + double arc_hittest = ArcTangente( relPos.y, relPos.x ); + + // Calculate relative angle between the starting point of the arc, and the test point + arc_hittest -= arc_angle_start; + + // Normalise arc_hittest between 0 ... 360 deg + NORMALIZE_ANGLE_POS( arc_hittest ); + + // Check angle: inside the arc angle when it is > 0 + // and outside the not drawn arc when it is < 0 + if( GetAngle() >= 0.0 ) { - if( m_Shape == S_CIRCLE ) + if( arc_hittest <= GetAngle() ) + return true; + } + else + { + if( arc_hittest >= (3600.0 + GetAngle()) ) return true; - - // For arcs, the test point angle must be >= arc angle start - // and <= arc angle end - // However angle values > 360 deg are not easy to handle - // so we calculate the relative angle between arc start point and teast point - // this relative arc should be < arc angle if arc angle > 0 (CW arc) - // and > arc angle if arc angle < 0 (CCW arc) - double arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg, in 0.1 deg - - double arc_hittest = ArcTangente( relPos.y, relPos.x ); - - // Calculate relative angle between the starting point of the arc, and the test point - arc_hittest -= arc_angle_start; - - // Normalise arc_hittest between 0 ... 360 deg - NORMALIZE_ANGLE_POS( arc_hittest ); - - // Check angle: inside the arc angle when it is > 0 - // and outside the not drawn arc when it is < 0 - if( GetAngle() >= 0.0 ) - { - if( arc_hittest <= GetAngle() ) - return true; - } - else - { - if( arc_hittest >= (3600.0 + GetAngle()) ) - return true; - } } } + } break; case S_CURVE: @@ -549,6 +553,7 @@ bool DRAWSEGMENT::HitTest( const wxPoint& aPosition ) const wxASSERT( 0 ); break; } + return false; } diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index f861798893..62661bc46f 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -280,11 +280,11 @@ void EDGE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) if( !board ) return; - aList.push_back( MSG_PANEL_ITEM( _( "Module" ), module->GetReference(), DARKCYAN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), module->GetReference(), DARKCYAN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Value" ), module->GetValue(), BLUE ) ); msg.Printf( wxT( "%8.8lX" ), module->GetTimeStamp() ); aList.push_back( MSG_PANEL_ITEM( _( "TimeStamp" ), msg, BROWN ) ); - aList.push_back( MSG_PANEL_ITEM( _( "Mod Layer" ), + aList.push_back( MSG_PANEL_ITEM( _( "Footprint Layer" ), module->GetLayerName(), RED ) ); // append the features shared with the base class @@ -311,8 +311,7 @@ EDA_ITEM* EDGE_MODULE::Clone() const } - -void EDGE_MODULE::Flip(const wxPoint& aCentre ) +void EDGE_MODULE::Flip( const wxPoint& aCentre ) { wxPoint pt; diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index d564b3f639..523b019e56 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -242,21 +242,21 @@ void MODULE::Copy( MODULE* aModule ) switch( item->Type() ) { case PCB_MODULE_TEXT_T: - { - TEXTE_MODULE* textm = new TEXTE_MODULE( this ); - textm->Copy( static_cast( item ) ); - m_Drawings.PushBack( textm ); - break; - } + { + TEXTE_MODULE* textm = new TEXTE_MODULE( this ); + textm->Copy( static_cast( item ) ); + m_Drawings.PushBack( textm ); + break; + } case PCB_MODULE_EDGE_T: - { - EDGE_MODULE * edge; - edge = new EDGE_MODULE( this ); - edge->Copy( (EDGE_MODULE*) item ); - m_Drawings.PushBack( edge ); - break; - } + { + EDGE_MODULE * edge; + edge = new EDGE_MODULE( this ); + edge->Copy( (EDGE_MODULE*) item ); + m_Drawings.PushBack( edge ); + break; + } default: wxLogMessage( wxT( "MODULE::Copy() Internal Err: unknown type" ) ); @@ -322,14 +322,14 @@ void MODULE::Add( BOARD_ITEM* aBoardItem, bool doAppend ) break; default: - { - wxString msg; - msg.Printf( wxT( "MODULE::Add() needs work: BOARD_ITEM type (%d) not handled" ), - aBoardItem->Type() ); - wxFAIL_MSG( msg ); + { + wxString msg; + msg.Printf( wxT( "MODULE::Add() needs work: BOARD_ITEM type (%d) not handled" ), + aBoardItem->Type() ); + wxFAIL_MSG( msg ); - return; - } + return; + } } aBoardItem->SetParent( this ); @@ -353,12 +353,12 @@ BOARD_ITEM* MODULE::Remove( BOARD_ITEM* aBoardItem ) return m_Pads.Remove( static_cast( aBoardItem ) ); default: - { - wxString msg; - msg.Printf( wxT( "MODULE::Remove() needs work: BOARD_ITEM type (%d) not handled" ), - aBoardItem->Type() ); - wxFAIL_MSG( msg ); - } + { + wxString msg; + msg.Printf( wxT( "MODULE::Remove() needs work: BOARD_ITEM type (%d) not handled" ), + aBoardItem->Type() ); + wxFAIL_MSG( msg ); + } } return NULL; @@ -552,7 +552,7 @@ void MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Last Change" ), msg, BROWN ) ); // display schematic path - aList.push_back( MSG_PANEL_ITEM( _( "Netlist path" ), m_Path, BROWN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Netlist Path" ), m_Path, BROWN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), RED ) ); @@ -576,32 +576,32 @@ void MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) if( m_ModuleStatus & MODULE_is_PLACED ) msg[1] = 'P'; - aList.push_back( MSG_PANEL_ITEM( _( "Stat" ), msg, MAGENTA ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Status" ), msg, MAGENTA ) ); msg.Printf( wxT( "%.1f" ), m_Orient / 10.0 ); - aList.push_back( MSG_PANEL_ITEM( _( "Orient" ), msg, BROWN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, BROWN ) ); // Controls on right side of the dialog switch( m_Attributs & 255 ) { case 0: - msg = _("Normal"); + msg = _( "Normal" ); break; case MOD_CMS: - msg = _("Insert"); + msg = _( "Insert" ); break; case MOD_VIRTUAL: - msg = _("Virtual"); + msg = _( "Virtual" ); break; default: - msg = wxT("???"); + msg = wxT( "???" ); break; } - aList.push_back( MSG_PANEL_ITEM( _( "Attrib" ), msg, BROWN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Attributes" ), msg, BROWN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), FROM_UTF8( m_fpid.Format().c_str() ), BLUE ) ); msg = _( "No 3D shape" ); @@ -619,7 +619,7 @@ void MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) wxString doc, keyword; doc.Printf( _( "Doc: %s" ), GetChars( m_Doc ) ); - keyword.Printf( _( "KeyW: %s" ), GetChars( m_KeyWord ) ); + keyword.Printf( _( "Key Words: %s" ), GetChars( m_KeyWord ) ); aList.push_back( MSG_PANEL_ITEM( doc, keyword, BLACK ) ); } @@ -1047,21 +1047,21 @@ void MODULE::MoveAnchorPosition( const wxPoint& aMoveVector ) switch( item->Type() ) { case PCB_MODULE_EDGE_T: - { - EDGE_MODULE* edge = static_cast( item ); - edge->m_Start0 += moveVector; - edge->m_End0 += moveVector; - edge->SetDrawCoord(); - break; - } + { + EDGE_MODULE* edge = static_cast( item ); + edge->m_Start0 += moveVector; + edge->m_End0 += moveVector; + edge->SetDrawCoord(); + break; + } case PCB_MODULE_TEXT_T: - { - TEXTE_MODULE* text = static_cast( item ); - text->SetPos0( text->GetPos0() + moveVector ); - text->SetDrawCoord(); - break; - } + { + TEXTE_MODULE* text = static_cast( item ); + text->SetPos0( text->GetPos0() + moveVector ); + text->SetDrawCoord(); + break; + } default: break; @@ -1103,7 +1103,6 @@ void MODULE::SetOrientation( double newangle ) { static_cast( item )->SetDrawCoord(); } - else if( item->Type() == PCB_MODULE_TEXT_T ) { static_cast( item )->SetDrawCoord(); diff --git a/pcbnew/class_netinfo_item.cpp b/pcbnew/class_netinfo_item.cpp index 4f54221a98..627fe0451e 100644 --- a/pcbnew/class_netinfo_item.cpp +++ b/pcbnew/class_netinfo_item.cpp @@ -132,7 +132,7 @@ void NETINFO_ITEM::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) // Displays the full net length (tracks on pcb + internal ICs connections ): txt = ::LengthDoubleToString( lengthnet + lengthPadToDie ); - aList.push_back( MSG_PANEL_ITEM( _( "Net Length:" ), txt, RED ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Net Length" ), txt, RED ) ); // Displays the net length of tracks only: txt = ::LengthDoubleToString( lengthnet ); diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index b628b56ab9..1250007d43 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -607,7 +607,7 @@ void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList ) if( module ) { wxString msg = module->GetReference(); - aList.push_back( MSG_PANEL_ITEM( _( "Module" ), msg, DARKCYAN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), msg, DARKCYAN ) ); StringPadName( Line ); aList.push_back( MSG_PANEL_ITEM( _( "Pad" ), Line, BROWN ) ); } @@ -629,10 +629,10 @@ void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList ) aList.push_back( MSG_PANEL_ITEM( ShowPadShape(), ShowPadAttr(), DARKGREEN ) ); Line = ::CoordinateToString( m_Size.x ); - aList.push_back( MSG_PANEL_ITEM( _( "H Size" ), Line, RED ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Width" ), Line, RED ) ); Line = ::CoordinateToString( m_Size.y ); - aList.push_back( MSG_PANEL_ITEM( _( "V Size" ), Line, RED ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Height" ), Line, RED ) ); Line = ::CoordinateToString( (unsigned) m_Drill.x ); @@ -658,13 +658,10 @@ void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList ) else Line.Printf( wxT( "%3.1f" ), m_Orient / 10.0 ); - aList.push_back( MSG_PANEL_ITEM( _( "Orient" ), Line, LIGHTBLUE ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), Line, LIGHTBLUE ) ); - Line = ::CoordinateToString( m_Pos.x ); - aList.push_back( MSG_PANEL_ITEM( _( "X Pos" ), Line, LIGHTBLUE ) ); - - Line = ::CoordinateToString( m_Pos.y ); - aList.push_back( MSG_PANEL_ITEM( _( "Y pos" ), Line, LIGHTBLUE ) ); + Line = ::CoordinateToString( m_Pos.x ) + wxT( ", " ) + ::CoordinateToString( m_Pos.y ); + aList.push_back( MSG_PANEL_ITEM( _( "Position" ), Line, LIGHTBLUE ) ); if( GetPadToDieLength() ) { diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index ecccb5ca41..a296fcaf91 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -143,16 +143,16 @@ void TEXTE_PCB::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), _( "Yes" ), DARKGREEN ) ); msg.Printf( wxT( "%.1f" ), m_Orient / 10.0 ); - aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), msg, DARKGREEN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) ); msg = ::CoordinateToString( m_Thickness ); aList.push_back( MSG_PANEL_ITEM( _( "Thickness" ), msg, MAGENTA ) ); msg = ::CoordinateToString( m_Size.x ); - aList.push_back( MSG_PANEL_ITEM( _( "Size X" ), msg, RED ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, RED ) ); msg = ::CoordinateToString( m_Size.y ); - aList.push_back( MSG_PANEL_ITEM( _( "Size Y" ), msg, RED ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, RED ) ); } const EDA_RECT TEXTE_PCB::GetBoundingBox() const diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index 645877f8aa..50b9957fb2 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -408,16 +408,16 @@ void TEXTE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), msg, DARKGREEN ) ); msg.Printf( wxT( "%.1f" ), m_Orient / 10.0 ); - aList.push_back( MSG_PANEL_ITEM( _( "Orient" ), msg, DARKGREEN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) ); msg = ::CoordinateToString( m_Thickness ); aList.push_back( MSG_PANEL_ITEM( _( "Thickness" ), msg, DARKGREEN ) ); msg = ::CoordinateToString( m_Size.x ); - aList.push_back( MSG_PANEL_ITEM( _( "H Size" ), msg, RED ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, RED ) ); msg = ::CoordinateToString( m_Size.y ); - aList.push_back( MSG_PANEL_ITEM( _( "V Size" ), msg, RED ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, RED ) ); } diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index b7c4a76c07..d70e650dbc 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -1023,15 +1023,15 @@ void TRACK::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) double lenPadToDie = 0; board->MarkTrace( this, NULL, &trackLen, &lenPadToDie, false ); msg = ::LengthDoubleToString( trackLen ); - aList.push_back( MSG_PANEL_ITEM( _( "Track Len" ), msg, DARKCYAN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Length" ), msg, DARKCYAN ) ); if( lenPadToDie != 0 ) { msg = ::LengthDoubleToString( trackLen + lenPadToDie ); - aList.push_back( MSG_PANEL_ITEM( _( "Full Len" ), msg, DARKCYAN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Full Length" ), msg, DARKCYAN ) ); msg = ::LengthDoubleToString( lenPadToDie ); - aList.push_back( MSG_PANEL_ITEM( _( "In Package" ), msg, DARKCYAN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Pad To Die Length" ), msg, DARKCYAN ) ); } } @@ -1155,7 +1155,7 @@ void SEGZONE::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList ) if( board ) msg = board->GetLayerName( m_Layer ); else - msg.Printf(wxT("%d"), m_Layer ); + msg.Printf( wxT( "%d" ), m_Layer ); aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), msg, BROWN ) ); @@ -1209,7 +1209,7 @@ void VIA::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList ) msg = board->GetLayerName( top_layer ) + wxT( "/" ) + board->GetLayerName( bottom_layer ); else - msg.Printf(wxT("%d/%d"), top_layer, bottom_layer ); + msg.Printf( wxT( "%d/%d" ), top_layer, bottom_layer ); aList.push_back( MSG_PANEL_ITEM( _( "Layers" ), msg, BROWN ) ); @@ -1217,7 +1217,7 @@ void VIA::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList ) msg = ::CoordinateToString( (unsigned) m_Width ); // Display diameter value: - aList.push_back( MSG_PANEL_ITEM( _( "Diam" ), msg, DARKCYAN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Diameter" ), msg, DARKCYAN ) ); // Display drill value int drill_value = GetDrillValue(); diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index ed9c217cab..40ccb300a4 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -608,7 +608,7 @@ void ZONE_CONTAINER::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) msg.Empty(); if( GetDoNotAllowVias() ) - AccumulateDescription( msg, _("No via") ); + AccumulateDescription( msg, _( "No via" ) ); if( GetDoNotAllowTracks() ) AccumulateDescription( msg, _("No track") ); @@ -663,16 +663,16 @@ void ZONE_CONTAINER::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) else msg = _( "Polygons" ); - aList.push_back( MSG_PANEL_ITEM( _( "Fill mode" ), msg, BROWN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Fill Mode" ), msg, BROWN ) ); // Useful for statistics : msg.Printf( wxT( "%d" ), (int) m_Poly->m_HatchLines.size() ); - aList.push_back( MSG_PANEL_ITEM( _( "Hatch lines" ), msg, BLUE ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Hatch Lines" ), msg, BLUE ) ); if( m_FilledPolysList.GetCornersCount() ) { msg.Printf( wxT( "%d" ), (int) m_FilledPolysList.GetCornersCount() ); - aList.push_back( MSG_PANEL_ITEM( _( "Corners in DrawList" ), msg, BLUE ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Corner Count" ), msg, BLUE ) ); } }