Commit dbc4a8f2 authored by Maciej Suminski's avatar Maciej Suminski

GAL zooms in and out using the default hot keys (F1/F2).

Screen size is saved in VECTOR2I instead of VECTOR2D.
parent 093e311a
......@@ -70,7 +70,7 @@ CAIRO_GAL::CAIRO_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
#endif
SetSize( aParent->GetSize() );
screenSize = VECTOR2D( aParent->GetSize() );
screenSize = VECTOR2I( aParent->GetSize() );
initCursor();
// Grid color settings are different in Cairo and OpenGL
......@@ -138,7 +138,7 @@ void CAIRO_GAL::EndDrawing()
*wxOutputPtr++ = value & 0xff; // Blue pixel
}
wxImage img( (int) screenSize.x, (int) screenSize.y, (unsigned char*) wxOutput, true );
wxImage img( screenSize.x, screenSize.y, (unsigned char*) wxOutput, true );
wxBitmap bmp( img );
wxClientDC client_dc( this );
wxBufferedDC dc;
......@@ -283,7 +283,7 @@ void CAIRO_GAL::DrawCurve( const VECTOR2D& aStartPoint, const VECTOR2D& aControl
void CAIRO_GAL::ResizeScreen( int aWidth, int aHeight )
{
screenSize = VECTOR2D( aWidth, aHeight );
screenSize = VECTOR2I( aWidth, aHeight );
// Recreate the bitmaps
deleteBitmaps();
......
......@@ -88,7 +88,7 @@ void GAL::ComputeWorldScreenMatrix()
MATRIX3x3D translation;
translation.SetIdentity();
translation.SetTranslation( 0.5 * screenSize );
translation.SetTranslation( 0.5 * VECTOR2D( screenSize ) );
MATRIX3x3D scale;
scale.SetIdentity();
......@@ -131,7 +131,7 @@ void GAL::DrawGrid()
// For the drawing the start points, end points and increments have
// to be calculated in world coordinates
VECTOR2D worldStartPoint = screenWorldMatrix * VECTOR2D( 0.0, 0.0 );
VECTOR2D worldEndPoint = screenWorldMatrix * screenSize;
VECTOR2D worldEndPoint = screenWorldMatrix * VECTOR2D( screenSize );
int gridScreenSizeDense = round( gridSize.x * worldScale );
int gridScreenSizeCoarse = round( gridSize.x * static_cast<double>( gridTick ) * worldScale );
......
......@@ -86,7 +86,7 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
#endif
SetSize( aParent->GetSize() );
screenSize = VECTOR2D( aParent->GetSize() );
screenSize = VECTOR2I( aParent->GetSize() );
// Grid color settings are different in Cairo and OpenGL
SetGridColor( COLOR4D( 0.8, 0.8, 0.8, 0.1 ) );
......@@ -562,7 +562,7 @@ void OPENGL_GAL::DrawCurve( const VECTOR2D& aStartPoint, const VECTOR2D& aContro
void OPENGL_GAL::ResizeScreen( int aWidth, int aHeight )
{
screenSize = VECTOR2D( aWidth, aHeight );
screenSize = VECTOR2I( aWidth, aHeight );
// Resize framebuffers
compositor.Resize( aWidth, aHeight );
......
......@@ -771,7 +771,7 @@ void VIEW::Redraw()
}
const VECTOR2D& VIEW::GetScreenPixelSize() const
const VECTOR2I& VIEW::GetScreenPixelSize() const
{
return m_gal->GetScreenPixelSize();
}
......
......@@ -203,8 +203,9 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
double zoom = 1.0 / ( zoomFactor * GetZoom() );
view->SetScale( zoom );
view->SetCenter( VECTOR2D( center ) );
VECTOR2D cursorWorld( GetCrossHairPosition() );
view->SetScale( zoom, cursorWorld );
GetGalCanvas()->Refresh();
}
......
......@@ -160,7 +160,7 @@ public:
virtual bool Show( bool aShow ) = 0;
/// @brief Returns GAL canvas size in pixels
const VECTOR2D& GetScreenPixelSize() const
const VECTOR2I& GetScreenPixelSize() const
{
return screenSize;
}
......@@ -831,7 +831,7 @@ public:
protected:
std::stack<double> depthStack; ///< Stored depth values
VECTOR2D screenSize; ///< Screen size in screen coordinates
VECTOR2I screenSize; ///< Screen size in screen coordinates
double worldUnitLength; ///< The unit length of the world coordinates [inch]
double screenDPI; ///< The dots per inch of the screen
......
......@@ -261,7 +261,7 @@ public:
* Returns the size of the our rendering area, in pixels.
* @return viewport screen size
*/
const VECTOR2D& GetScreenPixelSize() const;
const VECTOR2I& GetScreenPixelSize() const;
/**
* Function AddLayer()
......
......@@ -328,12 +328,12 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
*/
// Zoom In
text = AddHotkeyName( _( "Zoom &In" ), g_Pcbnew_Editor_Hokeys_Descr,
HK_ZOOM_IN, IS_ACCELERATOR );
HK_ZOOM_IN );
AddMenuItem( viewMenu, ID_ZOOM_IN, text, HELP_ZOOM_IN, KiBitmap( zoom_in_xpm ) );
// Zoom Out
text = AddHotkeyName( _( "Zoom &Out" ), g_Pcbnew_Editor_Hokeys_Descr,
HK_ZOOM_OUT, IS_ACCELERATOR );
HK_ZOOM_OUT );
AddMenuItem( viewMenu, ID_ZOOM_OUT, text, HELP_ZOOM_OUT, KiBitmap( zoom_out_xpm ) );
// Fit on Screen
......@@ -366,21 +366,21 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
viewMenu->AppendSeparator();
text = AddHotkeyName( _( "&Switch canvas to default" ), g_Pcbnew_Editor_Hokeys_Descr,
HK_CANVAS_DEFAULT, IS_ACCELERATOR );
HK_CANVAS_DEFAULT );
AddMenuItem( viewMenu, ID_MENU_CANVAS_DEFAULT,
text, _( "Switch the canvas implementation to default" ),
KiBitmap( tools_xpm ) );
text = AddHotkeyName( _( "&Switch canvas to OpenGL" ), g_Pcbnew_Editor_Hokeys_Descr,
HK_CANVAS_OPENGL, IS_ACCELERATOR );
HK_CANVAS_OPENGL );
AddMenuItem( viewMenu, ID_MENU_CANVAS_OPENGL,
text, _( "Switch the canvas implementation to OpenGL" ),
KiBitmap( tools_xpm ) );
text = AddHotkeyName( _( "&Switch canvas to Cairo" ), g_Pcbnew_Editor_Hokeys_Descr,
HK_CANVAS_CAIRO, IS_ACCELERATOR );
HK_CANVAS_CAIRO );
AddMenuItem( viewMenu, ID_MENU_CANVAS_CAIRO,
text, _( "Switch the canvas implementation to Cairo" ),
......@@ -391,13 +391,13 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
// Module
text = AddHotkeyName( _( "&Module" ), g_Pcbnew_Editor_Hokeys_Descr,
HK_ADD_MODULE, IS_ACCELERATOR );
HK_ADD_MODULE );
AddMenuItem( placeMenu, ID_PCB_MODULE_BUTT, text,
_( "Add modules" ), KiBitmap( module_xpm ) );
// Track
text = AddHotkeyName( _( "&Track" ), g_Pcbnew_Editor_Hokeys_Descr,
HK_ADD_NEW_TRACK, IS_ACCELERATOR );
HK_ADD_NEW_TRACK );
AddMenuItem( placeMenu, ID_TRACK_BUTT, text,
_( "Add tracks and vias" ), KiBitmap( add_tracks_xpm ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment