Add rectangle tool to PCBNew toolbar in favour of Aux Origin.

ADDED new rectangle graphics tool for PCBNew and Footprint Editor.

Also adds rectangle tool to both Footprint Editor and PCBNew Place
menus.

The Aux Origin tool can come back once we have multi-select toobar
buttons.

Also collapses an unnecessary level out of the auxOrigin and gridOrigin
settings.

Fixes https://gitlab.com/kicad/code/kicad/issues/2246
This commit is contained in:
Jeff Young 2020-07-01 13:28:10 +01:00
parent 32b7b0c617
commit 7b042f4a75
30 changed files with 62 additions and 182 deletions

View File

@ -132,20 +132,6 @@ const wxSize SCH_BASE_FRAME::GetPageSizeIU() const
} }
const wxPoint& SCH_BASE_FRAME::GetAuxOrigin() const
{
wxASSERT( GetScreen() );
return GetScreen()->GetAuxOrigin();
}
void SCH_BASE_FRAME::SetAuxOrigin( const wxPoint& aPosition )
{
wxASSERT( GetScreen() );
GetScreen()->SetAuxOrigin( aPosition );
}
const TITLE_BLOCK& SCH_BASE_FRAME::GetTitleBlock() const const TITLE_BLOCK& SCH_BASE_FRAME::GetTitleBlock() const
{ {
wxASSERT( GetScreen() ); wxASSERT( GetScreen() );

View File

@ -134,9 +134,6 @@ public:
const PAGE_INFO& GetPageSettings () const override; const PAGE_INFO& GetPageSettings () const override;
const wxSize GetPageSizeIU() const override; const wxSize GetPageSizeIU() const override;
const wxPoint& GetAuxOrigin() const override;
void SetAuxOrigin( const wxPoint& aPosition ) override;
const wxPoint& GetGridOrigin() const override const wxPoint& GetGridOrigin() const override
{ {
static wxPoint zero; static wxPoint zero;

View File

@ -958,20 +958,6 @@ void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
} }
const wxPoint& GERBVIEW_FRAME::GetAuxOrigin() const
{
wxASSERT( m_gerberLayout );
return m_gerberLayout->GetAuxOrigin();
}
void GERBVIEW_FRAME::SetAuxOrigin( const wxPoint& aPosition )
{
wxASSERT( m_gerberLayout );
m_gerberLayout->SetAuxOrigin( aPosition );
}
void GERBVIEW_FRAME::SetGridColor( COLOR4D aColor ) void GERBVIEW_FRAME::SetGridColor( COLOR4D aColor )
{ {
GetCanvas()->GetGAL()->SetGridColor( aColor ); GetCanvas()->GetGAL()->SetGridColor( aColor );

View File

@ -107,9 +107,6 @@ public:
const PAGE_INFO& GetPageSettings() const override; const PAGE_INFO& GetPageSettings() const override;
const wxSize GetPageSizeIU() const override; const wxSize GetPageSizeIU() const override;
const wxPoint& GetAuxOrigin() const override;
void SetAuxOrigin( const wxPoint& aPoint ) override;
const wxPoint& GetGridOrigin() const override { return m_grid_origin; } const wxPoint& GetGridOrigin() const override { return m_grid_origin; }
void SetGridOrigin( const wxPoint& aPoint ) override { m_grid_origin = aPoint; } void SetGridOrigin( const wxPoint& aPoint ) override { m_grid_origin = aPoint; }

View File

@ -185,12 +185,6 @@ public:
void ToggleUserUnits() override; void ToggleUserUnits() override;
/**
* Return the origin of the axis used for plotting and various exports.
*/
virtual const wxPoint& GetAuxOrigin() const = 0;
virtual void SetAuxOrigin( const wxPoint& aPosition ) = 0;
/** /**
* Return the absolute coordinates of the origin of the snap grid. This is * Return the absolute coordinates of the origin of the snap grid. This is
* treated as a relative offset, and snapping will occur at multiples of the grid * treated as a relative offset, and snapping will occur at multiples of the grid

View File

@ -141,9 +141,6 @@ public:
const PAGE_INFO& GetPageSettings() const override; const PAGE_INFO& GetPageSettings() const override;
const wxSize GetPageSizeIU() const override; const wxSize GetPageSizeIU() const override;
const wxPoint& GetAuxOrigin() const override;
void SetAuxOrigin( const wxPoint& aPoint ) override;
const wxPoint& GetGridOrigin() const override; const wxPoint& GetGridOrigin() const override;
void SetGridOrigin( const wxPoint& aPoint ) override; void SetGridOrigin( const wxPoint& aPoint ) override;

View File

@ -129,13 +129,6 @@ public:
return (PL_EDITOR_SCREEN*) EDA_DRAW_FRAME::GetScreen(); return (PL_EDITOR_SCREEN*) EDA_DRAW_FRAME::GetScreen();
} }
const wxPoint& GetAuxOrigin() const override
{
static wxPoint dummy; // ( 0,0 );
return dummy;
}
void SetAuxOrigin( const wxPoint& aPosition ) override {}
const wxPoint& GetGridOrigin() const override { return m_grid_origin; } const wxPoint& GetGridOrigin() const override { return m_grid_origin; }
void SetGridOrigin( const wxPoint& aPoint ) override { m_grid_origin = aPoint; } void SetGridOrigin( const wxPoint& aPoint ) override { m_grid_origin = aPoint; }

View File

@ -574,8 +574,8 @@ void ALTIUM_PCB::ParseBoard6Data(
THROW_IO_ERROR( "Board6 stream is not fully parsed" ); THROW_IO_ERROR( "Board6 stream is not fully parsed" );
} }
m_board->SetAuxOrigin( elem.sheetpos ); m_board->GetDesignSettings().m_AuxOrigin = elem.sheetpos;
m_board->SetGridOrigin( elem.sheetpos ); m_board->GetDesignSettings().m_GridOrigin = 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

@ -356,20 +356,6 @@ public:
PROJECT* GetProject() const { return m_project; } PROJECT* GetProject() const { return m_project; }
void SetProject( PROJECT* aProject ) { m_project = aProject; } void SetProject( PROJECT* aProject ) { m_project = aProject; }
/**
* Function SetAuxOrigin
* sets the origin point used for plotting.
*/
void SetAuxOrigin( const wxPoint& aPoint ) { m_designSettings.m_AuxOrigin = aPoint; }
const wxPoint& GetAuxOrigin() const { return m_designSettings.m_AuxOrigin; }
/**
* Function SetGridOrigin
* sets the origin point of the grid.
*/
void SetGridOrigin( const wxPoint& aPoint ) { m_designSettings.m_GridOrigin = aPoint; }
const wxPoint& GetGridOrigin() const { return m_designSettings.m_GridOrigin; }
/** /**
* Function ResetNetHighLight * Function ResetNetHighLight
* Reset all high light data to the init state * Reset all high light data to the init state

View File

@ -294,8 +294,8 @@ bool DIALOG_EXPORT_SVG::CreateSVGFile( const wxString& aFullFileName )
plot_opts.SetMirror( m_printMirror ); plot_opts.SetMirror( m_printMirror );
plot_opts.SetFormat( PLOT_FORMAT::SVG ); plot_opts.SetFormat( PLOT_FORMAT::SVG );
PAGE_INFO pageInfo = m_board->GetPageSettings(); PAGE_INFO savedPageInfo = m_board->GetPageSettings();
wxPoint axisorigin = m_board->GetAuxOrigin(); wxPoint savedAuxOrigin = m_board->GetDesignSettings().m_AuxOrigin;
if( m_rbSvgPageSizeOpt->GetSelection() == 2 ) // Page is board boundary size if( m_rbSvgPageSizeOpt->GetSelection() == 2 ) // Page is board boundary size
{ {
@ -307,7 +307,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->SetAuxOrigin( origin ); m_board->GetDesignSettings().m_AuxOrigin = origin;
} }
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager(); SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
@ -332,8 +332,9 @@ bool DIALOG_EXPORT_SVG::CreateSVGFile( const wxString& aFullFileName )
delete plotter; delete plotter;
m_board->SetAuxOrigin( axisorigin ); // reset to the values saved earlier // reset to the values saved earlier
m_board->SetPageSettings( pageInfo ); m_board->GetDesignSettings().m_AuxOrigin = savedAuxOrigin;
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_FileDrillOffset = wxPoint( 0, 0 ); m_FileDrillOffset = wxPoint( 0, 0 );
else else
m_FileDrillOffset = m_pcbEditFrame->GetAuxOrigin(); m_FileDrillOffset = m_board->GetDesignSettings().m_AuxOrigin;
if( m_UnitDrillIsInch ) if( m_UnitDrillIsInch )
m_Precision = precisionListForInches; m_Precision = precisionListForInches;

View File

@ -65,9 +65,8 @@ private:
public: public:
// Constructor and destructor // Constructor and destructor
DIALOG_MOVE_EXACT(PCB_BASE_FRAME *aParent, wxPoint& aTranslate, DIALOG_MOVE_EXACT( PCB_BASE_FRAME *aParent, wxPoint& aTranslate, double& aRotate,
double& aRotate, ROTATION_ANCHOR& aAnchor, ROTATION_ANCHOR& aAnchor, const EDA_RECT& aBbox );
const EDA_RECT& aBbox);
~DIALOG_MOVE_EXACT() { }; ~DIALOG_MOVE_EXACT() { };
private: private:

View File

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

View File

@ -91,10 +91,9 @@ static int iu_to_d356(int iu, int clamp)
} }
/* Extract the D356 record from the modules (pads) */ /* Extract the D356 record from the modules (pads) */
static void build_pad_testpoints( BOARD *aPcb, static void build_pad_testpoints( BOARD *aPcb, std::vector <D356_RECORD>& aRecords )
std::vector <D356_RECORD>& aRecords )
{ {
wxPoint origin = aPcb->GetAuxOrigin(); wxPoint origin = aPcb->GetDesignSettings().m_AuxOrigin;
for( auto module : aPcb->Modules() ) for( auto module : aPcb->Modules() )
{ {
@ -165,10 +164,9 @@ 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, static void build_via_testpoints( BOARD *aPcb, std::vector <D356_RECORD>& aRecords )
std::vector <D356_RECORD>& aRecords )
{ {
wxPoint origin = aPcb->GetAuxOrigin(); wxPoint origin = aPcb->GetDesignSettings().m_AuxOrigin;
// 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

@ -103,7 +103,7 @@ std::string PLACE_FILE_EXPORTER::GenPositionData()
int lenValText = 8; int lenValText = 8;
int lenPkgText = 16; int lenPkgText = 16;
m_place_Offset = m_board->GetAuxOrigin(); m_place_Offset = m_board->GetDesignSettings().m_AuxOrigin;
// Calculating the number of useful footprints (CMS attribute, not VIRTUAL) // Calculating the number of useful footprints (CMS attribute, not VIRTUAL)
m_fpCount = 0; m_fpCount = 0;

View File

@ -61,42 +61,6 @@ static void FootprintWriteShape( FILE* File, MODULE* module, const wxString& aSh
// layer names for Gencad export // layer names for Gencad export
#if 0 // was:
static const wxString GenCADLayerName[] =
{
wxT( "BOTTOM" ), wxT( "INNER1" ), wxT( "INNER2" ),
wxT( "INNER3" ), wxT( "INNER4" ), wxT( "INNER5" ),
wxT( "INNER6" ), wxT( "INNER7" ), wxT( "INNER8" ),
wxT( "INNER9" ), wxT( "INNER10" ), wxT( "INNER11" ),
wxT( "INNER12" ), wxT( "INNER13" ), wxT( "INNER14" ),
wxT( "TOP" ), wxT( "LAYER17" ), wxT( "LAYER18" ),
wxT( "SOLDERPASTE_BOTTOM" ), wxT( "SOLDERPASTE_TOP" ),
wxT( "SILKSCREEN_BOTTOM" ), wxT( "SILKSCREEN_TOP" ),
wxT( "SOLDERMASK_BOTTOM" ), wxT( "SOLDERMASK_TOP" ), wxT( "LAYER25" ),
wxT( "LAYER26" ), wxT( "LAYER27" ), wxT( "LAYER28" ),
wxT( "LAYER29" ), wxT( "LAYER30" ), wxT( "LAYER31" ),
wxT( "LAYER32" )
};
// flipped layer name for Gencad export (to make CAM350 imports correct)
static const wxString GenCADLayerNameFlipped[32] =
{
wxT( "TOP" ), wxT( "INNER14" ), wxT( "INNER13" ),
wxT( "INNER12" ), wxT( "INNER11" ), wxT( "INNER10" ),
wxT( "INNER9" ), wxT( "INNER8" ), wxT( "INNER7" ),
wxT( "INNER6" ), wxT( "INNER5" ), wxT( "INNER4" ),
wxT( "INNER3" ), wxT( "INNER2" ), wxT( "INNER1" ),
wxT( "BOTTOM" ), wxT( "LAYER17" ), wxT( "LAYER18" ),
wxT( "SOLDERPASTE_TOP" ), wxT( "SOLDERPASTE_BOTTOM" ),
wxT( "SILKSCREEN_TOP" ), wxT( "SILKSCREEN_BOTTOM" ),
wxT( "SOLDERMASK_TOP" ), wxT( "SOLDERMASK_BOTTOM" ), wxT( "LAYER25" ),
wxT( "LAYER26" ), wxT( "LAYER27" ), wxT( "LAYER28" ),
wxT( "LAYER29" ), wxT( "LAYER30" ), wxT( "LAYER31" ),
wxT( "LAYER32" )
};
#else
static std::string GenCADLayerName( int aCuCount, PCB_LAYER_ID aId ) static std::string GenCADLayerName( int aCuCount, PCB_LAYER_ID aId )
{ {
if( IsCopperLayer( aId ) ) if( IsCopperLayer( aId ) )
@ -212,7 +176,6 @@ static wxString escapeString( const wxString& aString )
return copy; return copy;
} }
#endif
static std::string fmt_mask( LSET aSet ) static std::string fmt_mask( LSET aSet )
{ {
@ -312,8 +275,9 @@ void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent )
GetBoard()->ComputeBoundingBox(); GetBoard()->ComputeBoundingBox();
// Save the auxiliary origin for the rest of the module // Save the auxiliary origin for the rest of the module
GencadOffsetX = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? GetAuxOrigin().x : 0; wxPoint auxOrigin = m_Pcb->GetDesignSettings().m_AuxOrigin;
GencadOffsetY = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? GetAuxOrigin().y : 0; GencadOffsetX = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? auxOrigin.x : 0;
GencadOffsetY = optionsDialog.GetOption( USE_AUX_ORIGIN ) ? auxOrigin.y : 0;
// No idea on *why* this should be needed... maybe to fix net names? // No idea on *why* this should be needed... maybe to fix net names?
Compile_Ratsnest( true ); Compile_Ratsnest( true );

View File

@ -32,7 +32,6 @@
#include <kicad_string.h> #include <kicad_string.h>
#include <pcb_edit_frame.h> #include <pcb_edit_frame.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <build_version.h>
#include <class_board.h> #include <class_board.h>
@ -42,7 +41,6 @@
#include <reporter.h> #include <reporter.h>
#include <gbr_metadata.h> #include <gbr_metadata.h>
#include <class_module.h> #include <class_module.h>
#include <pcbplot.h>
PLACEFILE_GERBER_WRITER::PLACEFILE_GERBER_WRITER( BOARD* aPcb ) PLACEFILE_GERBER_WRITER::PLACEFILE_GERBER_WRITER( BOARD* aPcb )
@ -57,16 +55,15 @@ PLACEFILE_GERBER_WRITER::PLACEFILE_GERBER_WRITER( BOARD* aPcb )
} }
int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER_ID aLayer,
PCB_LAYER_ID aLayer, bool aIncludeBrdEdges bool aIncludeBrdEdges )
)
{ {
m_layer = aLayer; m_layer = aLayer;
PCB_PLOT_PARAMS plotOpts = m_pcb->GetPlotOptions(); PCB_PLOT_PARAMS plotOpts = m_pcb->GetPlotOptions();
if( plotOpts.GetUseAuxOrigin() ) if( plotOpts.GetUseAuxOrigin() )
m_offset = m_pcb->GetAuxOrigin(); m_offset = m_pcb->GetDesignSettings().m_AuxOrigin;
// Collect footprints on the right layer // Collect footprints on the right layer
std::vector<MODULE*> fp_list; std::vector<MODULE*> fp_list;

View File

@ -582,14 +582,15 @@ void PCB_IO::formatSetup( 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 ) )
m_out->Print( aNestLevel+1, "(aux_axis_origin %s %s)\n", m_out->Print( aNestLevel+1, "(aux_axis_origin %s %s)\n",
FormatInternalUnits( aBoard->GetAuxOrigin().x ).c_str(), FormatInternalUnits( dsnSettings.m_AuxOrigin.x ).c_str(),
FormatInternalUnits( aBoard->GetAuxOrigin().y ).c_str() ); FormatInternalUnits( dsnSettings.m_AuxOrigin.y ).c_str() );
if( aBoard->GetGridOrigin().x || aBoard->GetGridOrigin().y ) if( dsnSettings.m_GridOrigin != wxPoint( 0, 0 ) )
m_out->Print( aNestLevel+1, "(grid_origin %s %s)\n", m_out->Print( aNestLevel+1, "(grid_origin %s %s)\n",
FormatInternalUnits( aBoard->GetGridOrigin().x ).c_str(), FormatInternalUnits( dsnSettings.m_GridOrigin.x ).c_str(),
FormatInternalUnits( aBoard->GetGridOrigin().y ).c_str() ); FormatInternalUnits( dsnSettings.m_GridOrigin.y ).c_str() );
m_out->Print( aNestLevel+1, "(visible_elements %X)\n", m_out->Print( aNestLevel+1, "(visible_elements %X)\n",
dsnSettings.GetVisibleElements() ); dsnSettings.GetVisibleElements() );

View File

@ -234,6 +234,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
placeMenu->AddSeparator(); placeMenu->AddSeparator();
placeMenu->AddItem( PCB_ACTIONS::placeText, haveFootprintCondition ); placeMenu->AddItem( PCB_ACTIONS::placeText, haveFootprintCondition );
placeMenu->AddItem( PCB_ACTIONS::drawArc, haveFootprintCondition ); placeMenu->AddItem( PCB_ACTIONS::drawArc, haveFootprintCondition );
placeMenu->AddItem( PCB_ACTIONS::drawRectangle, haveFootprintCondition );
placeMenu->AddItem( PCB_ACTIONS::drawCircle, haveFootprintCondition ); placeMenu->AddItem( PCB_ACTIONS::drawCircle, haveFootprintCondition );
placeMenu->AddItem( PCB_ACTIONS::drawLine, haveFootprintCondition ); placeMenu->AddItem( PCB_ACTIONS::drawLine, haveFootprintCondition );
placeMenu->AddItem( PCB_ACTIONS::drawPolygon, haveFootprintCondition ); placeMenu->AddItem( PCB_ACTIONS::drawPolygon, haveFootprintCondition );

View File

@ -414,6 +414,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
placeMenu->AddItem( PCB_ACTIONS::drawZoneKeepout, SELECTION_CONDITIONS::ShowAlways ); placeMenu->AddItem( PCB_ACTIONS::drawZoneKeepout, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddItem( PCB_ACTIONS::placeText, SELECTION_CONDITIONS::ShowAlways ); placeMenu->AddItem( PCB_ACTIONS::placeText, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddItem( PCB_ACTIONS::drawArc, SELECTION_CONDITIONS::ShowAlways ); placeMenu->AddItem( PCB_ACTIONS::drawArc, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddItem( PCB_ACTIONS::drawRectangle, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddItem( PCB_ACTIONS::drawCircle, SELECTION_CONDITIONS::ShowAlways ); placeMenu->AddItem( PCB_ACTIONS::drawCircle, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddItem( PCB_ACTIONS::drawLine, SELECTION_CONDITIONS::ShowAlways ); placeMenu->AddItem( PCB_ACTIONS::drawLine, SELECTION_CONDITIONS::ShowAlways );
placeMenu->AddItem( PCB_ACTIONS::drawPolygon, SELECTION_CONDITIONS::ShowAlways ); placeMenu->AddItem( PCB_ACTIONS::drawPolygon, SELECTION_CONDITIONS::ShowAlways );

View File

@ -97,7 +97,7 @@ void PCB_BASE_EDIT_FRAME::SetBoard( BOARD* aBoard )
PCB_BASE_FRAME::SetBoard( aBoard ); PCB_BASE_FRAME::SetBoard( aBoard );
GetCanvas()->GetGAL()->SetGridOrigin( VECTOR2D( aBoard->GetGridOrigin() ) ); GetCanvas()->GetGAL()->SetGridOrigin( VECTOR2D( aBoard->GetDesignSettings().m_GridOrigin ) );
// update the tool manager with the new board and its view. // update the tool manager with the new board and its view.
if( m_toolManager ) if( m_toolManager )

View File

@ -242,31 +242,17 @@ const wxSize PCB_BASE_FRAME::GetPageSizeIU() const
} }
const wxPoint& PCB_BASE_FRAME::GetAuxOrigin() const
{
wxASSERT( m_Pcb );
return m_Pcb->GetAuxOrigin();
}
void PCB_BASE_FRAME::SetAuxOrigin( const wxPoint& aPoint )
{
wxASSERT( m_Pcb );
m_Pcb->SetAuxOrigin( aPoint );
}
const wxPoint& PCB_BASE_FRAME::GetGridOrigin() const const wxPoint& PCB_BASE_FRAME::GetGridOrigin() const
{ {
wxASSERT( m_Pcb ); wxASSERT( m_Pcb );
return m_Pcb->GetGridOrigin(); return m_Pcb->GetDesignSettings().m_GridOrigin;
} }
void PCB_BASE_FRAME::SetGridOrigin( const wxPoint& aPoint ) void PCB_BASE_FRAME::SetGridOrigin( const wxPoint& aPoint )
{ {
wxASSERT( m_Pcb ); wxASSERT( m_Pcb );
m_Pcb->SetGridOrigin( aPoint ); m_Pcb->GetDesignSettings().m_GridOrigin = aPoint;
} }

View File

@ -341,7 +341,7 @@ void AddGerberX2Header( PLOTTER * aPlotter,
// 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->GetAuxOrigin(); wxPoint auxOrigin = aBoard->GetDesignSettings().m_AuxOrigin;
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

@ -30,8 +30,6 @@
#include <fctsys.h> #include <fctsys.h>
#include <common.h>
#include <plotter.h>
#include <base_struct.h> #include <base_struct.h>
#include <gr_text.h> #include <gr_text.h>
#include <geometry/geometry_utils.h> #include <geometry/geometry_utils.h>
@ -1027,7 +1025,7 @@ static void initializePlotter( PLOTTER *aPlotter, BOARD * aBoard,
else else
{ {
if( aPlotOpts->GetUseAuxOrigin() ) if( aPlotOpts->GetUseAuxOrigin() )
offset = aBoard->GetAuxOrigin(); offset = aBoard->GetDesignSettings().m_AuxOrigin;
} }
aPlotter->SetPageSettings( *sheet_info ); aPlotter->SetPageSettings( *sheet_info );

View File

@ -371,6 +371,7 @@ void PCB_EDIT_FRAME::ReCreateVToolbar()
m_drawToolBar->AddScaledSeparator( this ); m_drawToolBar->AddScaledSeparator( this );
m_drawToolBar->Add( PCB_ACTIONS::drawLine, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::drawLine, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( PCB_ACTIONS::drawRectangle, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( PCB_ACTIONS::drawCircle, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::drawCircle, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( PCB_ACTIONS::drawArc, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::drawArc, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( PCB_ACTIONS::drawPolygon, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::drawPolygon, ACTION_TOOLBAR::TOGGLE );
@ -380,7 +381,8 @@ void PCB_EDIT_FRAME::ReCreateVToolbar()
m_drawToolBar->Add( ACTIONS::deleteTool, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( ACTIONS::deleteTool, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->AddScaledSeparator( this ); m_drawToolBar->AddScaledSeparator( this );
m_drawToolBar->Add( PCB_ACTIONS::drillOrigin, ACTION_TOOLBAR::TOGGLE ); // TODO: re-insert when we have a multi-select tool button
// m_drawToolBar->Add( PCB_ACTIONS::drillOrigin, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( PCB_ACTIONS::gridSetOrigin, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( PCB_ACTIONS::gridSetOrigin, ACTION_TOOLBAR::TOGGLE );
m_drawToolBar->Add( ACTIONS::measureTool, ACTION_TOOLBAR::TOGGLE ); m_drawToolBar->Add( ACTIONS::measureTool, ACTION_TOOLBAR::TOGGLE );
@ -747,6 +749,7 @@ void PCB_EDIT_FRAME::SyncToolbars()
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawZone ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawZone );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawZoneKeepout ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawZoneKeepout );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawLine ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawLine );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawRectangle );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawCircle ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawCircle );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawArc ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawArc );
TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawPolygon ); TOGGLE_TOOL( m_drawToolBar, PCB_ACTIONS::drawPolygon );

View File

@ -1090,7 +1090,6 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
if( selection.Empty() ) if( selection.Empty() )
return 0; return 0;
PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
wxPoint translation; wxPoint translation;
double rotation; double rotation;
ROTATION_ANCHOR rotationAnchor = selection.Size() > 1 ? ROTATE_AROUND_SEL_CENTER ROTATION_ANCHOR rotationAnchor = selection.Size() > 1 ? ROTATE_AROUND_SEL_CENTER
@ -1099,7 +1098,7 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
// TODO: Implement a visible bounding border at the edge // TODO: Implement a visible bounding border at the edge
auto sel_box = selection.GetBoundingBox(); auto sel_box = selection.GetBoundingBox();
DIALOG_MOVE_EXACT dialog( editFrame, translation, rotation, rotationAnchor, sel_box ); DIALOG_MOVE_EXACT dialog( frame(), translation, rotation, rotationAnchor, sel_box );
int ret = dialog.ShowModal(); int ret = dialog.ShowModal();
if( ret == wxID_OK ) if( ret == wxID_OK )
@ -1132,10 +1131,10 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
item->Rotate( selCenter, rotation ); item->Rotate( selCenter, rotation );
break; break;
case ROTATE_AROUND_USER_ORIGIN: case ROTATE_AROUND_USER_ORIGIN:
item->Rotate( (wxPoint) editFrame->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( editFrame->GetAuxOrigin(), rotation ); item->Rotate( board()->GetDesignSettings().m_AuxOrigin, rotation );
break; break;
} }

View File

@ -573,7 +573,8 @@ TOOL_ACTION PCB_ACTIONS::placeModule( "pcbnew.EditorControl.placeModule",
TOOL_ACTION PCB_ACTIONS::drillOrigin( "pcbnew.EditorControl.drillOrigin", TOOL_ACTION PCB_ACTIONS::drillOrigin( "pcbnew.EditorControl.drillOrigin",
AS_GLOBAL, 0, "", AS_GLOBAL, 0, "",
_( "Drill and Place Offset" ), _( "Place origin point for drill and place files" ), _( "Drill/Place File Origin" ),
_( "Place origin point for drill files and footprint position files" ),
pcb_offset_xpm, AF_ACTIVATE ); pcb_offset_xpm, AF_ACTIVATE );
TOOL_ACTION PCB_ACTIONS::toggleLock( "pcbnew.EditorControl.toggleLock", TOOL_ACTION PCB_ACTIONS::toggleLock( "pcbnew.EditorControl.toggleLock",

View File

@ -408,6 +408,7 @@ public:
static TOOL_ACTION highlightNetSelection; static TOOL_ACTION highlightNetSelection;
static TOOL_ACTION highlightItem; static TOOL_ACTION highlightItem;
static TOOL_ACTION drillOrigin; static TOOL_ACTION drillOrigin;
static TOOL_ACTION placeFileOrigin;
static TOOL_ACTION appendBoard; static TOOL_ACTION appendBoard;
static TOOL_ACTION showEeschema; static TOOL_ACTION showEeschema;
static TOOL_ACTION boardStatistics; static TOOL_ACTION boardStatistics;

View File

@ -164,7 +164,7 @@ void PCB_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>()->GetAuxOrigin() ); m_placeOrigin->SetPosition( getModel<BOARD>()->GetDesignSettings().m_AuxOrigin );
getView()->Remove( m_placeOrigin.get() ); getView()->Remove( m_placeOrigin.get() );
getView()->Add( m_placeOrigin.get() ); getView()->Add( m_placeOrigin.get() );
} }
@ -1160,8 +1160,8 @@ int PCB_EDITOR_CONTROL::EditFpInFpEditor( const TOOL_EVENT& aEvent )
void PCB_EDITOR_CONTROL::DoSetDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame, void PCB_EDITOR_CONTROL::DoSetDrillOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
BOARD_ITEM* originViewItem, const VECTOR2D& aPosition ) BOARD_ITEM* originViewItem, const VECTOR2D& aPosition )
{ {
aFrame->SetAuxOrigin( wxPoint( aPosition.x, aPosition.y ) ); aFrame->GetDesignSettings().m_AuxOrigin = (wxPoint) aPosition;
originViewItem->SetPosition( wxPoint( aPosition.x, aPosition.y ) ); originViewItem->SetPosition( (wxPoint) aPosition );
aView->MarkDirty(); aView->MarkDirty();
aFrame->OnModify(); aFrame->OnModify();
} }

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2014-2016 CERN * Copyright (C) 2014-2016 CERN
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors.
* @author Maciej Suminski <maciej.suminski@cern.ch> * @author Maciej Suminski <maciej.suminski@cern.ch>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -39,22 +39,16 @@
#include <class_edge_mod.h> #include <class_edge_mod.h>
#include <confirm.h> #include <confirm.h>
#include <connectivity/connectivity_data.h> #include <connectivity/connectivity_data.h>
#include <gal/graphics_abstraction_layer.h>
#include <io_mgr.h>
#include <kicad_clipboard.h> #include <kicad_clipboard.h>
#include <kiway.h>
#include <origin_viewitem.h> #include <origin_viewitem.h>
#include <pcb_edit_frame.h> #include <pcb_edit_frame.h>
#include <pcb_painter.h> #include <pcb_painter.h>
#include <pcb_screen.h>
#include <properties.h> #include <properties.h>
#include <settings/color_settings.h> #include <settings/color_settings.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <view/view_controls.h> #include <view/view_controls.h>
#include <functional>
#include <footprint_viewer_frame.h> #include <footprint_viewer_frame.h>
#include <footprint_edit_frame.h> #include <footprint_edit_frame.h>
#include <math/util.h> // for KiROUND
using namespace std::placeholders; using namespace std::placeholders;
@ -85,7 +79,7 @@ void PCBNEW_CONTROL::Reset( RESET_REASON aReason )
if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH ) if( aReason == MODEL_RELOAD || aReason == GAL_SWITCH )
{ {
m_gridOrigin->SetPosition( board()->GetGridOrigin() ); m_gridOrigin->SetPosition( board()->GetDesignSettings().m_GridOrigin );
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() );
@ -368,9 +362,9 @@ int PCBNEW_CONTROL::LayerAlphaDec( const TOOL_EVENT& aEvent )
void PCBNEW_CONTROL::DoSetGridOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame, void PCBNEW_CONTROL::DoSetGridOrigin( KIGFX::VIEW* aView, PCB_BASE_FRAME* aFrame,
BOARD_ITEM* originViewItem, const VECTOR2D& aPoint ) BOARD_ITEM* originViewItem, const VECTOR2D& aPoint )
{ {
aFrame->SetGridOrigin( wxPoint( aPoint.x, aPoint.y ) ); aFrame->GetDesignSettings().m_GridOrigin = (wxPoint) aPoint;
aView->GetGAL()->SetGridOrigin( aPoint ); aView->GetGAL()->SetGridOrigin( aPoint );
originViewItem->SetPosition( wxPoint( aPoint.x, aPoint.y ) ); originViewItem->SetPosition( (wxPoint) aPoint );
aView->MarkDirty(); aView->MarkDirty();
aFrame->OnModify(); aFrame->OnModify();
} }