Use worksheet bounding box when the board is empty
Fixes: lp:1742140 * https://bugs.launchpad.net/kicad/+bug/1742140
This commit is contained in:
parent
47dfabc6c8
commit
5fd1236d7a
|
@ -114,21 +114,15 @@ int COMMON_TOOLS::ZoomFitScreen( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
|
if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
|
||||||
{
|
{
|
||||||
// Empty view
|
bBox = galCanvas->GetDefaultViewBBox();
|
||||||
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() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
// Take scrollbars into account
|
||||||
VECTOR2D worldScrollbarSize = view->ToWorld( scrollbarSize, false );
|
VECTOR2D worldScrollbarSize = view->ToWorld( scrollbarSize, false );
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#include <wx/window.h>
|
#include <wx/window.h>
|
||||||
#include <wx/timer.h>
|
#include <wx/timer.h>
|
||||||
|
#include <math/box2.h>
|
||||||
#include <math/vector2d.h>
|
#include <math/vector2d.h>
|
||||||
#include <msgpanel.h>
|
#include <msgpanel.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -224,6 +225,17 @@ public:
|
||||||
*/
|
*/
|
||||||
int GetCurrentCursor() const { return m_currentCursor; }
|
int GetCurrentCursor() const { return m_currentCursor; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the bounding box of the view that should be used if model is not valid
|
||||||
|
* For example, the worksheet bounding box for an empty PCB
|
||||||
|
*
|
||||||
|
* @return the default bounding box for the panel
|
||||||
|
*/
|
||||||
|
virtual BOX2I GetDefaultViewBBox() const
|
||||||
|
{
|
||||||
|
return BOX2I();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onPaint( wxPaintEvent& WXUNUSED( aEvent ) );
|
void onPaint( wxPaintEvent& WXUNUSED( aEvent ) );
|
||||||
|
|
|
@ -395,6 +395,15 @@ void PCB_DRAW_PANEL_GAL::RedrawRatsnest()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOX2I PCB_DRAW_PANEL_GAL::GetDefaultViewBBox() const
|
||||||
|
{
|
||||||
|
if( m_worksheet )
|
||||||
|
return m_worksheet->ViewBBox();
|
||||||
|
|
||||||
|
return BOX2I();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_DRAW_PANEL_GAL::setDefaultLayerDeps()
|
void PCB_DRAW_PANEL_GAL::setDefaultLayerDeps()
|
||||||
{
|
{
|
||||||
// caching makes no sense for Cairo and other software renderers
|
// caching makes no sense for Cairo and other software renderers
|
||||||
|
|
|
@ -103,6 +103,9 @@ public:
|
||||||
///> Forces refresh of the ratsnest visual representation
|
///> Forces refresh of the ratsnest visual representation
|
||||||
void RedrawRatsnest();
|
void RedrawRatsnest();
|
||||||
|
|
||||||
|
///> @copydoc EDA_DRAW_PANEL_GAL::GetDefaultViewBBox()
|
||||||
|
BOX2I GetDefaultViewBBox() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
KIGFX::PCB_VIEW* view() const;
|
KIGFX::PCB_VIEW* view() const;
|
||||||
|
|
Loading…
Reference in New Issue