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