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 
37 
41 
43 
46 
48 
50 
52 
53  /* Used to inhibit a response to a mouse left button release, after a double click
54  * (when releasing the left button at the end of the second click. Used in Eeschema
55  * to inhibit a mouse left release command when switching between hierarchical sheets
56  * on a double click.
57  */
59 
61 
69 
73 
76 
79 
84 
86 
87 public:
88 
90  virtual ~EDA_DRAW_PANEL(){};
91 
97  virtual void* GetDisplayOptions() { printf("EDA_DRAW_PANEL:Unimplemented\n"); wxASSERT(false); return nullptr; };
98 
99  virtual BASE_SCREEN* GetScreen() = 0;
100 
101  virtual EDA_DRAW_FRAME* GetParent() const = 0;
102 
103  //virtual void OnPaint( wxPaintEvent& event );
104 
105  virtual EDA_RECT* GetClipBox() { return &m_ClipBox; }
106 
107  void SetClipBox( const EDA_RECT& aRect ) { m_ClipBox = aRect; }
108 
109  bool GetAbortRequest() const { return m_abortRequest; }
110 
111  void SetAbortRequest( bool aAbortRequest ) { m_abortRequest = aAbortRequest; }
112 
114 
115  virtual void SetEnableMousewheelPan( bool aEnable ) { m_enableMousewheelPan = aEnable; };
116 
118 
119  virtual void SetEnableZoomNoCenter( bool aEnable ) { m_enableZoomNoCenter = aEnable; };
120 
121  bool GetEnableAutoPan() const { return m_enableAutoPan; }
122 
123  virtual void SetEnableAutoPan( bool aEnable ) { m_enableAutoPan = aEnable; };
124 
125  void SetAutoPanRequest( bool aEnable ) { m_requestAutoPan = aEnable; }
126 
127  void SetIgnoreMouseEvents( bool aIgnore ) { m_ignoreMouseEvents = aIgnore; }
128 
129  void SetIgnoreLeftButtonReleaseEvent( bool aIgnore ) { m_ignoreNextLeftButtonRelease = aIgnore; }
130 
131  void SetEnableBlockCommands( bool aEnable ) { m_enableBlockCommands = aEnable; }
132 
133  bool GetPrintMirrored() const { return m_PrintIsMirrored; }
134  void SetPrintMirrored( bool aMirror ) { m_PrintIsMirrored = aMirror; }
135 
136  void SetCanStartBlock( int aStartBlock ) { m_canStartBlock = aStartBlock; }
137 
146  virtual void DrawBackGround( wxDC* DC ) { printf("EDA_DRAW_PANEL:Unimplemented1\n"); };
147 
156  virtual void DrawGrid( wxDC* aDC ) { printf("EDA_DRAW_PANEL:Unimplemented2\n"); };
157 
165  virtual void DrawAuxiliaryAxis( wxDC* aDC, GR_DRAWMODE aDrawMode ) { printf("EDA_DRAW_PANEL:Unimplemented2\n");};
166 
175  virtual void DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aGridOrigin ) { printf("EDA_DRAW_PANEL:Unimplemented4\n"); };
176 
187  virtual wxRect DeviceToLogical( const wxRect& aRect, wxDC& aDC ) { printf("EDA_DRAW_PANEL:Unimplemented5\n");wxASSERT(false); return wxRect(); };
188 
189  /* Mouse and keys events */
190 
201  virtual void EraseScreen( wxDC* DC ) { printf("EDA_DRAW_PANEL:Unimplemented6\n"); };;
202 
203  virtual void SetZoom( double mode ) { printf("EDA_DRAW_PANEL:Unimplemented7\n"); };;
204  virtual double GetZoom() { printf("EDA_DRAW_PANEL:Unimplemented8\n"); return 1.0; };;
205 
206  //virtual void SetGrid( const wxRealPoint& size ) { printf("EDA_DRAW_PANEL:Unimplemented\n"); };;
207  //virtual wxRealPoint GetGrid() { printf("EDA_DRAW_PANEL:Unimplemented\n"); return wxRealPoint(1.0, 1.0); };;
208 
209 
216  virtual bool IsPointOnDisplay( const wxPoint& aPosition ) { printf("EDA_DRAW_PANEL:Unimplemented9\n"); return false; };;
217 
234  virtual void SetClipBox( wxDC& aDC, const wxRect* aRect = NULL ) { printf("EDA_DRAW_PANEL:Unimplemented10\n"); };;
235 
236  virtual void ReDraw( wxDC* aDC, bool aEraseBackground = true ) { printf("EDA_DRAW_PANEL:Unimplemented11\n"); };;
237 
245  virtual void RefreshDrawingRect( const EDA_RECT& aRect, bool aEraseBackground = true ) { printf("EDA_DRAW_PANEL:Unimplemented12\n"); };;
246 
248  //virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL );
249 
254  virtual wxPoint GetScreenCenterLogicalPosition() { printf("EDA_DRAW_PANEL:Unimplemented13\n"); return wxPoint(0, 0); };;
255 
260  virtual void MoveCursorToCrossHair() { printf("EDA_DRAW_PANEL:Unimplemented14\n"); };;
261 
266  virtual wxPoint ToDeviceXY( const wxPoint& pos ) { printf("EDA_DRAW_PANEL:Unimplemented15\n"); return wxPoint(0, 0); };;
267 
272  virtual wxPoint ToLogicalXY( const wxPoint& pos ) { printf("EDA_DRAW_PANEL:Unimplemented16\n"); return wxPoint(0, 0); };;
273 
279  virtual void MoveCursor( const wxPoint& aPosition ) { printf("EDA_DRAW_PANEL:Unimplemented17\n"); };;
280 
281  /* Cursor functions */
294  virtual void DrawCrossHair( wxDC* aDC=nullptr, COLOR4D aColor = COLOR4D::WHITE ) { printf("EDA_DRAW_PANEL:Unimplemented18\n"); };;
295 
296  // Hide the cross hair.
297  virtual void CrossHairOff( wxDC* DC=nullptr ) { printf("EDA_DRAW_PANEL:Unimplemented19\n"); };;
298 
299  // Show the cross hair.
300  virtual void CrossHairOn( wxDC* DC=nullptr ) { printf("EDA_DRAW_PANEL:Unimplemented20\n"); };;
301 
307  virtual void SetMouseCapture( MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback,
308  END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback )
309  {
310  m_mouseCaptureCallback = aMouseCaptureCallback;
311  m_endMouseCaptureCallback = aEndMouseCaptureCallback;
312  }
313 
314 
315  virtual void SetMouseCaptureCallback( MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback )
316  {
317  m_mouseCaptureCallback = aMouseCaptureCallback;
318  }
319 
320 
333  virtual void EndMouseCapture( int aId = -1, int aCursorId = -1,
334  const wxString& aTitle = wxEmptyString,
335  bool aCallEndFunc = true ) { printf("EDA_DRAW_PANEL:Unimplemented21\n"); wxASSERT(false); };;
336 
337  inline bool IsMouseCaptured() const { return m_mouseCaptureCallback != NULL; }
338 
349  virtual void CallMouseCapture( wxDC* aDC, const wxPoint& aPosition, bool aErase ) { printf("EDA_DRAW_PANEL:Unimplemented22\n"); wxASSERT(false); };;
350 
357  virtual void CallEndMouseCapture( wxDC* aDC ) { printf("EDA_DRAW_PANEL:Unimplemented23\n"); wxASSERT(false); };;
358 
359  virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL ) {}
360 
361  virtual wxWindow* GetWindow() = 0;
362 };
363 
364 #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.
bool m_requestAutoPan
true to request an auto pan. Valid only when m_enableAutoPan = true.
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 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)
void SetAutoPanRequest(bool aEnable)
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)