Implement zoom for GAL canvas.
This commit is contained in:
parent
a67d8c60df
commit
c5330ac0bf
|
@ -138,9 +138,12 @@ bool BASE_SCREEN::SetZoom( double iu_per_du )
|
|||
|
||||
bool BASE_SCREEN::SetNextZoom()
|
||||
{
|
||||
// Step must be AT LEAST 1.2
|
||||
double target = m_Zoom * 1.2;
|
||||
|
||||
for( unsigned i=0; i < m_ZoomList.size(); ++i )
|
||||
{
|
||||
if( m_Zoom < m_ZoomList[i] )
|
||||
if( target < m_ZoomList[i] )
|
||||
{
|
||||
SetZoom( m_ZoomList[i] );
|
||||
return true;
|
||||
|
@ -153,9 +156,12 @@ bool BASE_SCREEN::SetNextZoom()
|
|||
|
||||
bool BASE_SCREEN::SetPreviousZoom()
|
||||
{
|
||||
// Step must be AT LEAST 1.2
|
||||
double target = m_Zoom / 1.2;
|
||||
|
||||
for( unsigned i = m_ZoomList.size(); i != 0; --i )
|
||||
{
|
||||
if( m_Zoom > m_ZoomList[i - 1] )
|
||||
if( target > m_ZoomList[i - 1] )
|
||||
{
|
||||
SetZoom( m_ZoomList[i - 1] );
|
||||
return true;
|
||||
|
|
|
@ -337,8 +337,8 @@ bool SCH_BASE_FRAME::saveSymbolLibTables( bool aGlobal, bool aProject )
|
|||
|
||||
void SCH_BASE_FRAME::Zoom_Automatique( bool aWarpPointer )
|
||||
{
|
||||
auto galCanvas = GetGalCanvas();
|
||||
auto view = GetGalCanvas()->GetView();
|
||||
EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas();
|
||||
KIGFX::VIEW* view = GetGalCanvas()->GetView();
|
||||
|
||||
BOX2I bBox = GetDocumentExtents();
|
||||
|
||||
|
@ -365,7 +365,11 @@ void SCH_BASE_FRAME::Zoom_Automatique( bool aWarpPointer )
|
|||
margin_scale_factor = 1.2;
|
||||
}
|
||||
|
||||
view->SetScale( scale / margin_scale_factor );
|
||||
scale /= margin_scale_factor;
|
||||
|
||||
GetScreen()->SetScalingFactor( 1 / scale );
|
||||
|
||||
view->SetScale( scale );
|
||||
view->SetCenter( bBox.Centre() );
|
||||
|
||||
// Take scrollbars into account
|
||||
|
@ -377,7 +381,7 @@ void SCH_BASE_FRAME::Zoom_Automatique( bool aWarpPointer )
|
|||
/* Set the zoom level to show the area Rect */
|
||||
void SCH_BASE_FRAME::Window_Zoom( EDA_RECT& Rect )
|
||||
{
|
||||
auto view = GetGalCanvas()->GetView();
|
||||
KIGFX::VIEW* view = GetGalCanvas()->GetView();
|
||||
BOX2I selectionBox ( Rect.GetPosition(), Rect.GetSize() );
|
||||
|
||||
VECTOR2D screenSize = view->ToWorld( GetGalCanvas()->GetClientSize(), false );
|
||||
|
@ -392,6 +396,8 @@ void SCH_BASE_FRAME::Window_Zoom( EDA_RECT& Rect )
|
|||
|
||||
scale = view->GetScale() / ratio;
|
||||
|
||||
GetScreen()->SetScalingFactor( 1 / scale );
|
||||
|
||||
view->SetScale( scale );
|
||||
view->SetCenter( selectionBox.Centre() );
|
||||
GetGalCanvas()->Refresh();
|
||||
|
@ -400,12 +406,34 @@ void SCH_BASE_FRAME::Window_Zoom( EDA_RECT& Rect )
|
|||
|
||||
void SCH_BASE_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer )
|
||||
{
|
||||
GetGalCanvas()->Refresh();
|
||||
KIGFX::GAL* gal = GetCanvas()->GetGAL();
|
||||
|
||||
double selectedZoom = GetScreen()->GetZoom();
|
||||
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
|
||||
double scale = 1.0 / ( zoomFactor * selectedZoom );
|
||||
|
||||
if( aCenterPoint != wxPoint( 0, 0 ) )
|
||||
GetCanvas()->GetView()->SetScale( scale, aCenterPoint );
|
||||
else
|
||||
GetCanvas()->GetView()->SetScale( scale );
|
||||
|
||||
if( aWarpPointer )
|
||||
GetCanvas()->GetViewControls()->CenterOnCursor();
|
||||
|
||||
GetCanvas()->Refresh();
|
||||
}
|
||||
|
||||
|
||||
void SCH_BASE_FRAME::RedrawScreen2( const wxPoint& posBefore )
|
||||
{
|
||||
KIGFX::GAL* gal = GetCanvas()->GetGAL();
|
||||
|
||||
double selectedZoom = GetScreen()->GetZoom();
|
||||
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
|
||||
double scale = 1.0 / ( zoomFactor * selectedZoom );
|
||||
|
||||
GetCanvas()->GetView()->SetScale( scale );
|
||||
|
||||
GetGalCanvas()->Refresh();
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include <sch_text.h>
|
||||
#include <lib_pin.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <tool/common_tools.h>
|
||||
|
||||
#define EESCHEMA_FILE_STAMP "EESchema"
|
||||
|
||||
|
@ -1606,13 +1607,6 @@ int SCH_SCREENS::ChangeSymbolLibNickname( const wxString& aFrom, const wxString&
|
|||
}
|
||||
|
||||
|
||||
bool SCH_SCREEN::SetZoom( double iu_per_du )
|
||||
{
|
||||
printf("SetZoom!\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void SCH_SCREENS::BuildClientSheetPathList()
|
||||
{
|
||||
SCH_SHEET_LIST sheetList( g_RootSheet );
|
||||
|
|
|
@ -165,7 +165,6 @@ public:
|
|||
--m_modification_sync;
|
||||
}
|
||||
|
||||
virtual bool SetZoom( double iu_per_du ) override;
|
||||
/**
|
||||
* Copy the contents of \a aScreen into this #SCH_SCREEN object.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue