KiCad PCB EDA Suite
class_draw_panel_gal.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2013-2016 CERN
5  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
6  * @author Maciej Suminski <maciej.suminski@cern.ch>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
31 #ifndef PANELGAL_WXSTRUCT_H
32 #define PANELGAL_WXSTRUCT_H
33 
34 #include <wx/window.h>
35 #include <wx/timer.h>
36 #include <math/vector2d.h>
37 #include <msgpanel.h>
38 
39 class BOARD;
40 class EDA_DRAW_FRAME;
41 class TOOL_DISPATCHER;
42 
43 namespace KIGFX
44 {
45 class GAL;
46 class VIEW;
47 class WX_VIEW_CONTROLS;
48 class VIEW_CONTROLS;
49 class PAINTER;
50 class GAL_DISPLAY_OPTIONS;
51 };
52 
53 
54 class EDA_DRAW_PANEL_GAL : public wxScrolledCanvas
55 {
56 public:
57  enum GAL_TYPE {
62  };
63 
64  EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId, const wxPoint& aPosition,
65  const wxSize& aSize, KIGFX::GAL_DISPLAY_OPTIONS& aOptions,
66  GAL_TYPE aGalType = GAL_TYPE_OPENGL );
68 
69  virtual void SetFocus() override;
70 
76  virtual bool SwitchBackend( GAL_TYPE aGalType );
77 
82  inline GAL_TYPE GetBackend() const
83  {
84  return m_backend;
85  }
86 
92  KIGFX::GAL* GetGAL() const
93  {
94  return m_gal;
95  }
96 
103  {
104  return m_view;
105  }
106 
113  {
115  }
116 
118  void Refresh( bool aEraseBackground = true, const wxRect* aRect = NULL ) override;
119 
124  void ForceRefresh();
125 
133  void SetEventDispatcher( TOOL_DISPATCHER* aEventDispatcher );
134 
139  void StartDrawing();
140 
146  void StopDrawing();
147 
152  virtual void SetHighContrastLayer( int aLayer );
153 
158  virtual void SetTopLayer( int aLayer );
159 
160  virtual void GetMsgPanelInfo( std::vector<MSG_PANEL_ITEM>& aList )
161  {
162  assert( false );
163  }
164 
169  double GetLegacyZoom() const;
170 
176  {
177  return m_edaFrame;
178  }
179 
184  virtual void OnShow() {}
185 
191  void SetStealsFocus( bool aStealsFocus )
192  {
193  m_stealsFocus = aStealsFocus;
194  }
195 
199  bool GetStealsFocus() const
200  {
201  return m_stealsFocus;
202  }
203 
208  void SetCurrentCursor( int aCursor )
209  {
210  m_currentCursor = aCursor;
211  SetCursor( (wxStockCursor) m_currentCursor );
212  }
213 
218  int GetDefaultCursor() const { return m_defaultCursor; }
219 
224  int GetCurrentCursor() const { return m_currentCursor; }
225 
226 
227 protected:
228  void onPaint( wxPaintEvent& WXUNUSED( aEvent ) );
229  void onSize( wxSizeEvent& aEvent );
230  void onEvent( wxEvent& aEvent );
231  void onEnter( wxEvent& aEvent );
232  void onLostFocus( wxFocusEvent& aEvent );
233  void onRefreshTimer( wxTimerEvent& aEvent );
234  void onShowTimer( wxTimerEvent& aEvent );
235 
236  static const int MinRefreshPeriod = 17;
237 
242 
244  wxWindow* m_parent;
245 
248 
250  wxLongLong m_lastRefresh;
251 
254 
256  bool m_drawing;
257 
260 
262  wxTimer m_refreshTimer;
263 
265  wxTimer m_onShowTimer;
266 
269 
272 
275 
278 
282 
285 
289 
293 };
294 
295 #endif
bool m_pendingRefresh
Is there a redraw event requested?
wxTimer m_refreshTimer
Timer responsible for preventing too frequent refresh.
KIGFX::GAL * m_gal
Interface for drawing objects on a 2D-surface.
virtual void SetHighContrastLayer(int aLayer)
Function SetHighContrastLayer Takes care of display settings for the given layer to be displayed in h...
void ForceRefresh()
Function ForceRefresh() Forces a redraw.
KIGFX::WX_VIEW_CONTROLS * m_viewControls
Control for VIEW (moving, zooming, etc.)
GAL_TYPE m_backend
Currently used GAL.
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:58
GAL_TYPE GetBackend() const
Function GetBackend Returns the type of backend currently used by GAL canvas.
Class WX_VIEW_CONTROLS is a specific implementation of class VIEW_CONTROLS for wxWidgets library...
double GetLegacyZoom() const
Function GetLegacyZoom() Returns current view scale converted to zoom value used by the legacy canvas...
virtual bool SwitchBackend(GAL_TYPE aGalType)
Function SwitchBackend Switches method of rendering graphics.
EDA_DRAW_FRAME * GetParentEDAFrame() const
Function GetParentEDAFrame() Returns parent EDA_DRAW_FRAME, if available or NULL otherwise.
KIGFX::GAL_DISPLAY_OPTIONS & m_options
virtual void OnShow()
Function OnShow() Called when the window is shown for the first time.
int GetCurrentCursor() const
Function GetCurrentCursor.
void onLostFocus(wxFocusEvent &aEvent)
int m_currentCursor
Current mouse cursor shape id.
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
Sentinel, do not use as a parameter.
void onShowTimer(wxTimerEvent &aEvent)
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:54
int m_defaultCursor
The default mouse cursor shape id.
void onRefreshTimer(wxTimerEvent &aEvent)
bool m_drawing
True if GAL is currently redrawing the view.
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
wxWindow * m_parent
Pointer to the parent window.
Class PAINTER contains all the knowledge about how to draw graphical object onto any particular outpu...
Definition: painter.h:278
void onPaint(wxPaintEvent &WXUNUSED(aEvent))
static const int MinRefreshPeriod
60 FPS.
virtual void SetTopLayer(int aLayer)
Function SetTopLayer Moves the selected layer to the top, so it is displayed above all others...
void SetStealsFocus(bool aStealsFocus)
Set whether focus is taken on certain events (mouseover, keys, etc).
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
EDA_DRAW_PANEL_GAL(wxWindow *aParentWindow, wxWindowID aWindowId, const wxPoint &aPosition, const wxSize &aSize, KIGFX::GAL_DISPLAY_OPTIONS &aOptions, GAL_TYPE aGalType=GAL_TYPE_OPENGL)
bool m_lostFocus
Flag to indicate that focus should be regained on the next mouse event.
virtual void SetFocus() override
EDA_DRAW_FRAME * m_edaFrame
Parent EDA_DRAW_FRAME (if available)
void SetCurrentCursor(int aCursor)
Function SetCurrentCursor Set the current cursor shape for this panel.
void onSize(wxSizeEvent &aEvent)
void StartDrawing()
Function StartDrawing() Begins drawing if it was stopped previously.
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Class TOOL_DISPATCHER.
bool GetStealsFocus() const
Get whether focus is taken on certain events (see SetStealsFocus()).
TOOL_DISPATCHER * m_eventDispatcher
Processes and forwards events to tools.
wxTimer m_onShowTimer
Timer used to execute OnShow() when the window finally appears on the screen.
KIGFX::VIEW * m_view
Stores view settings (scale, center, etc.) and items to be drawn.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools...
bool m_drawingEnabled
Flag that determines if VIEW may use GAL for redrawing the screen.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel...
wxLongLong m_lastRefresh
Last timestamp when the panel was refreshed.
void onEnter(wxEvent &aEvent)
void onEvent(wxEvent &aEvent)
Class VIEW.
Definition: view.h:58
KIGFX::PAINTER * m_painter
Contains information about how to draw items using GAL.
int GetDefaultCursor() const
Function GetDefaultCursor.
bool m_stealsFocus
Flag to indicate whether the panel should take focus at certain times (when moused over...
Message panel definition file.
void StopDrawing()
Function StopDrawing() Prevents the GAL canvas from further drawing till it is recreated or StartDraw...
Class GAL is the abstract interface for drawing on a 2D-surface.
virtual void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList)