KiCad PCB EDA Suite
legacy_gal/class_drawpanel.h
Go to the documentation of this file.
1 #ifndef __EDA_DRAW_PANEL_H
2 #define __EDA_DRAW_PANEL_H
3 
4 #include <wx/wx.h>
5 #include <base_struct.h>
6 #include <gr_basic.h>
7 #include <eda_rect.h>
8 
13 class BASE_SCREEN;
14 
15 class EDA_DRAW_PANEL;
16 
17 typedef void ( *MOUSE_CAPTURE_CALLBACK )( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
18  const wxPoint& aPosition, bool aErase );
19 
23 typedef void ( *END_MOUSE_CAPTURE_CALLBACK )( EDA_DRAW_PANEL* aPanel, wxDC* aDC );
24 
25 
27 {
28 protected:
33 
34  wxPoint m_CursorStartPos;
35  wxPoint m_PanStartCenter;
37 
41 
43 
46 
48 
50 
51  /* Used to inhibit a response to a mouse left button release, after a double click
52  * (when releasing the left button at the end of the second click. Used in Eeschema
53  * to inhibit a mouse left release command when switching between hierarchical sheets
54  * on a double click.
55  */
57 
59 
67 
71 
74 
77 
82 
84 
85 public:
86 
88  m_showCrossHair( true ),
89  m_cursorLevel( 0 ),
90  m_scrollIncrementX( 1 ),
91  m_scrollIncrementY( 1 ),
92  m_abortRequest( false ),
93  m_enableZoomNoCenter( false ),
94  m_enableMousewheelPan( false ),
95  m_enableAutoPan( false ),
96  m_ignoreMouseEvents( false ),
97  m_ignoreNextLeftButtonRelease( false ),
98  m_enableBlockCommands( true ),
99  m_minDragEventCount( 5 ),
100  m_PrintIsMirrored( false ),
101  m_mouseCaptureCallback( nullptr ),
102  m_endMouseCaptureCallback( nullptr ),
103  m_canStartBlock( true ),
104  m_doubleClickInterval( 0 )
105  {};
106 
107  virtual ~EDA_DRAW_PANEL(){};
108 
114  virtual void* GetDisplayOptions() { printf("EDA_DRAW_PANEL:Unimplemented\n"); wxASSERT(false); return nullptr; };
115 
116  virtual BASE_SCREEN* GetScreen() = 0;
117 
118  virtual EDA_DRAW_FRAME* GetParent() const = 0;
119 
120  //virtual void OnPaint( wxPaintEvent& event );
121 
122  virtual EDA_RECT* GetClipBox() { return &m_ClipBox; }
123 
124  void SetClipBox( const EDA_RECT& aRect ) { m_ClipBox = aRect; }
125 
126  bool GetAbortRequest() const { return m_abortRequest; }
127 
128  void SetAbortRequest( bool aAbortRequest ) { m_abortRequest = aAbortRequest; }
129 
131 
132  virtual void SetEnableMousewheelPan( bool aEnable ) { m_enableMousewheelPan = aEnable; };
133 
135 
136  virtual void SetEnableZoomNoCenter( bool aEnable ) { m_enableZoomNoCenter = aEnable; };
137 
138  bool GetEnableAutoPan() const { return m_enableAutoPan; }
139 
140  virtual void SetEnableAutoPan( bool aEnable ) { m_enableAutoPan = aEnable; };
141 
142  virtual void SetAutoPanRequest( bool aEnable ) = 0;
143 
144  void SetIgnoreMouseEvents( bool aIgnore ) { m_ignoreMouseEvents = aIgnore; }
145 
146  void SetIgnoreLeftButtonReleaseEvent( bool aIgnore ) { m_ignoreNextLeftButtonRelease = aIgnore; }
147 
148  void SetEnableBlockCommands( bool aEnable ) { m_enableBlockCommands = aEnable; }
149 
150  bool GetPrintMirrored() const { return m_PrintIsMirrored; }
151  void SetPrintMirrored( bool aMirror ) { m_PrintIsMirrored = aMirror; }
152 
153  void SetCanStartBlock( int aStartBlock ) { m_canStartBlock = aStartBlock; }
154 
163  virtual void DrawBackGround( wxDC* DC ) { printf("EDA_DRAW_PANEL:Unimplemented1\n"); };
164 
173  virtual void DrawGrid( wxDC* aDC ) { printf("EDA_DRAW_PANEL:Unimplemented2\n"); };
174 
182  virtual void DrawAuxiliaryAxis( wxDC* aDC, GR_DRAWMODE aDrawMode ) { printf("EDA_DRAW_PANEL:Unimplemented2\n");};
183 
192  virtual void DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aGridOrigin ) { printf("EDA_DRAW_PANEL:Unimplemented4\n"); };
193 
204  virtual wxRect DeviceToLogical( const wxRect& aRect, wxDC& aDC ) { printf("EDA_DRAW_PANEL:Unimplemented5\n");wxASSERT(false); return wxRect(); };
205 
206  /* Mouse and keys events */
207 
218  virtual void EraseScreen( wxDC* DC ) { printf("EDA_DRAW_PANEL:Unimplemented6\n"); };;
219 
220  virtual void SetZoom( double mode ) { printf("EDA_DRAW_PANEL:Unimplemented7\n"); };;
221  virtual double GetZoom() { printf("EDA_DRAW_PANEL:Unimplemented8\n"); return 1.0; };;
222 
223  //virtual void SetGrid( const wxRealPoint& size ) { printf("EDA_DRAW_PANEL:Unimplemented\n"); };;
224  //virtual wxRealPoint GetGrid() { printf("EDA_DRAW_PANEL:Unimplemented\n"); return wxRealPoint(1.0, 1.0); };;
225 
226 
233  virtual bool IsPointOnDisplay( const wxPoint& aPosition ) { printf("EDA_DRAW_PANEL:Unimplemented9\n"); return false; };;
234 
251  virtual void SetClipBox( wxDC& aDC, const wxRect* aRect = NULL ) { printf("EDA_DRAW_PANEL:Unimplemented10\n"); };;
252 
253  virtual void ReDraw( wxDC* aDC, bool aEraseBackground = true ) { printf("EDA_DRAW_PANEL:Unimplemented11\n"); };;
254 
262  virtual void RefreshDrawingRect( const EDA_RECT& aRect, bool aEraseBackground = true ) { printf("EDA_DRAW_PANEL:Unimplemented12\n"); };;
263 
265  //virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL );
266 
271  virtual wxPoint GetScreenCenterLogicalPosition() { printf("EDA_DRAW_PANEL:Unimplemented13\n"); return wxPoint(0, 0); };;
272 
277  virtual void MoveCursorToCrossHair() { printf("EDA_DRAW_PANEL:Unimplemented14\n"); };;
278 
283  virtual wxPoint ToDeviceXY( const wxPoint& pos ) { printf("EDA_DRAW_PANEL:Unimplemented15\n"); return wxPoint(0, 0); };;
284 
289  virtual wxPoint ToLogicalXY( const wxPoint& pos ) { printf("EDA_DRAW_PANEL:Unimplemented16\n"); return wxPoint(0, 0); };;
290 
296  virtual void MoveCursor( const wxPoint& aPosition ) { printf("EDA_DRAW_PANEL:Unimplemented17\n"); };;
297 
298  /* Cursor functions */
311  virtual void DrawCrossHair( wxDC* aDC=nullptr, COLOR4D aColor = COLOR4D::WHITE ) { printf("EDA_DRAW_PANEL:Unimplemented18\n"); };;
312 
313  // Hide the cross hair.
314  virtual void CrossHairOff( wxDC* DC=nullptr ) { printf("EDA_DRAW_PANEL:Unimplemented19\n"); };;
315 
316  // Show the cross hair.
317  virtual void CrossHairOn( wxDC* DC=nullptr ) { printf("EDA_DRAW_PANEL:Unimplemented20\n"); };;
318 
324  virtual void SetMouseCapture( MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback,
325  END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback )
326  {
327  m_mouseCaptureCallback = aMouseCaptureCallback;
328  m_endMouseCaptureCallback = aEndMouseCaptureCallback;
329  }
330 
331 
332  virtual void SetMouseCaptureCallback( MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback )
333  {
334  m_mouseCaptureCallback = aMouseCaptureCallback;
335  }
336 
337 
350  virtual void EndMouseCapture( int aId = -1, int aCursorId = -1,
351  const wxString& aTitle = wxEmptyString,
352  bool aCallEndFunc = true ) { printf("EDA_DRAW_PANEL:Unimplemented21\n"); wxASSERT(false); };;
353 
354  inline bool IsMouseCaptured() const { return m_mouseCaptureCallback != NULL; }
355 
366  virtual void CallMouseCapture( wxDC* aDC, const wxPoint& aPosition, bool aErase ) { printf("EDA_DRAW_PANEL:Unimplemented22\n"); wxASSERT(false); };;
367 
374  virtual void CallEndMouseCapture( wxDC* aDC ) { printf("EDA_DRAW_PANEL:Unimplemented23\n"); wxASSERT(false); };;
375 
376  virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL ) {}
377 
378  virtual wxWindow* GetWindow() = 0;
379 };
380 
381 #endif
virtual BASE_SCREEN * GetScreen()=0
bool m_abortRequest
Flag used to abort long commands.
int m_canStartBlock
useful to avoid false start block in certain cases (like switch from a sheet to another sheet >= 0 (o...
virtual wxPoint GetScreenCenterLogicalPosition()
Update the board display after modifying it by a python script (note: it is automatically called by a...
void(* MOUSE_CAPTURE_CALLBACK)(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
virtual void SetClipBox(wxDC &aDC, const wxRect *aRect=NULL)
Function SetClipBox sets the clip box in drawing (logical) units from aRect in device units...
virtual wxPoint ToDeviceXY(const wxPoint &pos)
Function ToDeviceXY transforms logical to device coordinates.
virtual void SetEnableZoomNoCenter(bool aEnable)
bool m_enableZoomNoCenter
True to enable zooming around the crosshair instead of the center.
int m_scrollIncrementX
X axis scroll increment in pixels per unit.
EDA_RECT m_ClipBox
The drawing area used to redraw the screen which is usually the visible area of the drawing in intern...
bool m_PrintIsMirrored
True when drawing in mirror mode.
virtual void DrawGrid(wxDC *aDC)
Function DrawGrid draws a grid to aDC.
END_MOUSE_CAPTURE_CALLBACK m_endMouseCaptureCallback
Abort mouse capture callback function.
virtual void EndMouseCapture(int aId=-1, int aCursorId=-1, const wxString &aTitle=wxEmptyString, bool aCallEndFunc=true)
Function EndMouseCapture ends mouse a capture.
void SetCanStartBlock(int aStartBlock)
virtual void RefreshDrawingRect(const EDA_RECT &aRect, bool aEraseBackground=true)
Function RefreshDrawingRect redraws the contents of aRect in drawing units.
wxPoint m_PanStartEventPosition
Initial position of mouse event when pan started.
virtual EDA_RECT * GetClipBox()
virtual void SetAutoPanRequest(bool aEnable)=0
virtual void MoveCursor(const wxPoint &aPosition)
Function MoveCursor moves the mouse pointer to aPosition in logical (drawing) units.
The base class for create windows for drawing purpose.
Definition: draw_frame.h:78
virtual void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
bool m_enableBlockCommands
True enables block commands.
virtual void CallEndMouseCapture(wxDC *aDC)
Function CallEndMouseCapture calls the end mouse capture callback.
void SetClipBox(const EDA_RECT &aRect)
MOUSE_CAPTURE_CALLBACK m_mouseCaptureCallback
Mouse capture move callback function.
virtual void DrawGridAxis(wxDC *aDC, GR_DRAWMODE aDrawMode, const wxPoint &aGridOrigin)
Function DrawGridAxis Draw on auxiliary axis, used in Pcbnew to show grid origin, when the grid origi...
virtual EDA_DRAW_FRAME * GetParent() const =0
virtual wxPoint ToLogicalXY(const wxPoint &pos)
Function ToLogicalXY transforms device to logical coordinates.
virtual bool IsPointOnDisplay(const wxPoint &aPosition)
Function IsPointOnDisplay.
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
virtual void CrossHairOn(wxDC *DC=nullptr)
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
virtual void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
bool GetEnableZoomNoCenter() const
bool m_ignoreMouseEvents
Ignore mouse events when true.
virtual void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
virtual void SetZoom(double mode)
virtual wxRect DeviceToLogical(const wxRect &aRect, wxDC &aDC)
Function DeviceToLogical converts aRect from device to drawing (logical) coordinates.
virtual void DrawCrossHair(wxDC *aDC=nullptr, COLOR4D aColor=COLOR4D::WHITE)
Function DrawCrossHair draws the user cross hair.
virtual void CrossHairOff(wxDC *DC=nullptr)
virtual wxWindow * GetWindow()=0
bool m_ignoreNextLeftButtonRelease
Ignore the next mouse left button release when true.
void SetAbortRequest(bool aAbortRequest)
void(* END_MOUSE_CAPTURE_CALLBACK)(EDA_DRAW_PANEL *aPanel, wxDC *aDC)
End mouse capture callback function prototype.
wxPoint m_PanStartCenter
Initial scroll center position when pan started.
bool m_showCrossHair
Indicate if cross hair is to be shown.
virtual void ReDraw(wxDC *aDC, bool aEraseBackground=true)
bool GetEnableMousewheelPan() const
bool m_enableMousewheelPan
True to enable mousewheel panning by default.
void SetIgnoreMouseEvents(bool aIgnore)
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
virtual void SetEnableMousewheelPan(bool aEnable)
Definition: colors.h:49
void SetPrintMirrored(bool aMirror)
void SetEnableBlockCommands(bool aEnable)
virtual void DrawAuxiliaryAxis(wxDC *aDC, GR_DRAWMODE aDrawMode)
Function DrawAuxiliaryAxis Draw the Auxiliary Axis, used in Pcbnew which as origin coordinates for ge...
int m_minDragEventCount
Count the drag events.
wxPoint m_CursorStartPos
Used for testing the cursor movement.
virtual void DrawBackGround(wxDC *DC)
Function DrawBackGround.
bool m_enableAutoPan
True to enable automatic panning.
virtual void * GetDisplayOptions()
Function GetDisplayOptions A way to pass info to draw functions.
Basic classes for most KiCad items.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)
virtual void EraseScreen(wxDC *DC)
Function OnMouseWheel handles mouse wheel events.
virtual void SetEnableAutoPan(bool aEnable)
int m_cursorLevel
Index for cursor redraw in XOR mode.
virtual void SetMouseCaptureCallback(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback)
int m_scrollIncrementY
Y axis scroll increment in pixels per unit.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void SetIgnoreLeftButtonReleaseEvent(bool aIgnore)