From f629898c8bf16adfc8b73d04e17a1e6c84084af4 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Tue, 17 Oct 2023 08:07:15 -0400 Subject: [PATCH] Coding policy fixes. --- eeschema/dialogs/dialog_symbol_properties.cpp | 17 +++++++------- pcbnew/dialogs/dialog_export_vrml.cpp | 22 +++++++++---------- pcbnew/import_gfx/dialog_import_gfx_pcb.cpp | 6 +++-- pcbnew/router/pns_item.cpp | 19 +++++++++------- pcbnew/router/pns_walkaround.cpp | 19 +++++++++++----- 5 files changed, 48 insertions(+), 35 deletions(-) diff --git a/eeschema/dialogs/dialog_symbol_properties.cpp b/eeschema/dialogs/dialog_symbol_properties.cpp index cc0eaf7dbb..ff530ffa4a 100644 --- a/eeschema/dialogs/dialog_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_symbol_properties.cpp @@ -67,12 +67,6 @@ enum PIN_TABLE_COL_ORDER class SCH_PIN_TABLE_DATA_MODEL : public wxGridTableBase, public std::vector { -protected: - std::vector m_nameAttrs; - wxGridCellAttr* m_readOnlyAttr; - wxGridCellAttr* m_typeAttr; - wxGridCellAttr* m_shapeAttr; - public: SCH_PIN_TABLE_DATA_MODEL() : m_readOnlyAttr( nullptr ), @@ -298,6 +292,12 @@ public: return compare( lhs, rhs, aSortCol, ascending ); } ); } + +protected: + std::vector m_nameAttrs; + wxGridCellAttr* m_readOnlyAttr; + wxGridCellAttr* m_typeAttr; + wxGridCellAttr* m_shapeAttr; }; @@ -746,7 +746,7 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow() // reference. m_symbol->SetRef( &GetParent()->GetCurrentSheet(), m_fields->at( REFERENCE_FIELD ).GetText() ); - // Similar for Value and Footprint, except that the GUI behaviour is that they are kept + // Similar for Value and Footprint, except that the GUI behavior is that they are kept // in sync between multiple instances. m_symbol->SetValueFieldText( m_fields->at( VALUE_FIELD ).GetText() ); m_symbol->SetFootprintFieldText( m_fields->at( FOOTPRINT_FIELD ).GetText() ); @@ -907,7 +907,8 @@ void DIALOG_SYMBOL_PROPERTIES::OnAddField( wxCommandEvent& event ) SCHEMATIC_SETTINGS& settings = m_symbol->Schematic()->Settings(); int fieldID = (int) m_fields->size(); SCH_FIELD newField( VECTOR2I( 0, 0 ), fieldID, m_symbol, - TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldID, DO_TRANSLATE ) ); + TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldID, + DO_TRANSLATE ) ); newField.SetTextAngle( m_fields->at( REFERENCE_FIELD ).GetTextAngle() ); newField.SetTextSize( VECTOR2I( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) ); diff --git a/pcbnew/dialogs/dialog_export_vrml.cpp b/pcbnew/dialogs/dialog_export_vrml.cpp index 94d3926478..d20f1568bd 100644 --- a/pcbnew/dialogs/dialog_export_vrml.cpp +++ b/pcbnew/dialogs/dialog_export_vrml.cpp @@ -45,17 +45,6 @@ class DIALOG_EXPORT_3DFILE : public DIALOG_EXPORT_3DFILE_BASE { -private: - PCB_EDIT_FRAME* m_parent; - int m_unitsOpt; // Remember last units option - bool m_copy3DFilesOpt; // Remember last copy model files option - bool m_useRelativePathsOpt; // Remember last use absolute paths option - int m_RefUnits; // Remember last units for Reference Point - double m_XRef; // Remember last X Reference Point - double m_YRef; // Remember last Y Reference Point - int m_originMode; // Origin selection option - // (0 = user, 1 = board center) - public: DIALOG_EXPORT_3DFILE( PCB_EDIT_FRAME* parent ) : DIALOG_EXPORT_3DFILE_BASE( parent ), m_parent( parent ) @@ -181,6 +170,17 @@ public: } bool TransferDataFromWindow() override; + +private: + PCB_EDIT_FRAME* m_parent; + int m_unitsOpt; // Remember last units option + bool m_copy3DFilesOpt; // Remember last copy model files option + bool m_useRelativePathsOpt; // Remember last use absolute paths option + int m_RefUnits; // Remember last units for Reference Point + double m_XRef; // Remember last X Reference Point + double m_YRef; // Remember last Y Reference Point + int m_originMode; // Origin selection option + // (0 = user, 1 = board center) }; diff --git a/pcbnew/import_gfx/dialog_import_gfx_pcb.cpp b/pcbnew/import_gfx/dialog_import_gfx_pcb.cpp index f82244e120..64e464cdb9 100644 --- a/pcbnew/import_gfx/dialog_import_gfx_pcb.cpp +++ b/pcbnew/import_gfx/dialog_import_gfx_pcb.cpp @@ -56,7 +56,8 @@ const std::map dxfUnitsMap = { }; -DIALOG_IMPORT_GFX_PCB::DIALOG_IMPORT_GFX_PCB( PCB_BASE_FRAME* aParent, bool aImportAsFootprintGraphic ) : +DIALOG_IMPORT_GFX_PCB::DIALOG_IMPORT_GFX_PCB( PCB_BASE_FRAME* aParent, + bool aImportAsFootprintGraphic ) : DIALOG_IMPORT_GFX_PCB_BASE( aParent ), m_parent( aParent ), m_xOrigin( aParent, m_xLabel, m_xCtrl, m_xUnits ), @@ -273,7 +274,8 @@ bool DIALOG_IMPORT_GFX_PCB::TransferDataFromWindow() m_importer->SetPlugin( std::move( plugin ) ); m_importer->SetLayer( PCB_LAYER_ID( m_SelLayerBox->GetLayerSelection() ) ); - m_importer->SetImportOffsetMM( { pcbIUScale.IUTomm( origin.x ), pcbIUScale.IUTomm( origin.y ) } ); + m_importer->SetImportOffsetMM( { pcbIUScale.IUTomm( origin.x ), + pcbIUScale.IUTomm( origin.y ) } ); LOCALE_IO dummy; // Ensure floats can be read. diff --git a/pcbnew/router/pns_item.cpp b/pcbnew/router/pns_item.cpp index cca36bad83..1962ed95a5 100644 --- a/pcbnew/router/pns_item.cpp +++ b/pcbnew/router/pns_item.cpp @@ -44,6 +44,7 @@ static void dumpObstacles( const PNS::NODE::OBSTACLES &obstacles ) } } + // prune self-collisions, i.e. a via/pad annular ring with its own hole static bool shouldWeConsiderHoleCollisions( const ITEM* aItem, const ITEM* aHead ) { @@ -60,14 +61,16 @@ static bool shouldWeConsiderHoleCollisions( const ITEM* aItem, const ITEM* aHead const VIA* parentViaI = dyn_cast( parentI ); const VIA* parentViaH = dyn_cast( parentH ); - // Note to self: the if() below is an ugly heuristic to determine if we aren't trying to check for collisions - // of the hole of the via with another (although identical) copy of it. Such case occurs when - // checking a LINE against a NODE where this LINE has been already added. LINE has no notion of - // ownership of it's via (it's just a copy) and before hole-to-hole clearance support has been introduced - // it didn't matter becasue we didn't consider collisions of the objects belonging to the same net anyway - // Now that hole clearance check doesn't care about the nets assigned to the parent vias/solids, I'll probably - // have to refactor the LINE class to manage ownership of its (optional) VIA. For the moment, we just treat - // via holes that are geometrically identical and belonging to the same net as non-colliding. + // Note to self: the if() below is an ugly heuristic to determine if we aren't trying + // to check for collisions of the hole of the via with another (although identical) + // copy of it. Such case occurs when checking a LINE against a NODE where this LINE + // has been already added. LINE has no notion of ownership of it's via (it's just a + // copy) and before hole-to-hole clearance support has been introduced it didn't matter + // becasue we didn't consider collisions of the objects belonging to the same net anyway + // Now that hole clearance check doesn't care about the nets assigned to the parent + // vias/solids, I'll probably have to refactor the LINE class to manage ownership of + // its (optional) VIA. For the moment, we just treat via holes that are geometrically + // identical and belonging to the same net as non-colliding. if( parentViaI && parentViaH && parentViaI->Pos() == parentViaH->Pos() && parentViaI->Diameter() == parentViaH->Diameter() diff --git a/pcbnew/router/pns_walkaround.cpp b/pcbnew/router/pns_walkaround.cpp index 180883afd1..18a7655f2a 100644 --- a/pcbnew/router/pns_walkaround.cpp +++ b/pcbnew/router/pns_walkaround.cpp @@ -100,15 +100,20 @@ WALKAROUND::WALKAROUND_STATUS WALKAROUND::singleStep( LINE& aPath, bool aWinding SHAPE_LINE_CHAIN path_walk; - SHAPE_LINE_CHAIN hull = current_obs->m_item->Hull( current_obs->m_clearance, aPath.Width() ); bool s_cw = aPath.Walkaround( hull, path_walk, aWindingDirection ); PNS_DBG( Dbg(), BeginGroup, "hull/walk", 1 ); - PNS_DBG( Dbg(), AddShape, &hull, RED, 0, wxString::Format( "hull-%s-%d-cl %d", aWindingDirection ? wxT( "cw" ) : wxT( "ccw" ), m_iteration, current_obs->m_clearance ) ); - PNS_DBG( Dbg(), AddShape, &aPath.CLine(), GREEN, 0, wxString::Format( "path-%s-%d", aWindingDirection ? wxT( "cw" ) : wxT( "ccw" ), m_iteration ) ); - PNS_DBG( Dbg(), AddShape, &path_walk, BLUE, 0, wxString::Format( "result-%s-%d", aWindingDirection ? wxT( "cw" ) : wxT( "ccw" ), m_iteration ) ); + PNS_DBG( Dbg(), AddShape, &hull, RED, 0, + wxString::Format( "hull-%s-%d-cl %d", aWindingDirection ? wxT( "cw" ) : wxT( "ccw" ), + m_iteration, current_obs->m_clearance ) ); + PNS_DBG( Dbg(), AddShape, &aPath.CLine(), GREEN, 0, + wxString::Format( "path-%s-%d", aWindingDirection ? wxT( "cw" ) : wxT( "ccw" ), + m_iteration ) ); + PNS_DBG( Dbg(), AddShape, &path_walk, BLUE, 0, + wxString::Format( "result-%s-%d", aWindingDirection ? wxT( "cw" ) : wxT( "ccw" ), + m_iteration ) ); PNS_DBG( Dbg(), Message, wxString::Format( wxT( "Stat cw %d" ), !!s_cw ) ); PNS_DBGN( Dbg(), EndGroup ); @@ -200,7 +205,8 @@ const WALKAROUND::RESULT WALKAROUND::Route( const LINE& aInitialPath ) // Safety valve - if( m_lengthLimitOn && path_cw.Line().Length() > lengthLimit && path_ccw.Line().Length() > lengthLimit ) + if( m_lengthLimitOn && path_cw.Line().Length() > lengthLimit && path_ccw.Line().Length() > + lengthLimit ) break; m_iteration++; @@ -257,7 +263,8 @@ WALKAROUND::WALKAROUND_STATUS WALKAROUND::Route( const LINE& aInitialPath, LINE& // special case for via-in-the-middle-of-track placement if( aInitialPath.PointCount() <= 1 ) { - if( aInitialPath.EndsWithVia() && m_world->CheckColliding( &aInitialPath.Via(), m_itemMask ) ) + if( aInitialPath.EndsWithVia() && m_world->CheckColliding( &aInitialPath.Via(), + m_itemMask ) ) return STUCK; aWalkPath = aInitialPath;