Move ZoomFitScreen and ZoomPreset from PCBNEW_CONTROL to COMMON_TOOLS
BOARD::GetBoundingBox() now directly calls BOARD::ComputeBoundingBox() and there is a new method BOARD::GetBoardEdgesBoundingBox() used for call sites that needed to use ComputeBoundingBox( true ) in the past. This allows COMMON_TOOLS to implement ZoomFitScreen without knowledge of the BOARD class.
This commit is contained in:
parent
dda51ab550
commit
88f7c55d95
|
@ -98,6 +98,69 @@ int COMMON_TOOLS::ZoomCenter( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int COMMON_TOOLS::ZoomFitScreen( const TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
KIGFX::VIEW* view = getView();
|
||||||
|
EDA_DRAW_PANEL_GAL* galCanvas = m_frame->GetGalCanvas();
|
||||||
|
EDA_ITEM* model = getModel<EDA_ITEM>();
|
||||||
|
|
||||||
|
BOX2I bBox = model->ViewBBox();
|
||||||
|
VECTOR2D scrollbarSize = VECTOR2D( galCanvas->GetSize() - galCanvas->GetClientSize() );
|
||||||
|
VECTOR2D screenSize = view->ToWorld( galCanvas->GetClientSize(), false );
|
||||||
|
|
||||||
|
if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
|
||||||
|
{
|
||||||
|
// Empty view
|
||||||
|
view->SetScale( 17.0 ); // works fine for the standard worksheet frame
|
||||||
|
|
||||||
|
view->SetCenter( screenSize / 2.0 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VECTOR2D vsize = bBox.GetSize();
|
||||||
|
double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ),
|
||||||
|
fabs( vsize.y / screenSize.y ) );
|
||||||
|
|
||||||
|
view->SetScale( scale );
|
||||||
|
view->SetCenter( bBox.Centre() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Take scrollbars into account
|
||||||
|
VECTOR2D worldScrollbarSize = view->ToWorld( scrollbarSize, false );
|
||||||
|
view->SetCenter( view->GetCenter() + worldScrollbarSize / 2.0 );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int COMMON_TOOLS::ZoomPreset( const TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
unsigned int idx = aEvent.Parameter<intptr_t>();
|
||||||
|
std::vector<double>& zoomList = m_frame->GetScreen()->m_ZoomList;
|
||||||
|
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
|
||||||
|
KIGFX::GAL* gal = m_frame->GetGalCanvas()->GetGAL();
|
||||||
|
|
||||||
|
m_frame->SetPresetZoom( idx );
|
||||||
|
|
||||||
|
if( idx == 0 ) // Zoom Auto
|
||||||
|
{
|
||||||
|
return ZoomFitScreen( aEvent );
|
||||||
|
}
|
||||||
|
else if( idx >= zoomList.size() )
|
||||||
|
{
|
||||||
|
assert( false );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
double selectedZoom = zoomList[idx];
|
||||||
|
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
|
||||||
|
view->SetScale( 1.0 / ( zoomFactor * selectedZoom ) );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Grid control
|
// Grid control
|
||||||
int COMMON_TOOLS::GridNext( const TOOL_EVENT& aEvent )
|
int COMMON_TOOLS::GridNext( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
|
@ -135,6 +198,8 @@ void COMMON_TOOLS::SetTransitions()
|
||||||
Go( &COMMON_TOOLS::ZoomInOutCenter, ACTIONS::zoomInCenter.MakeEvent() );
|
Go( &COMMON_TOOLS::ZoomInOutCenter, ACTIONS::zoomInCenter.MakeEvent() );
|
||||||
Go( &COMMON_TOOLS::ZoomInOutCenter, ACTIONS::zoomOutCenter.MakeEvent() );
|
Go( &COMMON_TOOLS::ZoomInOutCenter, ACTIONS::zoomOutCenter.MakeEvent() );
|
||||||
Go( &COMMON_TOOLS::ZoomCenter, ACTIONS::zoomCenter.MakeEvent() );
|
Go( &COMMON_TOOLS::ZoomCenter, ACTIONS::zoomCenter.MakeEvent() );
|
||||||
|
Go( &COMMON_TOOLS::ZoomFitScreen, ACTIONS::zoomFitScreen.MakeEvent() );
|
||||||
|
Go( &COMMON_TOOLS::ZoomPreset, ACTIONS::zoomPreset.MakeEvent() );
|
||||||
|
|
||||||
Go( &COMMON_TOOLS::GridNext, ACTIONS::gridNext.MakeEvent() );
|
Go( &COMMON_TOOLS::GridNext, ACTIONS::gridNext.MakeEvent() );
|
||||||
Go( &COMMON_TOOLS::GridPrev, ACTIONS::gridPrev.MakeEvent() );
|
Go( &COMMON_TOOLS::GridPrev, ACTIONS::gridPrev.MakeEvent() );
|
||||||
|
|
|
@ -48,6 +48,8 @@ public:
|
||||||
int ZoomInOut( const TOOL_EVENT& aEvent );
|
int ZoomInOut( const TOOL_EVENT& aEvent );
|
||||||
int ZoomInOutCenter( const TOOL_EVENT& aEvent );
|
int ZoomInOutCenter( const TOOL_EVENT& aEvent );
|
||||||
int ZoomCenter( const TOOL_EVENT& aEvent );
|
int ZoomCenter( const TOOL_EVENT& aEvent );
|
||||||
|
int ZoomFitScreen( const TOOL_EVENT& aEvent );
|
||||||
|
int ZoomPreset( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
// Grid control
|
// Grid control
|
||||||
int GridNext( const TOOL_EVENT& aEvent );
|
int GridNext( const TOOL_EVENT& aEvent );
|
||||||
|
|
|
@ -459,7 +459,7 @@ int genPlacementRoutingMatrix( BOARD* aBrd, EDA_MSG_PANEL* messagePanel )
|
||||||
|
|
||||||
RoutingMatrix.UnInitRoutingMatrix();
|
RoutingMatrix.UnInitRoutingMatrix();
|
||||||
|
|
||||||
EDA_RECT bbox = aBrd->ComputeBoundingBox( true );
|
EDA_RECT bbox = aBrd->GetBoardEdgesBoundingBox();
|
||||||
|
|
||||||
if( bbox.GetWidth() == 0 || bbox.GetHeight() == 0 )
|
if( bbox.GetWidth() == 0 || bbox.GetHeight() == 0 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,10 +69,8 @@ MATRIX_ROUTING_HEAD::~MATRIX_ROUTING_HEAD()
|
||||||
|
|
||||||
bool MATRIX_ROUTING_HEAD::ComputeMatrixSize( BOARD* aPcb, bool aUseBoardEdgesOnly )
|
bool MATRIX_ROUTING_HEAD::ComputeMatrixSize( BOARD* aPcb, bool aUseBoardEdgesOnly )
|
||||||
{
|
{
|
||||||
aPcb->ComputeBoundingBox( aUseBoardEdgesOnly );
|
|
||||||
|
|
||||||
// The boundary box must have its start point on routing grid:
|
// The boundary box must have its start point on routing grid:
|
||||||
m_BrdBox = aPcb->GetBoundingBox();
|
m_BrdBox = aUseBoardEdgesOnly ? aPcb->GetBoardEdgesBoundingBox() : aPcb->GetBoundingBox();
|
||||||
|
|
||||||
m_BrdBox.SetX( m_BrdBox.GetX() - ( m_BrdBox.GetX() % m_GridRouting ) );
|
m_BrdBox.SetX( m_BrdBox.GetX() - ( m_BrdBox.GetX() % m_GridRouting ) );
|
||||||
m_BrdBox.SetY( m_BrdBox.GetY() - ( m_BrdBox.GetY() % m_GridRouting ) );
|
m_BrdBox.SetY( m_BrdBox.GetY() - ( m_BrdBox.GetY() % m_GridRouting ) );
|
||||||
|
|
|
@ -177,7 +177,7 @@ void PCB_EDIT_FRAME::SpreadFootprints( std::vector<MODULE*>* aFootprints,
|
||||||
wxPoint aSpreadAreaPosition,
|
wxPoint aSpreadAreaPosition,
|
||||||
bool aPrepareUndoCommand )
|
bool aPrepareUndoCommand )
|
||||||
{
|
{
|
||||||
EDA_RECT bbox = GetBoard()->ComputeBoundingBox( true );
|
EDA_RECT bbox = GetBoard()->GetBoardEdgesBoundingBox();
|
||||||
bool edgesExist = bbox.GetWidth() || bbox.GetHeight();
|
bool edgesExist = bbox.GetWidth() || bbox.GetHeight();
|
||||||
// if aFootprintsOutsideBoardOnly is true, and if board outline exists,
|
// if aFootprintsOutsideBoardOnly is true, and if board outline exists,
|
||||||
// we have to filter footprints to move:
|
// we have to filter footprints to move:
|
||||||
|
|
|
@ -294,7 +294,7 @@ EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
|
||||||
{
|
{
|
||||||
wxASSERT( m_Pcb );
|
wxASSERT( m_Pcb );
|
||||||
|
|
||||||
EDA_RECT area = m_Pcb->ComputeBoundingBox( aBoardEdgesOnly );
|
EDA_RECT area = aBoardEdgesOnly ? m_Pcb->GetBoardEdgesBoundingBox() : m_Pcb->GetBoundingBox();
|
||||||
|
|
||||||
if( area.GetWidth() == 0 && area.GetHeight() == 0 )
|
if( area.GetWidth() == 0 && area.GetHeight() == 0 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -79,7 +79,7 @@ wxPoint BOARD_NETLIST_UPDATER::estimateComponentInsertionPosition()
|
||||||
if( !m_board->IsEmpty() )
|
if( !m_board->IsEmpty() )
|
||||||
{
|
{
|
||||||
// Position new components below any existing board features.
|
// Position new components below any existing board features.
|
||||||
EDA_RECT bbox = m_board->ComputeBoundingBox( true );
|
EDA_RECT bbox = m_board->GetBoardEdgesBoundingBox();
|
||||||
|
|
||||||
if( bbox.GetWidth() || bbox.GetHeight() )
|
if( bbox.GetWidth() || bbox.GetHeight() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1054,7 +1054,7 @@ unsigned BOARD::GetNodesCount() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EDA_RECT BOARD::ComputeBoundingBox( bool aBoardEdgesOnly )
|
EDA_RECT BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const
|
||||||
{
|
{
|
||||||
bool hasItems = false;
|
bool hasItems = false;
|
||||||
EDA_RECT area;
|
EDA_RECT area;
|
||||||
|
@ -2364,6 +2364,7 @@ ZONE_CONTAINER* BOARD::InsertArea( int netcode, int iarea, LAYER_ID layer, int x
|
||||||
m_ZoneDescriptorList.push_back( new_area );
|
m_ZoneDescriptorList.push_back( new_area );
|
||||||
|
|
||||||
new_area->Outline()->Start( layer, x, y, hatch );
|
new_area->Outline()->Start( layer, x, y, hatch );
|
||||||
|
|
||||||
return new_area;
|
return new_area;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2425,7 +2426,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
|
||||||
if( !IsEmpty() )
|
if( !IsEmpty() )
|
||||||
{
|
{
|
||||||
// Position new components below any existing board features.
|
// Position new components below any existing board features.
|
||||||
EDA_RECT bbbox = ComputeBoundingBox( true );
|
EDA_RECT bbbox = GetBoardEdgesBoundingBox();
|
||||||
|
|
||||||
if( bbbox.GetWidth() || bbbox.GetHeight() )
|
if( bbbox.GetWidth() || bbbox.GetHeight() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -185,7 +185,7 @@ private:
|
||||||
|
|
||||||
int m_fileFormatVersionAtLoad; ///< the version loaded from the file
|
int m_fileFormatVersionAtLoad; ///< the version loaded from the file
|
||||||
|
|
||||||
EDA_RECT m_BoundingBox;
|
mutable EDA_RECT m_BoundingBox;
|
||||||
NETINFO_LIST m_NetInfo; ///< net info list (name, design constraints ..
|
NETINFO_LIST m_NetInfo; ///< net info list (name, design constraints ..
|
||||||
RN_DATA* m_ratsnest;
|
RN_DATA* m_ratsnest;
|
||||||
|
|
||||||
|
@ -825,7 +825,7 @@ public:
|
||||||
* @return EDA_RECT - the board's bounding box
|
* @return EDA_RECT - the board's bounding box
|
||||||
* @see PCB_BASE_FRAME::GetBoardBoundingBox() which calls this and doctors the result
|
* @see PCB_BASE_FRAME::GetBoardBoundingBox() which calls this and doctors the result
|
||||||
*/
|
*/
|
||||||
EDA_RECT ComputeBoundingBox( bool aBoardEdgesOnly = false );
|
EDA_RECT ComputeBoundingBox( bool aBoardEdgesOnly = false ) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetBoundingBox
|
* Function GetBoundingBox
|
||||||
|
@ -833,7 +833,22 @@ public:
|
||||||
* as long as the BOARD has not changed. Remember, ComputeBoundingBox()'s
|
* as long as the BOARD has not changed. Remember, ComputeBoundingBox()'s
|
||||||
* aBoardEdgesOnly argument is considered in this return value also.
|
* aBoardEdgesOnly argument is considered in this return value also.
|
||||||
*/
|
*/
|
||||||
const EDA_RECT GetBoundingBox() const override { return m_BoundingBox; }
|
const EDA_RECT GetBoundingBox() const override
|
||||||
|
{
|
||||||
|
return ComputeBoundingBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function GetBoardEdgesBoundingBox
|
||||||
|
* Returns the board bounding box calculated using exclusively the board edges (graphics
|
||||||
|
* on Edge.Cuts layer). If there are items outside of the area limited by Edge.Cuts graphics,
|
||||||
|
* the items will not be taken into account.
|
||||||
|
* @return bounding box calculated using exclusively the board edges.
|
||||||
|
*/
|
||||||
|
const EDA_RECT GetBoardEdgesBoundingBox() const
|
||||||
|
{
|
||||||
|
return ComputeBoundingBox( true );
|
||||||
|
}
|
||||||
|
|
||||||
void SetBoundingBox( const EDA_RECT& aBox ) { m_BoundingBox = aBox; }
|
void SetBoundingBox( const EDA_RECT& aBox ) { m_BoundingBox = aBox; }
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,7 @@ void PCB_EDIT_FRAME::OnExportIDF3( wxCommandEvent& event )
|
||||||
|
|
||||||
if( dlg.GetAutoAdjustOffset() )
|
if( dlg.GetAutoAdjustOffset() )
|
||||||
{
|
{
|
||||||
EDA_RECT bbox = GetBoard()->ComputeBoundingBox( true );
|
EDA_RECT bbox = GetBoard()->GetBoardEdgesBoundingBox();
|
||||||
|
|
||||||
aXRef = bbox.Centre().x * MM_PER_IU;
|
aXRef = bbox.Centre().x * MM_PER_IU;
|
||||||
aYRef = bbox.Centre().y * MM_PER_IU;
|
aYRef = bbox.Centre().y * MM_PER_IU;
|
||||||
|
|
|
@ -70,7 +70,7 @@ void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun )
|
||||||
|
|
||||||
// keep trace of the initial baord area, if we want to place new footprints
|
// keep trace of the initial baord area, if we want to place new footprints
|
||||||
// outside the existinag board
|
// outside the existinag board
|
||||||
EDA_RECT bbox = board->ComputeBoundingBox( false );
|
EDA_RECT bbox = board->GetBoundingBox();
|
||||||
|
|
||||||
if( !aDryRun )
|
if( !aDryRun )
|
||||||
{
|
{
|
||||||
|
|
|
@ -2991,7 +2991,7 @@ void EAGLE_PLUGIN::centerBoard()
|
||||||
if( m_props->Value( "page_width", &page_width ) &&
|
if( m_props->Value( "page_width", &page_width ) &&
|
||||||
m_props->Value( "page_height", &page_height ) )
|
m_props->Value( "page_height", &page_height ) )
|
||||||
{
|
{
|
||||||
EDA_RECT bbbox = m_board->ComputeBoundingBox( true );
|
EDA_RECT bbbox = m_board->GetBoardEdgesBoundingBox();
|
||||||
|
|
||||||
int w = atoi( page_width.c_str() );
|
int w = atoi( page_width.c_str() );
|
||||||
int h = atoi( page_height.c_str() );
|
int h = atoi( page_height.c_str() );
|
||||||
|
|
|
@ -199,7 +199,7 @@ UseBoundingBox:
|
||||||
// there is always some uncertainty in the board dimensions
|
// there is always some uncertainty in the board dimensions
|
||||||
// computed via ComputeBoundingBox() since this depends on the
|
// computed via ComputeBoundingBox() since this depends on the
|
||||||
// individual module entities.
|
// individual module entities.
|
||||||
EDA_RECT bbbox = aPcb->ComputeBoundingBox( true );
|
EDA_RECT bbbox = aPcb->GetBoardEdgesBoundingBox();
|
||||||
|
|
||||||
// convert to mm and compensate for an assumed LINE_WIDTH line thickness
|
// convert to mm and compensate for an assumed LINE_WIDTH line thickness
|
||||||
double x = ( bbbox.GetOrigin().x + LINE_WIDTH / 2 ) * scale + offX;
|
double x = ( bbbox.GetOrigin().x + LINE_WIDTH / 2 ) * scale + offX;
|
||||||
|
|
|
@ -70,7 +70,7 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
|
||||||
const PAGE_INFO& page_info = m_pageInfo ? *m_pageInfo : dummy;
|
const PAGE_INFO& page_info = m_pageInfo ? *m_pageInfo : dummy;
|
||||||
|
|
||||||
// Calculate dimensions and center of PCB
|
// Calculate dimensions and center of PCB
|
||||||
EDA_RECT bbbox = m_pcb->ComputeBoundingBox( true );
|
EDA_RECT bbbox = m_pcb->GetBoardEdgesBoundingBox();
|
||||||
|
|
||||||
// Calculate the scale for the format type, scale 1 in HPGL, drawing on
|
// Calculate the scale for the format type, scale 1 in HPGL, drawing on
|
||||||
// an A4 sheet in PS, + text description of symbols
|
// an A4 sheet in PS, + text description of symbols
|
||||||
|
|
|
@ -72,7 +72,7 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName,
|
||||||
std::vector<MODULE*> newFootprints;
|
std::vector<MODULE*> newFootprints;
|
||||||
// keep trace of the initial baord area, if we want to place new footprints
|
// keep trace of the initial baord area, if we want to place new footprints
|
||||||
// outside the existinag board
|
// outside the existinag board
|
||||||
EDA_RECT bbox = board->ComputeBoundingBox( false );
|
EDA_RECT bbox = board->GetBoundingBox();
|
||||||
|
|
||||||
netlist.SetIsDryRun( aIsDryRun );
|
netlist.SetIsDryRun( aIsDryRun );
|
||||||
netlist.SetFindByTimeStamp( aSelectByTimeStamp );
|
netlist.SetFindByTimeStamp( aSelectByTimeStamp );
|
||||||
|
|
|
@ -1396,7 +1396,7 @@ bool SPECCTRA_DB::GetBoardPolygonOutlines( BOARD* aBoard,
|
||||||
if( aErrorText )
|
if( aErrorText )
|
||||||
*aErrorText = ioe.What();
|
*aErrorText = ioe.What();
|
||||||
|
|
||||||
EDA_RECT bbbox = aBoard->ComputeBoundingBox( true );
|
EDA_RECT bbbox = aBoard->GetBoardEdgesBoundingBox();
|
||||||
|
|
||||||
// Ensure non null area. If happen, gives a minimal size.
|
// Ensure non null area. If happen, gives a minimal size.
|
||||||
if( ( bbbox.GetWidth() ) == 0 || ( bbbox.GetHeight() == 0 ) )
|
if( ( bbbox.GetWidth() ) == 0 || ( bbbox.GetHeight() == 0 ) )
|
||||||
|
|
|
@ -251,70 +251,6 @@ void PCBNEW_CONTROL::Reset( RESET_REASON aReason )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PCBNEW_CONTROL::ZoomFitScreen( const TOOL_EVENT& aEvent )
|
|
||||||
{
|
|
||||||
KIGFX::VIEW* view = getView();
|
|
||||||
EDA_DRAW_PANEL_GAL* galCanvas = m_frame->GetGalCanvas();
|
|
||||||
BOARD* board = getModel<BOARD>();
|
|
||||||
board->ComputeBoundingBox();
|
|
||||||
|
|
||||||
BOX2I boardBBox = board->ViewBBox();
|
|
||||||
VECTOR2D scrollbarSize = VECTOR2D( galCanvas->GetSize() - galCanvas->GetClientSize() );
|
|
||||||
VECTOR2D screenSize = view->ToWorld( galCanvas->GetClientSize(), false );
|
|
||||||
|
|
||||||
if( boardBBox.GetWidth() == 0 || boardBBox.GetHeight() == 0 )
|
|
||||||
{
|
|
||||||
// Empty view
|
|
||||||
view->SetScale( 17.0 ); // works fine for the standard worksheet frame
|
|
||||||
|
|
||||||
view->SetCenter( screenSize / 2.0 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
VECTOR2D vsize = boardBBox.GetSize();
|
|
||||||
double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ),
|
|
||||||
fabs( vsize.y / screenSize.y ) );
|
|
||||||
|
|
||||||
view->SetScale( scale );
|
|
||||||
view->SetCenter( boardBBox.Centre() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Take scrollbars into account
|
|
||||||
VECTOR2D worldScrollbarSize = view->ToWorld( scrollbarSize, false );
|
|
||||||
view->SetCenter( view->GetCenter() + worldScrollbarSize / 2.0 );
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int PCBNEW_CONTROL::ZoomPreset( const TOOL_EVENT& aEvent )
|
|
||||||
{
|
|
||||||
unsigned int idx = aEvent.Parameter<intptr_t>();
|
|
||||||
std::vector<double>& zoomList = m_frame->GetScreen()->m_ZoomList;
|
|
||||||
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
|
|
||||||
KIGFX::GAL* gal = m_frame->GetGalCanvas()->GetGAL();
|
|
||||||
|
|
||||||
m_frame->SetPresetZoom( idx );
|
|
||||||
|
|
||||||
if( idx == 0 ) // Zoom Auto
|
|
||||||
{
|
|
||||||
return ZoomFitScreen( aEvent );
|
|
||||||
}
|
|
||||||
else if( idx >= zoomList.size() )
|
|
||||||
{
|
|
||||||
assert( false );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
double selectedZoom = zoomList[idx];
|
|
||||||
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
|
|
||||||
view->SetScale( 1.0 / ( zoomFactor * selectedZoom ) );
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int PCBNEW_CONTROL::TrackDisplayMode( const TOOL_EVENT& aEvent )
|
int PCBNEW_CONTROL::TrackDisplayMode( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() );
|
auto painter = static_cast<KIGFX::PCB_PAINTER*>( getView()->GetPainter() );
|
||||||
|
@ -998,10 +934,6 @@ int PCBNEW_CONTROL::ToBeDone( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
void PCBNEW_CONTROL::SetTransitions()
|
void PCBNEW_CONTROL::SetTransitions()
|
||||||
{
|
{
|
||||||
// View controls
|
|
||||||
Go( &PCBNEW_CONTROL::ZoomFitScreen, ACTIONS::zoomFitScreen.MakeEvent() );
|
|
||||||
Go( &PCBNEW_CONTROL::ZoomPreset, ACTIONS::zoomPreset.MakeEvent() );
|
|
||||||
|
|
||||||
// Display modes
|
// Display modes
|
||||||
Go( &PCBNEW_CONTROL::TrackDisplayMode, PCB_ACTIONS::trackDisplayMode.MakeEvent() );
|
Go( &PCBNEW_CONTROL::TrackDisplayMode, PCB_ACTIONS::trackDisplayMode.MakeEvent() );
|
||||||
Go( &PCBNEW_CONTROL::PadDisplayMode, PCB_ACTIONS::padDisplayMode.MakeEvent() );
|
Go( &PCBNEW_CONTROL::PadDisplayMode, PCB_ACTIONS::padDisplayMode.MakeEvent() );
|
||||||
|
|
|
@ -48,10 +48,6 @@ public:
|
||||||
/// @copydoc TOOL_INTERACTIVE::Reset()
|
/// @copydoc TOOL_INTERACTIVE::Reset()
|
||||||
void Reset( RESET_REASON aReason ) override;
|
void Reset( RESET_REASON aReason ) override;
|
||||||
|
|
||||||
// View controls
|
|
||||||
int ZoomFitScreen( const TOOL_EVENT& aEvent );
|
|
||||||
int ZoomPreset( const TOOL_EVENT& aEvent );
|
|
||||||
|
|
||||||
// Display modes
|
// Display modes
|
||||||
int TrackDisplayMode( const TOOL_EVENT& aEvent );
|
int TrackDisplayMode( const TOOL_EVENT& aEvent );
|
||||||
int PadDisplayMode( const TOOL_EVENT& aEvent );
|
int PadDisplayMode( const TOOL_EVENT& aEvent );
|
||||||
|
|
Loading…
Reference in New Issue