Move to getters/setters for aux and grid origin

Fixes https://gitlab.com/kicad/code/kicad/-/issues/8836
This commit is contained in:
Jon Evans 2021-11-08 22:36:40 -05:00
parent ee7e3fc171
commit 75d75799f7
20 changed files with 57 additions and 41 deletions

View File

@ -664,6 +664,12 @@ public:
int GetLayerClass( PCB_LAYER_ID aLayer ) const; int GetLayerClass( PCB_LAYER_ID aLayer ) const;
void SetAuxOrigin( const wxPoint& aOrigin ) { m_auxOrigin = aOrigin; }
const wxPoint& GetAuxOrigin() { return m_auxOrigin; }
void SetGridOrigin( const wxPoint& aOrigin ) { m_gridOrigin = aOrigin; }
const wxPoint& GetGridOrigin() { return m_gridOrigin; }
private: private:
void initFromOther( const BOARD_DESIGN_SETTINGS& aOther ); void initFromOther( const BOARD_DESIGN_SETTINGS& aOther );
@ -749,9 +755,6 @@ public:
int m_DimensionExtensionOffset; int m_DimensionExtensionOffset;
// Miscellaneous // Miscellaneous
wxPoint m_AuxOrigin; ///< origin for plot exports
wxPoint m_GridOrigin; ///< origin for grid offsets
std::unique_ptr<PAD> m_Pad_Master; // A dummy pad to store all default parameters std::unique_ptr<PAD> m_Pad_Master; // A dummy pad to store all default parameters
// when importing values or creating a new pad // when importing values or creating a new pad
@ -764,6 +767,9 @@ public:
bool m_UseHeightForLengthCalcs; bool m_UseHeightForLengthCalcs;
private: private:
wxPoint m_auxOrigin; ///< origin for plot exports
wxPoint m_gridOrigin; ///< origin for grid offsets
// Indices into the trackWidth, viaSizes and diffPairDimensions lists. // Indices into the trackWidth, viaSizes and diffPairDimensions lists.
// The 0 index is always the current netclass value(s) // The 0 index is always the current netclass value(s)
unsigned m_trackWidthIndex; unsigned m_trackWidthIndex;

View File

@ -725,8 +725,8 @@ void BOARD_DESIGN_SETTINGS::initFromOther( const BOARD_DESIGN_SETTINGS& aOther )
m_DimensionArrowLength = aOther.m_DimensionArrowLength; m_DimensionArrowLength = aOther.m_DimensionArrowLength;
m_DimensionExtensionOffset = aOther.m_DimensionExtensionOffset; m_DimensionExtensionOffset = aOther.m_DimensionExtensionOffset;
m_AuxOrigin = aOther.m_AuxOrigin; m_auxOrigin = aOther.m_auxOrigin;
m_GridOrigin = aOther.m_GridOrigin; m_gridOrigin = aOther.m_gridOrigin;
m_HasStackup = aOther.m_HasStackup; m_HasStackup = aOther.m_HasStackup;
m_UseHeightForLengthCalcs= aOther.m_UseHeightForLengthCalcs; m_UseHeightForLengthCalcs= aOther.m_UseHeightForLengthCalcs;

View File

@ -322,7 +322,7 @@ bool DIALOG_EXPORT_SVG::CreateSVGFile( const wxString& aFullFileName )
plot_opts.SetFormat( PLOT_FORMAT::SVG ); plot_opts.SetFormat( PLOT_FORMAT::SVG );
PAGE_INFO savedPageInfo = m_board->GetPageSettings(); PAGE_INFO savedPageInfo = m_board->GetPageSettings();
wxPoint savedAuxOrigin = m_board->GetDesignSettings().m_AuxOrigin; wxPoint savedAuxOrigin = m_board->GetDesignSettings().GetAuxOrigin();
if( m_rbSvgPageSizeOpt->GetSelection() == 2 ) // Page is board boundary size if( m_rbSvgPageSizeOpt->GetSelection() == 2 ) // Page is board boundary size
{ {
@ -334,7 +334,7 @@ bool DIALOG_EXPORT_SVG::CreateSVGFile( const wxString& aFullFileName )
m_board->SetPageSettings( currpageInfo ); m_board->SetPageSettings( currpageInfo );
plot_opts.SetUseAuxOrigin( true ); plot_opts.SetUseAuxOrigin( true );
wxPoint origin = bbox.GetOrigin(); wxPoint origin = bbox.GetOrigin();
m_board->GetDesignSettings().m_AuxOrigin = origin; m_board->GetDesignSettings().SetAuxOrigin( origin );
} }
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
@ -360,7 +360,7 @@ bool DIALOG_EXPORT_SVG::CreateSVGFile( const wxString& aFullFileName )
delete plotter; delete plotter;
// reset to the values saved earlier // reset to the values saved earlier
m_board->GetDesignSettings().m_AuxOrigin = savedAuxOrigin; m_board->GetDesignSettings().SetAuxOrigin( savedAuxOrigin );
m_board->SetPageSettings( savedPageInfo ); m_board->SetPageSettings( savedPageInfo );
return true; return true;

View File

@ -345,7 +345,7 @@ void DIALOG_GENDRILL::UpdateDrillParams()
if( m_Choice_Drill_Offset->GetSelection() == 0 ) if( m_Choice_Drill_Offset->GetSelection() == 0 )
m_DrillFileOffset = wxPoint( 0, 0 ); m_DrillFileOffset = wxPoint( 0, 0 );
else else
m_DrillFileOffset = m_board->GetDesignSettings().m_AuxOrigin; m_DrillFileOffset = m_board->GetDesignSettings().GetAuxOrigin();
if( m_UnitDrillIsInch ) if( m_UnitDrillIsInch )
m_Precision = precisionListForInches; m_Precision = precisionListForInches;

View File

@ -236,7 +236,7 @@ void DIALOG_POSITION_RELATIVE::OnUseGridOriginClick( wxCommandEvent& event )
{ {
BOARD* board = (BOARD*) m_toolMgr->GetModel(); BOARD* board = (BOARD*) m_toolMgr->GetModel();
m_anchor_position = board->GetDesignSettings().m_GridOrigin; m_anchor_position = board->GetDesignSettings().GetGridOrigin();
m_referenceInfo->SetLabel( _( "Reference location: grid origin" ) ); m_referenceInfo->SetLabel( _( "Reference location: grid origin" ) );
} }

View File

@ -95,7 +95,7 @@ static int iu_to_d356(int iu, int clamp)
/* Extract the D356 record from the footprints (pads) */ /* Extract the D356 record from the footprints (pads) */
static void build_pad_testpoints( BOARD *aPcb, std::vector <D356_RECORD>& aRecords ) static void build_pad_testpoints( BOARD *aPcb, std::vector <D356_RECORD>& aRecords )
{ {
wxPoint origin = aPcb->GetDesignSettings().m_AuxOrigin; wxPoint origin = aPcb->GetDesignSettings().GetAuxOrigin();
for( FOOTPRINT* footprint : aPcb->Footprints() ) for( FOOTPRINT* footprint : aPcb->Footprints() )
{ {
@ -168,7 +168,7 @@ static int via_access_code( BOARD *aPcb, int top_layer, int bottom_layer )
/* Extract the D356 record from the vias */ /* Extract the D356 record from the vias */
static void build_via_testpoints( BOARD *aPcb, std::vector <D356_RECORD>& aRecords ) static void build_via_testpoints( BOARD *aPcb, std::vector <D356_RECORD>& aRecords )
{ {
wxPoint origin = aPcb->GetDesignSettings().m_AuxOrigin; wxPoint origin = aPcb->GetDesignSettings().GetAuxOrigin();
// Enumerate all the track segments and keep the vias // Enumerate all the track segments and keep the vias
for( auto track : aPcb->Tracks() ) for( auto track : aPcb->Tracks() )

View File

@ -95,7 +95,7 @@ PLACE_FILE_EXPORTER::PLACE_FILE_EXPORTER( BOARD* aBoard, bool aUnitsMM, bool aOn
m_formatCSV = aFormatCSV; m_formatCSV = aFormatCSV;
if( aUseAuxOrigin ) if( aUseAuxOrigin )
m_place_Offset = m_board->GetDesignSettings().m_AuxOrigin; m_place_Offset = m_board->GetDesignSettings().GetAuxOrigin();
else else
m_place_Offset = wxPoint( 0, 0 ); m_place_Offset = wxPoint( 0, 0 );
} }

View File

@ -268,7 +268,7 @@ void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent )
GetBoard()->ComputeBoundingBox(); GetBoard()->ComputeBoundingBox();
// Save the auxiliary origin for the rest of the footprint // Save the auxiliary origin for the rest of the footprint
wxPoint auxOrigin = m_pcb->GetDesignSettings().m_AuxOrigin; wxPoint auxOrigin = m_pcb->GetDesignSettings().GetAuxOrigin();
GencadOffsetX = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? auxOrigin.x : 0; GencadOffsetX = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? auxOrigin.x : 0;
GencadOffsetY = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? auxOrigin.y : 0; GencadOffsetY = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? auxOrigin.y : 0;

View File

@ -59,7 +59,7 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
PCB_PLOT_PARAMS plotOpts = m_pcb->GetPlotOptions(); PCB_PLOT_PARAMS plotOpts = m_pcb->GetPlotOptions();
if( plotOpts.GetUseAuxOrigin() ) if( plotOpts.GetUseAuxOrigin() )
m_offset = m_pcb->GetDesignSettings().m_AuxOrigin; m_offset = m_pcb->GetDesignSettings().GetAuxOrigin();
// Collect footprints on the right layer // Collect footprints on the right layer
std::vector<FOOTPRINT*> fp_list; std::vector<FOOTPRINT*> fp_list;

View File

@ -152,7 +152,7 @@ void PCB_BASE_EDIT_FRAME::SetBoard( BOARD* aBoard )
PCB_BASE_FRAME::SetBoard( aBoard ); PCB_BASE_FRAME::SetBoard( aBoard );
GetCanvas()->GetGAL()->SetGridOrigin( VECTOR2D( aBoard->GetDesignSettings().m_GridOrigin ) ); GetCanvas()->GetGAL()->SetGridOrigin( VECTOR2D( aBoard->GetDesignSettings().GetGridOrigin() ) );
if( new_board ) if( new_board )
{ {

View File

@ -380,19 +380,19 @@ const wxSize PCB_BASE_FRAME::GetPageSizeIU() const
const wxPoint& PCB_BASE_FRAME::GetGridOrigin() const const wxPoint& PCB_BASE_FRAME::GetGridOrigin() const
{ {
return m_pcb->GetDesignSettings().m_GridOrigin; return m_pcb->GetDesignSettings().GetGridOrigin();
} }
void PCB_BASE_FRAME::SetGridOrigin( const wxPoint& aPoint ) void PCB_BASE_FRAME::SetGridOrigin( const wxPoint& aPoint )
{ {
m_pcb->GetDesignSettings().m_GridOrigin = aPoint; m_pcb->GetDesignSettings().SetGridOrigin( aPoint );
} }
const wxPoint& PCB_BASE_FRAME::GetAuxOrigin() const const wxPoint& PCB_BASE_FRAME::GetAuxOrigin() const
{ {
return m_pcb->GetDesignSettings().m_AuxOrigin; return m_pcb->GetDesignSettings().GetAuxOrigin();
} }

View File

@ -340,7 +340,7 @@ void AddGerberX2Header( PLOTTER* aPlotter, const BOARD* aBoard, bool aUseX1Compa
// Please, if absolute Pcbnew coordinates, one day, are set by user, change the way // Please, if absolute Pcbnew coordinates, one day, are set by user, change the way
// the key is built to ensure file only using the *same* axis have the same key. // the key is built to ensure file only using the *same* axis have the same key.
wxString registration_id = "Original"; wxString registration_id = "Original";
wxPoint auxOrigin = aBoard->GetDesignSettings().m_AuxOrigin; wxPoint auxOrigin = aBoard->GetDesignSettings().GetAuxOrigin();
if( aBoard->GetPlotOptions().GetUseAuxOrigin() && auxOrigin.x && auxOrigin.y ) if( aBoard->GetPlotOptions().GetUseAuxOrigin() && auxOrigin.x && auxOrigin.y )
registration_id.Printf( "PX%xPY%x", auxOrigin.x, auxOrigin.y ); registration_id.Printf( "PX%xPY%x", auxOrigin.x, auxOrigin.y );

View File

@ -1067,7 +1067,7 @@ static void initializePlotter( PLOTTER* aPlotter, const BOARD* aBoard,
else else
{ {
if( aPlotOpts->GetUseAuxOrigin() ) if( aPlotOpts->GetUseAuxOrigin() )
offset = aBoard->GetDesignSettings().m_AuxOrigin; offset = aBoard->GetDesignSettings().GetAuxOrigin();
} }
aPlotter->SetPageSettings( *sheet_info ); aPlotter->SetPageSettings( *sheet_info );

View File

@ -618,8 +618,10 @@ void ALTIUM_PCB::Parse( const CFB::CompoundFileReader& aReader,
wxPoint movementVector( desired_x - bbbox.GetX(), desired_y - bbbox.GetY() ); wxPoint movementVector( desired_x - bbbox.GetX(), desired_y - bbbox.GetY() );
m_board->Move( movementVector ); m_board->Move( movementVector );
m_board->GetDesignSettings().m_AuxOrigin += movementVector;
m_board->GetDesignSettings().m_GridOrigin += movementVector; BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
bds.SetAuxOrigin( bds.GetAuxOrigin() + movementVector );
bds.SetGridOrigin( bds.GetGridOrigin() + movementVector );
m_board->SetModified(); m_board->SetModified();
} }
@ -710,8 +712,8 @@ void ALTIUM_PCB::ParseBoard6Data( const CFB::CompoundFileReader& aReader,
THROW_IO_ERROR( "Board6 stream is not fully parsed" ); THROW_IO_ERROR( "Board6 stream is not fully parsed" );
} }
m_board->GetDesignSettings().m_AuxOrigin = elem.sheetpos; m_board->GetDesignSettings().SetAuxOrigin( elem.sheetpos );
m_board->GetDesignSettings().m_GridOrigin = elem.sheetpos; m_board->GetDesignSettings().SetGridOrigin( elem.sheetpos );
// read layercount from stackup, because LAYERSETSCOUNT is not always correct?! // read layercount from stackup, because LAYERSETSCOUNT is not always correct?!
size_t layercount = 0; size_t layercount = 0;

View File

@ -499,15 +499,23 @@ void PCB_IO::formatSetup( const BOARD* aBoard, int aNestLevel ) const
m_out->Print( aNestLevel+1, "(pad_to_paste_clearance_ratio %s)\n", m_out->Print( aNestLevel+1, "(pad_to_paste_clearance_ratio %s)\n",
Double2Str( dsnSettings.m_SolderPasteMarginRatio ).c_str() ); Double2Str( dsnSettings.m_SolderPasteMarginRatio ).c_str() );
if( dsnSettings.m_AuxOrigin != wxPoint( 0, 0 ) ) wxPoint origin = dsnSettings.GetAuxOrigin();
m_out->Print( aNestLevel+1, "(aux_axis_origin %s %s)\n",
FormatInternalUnits( dsnSettings.m_AuxOrigin.x ).c_str(),
FormatInternalUnits( dsnSettings.m_AuxOrigin.y ).c_str() );
if( dsnSettings.m_GridOrigin != wxPoint( 0, 0 ) ) if( origin != wxPoint( 0, 0 ) )
{
m_out->Print( aNestLevel+1, "(aux_axis_origin %s %s)\n",
FormatInternalUnits( origin.x ).c_str(),
FormatInternalUnits( origin.y ).c_str() );
}
origin = dsnSettings.GetGridOrigin();
if( origin != wxPoint( 0, 0 ) )
{
m_out->Print( aNestLevel+1, "(grid_origin %s %s)\n", m_out->Print( aNestLevel+1, "(grid_origin %s %s)\n",
FormatInternalUnits( dsnSettings.m_GridOrigin.x ).c_str(), FormatInternalUnits( origin.x ).c_str(),
FormatInternalUnits( dsnSettings.m_GridOrigin.y ).c_str() ); FormatInternalUnits( origin.y ).c_str() );
}
aBoard->GetPlotOptions().Format( m_out, aNestLevel+1 ); aBoard->GetPlotOptions().Format( m_out, aNestLevel+1 );

View File

@ -2047,7 +2047,7 @@ void PCB_PARSER::parseSetup()
{ {
int x = parseBoardUnits( "auxiliary origin X" ); int x = parseBoardUnits( "auxiliary origin X" );
int y = parseBoardUnits( "auxiliary origin Y" ); int y = parseBoardUnits( "auxiliary origin Y" );
designSettings.m_AuxOrigin = wxPoint( x, y ); designSettings.SetAuxOrigin( wxPoint( x, y ) );
// Aux origin still stored in board for the moment // Aux origin still stored in board for the moment
//m_board->m_LegacyDesignSettingsLoaded = true; //m_board->m_LegacyDesignSettingsLoaded = true;
@ -2059,7 +2059,7 @@ void PCB_PARSER::parseSetup()
{ {
int x = parseBoardUnits( "grid origin X" ); int x = parseBoardUnits( "grid origin X" );
int y = parseBoardUnits( "grid origin Y" ); int y = parseBoardUnits( "grid origin Y" );
designSettings.m_GridOrigin = wxPoint( x, y ); designSettings.SetGridOrigin( wxPoint( x, y ) );
// Grid origin still stored in board for the moment // Grid origin still stored in board for the moment
//m_board->m_LegacyDesignSettingsLoaded = true; //m_board->m_LegacyDesignSettingsLoaded = true;
NeedRIGHT(); NeedRIGHT();

View File

@ -878,7 +878,7 @@ void LEGACY_PLUGIN::loadSETUP()
BIU gx = biuParse( line + SZ( "AuxiliaryAxisOrg" ), &data ); BIU gx = biuParse( line + SZ( "AuxiliaryAxisOrg" ), &data );
BIU gy = biuParse( data ); BIU gy = biuParse( data );
bds.m_AuxOrigin = wxPoint( gx, gy ); bds.SetAuxOrigin( wxPoint( gx, gy ) );
} }
else if( TESTSUBSTR( "Layer[" ) ) else if( TESTSUBSTR( "Layer[" ) )
{ {
@ -1071,7 +1071,7 @@ void LEGACY_PLUGIN::loadSETUP()
BIU x = biuParse( line + SZ( "GridOrigin" ), &data ); BIU x = biuParse( line + SZ( "GridOrigin" ), &data );
BIU y = biuParse( data ); BIU y = biuParse( data );
bds.m_GridOrigin = wxPoint( x, y ); bds.SetGridOrigin( wxPoint( x, y ) );
} }
else if( TESTLINE( "VisibleElements" ) ) else if( TESTLINE( "VisibleElements" ) )
{ {

View File

@ -196,7 +196,7 @@ void BOARD_EDITOR_CONTROL::Reset( RESET_REASON aReason )
if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH ) if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
{ {
m_placeOrigin->SetPosition( getModel<BOARD>()->GetDesignSettings().m_AuxOrigin ); m_placeOrigin->SetPosition( getModel<BOARD>()->GetDesignSettings().GetAuxOrigin() );
getView()->Remove( m_placeOrigin.get() ); getView()->Remove( m_placeOrigin.get() );
getView()->Add( m_placeOrigin.get() ); getView()->Add( m_placeOrigin.get() );
} }
@ -1491,7 +1491,7 @@ int BOARD_EDITOR_CONTROL::EditFpInFpEditor( const TOOL_EVENT& aEvent )
void BOARD_EDITOR_CONTROL::DoSetDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame, void BOARD_EDITOR_CONTROL::DoSetDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
EDA_ITEM* originViewItem, const VECTOR2D& aPosition ) EDA_ITEM* originViewItem, const VECTOR2D& aPosition )
{ {
aFrame->GetDesignSettings().m_AuxOrigin = (wxPoint) aPosition; aFrame->GetDesignSettings().SetAuxOrigin( wxPoint( aPosition ) );
originViewItem->SetPosition( (wxPoint) aPosition ); originViewItem->SetPosition( (wxPoint) aPosition );
aView->MarkDirty(); aView->MarkDirty();
aFrame->OnModify(); aFrame->OnModify();

View File

@ -2087,7 +2087,7 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
item->Rotate( (wxPoint) frame()->GetScreen()->m_LocalOrigin, rotation ); item->Rotate( (wxPoint) frame()->GetScreen()->m_LocalOrigin, rotation );
break; break;
case ROTATE_AROUND_AUX_ORIGIN: case ROTATE_AROUND_AUX_ORIGIN:
item->Rotate( board()->GetDesignSettings().m_AuxOrigin, rotation ); item->Rotate( board()->GetDesignSettings().GetAuxOrigin(), rotation );
break; break;
} }

View File

@ -88,7 +88,7 @@ void PCB_CONTROL::Reset( RESET_REASON aReason )
if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH ) if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
{ {
m_gridOrigin->SetPosition( board()->GetDesignSettings().m_GridOrigin ); m_gridOrigin->SetPosition( board()->GetDesignSettings().GetGridOrigin() );
m_gridOrigin->SetColor( m_frame->GetGridColor() ); m_gridOrigin->SetColor( m_frame->GetGridColor() );
getView()->Remove( m_gridOrigin.get() ); getView()->Remove( m_gridOrigin.get() );
getView()->Add( m_gridOrigin.get() ); getView()->Add( m_gridOrigin.get() );
@ -500,7 +500,7 @@ int PCB_CONTROL::LayerAlphaDec( const TOOL_EVENT& aEvent )
void PCB_CONTROL::DoSetGridOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame, void PCB_CONTROL::DoSetGridOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
EDA_ITEM* originViewItem, const VECTOR2D& aPoint ) EDA_ITEM* originViewItem, const VECTOR2D& aPoint )
{ {
aFrame->GetDesignSettings().m_GridOrigin = (wxPoint) aPoint; aFrame->GetDesignSettings().SetGridOrigin( wxPoint( aPoint ) );
aView->GetGAL()->SetGridOrigin( aPoint ); aView->GetGAL()->SetGridOrigin( aPoint );
originViewItem->SetPosition( (wxPoint) aPoint ); originViewItem->SetPosition( (wxPoint) aPoint );
aView->MarkDirty(); aView->MarkDirty();