KiCad PCB EDA Suite
EDA_DRAW_PANEL Class Reference

#include <class_drawpanel.h>

Inheritance diagram for EDA_DRAW_PANEL:

Public Member Functions

 EDA_DRAW_PANEL (EDA_DRAW_FRAME *parent, int id, const wxPoint &pos, const wxSize &size)
 
 ~EDA_DRAW_PANEL ()
 
void * GetDisplayOptions ()
 Function GetDisplayOptions A way to pass info to draw functions. More...
 
BASE_SCREENGetScreen ()
 
EDA_DRAW_FRAMEGetParent () const
 
void OnPaint (wxPaintEvent &event)
 
EDA_RECTGetClipBox ()
 
void SetClipBox (const EDA_RECT &aRect)
 
bool GetAbortRequest () const
 
void SetAbortRequest (bool aAbortRequest)
 
bool GetEnableMousewheelPan () const
 
void SetEnableMousewheelPan (bool aEnable)
 
bool GetEnableZoomNoCenter () const
 
void SetEnableZoomNoCenter (bool aEnable)
 
bool GetEnableAutoPan () const
 
void SetEnableAutoPan (bool aEnable)
 
void SetAutoPanRequest (bool aEnable)
 
void SetIgnoreMouseEvents (bool aIgnore)
 
void SetIgnoreLeftButtonReleaseEvent (bool aIgnore)
 
void SetEnableBlockCommands (bool aEnable)
 
bool GetPrintMirrored () const
 
void SetPrintMirrored (bool aMirror)
 
void SetCanStartBlock (int aStartBlock)
 
void DrawBackGround (wxDC *DC)
 Function DrawBackGround. More...
 
void DrawGrid (wxDC *aDC)
 Function DrawGrid draws a grid to aDC. More...
 
void DrawAuxiliaryAxis (wxDC *aDC, GR_DRAWMODE aDrawMode)
 Function DrawAuxiliaryAxis Draw the Auxiliary Axis, used in Pcbnew which as origin coordinates for gerber and excellon files. More...
 
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 origin is set by user, and is not (0,0) More...
 
void OnEraseBackground (wxEraseEvent &event)
 
void OnActivate (wxActivateEvent &event)
 Function OnActivate handles window activation events. More...
 
void OnTimer (wxTimerEvent &event)
 Function OnTimer handle timer events. More...
 
virtual void DoPrepareDC (wxDC &aDC) override
 Function DoPrepareDC sets up the device context aDC for drawing. More...
 
wxRect DeviceToLogical (const wxRect &aRect, wxDC &aDC)
 Function DeviceToLogical converts aRect from device to drawing (logical) coordinates. More...
 
void OnMouseWheel (wxMouseEvent &event)
 Function OnMouseWheel handles mouse wheel events. More...
 
void OnMouseEvent (wxMouseEvent &event)
 
void OnMouseEntering (wxMouseEvent &aEvent)
 
void OnMouseLeaving (wxMouseEvent &event)
 
void OnKeyEvent (wxKeyEvent &event)
 
void OnCharHook (wxKeyEvent &event)
 
void OnPan (wxCommandEvent &event)
 
void EraseScreen (wxDC *DC)
 
void OnScrollWin (wxCommandEvent &event)
 
void OnScroll (wxScrollWinEvent &event)
 
void SetZoom (double mode)
 
double GetZoom ()
 
void SetGrid (const wxRealPoint &size)
 
wxRealPoint GetGrid ()
 
bool OnRightClick (wxMouseEvent &event)
 Function OnRightClick builds and displays a context menu on a right mouse button click. More...
 
bool IsPointOnDisplay (const wxPoint &aPosition)
 Function IsPointOnDisplay. More...
 
void SetClipBox (wxDC &aDC, const wxRect *aRect=NULL)
 Function SetClipBox sets the clip box in drawing (logical) units from aRect in device units. More...
 
void ReDraw (wxDC *aDC, bool aEraseBackground=true)
 
void RefreshDrawingRect (const EDA_RECT &aRect, bool aEraseBackground=true)
 Function RefreshDrawingRect redraws the contents of aRect in drawing units. More...
 
virtual void Refresh (bool eraseBackground=true, const wxRect *rect=NULL) override
 Update the board display after modifying it bu a python script (note: it is automatically called by action plugins, after running the plugin, so call this function is usually not needed inside action plugins. More...
 
wxPoint GetScreenCenterLogicalPosition ()
 Function GetScreenCenterLogicalPosition. More...
 
void MoveCursorToCrossHair ()
 Function MoveCursorToCrossHair warps the cursor to the current cross hair position. More...
 
wxPoint ToDeviceXY (const wxPoint &pos)
 Function ToDeviceXY transforms logical to device coordinates. More...
 
wxPoint ToLogicalXY (const wxPoint &pos)
 Function ToLogicalXY transforms device to logical coordinates. More...
 
void MoveCursor (const wxPoint &aPosition)
 Function MoveCursor moves the mouse pointer to aPosition in logical (drawing) units. More...
 
void DrawCrossHair (wxDC *aDC, COLOR4D aColor=COLOR4D::WHITE)
 Function DrawCrossHair draws the user cross hair. More...
 
void CrossHairOff (wxDC *DC)
 
void CrossHairOn (wxDC *DC)
 
void SetMouseCapture (MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
 Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallback and aEndMouseCaptureCallback respectively. More...
 
void SetMouseCaptureCallback (MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback)
 
void EndMouseCapture (int aId=-1, int aCursorId=-1, const wxString &aTitle=wxEmptyString, bool aCallEndFunc=true)
 Function EndMouseCapture ends mouse a capture. More...
 
bool IsMouseCaptured () const
 
void CallMouseCapture (wxDC *aDC, const wxPoint &aPosition, bool aErase)
 Function CallMouseCapture calls the mouse capture callback. More...
 
void CallEndMouseCapture (wxDC *aDC)
 Function CallEndMouseCapture calls the end mouse capture callback. More...
 
void SetCurrentCursor (int aCursor)
 Function SetCurrentCursor Set the current cursor shape for drawpanel. More...
 
int GetDefaultCursor () const
 Function GetDefaultCursor. More...
 
int GetCurrentCursor () const
 Function GetCurrentCursor. More...
 

Private Attributes

int m_currentCursor
 Current mouse cursor shape id. More...
 
int m_defaultCursor
 The default mouse cursor shape id. More...
 
bool m_showCrossHair
 Indicate if cross hair is to be shown. More...
 
int m_cursorLevel
 Index for cursor redraw in XOR mode. More...
 
int m_scrollIncrementX
 X axis scroll increment in pixels per unit. More...
 
int m_scrollIncrementY
 Y axis scroll increment in pixels per unit. More...
 
wxPoint m_CursorStartPos
 Used for testing the cursor movement. More...
 
wxPoint m_PanStartCenter
 Initial scroll center position when pan started. More...
 
wxPoint m_PanStartEventPosition
 Initial position of mouse event when pan started. More...
 
wxPoint m_CursorClickPos
 Used for maintaining click position. More...
 
wxTimer * m_ClickTimer
 
EDA_RECT m_ClipBox
 The drawing area used to redraw the screen which is usually the visible area of the drawing in internal units. More...
 
bool m_abortRequest
 Flag used to abort long commands. More...
 
bool m_enableZoomNoCenter
 True to enable zooming around the crosshair instead of the center. More...
 
bool m_enableMousewheelPan
 True to enable mousewheel panning by default. More...
 
bool m_enableAutoPan
 True to enable automatic panning. More...
 
bool m_requestAutoPan
 true to request an auto pan. Valid only when m_enableAutoPan = true. More...
 
bool m_ignoreMouseEvents
 Ignore mouse events when true. More...
 
bool m_ignoreNextLeftButtonRelease
 Ignore the next mouse left button release when true. More...
 
bool m_enableBlockCommands
 True enables block commands. More...
 
int m_minDragEventCount
 Count the drag events. More...
 
bool m_PrintIsMirrored
 True when drawing in mirror mode. More...
 
MOUSE_CAPTURE_CALLBACK m_mouseCaptureCallback
 Mouse capture move callback function. More...
 
END_MOUSE_CAPTURE_CALLBACK m_endMouseCaptureCallback
 Abort mouse capture callback function. More...
 
int m_canStartBlock
 useful to avoid false start block in certain cases (like switch from a sheet to another sheet >= 0 (or >= n) if a block can start More...
 
int m_doubleClickInterval
 

Detailed Description

Definition at line 55 of file class_drawpanel.h.

Constructor & Destructor Documentation

EDA_DRAW_PANEL::EDA_DRAW_PANEL ( EDA_DRAW_FRAME parent,
int  id,
const wxPoint pos,
const wxSize &  size 
)

Definition at line 99 of file draw_panel.cpp.

References ENBL_AUTO_PAN_KEY, ENBL_MOUSEWHEEL_PAN_KEY, ENBL_ZOOM_NO_CENTER_KEY, EDA_DRAW_FRAME::GetDrawBgColor(), Kiface(), KIFACE_I::KifaceSettings(), m_abortRequest, m_canStartBlock, m_ClickTimer, m_ClipBox, m_currentCursor, m_cursorLevel, m_defaultCursor, m_doubleClickInterval, m_enableAutoPan, m_enableBlockCommands, m_enableMousewheelPan, m_enableZoomNoCenter, m_endMouseCaptureCallback, m_ignoreMouseEvents, m_ignoreNextLeftButtonRelease, m_minDragEventCount, m_mouseCaptureCallback, m_PrintIsMirrored, m_requestAutoPan, m_scrollIncrementX, m_scrollIncrementY, m_showCrossHair, min, EDA_RECT::SetSize(), EDA_RECT::SetX(), and EDA_RECT::SetY().

100  :
101  wxScrolledWindow( parent, id, pos, size, drawPanelStyle )
102 {
103  wxASSERT( parent );
104 
105  ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS );
106  DisableKeyboardScrolling();
107 
108  m_scrollIncrementX = std::min( size.x / 8, 10 );
109  m_scrollIncrementY = std::min( size.y / 8, 10 );
110 
111  SetLayoutDirection( wxLayout_LeftToRight );
112 
113  SetBackgroundColour( parent->GetDrawBgColor().ToColour() );
114 
115 #if KICAD_USE_BUFFERED_DC || KICAD_USE_BUFFERED_PAINTDC
116  SetBackgroundStyle( wxBG_STYLE_CUSTOM );
117 #endif
118 
119  m_ClipBox.SetSize( size );
120  m_ClipBox.SetX( 0 );
121  m_ClipBox.SetY( 0 );
122  m_canStartBlock = -1; // Command block can start if >= 0
123  m_abortRequest = false;
124  m_enableMousewheelPan = false;
125  m_enableZoomNoCenter = false;
126  m_enableAutoPan = true;
127  m_ignoreMouseEvents = false;
128  // Be sure a mouse release button event will be ignored when creating the canvas
129  // if the mouse click was not made inside the canvas (can happen sometimes, when
130  // launching a editor from a double click made in another frame)
132 
133  m_mouseCaptureCallback = NULL;
135 
136  wxConfigBase* cfg = Kiface().KifaceSettings();
137 
138  if( cfg )
139  {
140  cfg->Read( ENBL_MOUSEWHEEL_PAN_KEY, &m_enableMousewheelPan, false );
141  cfg->Read( ENBL_ZOOM_NO_CENTER_KEY, &m_enableZoomNoCenter, false );
142  cfg->Read( ENBL_AUTO_PAN_KEY, &m_enableAutoPan, true );
143  }
144 
145  m_requestAutoPan = false;
146  m_enableBlockCommands = false;
148 
149 #ifdef __WXMAC__
150  m_defaultCursor = m_currentCursor = wxCURSOR_CROSS;
151  m_showCrossHair = false;
152 #else
153  m_defaultCursor = m_currentCursor = wxCURSOR_ARROW;
154  m_showCrossHair = true;
155 #endif
156 
157  m_cursorLevel = 0;
158  m_PrintIsMirrored = false;
159 
160  m_ClickTimer = (wxTimer*) NULL;
161  m_doubleClickInterval = 250;
162 }
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...
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.
END_MOUSE_CAPTURE_CALLBACK m_endMouseCaptureCallback
Abort mouse capture callback function.
bool m_enableBlockCommands
True enables block commands.
const int drawPanelStyle
Definition: draw_panel.cpp:96
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
#define ENBL_ZOOM_NO_CENTER_KEY
Definition: draw_panel.cpp:55
MOUSE_CAPTURE_CALLBACK m_mouseCaptureCallback
Mouse capture move callback function.
#define ENBL_AUTO_PAN_KEY
Definition: draw_panel.cpp:59
virtual COLOR4D GetDrawBgColor() const
Definition: draw_frame.h:346
bool m_ignoreMouseEvents
Ignore mouse events when true.
#define ENBL_MOUSEWHEEL_PAN_KEY
Definition: draw_panel.cpp:56
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
void SetX(int val)
Definition: eda_rect.h:130
bool m_ignoreNextLeftButtonRelease
Ignore the next mouse left button release when true.
void SetY(int val)
Definition: eda_rect.h:131
bool m_showCrossHair
Indicate if cross hair is to be shown.
void SetSize(const wxSize &size)
Definition: eda_rect.h:126
bool m_enableMousewheelPan
True to enable mousewheel panning by default.
int m_currentCursor
Current mouse cursor shape id.
int m_defaultCursor
The default mouse cursor shape id.
wxTimer * m_ClickTimer
int m_minDragEventCount
Count the drag events.
bool m_enableAutoPan
True to enable automatic panning.
int m_cursorLevel
Index for cursor redraw in XOR mode.
int m_scrollIncrementY
Y axis scroll increment in pixels per unit.
#define min(a, b)
Definition: auxiliary.h:85
EDA_DRAW_PANEL::~EDA_DRAW_PANEL ( )

Definition at line 165 of file draw_panel.cpp.

References ENBL_AUTO_PAN_KEY, ENBL_MOUSEWHEEL_PAN_KEY, ENBL_ZOOM_NO_CENTER_KEY, Kiface(), KIFACE_I::KifaceSettings(), m_ClickTimer, m_enableAutoPan, m_enableMousewheelPan, and m_enableZoomNoCenter.

166 {
167  wxConfigBase* cfg = Kiface().KifaceSettings();
168 
169  if( cfg )
170  {
173  cfg->Write( ENBL_AUTO_PAN_KEY, m_enableAutoPan );
174  }
175 
176  wxDELETE( m_ClickTimer );
177 }
bool m_enableZoomNoCenter
True to enable zooming around the crosshair instead of the center.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
#define ENBL_ZOOM_NO_CENTER_KEY
Definition: draw_panel.cpp:55
#define ENBL_AUTO_PAN_KEY
Definition: draw_panel.cpp:59
#define ENBL_MOUSEWHEEL_PAN_KEY
Definition: draw_panel.cpp:56
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
bool m_enableMousewheelPan
True to enable mousewheel panning by default.
wxTimer * m_ClickTimer
bool m_enableAutoPan
True to enable automatic panning.

Member Function Documentation

void EDA_DRAW_PANEL::CallEndMouseCapture ( wxDC *  aDC)

Function CallEndMouseCapture calls the end mouse capture callback.

Parameters
aDCA point to a wxDC object to perform any drawing upon.

Definition at line 1571 of file draw_panel.cpp.

References m_endMouseCaptureCallback.

Referenced by LIB_EDIT_FRAME::deleteItem(), LIB_EDIT_FRAME::HandleBlockEnd(), SCH_EDIT_FRAME::HandleBlockEnd(), IsMouseCaptured(), PCB_EDIT_FRAME::OnPlaceOrRouteFootprints(), and PCB_EDIT_FRAME::Process_Special_Functions().

1572 {
1573  wxCHECK_RET( aDC != NULL, wxT( "Invalid device context." ) );
1574 
1575  // CallEndMouseCapture is sometimes called with m_endMouseCaptureCallback == NULL
1576  // for instance after an ABORT in block paste.
1578  m_endMouseCaptureCallback( this, aDC );
1579 }
END_MOUSE_CAPTURE_CALLBACK m_endMouseCaptureCallback
Abort mouse capture callback function.
void EDA_DRAW_PANEL::CallMouseCapture ( wxDC *  aDC,
const wxPoint aPosition,
bool  aErase 
)

Function CallMouseCapture calls the mouse capture callback.

Parameters
aDCA point to a wxDC object to perform any drawing upon.
aPositionA referecnce to a wxPoint object containing the current cursor position.
aEraseTrue indicates the item being drawn should be erase before drawing it a aPosition.

Definition at line 1562 of file draw_panel.cpp.

References m_mouseCaptureCallback.

Referenced by Abort_EditEdge(), AbortBlockCurrentCommand(), PCB_EDIT_FRAME::Begin_Route(), PCB_EDIT_FRAME::Begin_Self(), PCB_EDIT_FRAME::Begin_Zone(), SCH_EDIT_FRAME::BeginSegment(), LIB_EDIT_FRAME::CreateGraphicItem(), SCH_EDIT_FRAME::CreateSheet(), PCB_EDIT_FRAME::Delete_LastCreatedCorner(), PCB_EDIT_FRAME::Delete_Segment(), Exit_Self(), EDA_DRAW_FRAME::HandleBlockBegin(), PL_EDITOR_FRAME::HandleBlockEnd(), FOOTPRINT_EDIT_FRAME::HandleBlockEnd(), GERBVIEW_FRAME::HandleBlockEnd(), LIB_EDIT_FRAME::HandleBlockEnd(), PCB_EDIT_FRAME::HandleBlockEnd(), SCH_EDIT_FRAME::HandleBlockEnd(), PL_EDITOR_FRAME::HandleBlockPlace(), GERBVIEW_FRAME::HandleBlockPlace(), PCB_EDIT_FRAME::HandleBlockPlace(), SCH_EDIT_FRAME::HandleBlockPlace(), IsMouseCaptured(), PCB_EDIT_FRAME::OnHotKey(), PCB_EDIT_FRAME::Other_Layer_Route(), PCB_EDIT_FRAME::Process_Special_Functions(), FOOTPRINT_EDIT_FRAME::RedrawActiveWindow(), PL_EDITOR_FRAME::RedrawActiveWindow(), GERBVIEW_FRAME::RedrawActiveWindow(), SCH_EDIT_FRAME::RedrawActiveWindow(), LIB_EDIT_FRAME::RedrawActiveWindow(), PCB_EDIT_FRAME::RedrawActiveWindow(), EDA_DRAW_FRAME::RefreshCrossHair(), SCH_EDIT_FRAME::ReSizeSheet(), PCB_EDIT_FRAME::Start_Move_DrawItem(), FOOTPRINT_EDIT_FRAME::Start_Move_EdgeMod(), LIB_EDIT_FRAME::StartModifyDrawSymbol(), LIB_EDIT_FRAME::StartMoveDrawSymbol(), PCB_EDIT_FRAME::StartMoveModule(), PCB_EDIT_FRAME::StartMoveOneNodeOrSegment(), PCB_BASE_FRAME::StartMoveTexteModule(), and PCB_EDIT_FRAME::StartMoveTextePcb().

1563 {
1564  wxCHECK_RET( aDC != NULL, wxT( "Invalid device context." ) );
1565  wxCHECK_RET( m_mouseCaptureCallback != NULL, wxT( "Mouse capture callback not set." ) );
1566 
1567  m_mouseCaptureCallback( this, aDC, aPosition, aErase );
1568 }
MOUSE_CAPTURE_CALLBACK m_mouseCaptureCallback
Mouse capture move callback function.
wxRect EDA_DRAW_PANEL::DeviceToLogical ( const wxRect &  aRect,
wxDC &  aDC 
)

Function DeviceToLogical converts aRect from device to drawing (logical) coordinates.

aRect must be in scrolled device units.

Parameters
aRectThe rectangle to convert.
aDCThe device context used for the conversion.
Returns
A rectangle converted to drawing units.

Referenced by OnEraseBackground().

void EDA_DRAW_PANEL::DoPrepareDC ( wxDC &  aDC)
overridevirtual

Function DoPrepareDC sets up the device context aDC for drawing.

This overrides wxScrolledWindow::DoPrepareDC() for setting up the the device context used for drawing. The scale factor and drawing logical offset are set and the base method is called to set the DC device origin (scroll bar position). This connects everything together to achieve the appropriate coordinate manipulation using wxDC LogicalToDeviceXXX and DeviceToLogixalXXX methods. This gets called automatically for a paint event. If you do any drawing outside the paint event, you must call DoPrepareDC manually.

Parameters
aDCThe device context to prepare.

Definition at line 593 of file draw_panel.cpp.

References BASE_SCREEN::GetScalingFactor(), GetScreen(), GRResetPenAndBrush(), BASE_SCREEN::m_DrawOrg, scale, SetClipBox(), wxPoint::x, and wxPoint::y.

Referenced by GBR_LAYOUT::Draw(), and OnEraseBackground().

594 {
595  wxScrolledWindow::DoPrepareDC( dc );
596 
597  if( GetScreen() != NULL )
598  {
599  double scale = GetScreen()->GetScalingFactor();
600  dc.SetUserScale( scale, scale );
601 
602  wxPoint pt = GetScreen()->m_DrawOrg;
603  dc.SetLogicalOrigin( pt.x, pt.y );
604  }
605 
606  SetClipBox( dc ); // Reset the clip box to the entire screen.
607  GRResetPenAndBrush( &dc );
608  dc.SetBackgroundMode( wxTRANSPARENT );
609 }
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:218
double GetScalingFactor() const
Function GetScalingFactor returns the inverse of the current scale used to draw items on screen...
Definition: base_screen.cpp:92
void SetClipBox(const EDA_RECT &aRect)
const int scale
wxPoint m_DrawOrg
offsets for drawing the circuit on the screen
Definition: base_screen.h:183
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:193
void EDA_DRAW_PANEL::DrawAuxiliaryAxis ( wxDC *  aDC,
GR_DRAWMODE  aDrawMode 
)

Function DrawAuxiliaryAxis Draw the Auxiliary Axis, used in Pcbnew which as origin coordinates for gerber and excellon files.

Parameters
aDC= current Device Context
aDrawMode= draw mode (GR_COPY, GR_OR ..)

Definition at line 825 of file draw_panel.cpp.

References AXIS_SIZE_IN_PIXELS, color, EDA_DRAW_FRAME::GetAuxOrigin(), EDA_DRAW_FRAME::GetPageSizeIU(), GetParent(), GRCircle(), GRLine(), GRSetColorPen(), GRSetDrawMode(), m_ClipBox, RED, wxPoint::x, and wxPoint::y.

Referenced by DrawBackGround(), and SetCanStartBlock().

826 {
827  wxPoint origin = GetParent()->GetAuxOrigin();
828 
829  if( origin == wxPoint( 0, 0 ) )
830  return;
831 
832  COLOR4D color = COLOR4D( RED );
833 
834  GRSetDrawMode( aDC, aDrawMode );
835 
836 #if DRAW_AXIS_AS_LINES
837  wxSize pageSize = GetParent()->GetPageSizeIU();
838  // Draw the Y axis
839  GRLine( &m_ClipBox, aDC, origin.x, -pageSize.y,
840  origin.x, pageSize.y, 0, color );
841 
842  // Draw the X axis
843  GRLine( &m_ClipBox, aDC, -pageSize.x, origin.y,
844  pageSize.x, origin.y, 0, color );
845 #else
846  int radius = aDC->DeviceToLogicalXRel( AXIS_SIZE_IN_PIXELS );
847  int linewidth = aDC->DeviceToLogicalXRel( 1 );
848 
849  GRSetColorPen( aDC, color, linewidth );
850 
851  GRLine( &m_ClipBox, aDC, origin.x, origin.y-radius,
852  origin.x, origin.y+radius, 0, color );
853 
854  // Draw the + shape
855  GRLine( &m_ClipBox, aDC, origin.x-radius, origin.y,
856  origin.x+radius, origin.y, 0, color );
857 
858  GRCircle( &m_ClipBox, aDC, origin, radius, linewidth, color );
859 #endif
860 }
#define AXIS_SIZE_IN_PIXELS
Definition: draw_panel.cpp:823
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:318
EDA_RECT m_ClipBox
The drawing area used to redraw the screen which is usually the visible area of the drawing in intern...
int color
Definition: DXF_plotter.cpp:62
virtual const wxSize GetPageSizeIU() const =0
Function GetPageSizeIU works off of GetPageSettings() to return the size of the paper page in the int...
Definition: colors.h:60
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:380
virtual const wxPoint & GetAuxOrigin() const =0
Function GetAuxOrigin returns the origin of the axis used for plotting and various exports...
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:850
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context...
Definition: gr_basic.cpp:231
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void EDA_DRAW_PANEL::DrawBackGround ( wxDC *  DC)

Function DrawBackGround.

Parameters
DC= current Device Context Draws (if allowed) : the grid X and Y axis X and Y auxiliary axis

Definition at line 694 of file draw_panel.cpp.

References BLUE, DrawAuxiliaryAxis(), DrawGrid(), DrawGridAxis(), EDA_DRAW_FRAME::GetPageSizeIU(), GetParent(), GR_COPY, GRLine(), GRSetDrawMode(), and m_ClipBox.

Referenced by DISPLAY_FOOTPRINTS_FRAME::RedrawActiveWindow(), LIB_VIEW_FRAME::RedrawActiveWindow(), FOOTPRINT_EDIT_FRAME::RedrawActiveWindow(), PL_EDITOR_FRAME::RedrawActiveWindow(), FOOTPRINT_VIEWER_FRAME::RedrawActiveWindow(), FOOTPRINT_WIZARD_FRAME::RedrawActiveWindow(), GERBVIEW_FRAME::RedrawActiveWindow(), SCH_EDIT_FRAME::RedrawActiveWindow(), LIB_EDIT_FRAME::RedrawActiveWindow(), PCB_EDIT_FRAME::RedrawActiveWindow(), and SetCanStartBlock().

695 {
696  GRSetDrawMode( DC, GR_COPY );
697 
698  if( GetParent()->IsGridVisible() )
699  DrawGrid( DC );
700 
701  // Draw axis
702  if( GetParent()->m_showAxis )
703  {
704  COLOR4D axis_color = COLOR4D( BLUE );
705  wxSize pageSize = GetParent()->GetPageSizeIU();
706 
707  // Draw the Y axis
708  GRLine( &m_ClipBox, DC, 0, -pageSize.y, 0, pageSize.y, 0, axis_color );
709 
710  // Draw the X axis
711  GRLine( &m_ClipBox, DC, -pageSize.x, 0, pageSize.x, 0, 0, axis_color );
712  }
713 
714  if( GetParent()->m_showOriginAxis )
715  DrawAuxiliaryAxis( DC, GR_COPY );
716 
717  if( GetParent()->m_showGridAxis )
718  DrawGridAxis( DC, GR_COPY, GetParent()->GetGridOrigin() );
719 }
Definition: colors.h:57
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:318
EDA_RECT m_ClipBox
The drawing area used to redraw the screen which is usually the visible area of the drawing in intern...
void DrawGrid(wxDC *aDC)
Function DrawGrid draws a grid to aDC.
Definition: draw_panel.cpp:722
virtual const wxSize GetPageSizeIU() const =0
Function GetPageSizeIU works off of GetPageSettings() to return the size of the paper page in the int...
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...
Definition: draw_panel.cpp:863
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:380
void DrawAuxiliaryAxis(wxDC *aDC, GR_DRAWMODE aDrawMode)
Function DrawAuxiliaryAxis Draw the Auxiliary Axis, used in Pcbnew which as origin coordinates for ge...
Definition: draw_panel.cpp:825
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void EDA_DRAW_PANEL::DrawCrossHair ( wxDC *  aDC,
COLOR4D  aColor = COLOR4D::WHITE 
)

Function DrawCrossHair draws the user cross hair.

The user cross hair is not the mouse cursor although they may be at the same screen position. The mouse cursor is still render by the OS. This is a drawn cross hair that is used to snap to grid when grid snapping is enabled. This is as an indicator to where the next user action will take place.

Parameters
aDC- the device context to draw the cursor
aColor- the color to draw the cursor

Definition at line 221 of file draw_panel.cpp.

References CURSOR_SIZE, EDA_DRAW_FRAME::GetCrossHairPosition(), GetParent(), GR_XOR, GRLine(), GRSetDrawMode(), KIGFX::COLOR4D::Invert(), m_ClipBox, m_cursorLevel, m_showCrossHair, wxPoint::x, and wxPoint::y.

Referenced by CrossHairOff(), CrossHairOn(), OnEraseBackground(), DISPLAY_FOOTPRINTS_FRAME::RedrawActiveWindow(), LIB_VIEW_FRAME::RedrawActiveWindow(), FOOTPRINT_EDIT_FRAME::RedrawActiveWindow(), PL_EDITOR_FRAME::RedrawActiveWindow(), FOOTPRINT_VIEWER_FRAME::RedrawActiveWindow(), FOOTPRINT_WIZARD_FRAME::RedrawActiveWindow(), GERBVIEW_FRAME::RedrawActiveWindow(), SCH_EDIT_FRAME::RedrawActiveWindow(), LIB_EDIT_FRAME::RedrawActiveWindow(), and PCB_EDIT_FRAME::RedrawActiveWindow().

222 {
223  if( m_cursorLevel != 0 || aDC == NULL || !m_showCrossHair )
224  return;
225 
226  wxPoint cursor = GetParent()->GetCrossHairPosition();
227 
228 #ifdef USE_WX_GRAPHICS_CONTEXT
229  // Normally cursor color is set to white, so when it is xored with white
230  // background, it is painted black effectively. wxGraphicsContext does not have
231  // xor operation, so we need to invert the color manually.
232  aColor.Invert();
233 #else
234  GRSetDrawMode( aDC, GR_XOR );
235 #endif
236 
237  if( GetParent()->GetGalDisplayOptions().m_fullscreenCursor )
238  {
239  wxSize clientSize = GetClientSize();
240 
241  // Y axis
242  wxPoint lineStart( cursor.x, aDC->DeviceToLogicalY( 0 ) );
243  wxPoint lineEnd( cursor.x, aDC->DeviceToLogicalY( clientSize.y ) );
244 
245  GRLine( &m_ClipBox, aDC, lineStart, lineEnd, 0, aColor );
246 
247  // X axis
248  lineStart = wxPoint( aDC->DeviceToLogicalX( 0 ), cursor.y );
249  lineEnd = wxPoint( aDC->DeviceToLogicalX( clientSize.x ), cursor.y );
250 
251  GRLine( &m_ClipBox, aDC, lineStart, lineEnd, 0, aColor );
252  }
253  else
254  {
255  int len = aDC->DeviceToLogicalXRel( CURSOR_SIZE );
256 
257  GRLine( &m_ClipBox, aDC, cursor.x - len, cursor.y,
258  cursor.x + len, cursor.y, 0, aColor );
259  GRLine( &m_ClipBox, aDC, cursor.x, cursor.y - len,
260  cursor.x, cursor.y + len, 0, aColor );
261  }
262 }
COLOR4D & Invert()
Function Invert Makes the color inverted, alpha remains the same.
Definition: color4d.h:185
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:318
EDA_RECT m_ClipBox
The drawing area used to redraw the screen which is usually the visible area of the drawing in intern...
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:380
bool m_showCrossHair
Indicate if cross hair is to be shown.
static const int CURSOR_SIZE
Cursor size in pixels.
Definition: draw_panel.cpp:48
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
int m_cursorLevel
Index for cursor redraw in XOR mode.
void EDA_DRAW_PANEL::DrawGrid ( wxDC *  aDC)

Function DrawGrid draws a grid to aDC.

See also
m_ClipBox to determine the damaged area of the drawing to draw the grid.
EDA_DRAW_FRAME::IsGridVisible() to determine if grid is shown.
EDA_DRAW_FRAME::GetGridColor() for the color of the grid.
Parameters
aDCThe device context to draw the grid.

Definition at line 722 of file draw_panel.cpp.

References EDA_RECT::GetBottom(), BASE_SCREEN::GetGridSize(), EDA_DRAW_FRAME::GetNearestGridPosition(), GetParent(), EDA_RECT::GetPosition(), EDA_RECT::GetRight(), GetScreen(), EDA_RECT::GetX(), EDA_RECT::GetY(), GRSetColorPen(), KiROUND(), m_ClipBox, BASE_SCREEN::m_StartVisu, MIN_GRID_SIZE, wxPoint::x, and wxPoint::y.

Referenced by DrawBackGround(), and SetCanStartBlock().

723 {
724  #define MIN_GRID_SIZE 10 // min grid size in pixels to allow drawing
725  BASE_SCREEN* screen = GetScreen();
726  wxRealPoint gridSize;
727  wxSize screenSize;
728  wxPoint org;
729  wxRealPoint screenGridSize;
730 
731  /* The grid must be visible. this is possible only is grid value
732  * and zoom value are sufficient
733  */
734  gridSize = screen->GetGridSize();
735  screen->m_StartVisu = CalcUnscrolledPosition( wxPoint( 0, 0 ) );
736  screenSize = GetClientSize();
737 
738  screenGridSize.x = aDC->LogicalToDeviceXRel( KiROUND( gridSize.x ) );
739  screenGridSize.y = aDC->LogicalToDeviceYRel( KiROUND( gridSize.y ) );
740 
741  org = m_ClipBox.GetPosition();
742 
743  if( screenGridSize.x < MIN_GRID_SIZE || screenGridSize.y < MIN_GRID_SIZE )
744  {
745  screenGridSize.x *= 2.0;
746  screenGridSize.y *= 2.0;
747  gridSize.x *= 2.0;
748  gridSize.y *= 2.0;
749  }
750 
751  if( screenGridSize.x < MIN_GRID_SIZE || screenGridSize.y < MIN_GRID_SIZE )
752  return;
753 
754  org = GetParent()->GetNearestGridPosition( org, &gridSize );
755 
756  // Setting the nearest grid position can select grid points outside the clip box.
757  // Incrementing the start point by one grid step should prevent drawing grid points
758  // outside the clip box.
759  if( org.x < m_ClipBox.GetX() )
760  org.x += KiROUND( gridSize.x );
761 
762  if( org.y < m_ClipBox.GetY() )
763  org.y += KiROUND( gridSize.y );
764 
765  // Use a pixel based draw to display grid. There are a lot of calls, so the cost is
766  // high and grid is slowly drawn on some platforms. Another way using blit transfert was used,
767  // a long time ago, but it did not give very good results.
768  // The better way is highly dependent on the platform and the graphic card.
769  int xpos;
770  double right = ( double ) m_ClipBox.GetRight();
771  double bottom = ( double ) m_ClipBox.GetBottom();
772 
773 #if defined( USE_WX_GRAPHICS_CONTEXT )
774  wxGCDC *gcdc = wxDynamicCast( aDC, wxGCDC );
775 
776  if( gcdc )
777  {
778  // Much faster grid drawing on systems using wxGraphicsContext
779  wxGraphicsContext *gc = gcdc->GetGraphicsContext();
780 
781  // Grid point size
782  const int gsz = 1;
783  const double w = aDC->DeviceToLogicalXRel( gsz );
784  const double h = aDC->DeviceToLogicalYRel( gsz );
785 
786  // Use our own pen
787  wxPen pen( GetParent()->GetGridColor().ToColour(), h );
788  pen.SetCap( wxCAP_BUTT );
789  gc->SetPen( pen );
790 
791  // draw grid
792  wxGraphicsPath path = gc->CreatePath();
793  for( double x = (double) org.x - w/2.0; x <= right - w/2.0; x += gridSize.x )
794  {
795  for( double y = (double) org.y; y <= bottom; y += gridSize.y )
796  {
797  path.MoveToPoint( x, y );
798  path.AddLineToPoint( x+w, y );
799  }
800  }
801  gc->StrokePath( path );
802  }
803  else
804 #endif
805  {
806  GRSetColorPen( aDC, GetParent()->GetGridColor() );
807 
808  for( double x = (double) org.x; x <= right; x += gridSize.x )
809  {
810  xpos = KiROUND( x );
811 
812  for( double y = (double) org.y; y <= bottom; y += gridSize.y )
813  {
814  aDC->DrawPoint( xpos, KiROUND( y ) );
815  }
816  }
817  }
818 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:106
EDA_RECT m_ClipBox
The drawing area used to redraw the screen which is usually the visible area of the drawing in intern...
wxPoint m_StartVisu
Coordinates in drawing units of the current view position (upper left corner of device) ...
Definition: base_screen.h:198
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
#define MIN_GRID_SIZE
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
int GetBottom() const
Definition: eda_rect.h:122
int GetRight() const
Definition: eda_rect.h:119
const wxPoint GetPosition() const
Definition: eda_rect.h:113
wxPoint GetNearestGridPosition(const wxPoint &aPosition, wxRealPoint *aGridSize=NULL) const
Function GetNearestGridPosition returns the nearest aGridSize location to aPosition.
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:410
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context...
Definition: gr_basic.cpp:231
int GetX() const
Definition: eda_rect.h:109
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:193
int GetY() const
Definition: eda_rect.h:110
void EDA_DRAW_PANEL::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 origin is set by user, and is not (0,0)

Parameters
aDC= current Device Context
aDrawMode= draw mode (GR_COPY, GR_OR ..)
aGridOrigin= the absolute coordinate of grid origin for snap.

Definition at line 863 of file draw_panel.cpp.

References AXIS_SIZE_IN_PIXELS, color, EDA_DRAW_FRAME::GetGridColor(), EDA_DRAW_FRAME::GetPageSizeIU(), GetParent(), GRCircle(), GRLine(), GRSetColorPen(), GRSetDrawMode(), m_ClipBox, wxPoint::x, and wxPoint::y.

Referenced by DrawBackGround(), and SetCanStartBlock().

864 {
865  if( !GetParent()->m_showGridAxis || ( !aGridOrigin.x && !aGridOrigin.y ) )
866  return;
867 
869 
870  GRSetDrawMode( aDC, aDrawMode );
871 
872 #if DRAW_AXIS_AS_LINES
873  wxSize pageSize = GetParent()->GetPageSizeIU();
874  // Draw the Y axis
875  GRLine( &m_ClipBox, aDC, aGridOrigin.x, -pageSize.y,
876  aGridOrigin.x, pageSize.y, 0, color );
877 
878  // Draw the X axis
879  GRLine( &m_ClipBox, aDC, -pageSize.x, aGridOrigin.y,
880  pageSize.x, aGridOrigin.y, 0, color );
881 #else
882  int radius = aDC->DeviceToLogicalXRel( AXIS_SIZE_IN_PIXELS );
883  int linewidth = aDC->DeviceToLogicalXRel( 1 );
884 
885  GRSetColorPen( aDC, GetParent()->GetGridColor(), linewidth );
886 
887  GRLine( &m_ClipBox, aDC, aGridOrigin.x-radius, aGridOrigin.y-radius,
888  aGridOrigin.x+radius, aGridOrigin.y+radius, 0, color );
889 
890  // Draw the X shape
891  GRLine( &m_ClipBox, aDC, aGridOrigin.x+radius, aGridOrigin.y-radius,
892  aGridOrigin.x-radius, aGridOrigin.y+radius, 0, color );
893 
894  GRCircle( &m_ClipBox, aDC, aGridOrigin, radius, linewidth, color );
895 #endif
896 }
#define AXIS_SIZE_IN_PIXELS
Definition: draw_panel.cpp:823
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:318
EDA_RECT m_ClipBox
The drawing area used to redraw the screen which is usually the visible area of the drawing in intern...
int color
Definition: DXF_plotter.cpp:62
virtual const wxSize GetPageSizeIU() const =0
Function GetPageSizeIU works off of GetPageSettings() to return the size of the paper page in the int...
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:380
virtual COLOR4D GetGridColor()
Function GetGridColor() , virtual.
Definition: draw_frame.h:525
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:850
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context...
Definition: gr_basic.cpp:231
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void EDA_DRAW_PANEL::EndMouseCapture ( int  aId = -1,
int  aCursorId = -1,
const wxString &  aTitle = wxEmptyString,
bool  aCallEndFunc = true 
)

Function EndMouseCapture ends mouse a capture.

Check to see if the cursor is being managed for block or editing commands and release it.

Parameters
aIdThe command ID to restore or -1 to keep the current command ID.
aCursorIdThe wxWidgets stock cursor ID to set the cursor to or -1 to keep the current cursor.
aTitleThe tool message to display in the status bar or wxEmptyString to clear the message.
aCallEndFuncCall the abort mouse capture callback if true.

Definition at line 1541 of file draw_panel.cpp.

References GetParent(), INSTALL_UNBUFFERED_DC, m_endMouseCaptureCallback, m_mouseCaptureCallback, m_requestAutoPan, and EDA_DRAW_FRAME::SetToolID().

Referenced by EDA_DRAW_FRAME::CopyToClipboard(), LIB_EDIT_FRAME::CreateGraphicItem(), SCH_EDIT_FRAME::EndSegment(), PCB_EDIT_FRAME::Files_io_from_id(), PL_EDITOR_FRAME::HandleBlockEnd(), FOOTPRINT_EDIT_FRAME::HandleBlockEnd(), GERBVIEW_FRAME::HandleBlockEnd(), LIB_EDIT_FRAME::HandleBlockEnd(), PCB_EDIT_FRAME::HandleBlockEnd(), SCH_EDIT_FRAME::HandleBlockEnd(), PL_EDITOR_FRAME::HandleBlockPlace(), FOOTPRINT_EDIT_FRAME::HandleBlockPlace(), GERBVIEW_FRAME::HandleBlockPlace(), LIB_EDIT_FRAME::HandleBlockPlace(), PCB_EDIT_FRAME::HandleBlockPlace(), SCH_EDIT_FRAME::HandleBlockPlace(), SCH_EDIT_FRAME::OnCancelCurrentCommand(), LIB_EDIT_FRAME::OnCreateNewPart(), LIB_EDIT_FRAME::OnEditPin(), PL_EDITOR_FRAME::OnFileHistory(), PCB_EDIT_FRAME::OnFileHistory(), OnKeyEvent(), PCB_EDIT_FRAME::OnPlaceOrRouteFootprints(), LIB_EDIT_FRAME::OnSelectBodyStyle(), LIB_EDIT_FRAME::OnSelectTool(), SCH_EDIT_FRAME::OnSelectTool(), PCB_EDIT_FRAME::OnSelectTool(), LIB_EDIT_FRAME::Process_Special_Functions(), SCH_EDIT_FRAME::Process_Special_Functions(), PCB_EDIT_FRAME::Process_Special_Functions(), PCB_EDIT_FRAME::ProcessMuWaveFunctions(), LIB_EDIT_FRAME::saveLibrary(), and SetMouseCaptureCallback().

1543 {
1544  if( m_mouseCaptureCallback && m_endMouseCaptureCallback && aCallEndFunc )
1545  {
1546  INSTALL_UNBUFFERED_DC( dc, this );
1547  m_endMouseCaptureCallback( this, &dc );
1548  }
1549 
1550  m_mouseCaptureCallback = NULL;
1552  m_requestAutoPan = false;
1553 
1554  if( id != -1 && cursor != -1 )
1555  {
1556  wxASSERT( cursor > wxCURSOR_NONE && cursor < wxCURSOR_MAX );
1557  GetParent()->SetToolID( id, cursor, title );
1558  }
1559 }
bool m_requestAutoPan
true to request an auto pan. Valid only when m_enableAutoPan = true.
END_MOUSE_CAPTURE_CALLBACK m_endMouseCaptureCallback
Abort mouse capture callback function.
MOUSE_CAPTURE_CALLBACK m_mouseCaptureCallback
Mouse capture move callback function.
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
Definition: draw_frame.cpp:591
#define INSTALL_UNBUFFERED_DC(name, parent)
void EDA_DRAW_PANEL::EraseScreen ( wxDC *  DC)

Definition at line 574 of file draw_panel.cpp.

References EDA_RECT::GetBottom(), EDA_DRAW_FRAME::GetDrawBgColor(), GetParent(), EDA_RECT::GetRight(), EDA_RECT::GetX(), EDA_RECT::GetY(), GR_COPY, GRRect(), GRSetDrawMode(), GRSFilledRect(), LIGHTMAGENTA, and m_ClipBox.

Referenced by DrawPageOnClipboard(), OnEraseBackground(), ReDraw(), and PL_EDITOR_FRAME::RedrawActiveWindow().

575 {
576  GRSetDrawMode( DC, GR_COPY );
577 
578  COLOR4D bgColor = GetParent()->GetDrawBgColor();
579 
580  GRSFilledRect( NULL, DC, m_ClipBox.GetX(), m_ClipBox.GetY(),
582  0, bgColor, bgColor );
583 
584  // Set to one (1) to draw bounding box validate bounding box calculation.
585 #if DEBUG_SHOW_CLIP_RECT
586  EDA_RECT bBox = m_ClipBox;
587  GRRect( NULL, DC, bBox.GetOrigin().x, bBox.GetOrigin().y,
588  bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
589 #endif
590 }
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:318
void GRSFilledRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, COLOR4D aColor, COLOR4D aBgColor)
Definition: gr_basic.cpp:1173
EDA_RECT m_ClipBox
The drawing area used to redraw the screen which is usually the visible area of the drawing in intern...
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1098
virtual COLOR4D GetDrawBgColor() const
Definition: draw_frame.h:346
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
int GetBottom() const
Definition: eda_rect.h:122
int GetRight() const
Definition: eda_rect.h:119
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
int GetX() const
Definition: eda_rect.h:109
int GetY() const
Definition: eda_rect.h:110
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
EDA_RECT* EDA_DRAW_PANEL::GetClipBox ( )
inline

Definition at line 139 of file class_drawpanel.h.

References m_ClipBox.

Referenced by Autoroute_One_Track(), DisplayRoutingMatrix(), SCH_NO_CONNECT::Draw(), SCH_JUNCTION::Draw(), PCB_TARGET::Draw(), SCH_BUS_ENTRY_BASE::Draw(), TEXTE_PCB::Draw(), SCH_BITMAP::Draw(), EDGE_MODULE::Draw(), ZONE_CONTAINER::Draw(), SCH_LINE::Draw(), GBR_LAYOUT::Draw(), BLOCK_SELECTOR::Draw(), SCH_TEXT::Draw(), SCH_FIELD::Draw(), TEXTE_MODULE::Draw(), TRACK::Draw(), DIMENSION::Draw(), DRAWSEGMENT::Draw(), LIB_ITEM::Draw(), GERBER_DRAW_ITEM::Draw(), SCH_GLOBALLABEL::Draw(), SCH_HIERLABEL::Draw(), MODULE::Draw(), SEGZONE::Draw(), VIA::Draw(), SCH_SHEET::Draw(), LIB_PART::Draw(), SCH_COMPONENT::Draw(), D_PAD::Draw(), MODULE::DrawAncre(), DrawDanglingSymbol(), ZONE_CONTAINER::DrawFilledArea(), PCB_BASE_FRAME::DrawGeneralRatsnest(), LIB_CIRCLE::drawGraphic(), LIB_POLYLINE::drawGraphic(), LIB_RECTANGLE::drawGraphic(), LIB_BEZIER::drawGraphic(), LIB_TEXT::drawGraphic(), LIB_ARC::drawGraphic(), LIB_FIELD::drawGraphic(), LIB_PIN::drawGraphic(), GBR_LAYOUT::DrawItemsDCodeID(), MARKER_BASE::DrawMarker(), PLEDITOR_PRINTOUT::DrawPage(), SCH_PRINTOUT::DrawPage(), BOARD_PRINTOUT_CONTROLLER::DrawPage(), DrawPageOnClipboard(), LIB_PIN::DrawPinElectricalTypeName(), LIB_PIN::DrawPinSymbol(), LIB_PIN::DrawPinTexts(), D_PAD::DrawShape(), TRACK::DrawShortNetname(), TEXTE_MODULE::DrawUmbilical(), ZONE_CONTAINER::DrawWhileCreateOutline(), EDA_DRAW_FRAME::DrawWorkSheet(), getOptimalModulePlacement(), PCB_EDIT_FRAME::PrintPage(), ShowBoundingBoxMicroWaveInductor(), ShowNewTrackWhenMovingCursor(), PCB_BASE_FRAME::TraceAirWiresToTargets(), and PCB_BASE_FRAME::TraceModuleRatsNest().

139 { return &m_ClipBox; }
EDA_RECT m_ClipBox
The drawing area used to redraw the screen which is usually the visible area of the drawing in intern...
void * EDA_DRAW_PANEL::GetDisplayOptions ( )

Function GetDisplayOptions A way to pass info to draw functions.

this is just an accessor to the GetDisplayOptions() parent frame function.

Definition at line 187 of file draw_panel.cpp.

References EDA_DRAW_FRAME::GetDisplayOptions(), and GetParent().

Referenced by PCB_TARGET::Draw(), TEXTE_PCB::Draw(), EDGE_MODULE::Draw(), ZONE_CONTAINER::Draw(), TEXTE_MODULE::Draw(), TRACK::Draw(), DIMENSION::Draw(), DRAWSEGMENT::Draw(), SEGZONE::Draw(), ZONE_CONTAINER::DrawFilledArea(), drawMovingBlock(), MODULE::DrawOutlinesWhenMoving(), DrawSegment(), TRACK::DrawShortNetname(), ZONE_CONTAINER::DrawWhileCreateOutline(), Show_MoveNode(), and Trace_Pads_Only().

188 {
189  return GetParent()->GetDisplayOptions();
190 }
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
virtual void * GetDisplayOptions()
Function GetDisplayOptions A way to pass info to draw functions.
Definition: draw_frame.h:918
bool EDA_DRAW_PANEL::GetEnableAutoPan ( void  ) const
inline
bool EDA_DRAW_PANEL::GetEnableMousewheelPan ( void  ) const
inline
bool EDA_DRAW_PANEL::GetEnableZoomNoCenter ( void  ) const
inline
wxRealPoint EDA_DRAW_PANEL::GetGrid ( )

Definition at line 294 of file draw_panel.cpp.

References BASE_SCREEN::GetGridSize(), and GetScreen().

Referenced by OnEraseBackground().

295 {
296  return GetScreen()->GetGridSize();
297 }
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:410
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:193
EDA_DRAW_FRAME * EDA_DRAW_PANEL::GetParent ( void  ) const

Definition at line 180 of file draw_panel.cpp.

Referenced by Abort_Create_Track(), Abort_Edit_Pcb_Text(), Abort_EditEdge(), Abort_MoveOrCopyModule(), Abort_MoveTrack(), Abort_Zone_Create_Outline(), Abort_Zone_Move_Corner_Or_Outlines(), AbortBlockCurrentCommand(), AbortBuildDimension(), AbortCreateNewLine(), AbortMoveAndEditTarget(), abortMoveBitmap(), AbortMoveDimensionText(), abortMoveItem(), AbortPinMove(), AbortSymbolTraceOn(), BuildDimension(), PCB_TARGET::Draw(), TEXTE_PCB::Draw(), EDGE_MODULE::Draw(), ZONE_CONTAINER::Draw(), GBR_LAYOUT::Draw(), TEXTE_MODULE::Draw(), TRACK::Draw(), DIMENSION::Draw(), DRAWSEGMENT::Draw(), SEGZONE::Draw(), VIA::Draw(), D_PAD::Draw(), MODULE::DrawAncre(), DrawAndSizingBlockOutlines(), DrawAuxiliaryAxis(), DrawBackGround(), DrawCrossHair(), ZONE_CONTAINER::DrawFilledArea(), LIB_PIN::drawGraphic(), DrawGrid(), DrawGridAxis(), DrawMovePin(), drawMovingBlock(), DrawMovingBlockOutlines(), DrawMovingItems(), MODULE::DrawOutlinesWhenMoving(), drawPickedItems(), DrawSegment(), ZONE_CONTAINER::DrawWhileCreateOutline(), EndMouseCapture(), EraseScreen(), ExitSheet(), GetDisplayOptions(), GetScreen(), Move_Segment(), Move_Texte_Pcb(), moveBitmap(), MoveCursor(), MoveCursorToCrossHair(), MoveDimensionText(), MoveFootprint(), moveItem(), moveItemWithMouseCursor(), OnKeyEvent(), OnMouseEvent(), OnMouseLeaving(), OnMouseWheel(), OnPan(), OnRightClick(), OnScroll(), OnTimer(), PushTrack(), ReDraw(), RedrawWhileMovingCursor(), Refresh(), resizeSheetWithMouseCursor(), SetEnableAutoPan(), SetEnableMousewheelPan(), SetEnableZoomNoCenter(), Show_Drag_Track_Segment_With_Cte_Slope(), Show_MoveNode(), Show_MoveTexte_Module(), Show_New_Edge_While_Move_Mouse(), Show_Pad_Move(), Show_Zone_Corner_Or_Outline_While_Move_Mouse(), ShowBoundingBoxMicroWaveInductor(), ShowCurrentOutlineWhileMoving(), ShowNewEdgeModule(), ShowNewTrackWhenMovingCursor(), ShowTargetShapeWhileMovingMouse(), and SymbolDisplayDraw().

181 {
182  wxWindow* mom = wxScrolledWindow::GetParent();
183  return (EDA_DRAW_FRAME*) mom;
184 }
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:63
bool EDA_DRAW_PANEL::GetPrintMirrored ( ) const
inline

Definition at line 167 of file class_drawpanel.h.

References m_PrintIsMirrored.

Referenced by EDGE_MODULE::Draw(), and DRAWSEGMENT::Draw().

167 { return m_PrintIsMirrored; }
bool m_PrintIsMirrored
True when drawing in mirror mode.
BASE_SCREEN * EDA_DRAW_PANEL::GetScreen ( )

Definition at line 193 of file draw_panel.cpp.

References GetParent(), and EDA_DRAW_FRAME::GetScreen().

Referenced by Abort_Edit_Pcb_Text(), Abort_EditEdge(), Abort_Move_ModuleOutline(), AbortBlockCurrentCommand(), AbortBuildDimension(), AbortCreateNewLine(), AbortMoveAndEditTarget(), abortMoveBitmap(), AbortMoveDimensionText(), abortMoveItem(), AbortMoveTextModule(), EDA_DRAW_FRAME::AddMenuZoomAndGrid(), BuildDimension(), DoPrepareDC(), SCH_BUS_ENTRY_BASE::Draw(), TEXTE_PCB::Draw(), EDGE_MODULE::Draw(), ZONE_CONTAINER::Draw(), TEXTE_MODULE::Draw(), TRACK::Draw(), DRAWSEGMENT::Draw(), SEGZONE::Draw(), VIA::Draw(), LIB_PART::Draw(), SCH_COMPONENT::Draw(), DrawAndSizingBlockOutlines(), DrawDanglingSymbol(), ZONE_CONTAINER::DrawFilledArea(), DrawGrid(), drawMovingBlock(), DrawMovingBlockOutlines(), DrawMovingItems(), DrawPageOnClipboard(), drawPickedItems(), LIB_PIN::DrawPinSymbol(), DrawSegment(), TRACK::DrawShortNetname(), ZONE_CONTAINER::DrawWhileCreateOutline(), ExitSheet(), GetGrid(), GetZoom(), Move_Segment(), Move_Texte_Pcb(), moveBitmap(), MoveDimensionText(), MoveFootprint(), moveItem(), moveItemWithMouseCursor(), OnMouseEvent(), OnPaint(), ReDraw(), resizeSheetWithMouseCursor(), SetClipBox(), SetZoom(), Show_MoveTexte_Module(), ShowCurrentOutlineWhileMoving(), ShowNewEdgeModule(), ShowNewTrackWhenMovingCursor(), and ShowTargetShapeWhileMovingMouse().

194 {
195  EDA_DRAW_FRAME* parentFrame = GetParent();
196 
197  return parentFrame->GetScreen();
198 }
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:63
virtual BASE_SCREEN * GetScreen() const
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:369
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
wxPoint EDA_DRAW_PANEL::GetScreenCenterLogicalPosition ( )

Function GetScreenCenterLogicalPosition.

Returns
The current screen center position in logical (drawing) units.

Definition at line 351 of file draw_panel.cpp.

References INSTALL_UNBUFFERED_DC.

Referenced by OnEraseBackground(), and EDA_DRAW_FRAME::UseGalCanvas().

352 {
353  wxSize size = GetClientSize() / 2;
354  INSTALL_UNBUFFERED_DC( dc, this );
355 
356  return wxPoint( dc.DeviceToLogicalX( size.x ), dc.DeviceToLogicalY( size.y ) );
357 }
#define INSTALL_UNBUFFERED_DC(name, parent)
double EDA_DRAW_PANEL::GetZoom ( )

Definition at line 282 of file draw_panel.cpp.

References GetScreen(), and BASE_SCREEN::GetZoom().

Referenced by EDA_DRAW_FRAME::GeneralControl(), OnEraseBackground(), OnMouseWheel(), and EDA_DRAW_FRAME::UseGalCanvas().

283 {
284  return GetScreen()->GetZoom();
285 }
double GetZoom() const
Function GetZoom returns the current "zoom factor", which is a measure of "internal units per device ...
Definition: base_screen.h:340
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:193
bool EDA_DRAW_PANEL::IsMouseCaptured ( ) const
inline

Definition at line 430 of file class_drawpanel.h.

References CallEndMouseCapture(), and CallMouseCapture().

Referenced by AbortBlockCurrentCommand(), PCB_EDIT_FRAME::Begin_Zone(), PCB_EDIT_FRAME::Delete_LastCreatedCorner(), PCB_EDIT_FRAME::Delete_Segment(), LIB_EDIT_FRAME::deleteItem(), SCH_BUS_ENTRY_BASE::Draw(), SCH_COMPONENT::Draw(), Exit_Self(), EDA_DRAW_FRAME::HandleBlockBegin(), PL_EDITOR_FRAME::HandleBlockEnd(), FOOTPRINT_EDIT_FRAME::HandleBlockEnd(), GERBVIEW_FRAME::HandleBlockEnd(), LIB_EDIT_FRAME::HandleBlockEnd(), PCB_EDIT_FRAME::HandleBlockEnd(), SCH_EDIT_FRAME::HandleBlockEnd(), PL_EDITOR_FRAME::HandleBlockPlace(), FOOTPRINT_EDIT_FRAME::HandleBlockPlace(), GERBVIEW_FRAME::HandleBlockPlace(), LIB_EDIT_FRAME::HandleBlockPlace(), PCB_EDIT_FRAME::HandleBlockPlace(), SCH_EDIT_FRAME::HandleBlockPlace(), SCH_EDIT_FRAME::OnCancelCurrentCommand(), OnKeyEvent(), OnMouseEvent(), PCB_EDIT_FRAME::OnPlaceOrRouteFootprints(), LIB_EDIT_FRAME::Process_Special_Functions(), SCH_EDIT_FRAME::Process_Special_Functions(), PCB_EDIT_FRAME::Process_Special_Functions(), FOOTPRINT_EDIT_FRAME::RedrawActiveWindow(), PL_EDITOR_FRAME::RedrawActiveWindow(), GERBVIEW_FRAME::RedrawActiveWindow(), SCH_EDIT_FRAME::RedrawActiveWindow(), LIB_EDIT_FRAME::RedrawActiveWindow(), PCB_EDIT_FRAME::RedrawActiveWindow(), EDA_DRAW_FRAME::RefreshCrossHair(), and PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event().

430 { return m_mouseCaptureCallback != NULL; }
MOUSE_CAPTURE_CALLBACK m_mouseCaptureCallback
Mouse capture move callback function.
bool EDA_DRAW_PANEL::IsPointOnDisplay ( const wxPoint aPosition)

Function IsPointOnDisplay.

Parameters
aPositionThe position to test in logical (drawing) units.
Returns
true if aPosition is visible on the screen. false if aPosition is not visible on the screen.

Definition at line 300 of file draw_panel.cpp.

References EDA_RECT::Contains(), EDA_RECT::Inflate(), INSTALL_UNBUFFERED_DC, m_ClipBox, PIXEL_MARGIN, and SetClipBox().

Referenced by SCH_EDIT_FRAME::FindComponentAndItem(), PCB_BASE_FRAME::FocusOnLocation(), PL_EDITOR_FRAME::MoveItem(), and OnEraseBackground().

301 {
302  wxPoint pos;
303  EDA_RECT display_rect;
304 
305  INSTALL_UNBUFFERED_DC( dc, this ); // Refresh the clip box to the entire screen size.
306  SetClipBox( dc );
307 
308  display_rect = m_ClipBox;
309 
310  // Slightly decreased the size of the useful screen area to avoid drawing limits.
311  #define PIXEL_MARGIN 8
312  display_rect.Inflate( -PIXEL_MARGIN );
313 
314  return display_rect.Contains( aPosition );
315 }
#define PIXEL_MARGIN
bool Contains(const wxPoint &aPoint) const
Function Contains.
EDA_RECT m_ClipBox
The drawing area used to redraw the screen which is usually the visible area of the drawing in intern...
void SetClipBox(const EDA_RECT &aRect)
#define INSTALL_UNBUFFERED_DC(name, parent)
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
void EDA_DRAW_PANEL::MoveCursor ( const wxPoint aPosition)

Function MoveCursor moves the mouse pointer to aPosition in logical (drawing) units.

Parameters
aPositionThe position in logical units to move the cursor.

Definition at line 366 of file draw_panel.cpp.

References GetParent(), INSTALL_UNBUFFERED_DC, kicadTraceCoords, m_scrollIncrementX, m_scrollIncrementY, wxPoint::x, and wxPoint::y.

Referenced by SCH_EDIT_FRAME::FindComponentAndItem(), EDA_DRAW_FRAME::GeneralControlKeyMovement(), MoveCursorToCrossHair(), and OnEraseBackground().

367 {
368  if( GetParent()->IsGalCanvasActive() )
369  return;
370 
371  int x, y, xPpu, yPpu;
372  wxPoint screenPos, drawingPos;
373  wxRect clientRect( wxPoint( 0, 0 ), GetClientSize() );
374 
375  INSTALL_UNBUFFERED_DC( dc, this );
376  screenPos.x = dc.LogicalToDeviceX( aPosition.x );
377  screenPos.y = dc.LogicalToDeviceY( aPosition.y );
378 
379  // Scroll if the requested mouse position cursor is outside the drawing area.
380  if( !clientRect.Contains( screenPos ) )
381  {
382  GetViewStart( &x, &y );
383  GetScrollPixelsPerUnit( &xPpu, &yPpu );
384  CalcUnscrolledPosition( screenPos.x, screenPos.y, &drawingPos.x, &drawingPos.y );
385 
386  wxLogTrace( kicadTraceCoords,
387  wxT( "MoveCursor() initial screen position(%d, %d) " ) \
388  wxT( "rectangle(%d, %d, %d, %d) view(%d, %d)" ),
389  screenPos.x, screenPos.y, clientRect.x, clientRect.y,
390  clientRect.width, clientRect.height, x, y );
391 
392  if( screenPos.y < clientRect.GetTop() )
393  y -= m_scrollIncrementY * yPpu;
394  else if( screenPos.y > clientRect.GetBottom() )
395  y += m_scrollIncrementY * yPpu;
396  else if( clientRect.GetRight() < screenPos.x )
397  x += m_scrollIncrementX * xPpu;
398  else
399  x -= m_scrollIncrementX * xPpu;
400 
401  Scroll( x, y );
402  CalcScrolledPosition( drawingPos.x, drawingPos.y, &screenPos.x, &screenPos.y );
403 
404  wxLogTrace( kicadTraceCoords,
405  wxT( "MoveCursor() scrolled screen position(%d, %d) view(%d, %d)" ),
406  screenPos.x, screenPos.y, x, y );
407  }
408 
409  WarpPointer( screenPos.x, screenPos.y );
410 }
int m_scrollIncrementX
X axis scroll increment in pixels per unit.
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
#define INSTALL_UNBUFFERED_DC(name, parent)
const wxChar *const kicadTraceCoords
Flag to enable draw panel coordinate debug tracing.
int m_scrollIncrementY
Y axis scroll increment in pixels per unit.
void EDA_DRAW_PANEL::MoveCursorToCrossHair ( )

Function MoveCursorToCrossHair warps the cursor to the current cross hair position.

Definition at line 360 of file draw_panel.cpp.

References GetParent(), and MoveCursor().

Referenced by PCB_EDIT_FRAME::Begin_Zone(), PL_EDITOR_FRAME::Block_Move(), GERBVIEW_FRAME::Block_Move(), PCB_EDIT_FRAME::Create_MuWaveComponent(), PCB_EDIT_FRAME::Create_MuWavePolygonShape(), LIB_EDIT_FRAME::CreateGraphicItem(), LIB_EDIT_FRAME::CreatePin(), SCH_EDIT_FRAME::CreateSheet(), FOOTPRINT_EDIT_FRAME::CreateTextModule(), PCB_BASE_EDIT_FRAME::duplicateItem(), PCB_EDIT_FRAME::Edit_Zone_Params(), SCH_EDIT_FRAME::EditComponent(), SCH_EDIT_FRAME::EditComponentFieldText(), SCH_EDIT_FRAME::EditSheet(), PCB_EDIT_FRAME::End_Zone(), PCB_BASE_FRAME::FocusOnLocation(), LIB_EDIT_FRAME::HandleBlockEnd(), SCH_EDIT_FRAME::HandleBlockEnd(), InstallBlockCmdFrame(), SCH_EDIT_FRAME::Load_Component(), LIB_EDIT_FRAME::LoadOneSymbol(), PL_EDITOR_FRAME::Locate(), LIB_EDIT_FRAME::locateItem(), SCH_EDIT_FRAME::LocateItem(), PCB_EDIT_FRAME::moveExact(), SCH_EDIT_FRAME::MoveImage(), PL_EDITOR_FRAME::MoveItem(), PCB_EDIT_FRAME::MuWaveCommand(), DIALOG_LABEL_EDITOR::OnCancelClick(), SCH_EDIT_FRAME::OnDragItem(), FOOTPRINT_EDIT_FRAME::OnEditItemRequest(), OnEraseBackground(), PCB_EDIT_FRAME::OnLeftClick(), SCH_EDIT_FRAME::OnLeftDClick(), LIB_EDIT_FRAME::OnLeftDClick(), PCB_EDIT_FRAME::OnLeftDClick(), LIB_EDIT_FRAME::OnOrient(), SCH_EDIT_FRAME::OnOrient(), SCH_EDIT_FRAME::OnRotate(), SCH_EDIT_FRAME::OnSelectUnit(), EDA_DRAW_FRAME::OnZoom(), SCH_EDIT_FRAME::OrientComponent(), PCB_BASE_FRAME::PcbGeneralLocateAndDisplay(), LIB_EDIT_FRAME::PlacePin(), SCH_EDIT_FRAME::PrepareMoveItem(), LIB_EDIT_FRAME::Process_Special_Functions(), SCH_EDIT_FRAME::Process_Special_Functions(), PCB_EDIT_FRAME::Process_Special_Functions(), EDA_DRAW_FRAME::RedrawScreen(), SCH_EDIT_FRAME::ReSizeSheet(), LIB_EDIT_FRAME::StartMovePin(), PCB_BASE_FRAME::StartMoveTexteModule(), PCB_EDIT_FRAME::StartMoveTextePcb(), DIALOG_LABEL_EDITOR::TextPropertiesAccept(), and PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event().

361 {
362  MoveCursor( GetParent()->GetCrossHairPosition() );
363 }
void MoveCursor(const wxPoint &aPosition)
Function MoveCursor moves the mouse pointer to aPosition in logical (drawing) units.
Definition: draw_panel.cpp:366
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
void EDA_DRAW_PANEL::OnActivate ( wxActivateEvent &  event)

Function OnActivate handles window activation events.

The member m_canStartBlock is initialize to avoid a block start command on activation (because a left mouse button can be pressed and no block command wanted. This happens when enter on a hierarchy sheet on double click.

Definition at line 413 of file draw_panel.cpp.

References m_canStartBlock.

Referenced by EDA_DRAW_FRAME::GeneralControl(), and OnEraseBackground().

414 {
415  m_canStartBlock = -1; // Block Command can't start
416  event.Skip();
417 }
int m_canStartBlock
useful to avoid false start block in certain cases (like switch from a sheet to another sheet >= 0 (o...
void EDA_DRAW_PANEL::OnCharHook ( wxKeyEvent &  event)

Definition at line 1383 of file draw_panel.cpp.

References dump(), and kicadTraceKeyEvent.

Referenced by OnEraseBackground().

1384 {
1385  wxLogTrace( kicadTraceKeyEvent, "EDA_DRAW_PANEL::OnCharHook %s", dump( event ) );
1386  event.Skip();
1387 }
wxString dump(const wxArrayString &aArray)
Debug helper for printing wxArrayString contents.
const wxChar *const kicadTraceKeyEvent
Flag to enable wxKeyEvent debug tracing.
void EDA_DRAW_PANEL::OnKeyEvent ( wxKeyEvent &  event)

Definition at line 1390 of file draw_panel.cpp.

References dump(), EndMouseCapture(), GetParent(), GR_KB_ALT, GR_KB_CTRL, GR_KB_SHIFT, ID_NO_TOOL_SELECTED, INSTALL_UNBUFFERED_DC, IsMouseCaptured(), kicadTraceKeyEvent, m_abortRequest, m_defaultCursor, EDA_DRAW_FRAME::SetMousePosition(), wxPoint::x, and wxPoint::y.

Referenced by OnEraseBackground().

1391 {
1392  int localkey;
1393  wxPoint pos;
1394 
1395  wxLogTrace( kicadTraceKeyEvent, "EDA_DRAW_PANEL::OnKeyEvent %s", dump( event ) );
1396 
1397  localkey = event.GetKeyCode();
1398 
1399  switch( localkey )
1400  {
1401  default:
1402  break;
1403 
1404  case WXK_ESCAPE:
1405  m_abortRequest = true;
1406 
1407  if( IsMouseCaptured() )
1408  EndMouseCapture();
1409  else
1411  break;
1412  }
1413 
1414  /* Normalize keys code to easily handle keys from Ctrl+A to Ctrl+Z
1415  * They have an ascii code from 1 to 27 remapped
1416  * to GR_KB_CTRL + 'A' to GR_KB_CTRL + 'Z'
1417  */
1418  if( event.ControlDown() && localkey >= WXK_CONTROL_A && localkey <= WXK_CONTROL_Z )
1419  localkey += 'A' - 1;
1420 
1421  /* Disallow shift for keys that have two keycodes on them (e.g. number and
1422  * punctuation keys) leaving only the "letter keys" of A-Z.
1423  * Then, you can have, e.g. Ctrl-5 and Ctrl-% (GB layout)
1424  * and Ctrl-( and Ctrl-5 (FR layout).
1425  * Otherwise, you'd have to have to say Ctrl-Shift-5 on a FR layout
1426  */
1427  bool keyIsLetter = ( localkey >= 'A' && localkey <= 'Z' ) ||
1428  ( localkey >= 'a' && localkey <= 'z' );
1429 
1430  if( event.ShiftDown() && ( keyIsLetter || localkey > 256 ) )
1431  localkey |= GR_KB_SHIFT;
1432 
1433  if( event.ControlDown() )
1434  localkey |= GR_KB_CTRL;
1435 
1436  if( event.AltDown() )
1437  localkey |= GR_KB_ALT;
1438 
1439  INSTALL_UNBUFFERED_DC( DC, this );
1440 
1441  // Some key commands use the current mouse position: refresh it.
1442  pos = wxGetMousePosition() - GetScreenPosition();
1443 
1444  // Compute the cursor position in drawing units. Also known as logical units to wxDC.
1445  pos = wxPoint( DC.DeviceToLogicalX( pos.x ), DC.DeviceToLogicalY( pos.y ) );
1446 
1447  GetParent()->SetMousePosition( pos );
1448 
1449  if( !GetParent()->GeneralControl( &DC, pos, localkey ) )
1450  event.Skip();
1451 }
bool m_abortRequest
Flag used to abort long commands.
void EndMouseCapture(int aId=-1, int aCursorId=-1, const wxString &aTitle=wxEmptyString, bool aCallEndFunc=true)
Function EndMouseCapture ends mouse a capture.
#define GR_KB_ALT
Definition: common.h:65
wxString dump(const wxArrayString &aArray)
Debug helper for printing wxArrayString contents.
#define GR_KB_SHIFT
Definition: common.h:66
bool IsMouseCaptured() const
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
void SetMousePosition(const wxPoint &aPosition)
#define INSTALL_UNBUFFERED_DC(name, parent)
int m_defaultCursor
The default mouse cursor shape id.
const wxChar *const kicadTraceKeyEvent
Flag to enable wxKeyEvent debug tracing.
#define GR_KB_CTRL
Definition: common.h:64
void EDA_DRAW_PANEL::OnMouseEntering ( wxMouseEvent &  aEvent)

Definition at line 926 of file draw_panel.cpp.

References m_cursorLevel.

Referenced by OnEraseBackground().

927 {
928  // This is an ugly hack that fixes some cross hair display bugs when the mouse leaves the
929  // canvas area during middle button mouse panning.
930  if( m_cursorLevel != 0 )
931  m_cursorLevel = 0;
932 
933  aEvent.Skip();
934 }
int m_cursorLevel
Index for cursor redraw in XOR mode.
void EDA_DRAW_PANEL::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 1097 of file draw_panel.cpp.

References abs, BLOCK_MINSIZE_LIMIT, BLOCK_ZOOM, CrossHairOff(), CrossHairOn(), EDA_DRAW_FRAME::DisplayToolMsg(), EDA_DRAW_FRAME::GeneralControl(), EDA_DRAW_FRAME::GetCrossHairPosition(), BASE_SCREEN::GetCurItem(), EDA_ITEM::GetFlags(), EDA_RECT::GetHeight(), GetParent(), BASE_SCREEN::GetScalingFactor(), GetScreen(), EDA_DRAW_FRAME::GetScreen(), EDA_DRAW_FRAME::GetScrollCenterPosition(), BLOCK_SELECTOR::GetState(), EDA_DRAW_FRAME::GetToolId(), EDA_RECT::GetWidth(), GR_KB_ALT, GR_KB_CTRL, GR_KB_SHIFT, GR_M_DCLICK, GR_M_LEFT_DOWN, GR_M_MIDDLE_DOWN, EDA_DRAW_FRAME::HandleBlockBegin(), EDA_DRAW_FRAME::HandleBlockEnd(), EDA_DRAW_FRAME::HandleBlockPlace(), ID_NO_TOOL_SELECTED, ID_ZOOM_SELECTION, INSTALL_UNBUFFERED_DC, BASE_SCREEN::IsBlockActive(), IsMouseCaptured(), KiROUND(), BASE_SCREEN::m_BlockLocate, m_canStartBlock, m_ClickTimer, m_currentCursor, m_CursorClickPos, m_CursorStartPos, m_doubleClickInterval, m_enableBlockCommands, m_endMouseCaptureCallback, m_ignoreMouseEvents, m_ignoreNextLeftButtonRelease, m_minDragEventCount, m_PanStartCenter, m_PanStartEventPosition, m_requestAutoPan, MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND, EDA_DRAW_FRAME::OnLeftClick(), EDA_DRAW_FRAME::OnLeftDClick(), OnRightClick(), EDA_DRAW_FRAME::RedrawScreen(), EDA_DRAW_FRAME::RefPos(), Refresh(), scale, EDA_DRAW_FRAME::SetMousePosition(), EDA_RECT::SetOrigin(), STATE_BLOCK_END, STATE_BLOCK_MOVE, STATE_NO_BLOCK, wxPoint::x, and wxPoint::y.

Referenced by EDA_DRAW_FRAME::ExecuteRemoteCommand(), and OnEraseBackground().

1098 {
1099  int localbutt = 0;
1100  BASE_SCREEN* screen = GetScreen();
1101 
1102  if( !screen )
1103  return;
1104 
1105  /* Adjust value to filter mouse displacement before consider the drag
1106  * mouse is really a drag command, not just a movement while click
1107  */
1108 #define MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND 5
1109 
1110  if( event.Leaving() )
1111  m_canStartBlock = -1;
1112 
1113  if( !IsMouseCaptured() ) // No mouse capture in progress.
1114  m_requestAutoPan = false;
1115 
1116  if( GetParent()->IsActive() )
1117  SetFocus();
1118  else
1119  return;
1120 
1121  if( !event.IsButton() && !event.Moving() && !event.Dragging() )
1122  return;
1123 
1124  if( event.RightDown() )
1125  {
1126  OnRightClick( event );
1127  return;
1128  }
1129 
1130  if( m_ignoreMouseEvents )
1131  return;
1132 
1133  if( event.LeftDown() )
1134  localbutt = GR_M_LEFT_DOWN;
1135 
1136  if( event.ButtonDClick( 1 ) )
1137  localbutt = GR_M_LEFT_DOWN | GR_M_DCLICK;
1138 
1139  if( event.MiddleDown() )
1140  localbutt = GR_M_MIDDLE_DOWN;
1141 
1142  INSTALL_UNBUFFERED_DC( DC, this );
1143  DC.SetBackground( *wxBLACK_BRUSH );
1144 
1145  // Compute the cursor position in drawing (logical) units.
1146  GetParent()->SetMousePosition( event.GetLogicalPosition( DC ) );
1147 
1148  int kbstat = 0;
1149 
1150  if( event.ShiftDown() )
1151  kbstat |= GR_KB_SHIFT;
1152 
1153  if( event.ControlDown() )
1154  kbstat |= GR_KB_CTRL;
1155 
1156  if( event.AltDown() )
1157  kbstat |= GR_KB_ALT;
1158 
1159  // Calling Double Click and Click functions :
1160  if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) )
1161  {
1162  if( m_ClickTimer )
1163  {
1164  m_ClickTimer->Stop();
1165  wxDELETE( m_ClickTimer );
1166  }
1167  GetParent()->OnLeftDClick( &DC, GetParent()->RefPos( true ) );
1168 
1169  // inhibit a response to the mouse left button release,
1170  // because we have a double click, and we do not want a new
1171  // OnLeftClick command at end of this Double Click
1173  }
1174  else if( event.LeftUp() )
1175  {
1176  // A block command is in progress: a left up is the end of block
1177  // or this is the end of a double click, already seen
1178  // Note also m_ignoreNextLeftButtonRelease can be set by
1179  // the call to OnLeftClick(), so do not change it after calling OnLeftClick
1180  bool ignoreEvt = m_ignoreNextLeftButtonRelease;
1182 
1183  if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK && !ignoreEvt )
1184  {
1185  EDA_ITEM* item = screen->GetCurItem();
1186  m_CursorClickPos = GetParent()->RefPos( true );
1187 
1188  // If we have an item already selected, or we are using a tool,
1189  // we won't use the disambiguation menu so process the click immediately
1190  if( ( item && item->GetFlags() ) || GetParent()->GetToolId() != ID_NO_TOOL_SELECTED )
1192  else
1193  {
1194  wxDELETE( m_ClickTimer );
1195  m_ClickTimer = new wxTimer(this, ID_MOUSE_DOUBLECLICK);
1196  m_ClickTimer->StartOnce( m_doubleClickInterval );
1197  }
1198  }
1199 
1200  }
1201  else if( !event.LeftIsDown() )
1202  {
1203  /* be sure there is a response to a left button release command
1204  * even when a LeftUp event is not seen. This happens when a
1205  * double click opens a dialog box, and the release mouse button
1206  * is made when the dialog box is opened.
1207  */
1209  }
1210 
1211  if( event.ButtonDown( wxMOUSE_BTN_MIDDLE ) )
1212  {
1214  m_PanStartEventPosition = event.GetPosition();
1215 
1216  INSTALL_UNBUFFERED_DC( dc, this );
1217  CrossHairOff( &dc );
1218  SetCursor( wxCURSOR_SIZING );
1219  }
1220 
1221  if( event.ButtonUp( wxMOUSE_BTN_MIDDLE ) )
1222  {
1223  INSTALL_UNBUFFERED_DC( dc, this );
1224  CrossHairOn( &dc );
1225  SetCursor( (wxStockCursor) m_currentCursor );
1226  }
1227 
1228  if( event.MiddleIsDown() )
1229  {
1230  wxPoint currentPosition = event.GetPosition();
1231 
1232  double scale = GetParent()->GetScreen()->GetScalingFactor();
1233  int x = m_PanStartCenter.x +
1234  KiROUND( (double) ( m_PanStartEventPosition.x - currentPosition.x ) / scale );
1235  int y = m_PanStartCenter.y +
1236  KiROUND( (double) ( m_PanStartEventPosition.y - currentPosition.y ) / scale );
1237 
1238  GetParent()->RedrawScreen( wxPoint( x, y ), false );
1239  }
1240 
1241  // Calling the general function on mouse changes (and pseudo key commands)
1242  GetParent()->GeneralControl( &DC, event.GetLogicalPosition( DC ), 0 );
1243 
1244  /*******************************/
1245  /* Control of block commands : */
1246  /*******************************/
1247 
1248  // Command block can't start if mouse is dragging a new panel
1249  static EDA_DRAW_PANEL* lastPanel;
1250  if( lastPanel != this )
1251  {
1252  m_minDragEventCount = 0;
1253  m_canStartBlock = -1;
1254  }
1255 
1256  /* A new command block can start after a release buttons
1257  * and if the drag is enough
1258  * This is to avoid a false start block when a dialog box is dismissed,
1259  * or when changing panels in hierarchy navigation
1260  * or when clicking while and moving mouse
1261  */
1262  if( !event.LeftIsDown() && !event.MiddleIsDown() )
1263  {
1264  m_minDragEventCount = 0;
1265  m_canStartBlock = 0;
1266 
1267  /* Remember the last cursor position when a drag mouse starts
1268  * this is the last position ** before ** clicking a button
1269  * this is useful to start a block command from the point where the
1270  * mouse was clicked first
1271  * (a filter creates a delay for the real block command start, and
1272  * we must remember this point)
1273  */
1275  }
1276 
1277  if( m_enableBlockCommands && !(localbutt & GR_M_DCLICK) )
1278  {
1279  if( !screen->IsBlockActive() )
1280  {
1282  }
1283 
1284  if( event.LeftDown() )
1285  {
1286  if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE )
1287  {
1288  m_requestAutoPan = false;
1289  GetParent()->HandleBlockPlace( &DC );
1291  }
1292  }
1293  else if( ( m_canStartBlock >= 0 ) && event.LeftIsDown() && !IsMouseCaptured() )
1294  {
1295  // Mouse is dragging: if no block in progress, start a block command.
1296  if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK )
1297  {
1298  // Start a block command
1299  int cmd_type = kbstat;
1300 
1301  // A block command is started if the drag is enough. A small
1302  // drag is ignored (it is certainly a little mouse move when
1303  // clicking) not really a drag mouse
1306  else
1307  {
1308  auto cmd = (GetParent()->GetToolId() == ID_ZOOM_SELECTION) ? BLOCK_ZOOM : 0;
1309 
1310  if( !GetParent()->HandleBlockBegin( &DC, cmd_type, m_CursorStartPos, cmd ) )
1311  {
1312  // should not occur: error
1314  wxT( "EDA_DRAW_PANEL::OnMouseEvent() Block Error" ) );
1315  }
1316  else
1317  {
1318  m_requestAutoPan = true;
1319  SetCursor( wxCURSOR_SIZING );
1320  }
1321  }
1322  }
1323  }
1324 
1325  if( event.ButtonUp( wxMOUSE_BTN_LEFT ) )
1326  {
1327  /* Release the mouse button: end of block.
1328  * The command can finish (DELETE) or have a next command (MOVE,
1329  * COPY). However the block command is canceled if the block
1330  * size is small because a block command filtering is already
1331  * made, this case happens, but only when the on grid cursor has
1332  * not moved.
1333  */
1334  #define BLOCK_MINSIZE_LIMIT 1
1335  bool BlockIsSmall =
1337  && ( std::abs( screen->m_BlockLocate.GetHeight() ) < BLOCK_MINSIZE_LIMIT );
1338 
1339  if( (screen->m_BlockLocate.GetState() != STATE_NO_BLOCK) && BlockIsSmall )
1340  {
1342  {
1343  m_endMouseCaptureCallback( this, &DC );
1344  m_requestAutoPan = false;
1345  }
1346 
1347  SetCursor( (wxStockCursor) m_currentCursor );
1348  }
1349  else if( screen->m_BlockLocate.GetState() == STATE_BLOCK_END )
1350  {
1351  m_requestAutoPan = false;
1352  GetParent()->HandleBlockEnd( &DC );
1353  SetCursor( (wxStockCursor) m_currentCursor );
1354  if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE )
1355  {
1356  m_requestAutoPan = true;
1357  SetCursor( wxCURSOR_HAND );
1358  }
1359  }
1360  }
1361  }
1362 
1363  // End of block command on a double click
1364  // To avoid an unwanted block move command if the mouse is moved while double clicking
1365  if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) )
1366  {
1367  if( !screen->IsBlockActive() && IsMouseCaptured() )
1368  {
1369  m_endMouseCaptureCallback( this, &DC );
1370  }
1371  }
1372 
1373  lastPanel = this;
1374 
1375 #ifdef WXGTK3
1376  // Screen has to be updated on every operation, otherwise the cursor leaves a trail (when xor
1377  // operation is changed to copy) or is not updated at all.
1378  Refresh();
1379 #endif
1380 }
#define GR_M_DCLICK
Definition: gr_basic.h:77
int m_canStartBlock
useful to avoid false start block in certain cases (like switch from a sheet to another sheet >= 0 (o...
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:266
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
#define GR_M_MIDDLE_DOWN
Definition: gr_basic.h:76
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:106
EDA_ITEM * GetCurItem() const
Definition: base_screen.h:233
virtual void HandleBlockPlace(wxDC *DC)
Function HandleBlockPlace( ) Called after HandleBlockEnd, when a block command needs to be executed a...
Definition: draw_frame.cpp:714
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:338
double GetScalingFactor() const
Function GetScalingFactor returns the inverse of the current scale used to draw items on screen...
Definition: base_screen.cpp:92
bool m_requestAutoPan
true to request an auto pan. Valid only when m_enableAutoPan = true.
int GetHeight() const
Definition: eda_rect.h:118
END_MOUSE_CAPTURE_CALLBACK m_endMouseCaptureCallback
Abort mouse capture callback function.
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
const wxPoint & GetScrollCenterPosition() const
wxPoint m_PanStartEventPosition
Initial position of mouse event when pan started.
bool m_enableBlockCommands
True enables block commands.
#define abs(a)
Definition: auxiliary.h:84
#define GR_KB_ALT
Definition: common.h:65
virtual bool HandleBlockBegin(wxDC *aDC, EDA_KEY aKey, const wxPoint &aPosition, int aExplicitCommand=0)
Initialize a block command.
Definition: draw_frame.cpp:882
bool IsBlockActive() const
Definition: base_screen.h:499
virtual BASE_SCREEN * GetScreen() const
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:369
#define GR_KB_SHIFT
Definition: common.h:66
virtual void OnLeftClick(wxDC *DC, const wxPoint &MousePos)=0
bool IsMouseCaptured() const
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
#define BLOCK_MINSIZE_LIMIT
bool m_ignoreMouseEvents
Ignore mouse events when true.
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
#define MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND
void CrossHairOff(wxDC *DC)
Definition: draw_panel.cpp:265
bool m_ignoreNextLeftButtonRelease
Ignore the next mouse left button release when true.
virtual bool HandleBlockEnd(wxDC *DC)
Function HandleBlockEnd( ) Handle the "end" of a block command, i.e.
Definition: draw_frame.cpp:719
wxPoint m_PanStartCenter
Initial scroll center position when pan started.
wxPoint RefPos(bool useMouse) const
Function RefPos Return the reference position, coming from either the mouse position or the cursor po...
void RedrawScreen(const wxPoint &aCenterPoint, bool aWarpPointer)
Function RedrawScreen redraws the entire screen area by updating the scroll bars and mouse pointer in...
Definition: zoom.cpp:46
#define GR_M_LEFT_DOWN
Definition: gr_basic.h:74
wxPoint m_CursorClickPos
Used for maintaining click position.
void CrossHairOn(wxDC *DC)
Definition: draw_panel.cpp:272
const int scale
void DisplayToolMsg(const wxString &msg)
Definition: draw_frame.cpp:553
void SetMousePosition(const wxPoint &aPosition)
BLOCK_STATE_T GetState() const
#define INSTALL_UNBUFFERED_DC(name, parent)
int m_currentCursor
Current mouse cursor shape id.
int GetToolId() const
Definition: draw_frame.h:496
wxTimer * m_ClickTimer
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:193
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:162
int GetWidth() const
Definition: eda_rect.h:117
bool OnRightClick(wxMouseEvent &event)
Function OnRightClick builds and displays a context menu on a right mouse button click.
Definition: draw_panel.cpp:899
int m_minDragEventCount
Count the drag events.
wxPoint m_CursorStartPos
Used for testing the cursor movement.
virtual bool GeneralControl(wxDC *aDC, const wxPoint &aPosition, EDA_KEY aHotKey=0)
Function GeneralControl performs application specific control using aDC at aPosition in logical units...
Definition: draw_frame.h:614
virtual void OnLeftDClick(wxDC *DC, const wxPoint &MousePos)
Definition: draw_frame.cpp:548
#define GR_KB_CTRL
Definition: common.h:64
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
void EDA_DRAW_PANEL::OnMouseLeaving ( wxMouseEvent &  event)

Definition at line 937 of file draw_panel.cpp.

References GetParent(), ID_POPUP_ZOOM_CENTER, INSTALL_UNBUFFERED_DC, m_enableAutoPan, m_ignoreMouseEvents, m_mouseCaptureCallback, m_requestAutoPan, EDA_DRAW_FRAME::SetCrossHairPosition(), wxPoint::x, and wxPoint::y.

Referenced by OnEraseBackground().

938 {
939  if( m_mouseCaptureCallback == NULL ) // No command in progress.
940  m_requestAutoPan = false;
941 
943  return;
944 
945  // Auto pan when mouse has left the client window
946  // Ensure the cross_hair position is updated,
947  // because it will be used to center the screen.
948  // We use a position inside the client window
949  wxRect area( wxPoint( 0, 0 ), GetClientSize() );
950  wxPoint cross_hair_pos = event.GetPosition();
951 
952  // Certain window managers (e.g. awesome wm) incorrectly trigger "on leave" event,
953  // therefore test if the cursor has really left the panel area
954  if( !area.Contains( cross_hair_pos ) )
955  {
956  INSTALL_UNBUFFERED_DC( dc, this );
957  cross_hair_pos.x = dc.DeviceToLogicalX( cross_hair_pos.x );
958  cross_hair_pos.y = dc.DeviceToLogicalY( cross_hair_pos.y );
959 
960  GetParent()->SetCrossHairPosition( cross_hair_pos );
961 
962  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_POPUP_ZOOM_CENTER );
963  cmd.SetEventObject( this );
964  GetEventHandler()->ProcessEvent( cmd );
965  }
966 
967  event.Skip();
968 }
bool m_requestAutoPan
true to request an auto pan. Valid only when m_enableAutoPan = true.
MOUSE_CAPTURE_CALLBACK m_mouseCaptureCallback
Mouse capture move callback function.
bool m_ignoreMouseEvents
Ignore mouse events when true.
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
#define INSTALL_UNBUFFERED_DC(name, parent)
bool m_enableAutoPan
True to enable automatic panning.
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Function SetCrossHairPosition sets the screen cross hair position to aPosition in logical (drawing) u...
void EDA_DRAW_PANEL::OnMouseWheel ( wxMouseEvent &  event)

Function OnMouseWheel handles mouse wheel events.

The mouse wheel is used to provide support for zooming and panning. This is accomplished by converting mouse wheel events in pseudo menu command events and sending them to the appropriate parent window event handler.

Definition at line 971 of file draw_panel.cpp.

References EDA_DRAW_FRAME::GetCursorPosition(), GetParent(), BASE_SCREEN::GetScalingFactor(), EDA_DRAW_FRAME::GetScreen(), EDA_DRAW_FRAME::GetScrollCenterPosition(), GetZoom(), ID_OFFCENTER_ZOOM_IN, ID_OFFCENTER_ZOOM_OUT, ID_PAN_DOWN, ID_PAN_LEFT, ID_POPUP_ZOOM_IN, ID_POPUP_ZOOM_OUT, INSTALL_UNBUFFERED_DC, kicadTraceCoords, KiROUND(), m_enableMousewheelPan, m_enableZoomNoCenter, m_ignoreMouseEvents, EDA_DRAW_FRAME::RedrawScreen(), scale, EDA_DRAW_FRAME::SetCrossHairPosition(), EDA_DRAW_FRAME::SetScrollCenterPosition(), SetZoom(), wxPoint::x, and wxPoint::y.

Referenced by OnEraseBackground().

972 {
973  if( m_ignoreMouseEvents )
974  return;
975 
976  wxRect rect = wxRect( wxPoint( 0, 0 ), GetClientSize() );
977 
978  // Ignore scroll events if the cursor is outside the drawing area.
979  if( event.GetWheelRotation() == 0 || !GetParent()->IsEnabled()
980  || !rect.Contains( event.GetPosition() ) )
981  {
982  wxLogTrace( kicadTraceCoords,
983  wxT( "OnMouseWheel() position(%d, %d) rectangle(%d, %d, %d, %d)" ),
984  event.GetPosition().x, event.GetPosition().y,
985  rect.x, rect.y, rect.width, rect.height );
986  event.Skip();
987  return;
988  }
989 
990  INSTALL_UNBUFFERED_DC( dc, this );
991  GetParent()->SetCrossHairPosition( event.GetLogicalPosition( dc ) );
992 
993  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
994  cmd.SetEventObject( this );
995 
996  bool offCenterReq = event.ControlDown() && event.ShiftDown();
997  offCenterReq = offCenterReq || m_enableZoomNoCenter;
998 
999  int axis = event.GetWheelAxis();
1000  int wheelRotation = event.GetWheelRotation();
1001 
1002  if( m_enableMousewheelPan )
1003  {
1004  // MousewheelPAN + Ctrl = zooming
1005  if( event.ControlDown() && !event.ShiftDown() )
1006  {
1007  if( wheelRotation > 0 )
1008  cmd.SetId( ID_POPUP_ZOOM_IN );
1009  else if( wheelRotation < 0)
1010  cmd.SetId( ID_POPUP_ZOOM_OUT );
1011  }
1012  // MousewheelPAN + Shift = horizontal scrolling
1013  // Without modifiers MousewheelPAN - just pan
1014  else
1015  {
1016  if( event.ShiftDown() && !event.ControlDown() )
1017  axis = wxMOUSE_WHEEL_HORIZONTAL;
1018 
1019  wxPoint newStart = GetViewStart();
1021  double scale = GetParent()->GetScreen()->GetScalingFactor();
1022 
1023  if( axis == wxMOUSE_WHEEL_HORIZONTAL )
1024  {
1025  newStart.x += wheelRotation;
1026  center.x += KiROUND( (double) wheelRotation / scale );
1027  }
1028  else
1029  {
1030  newStart.y -= wheelRotation;
1031  center.y -= KiROUND( (double) wheelRotation / scale );
1032  }
1033  Scroll( newStart );
1034 
1035  GetParent()->SetScrollCenterPosition( center );
1036  GetParent()->SetCrossHairPosition( center, true );
1037  GetParent()->RedrawScreen( center, false );
1038  }
1039  }
1040  else if( wheelRotation > 0 )
1041  {
1042  if( event.ShiftDown() && !event.ControlDown() )
1043  cmd.SetId( ID_PAN_UP );
1044  else if( event.ControlDown() && !event.ShiftDown() )
1045  cmd.SetId( ID_PAN_LEFT );
1046  else if( offCenterReq )
1047  cmd.SetId( ID_OFFCENTER_ZOOM_IN );
1048  else
1049  cmd.SetId( ID_POPUP_ZOOM_IN );
1050  }
1051  else if( wheelRotation < 0 )
1052  {
1053  if( event.ShiftDown() && !event.ControlDown() )
1054  cmd.SetId( ID_PAN_DOWN );
1055  else if( event.ControlDown() && !event.ShiftDown() )
1056  cmd.SetId( ID_PAN_RIGHT );
1057  else if( offCenterReq )
1058  cmd.SetId( ID_OFFCENTER_ZOOM_OUT );
1059  else
1060  cmd.SetId( ID_POPUP_ZOOM_OUT );
1061  }
1062 
1063  if( cmd.GetId() )
1064  GetEventHandler()->ProcessEvent( cmd );
1065  event.Skip();
1066 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:106
double GetScalingFactor() const
Function GetScalingFactor returns the inverse of the current scale used to draw items on screen...
Definition: base_screen.cpp:92
bool m_enableZoomNoCenter
True to enable zooming around the crosshair instead of the center.
void SetScrollCenterPosition(const wxPoint &aPoint)
const wxPoint & GetScrollCenterPosition() const
virtual BASE_SCREEN * GetScreen() const
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:369
bool m_ignoreMouseEvents
Ignore mouse events when true.
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
void RedrawScreen(const wxPoint &aCenterPoint, bool aWarpPointer)
Function RedrawScreen redraws the entire screen area by updating the scroll bars and mouse pointer in...
Definition: zoom.cpp:46
const int scale
bool m_enableMousewheelPan
True to enable mousewheel panning by default.
#define INSTALL_UNBUFFERED_DC(name, parent)
Definition: id.h:256
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Function SetCrossHairPosition sets the screen cross hair position to aPosition in logical (drawing) u...
const wxChar *const kicadTraceCoords
Flag to enable draw panel coordinate debug tracing.
void EDA_DRAW_PANEL::OnPaint ( wxPaintEvent &  event)

Definition at line 612 of file draw_panel.cpp.

References GetScreen(), INSTALL_PAINTDC, ReDraw(), and SetClipBox().

613 {
614  if( GetScreen() == NULL )
615  {
616  event.Skip();
617  return;
618  }
619 
620  INSTALL_PAINTDC( paintDC, this );
621 
622  wxRect region = GetUpdateRegion().GetBox();
623  SetClipBox( paintDC, &region );
624  ReDraw( &paintDC, true );
625 }
#define INSTALL_PAINTDC(name, parent)
void SetClipBox(const EDA_RECT &aRect)
void ReDraw(wxDC *aDC, bool aEraseBackground=true)
Definition: draw_panel.cpp:628
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:193
void EDA_DRAW_PANEL::OnPan ( wxCommandEvent &  event)

Definition at line 1454 of file draw_panel.cpp.

References GetParent(), BASE_SCREEN::GetScalingFactor(), EDA_DRAW_FRAME::GetScreen(), EDA_DRAW_FRAME::GetScrollCenterPosition(), ID_PAN_DOWN, ID_PAN_LEFT, kicadTraceCoords, KiROUND(), m_scrollIncrementX, m_scrollIncrementY, scale, EDA_DRAW_FRAME::SetScrollCenterPosition(), wxPoint::x, and wxPoint::y.

Referenced by OnEraseBackground().

1455 {
1456  int x, y;
1457  int ppux, ppuy;
1458  int unitsX, unitsY;
1459  int maxX, maxY;
1460  int tmpX, tmpY;
1461 
1462  GetViewStart( &x, &y );
1463  GetScrollPixelsPerUnit( &ppux, &ppuy );
1464  GetVirtualSize( &unitsX, &unitsY );
1465  tmpX = x;
1466  tmpY = y;
1467  maxX = unitsX;
1468  maxY = unitsY;
1469  unitsX /= ppux;
1470  unitsY /= ppuy;
1471 
1472  wxLogTrace( kicadTraceCoords,
1473  wxT( "Scroll center position before pan: (%d, %d)" ), tmpX, tmpY );
1474 
1475  switch( event.GetId() )
1476  {
1477  case ID_PAN_UP:
1478  y -= m_scrollIncrementY;
1479  break;
1480 
1481  case ID_PAN_DOWN:
1482  y += m_scrollIncrementY;
1483  break;
1484 
1485  case ID_PAN_LEFT:
1486  x -= m_scrollIncrementX;
1487  break;
1488 
1489  case ID_PAN_RIGHT:
1490  x += m_scrollIncrementX;
1491  break;
1492 
1493  default:
1494  wxLogDebug( wxT( "Unknown ID %d in EDA_DRAW_PANEL::OnPan()." ), event.GetId() );
1495  }
1496 
1497  bool updateCenterScrollPos = true;
1498 
1499  if( x < 0 )
1500  {
1501  x = 0;
1502  updateCenterScrollPos = false;
1503  }
1504 
1505  if( y < 0 )
1506  {
1507  y = 0;
1508  updateCenterScrollPos = false;
1509  }
1510 
1511  if( x > maxX )
1512  {
1513  x = maxX;
1514  updateCenterScrollPos = false;
1515  }
1516 
1517  if( y > maxY )
1518  {
1519  y = maxY;
1520  updateCenterScrollPos = false;
1521  }
1522 
1523  // Don't update the scroll position beyond the scroll limits.
1524  if( updateCenterScrollPos )
1525  {
1526  double scale = GetParent()->GetScreen()->GetScalingFactor();
1527 
1529  center.x += KiROUND( (double) ( x - tmpX ) / scale );
1530  center.y += KiROUND( (double) ( y - tmpY ) / scale );
1531  GetParent()->SetScrollCenterPosition( center );
1532 
1533  wxLogTrace( kicadTraceCoords,
1534  wxT( "Scroll center position after pan: (%d, %d)" ), center.x, center.y );
1535  }
1536 
1537  Scroll( x/ppux, y/ppuy );
1538 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:106
double GetScalingFactor() const
Function GetScalingFactor returns the inverse of the current scale used to draw items on screen...
Definition: base_screen.cpp:92
int m_scrollIncrementX
X axis scroll increment in pixels per unit.
void SetScrollCenterPosition(const wxPoint &aPoint)
const wxPoint & GetScrollCenterPosition() const
virtual BASE_SCREEN * GetScreen() const
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:369
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
const int scale
Definition: id.h:256
const wxChar *const kicadTraceCoords
Flag to enable draw panel coordinate debug tracing.
int m_scrollIncrementY
Y axis scroll increment in pixels per unit.
bool EDA_DRAW_PANEL::OnRightClick ( wxMouseEvent &  event)

Function OnRightClick builds and displays a context menu on a right mouse button click.

Returns
true if the context menu is shown, or false

Definition at line 899 of file draw_panel.cpp.

References EDA_DRAW_FRAME::AddMenuZoomAndGrid(), GetParent(), INSTALL_UNBUFFERED_DC, and m_ignoreMouseEvents.

Referenced by EDA_DRAW_FRAME::GeneralControl(), OnEraseBackground(), and OnMouseEvent().

900 {
901  wxPoint pos;
902  wxMenu MasterMenu;
903 
904  INSTALL_UNBUFFERED_DC( dc, this );
905 
906  pos = event.GetLogicalPosition( dc );
907 
908  if( !GetParent()->OnRightClick( pos, &MasterMenu ) )
909  return false;
910 
911  GetParent()->AddMenuZoomAndGrid( &MasterMenu );
912 
913  pos = event.GetPosition();
914  m_ignoreMouseEvents = true;
915  PopupMenu( &MasterMenu, pos );
916 
917  // The ZoomAndGrid menu is only invoked over empty space so there's no point in warping
918  // the cursor back to the crosshair, and it's very annoying if one clicked out of the menu.
919 
920  m_ignoreMouseEvents = false;
921 
922  return true;
923 }
bool m_ignoreMouseEvents
Ignore mouse events when true.
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
#define INSTALL_UNBUFFERED_DC(name, parent)
bool OnRightClick(wxMouseEvent &event)
Function OnRightClick builds and displays a context menu on a right mouse button click.
Definition: draw_panel.cpp:899
virtual void AddMenuZoomAndGrid(wxMenu *aMasterMenu)
Function AddMenuZoomAndGrid (virtual) Add standard zoom commands and submenu zoom and grid selection ...
Definition: zoom.cpp:266
void EDA_DRAW_PANEL::OnScroll ( wxScrollWinEvent &  event)

Definition at line 428 of file draw_panel.cpp.

References GetParent(), BASE_SCREEN::GetScalingFactor(), EDA_DRAW_FRAME::GetScreen(), EDA_DRAW_FRAME::GetScrollCenterPosition(), kicadTraceCoords, KiROUND(), m_scrollIncrementX, m_scrollIncrementY, scale, EDA_DRAW_FRAME::SetScrollCenterPosition(), wxPoint::x, and wxPoint::y.

Referenced by OnEraseBackground().

429 {
430  int id = event.GetEventType();
431  int x, y;
432  int ppux, ppuy;
433  int csizeX, csizeY;
434  int unitsX, unitsY;
435 
436  GetViewStart( &x, &y );
437  GetScrollPixelsPerUnit( &ppux, &ppuy );
438  GetClientSize( &csizeX, &csizeY );
439  GetVirtualSize( &unitsX, &unitsY );
440 
441  int tmpX = x;
442  int tmpY = y;
443 
444  csizeX /= ppux;
445  csizeY /= ppuy;
446 
447  unitsX /= ppux;
448  unitsY /= ppuy;
449 
450  int dir = event.GetOrientation(); // wxHORIZONTAL or wxVERTICAL
451 
452  // On windows and on wxWidgets >= 2.9.5 and < 3.1,
453  // there is a bug in mousewheel event which always generates 2 scroll events
454  // (should be the case only for the default mousewheel event)
455  // with id = wxEVT_SCROLLWIN_LINEUP or wxEVT_SCROLLWIN_LINEDOWN
456  // so we skip these events.
457  // Note they are here just in case, because they are not actually used
458  // in Kicad
459 #if wxCHECK_VERSION( 3, 1, 0 ) || !wxCHECK_VERSION( 2, 9, 5 ) || ( !defined (__WINDOWS__) && !defined (__WXMAC__) )
460  int maxX = unitsX - csizeX;
461  int maxY = unitsY - csizeY;
462 
463  if( id == wxEVT_SCROLLWIN_LINEUP )
464  {
465  if( dir == wxHORIZONTAL )
466  {
467  x -= m_scrollIncrementX;
468 
469  if( x < 0 )
470  x = 0;
471  }
472  else
473  {
474  y -= m_scrollIncrementY;
475 
476  if( y < 0 )
477  y = 0;
478  }
479  }
480  else if( id == wxEVT_SCROLLWIN_LINEDOWN )
481  {
482  if( dir == wxHORIZONTAL )
483  {
484  x += m_scrollIncrementX;
485  if( x > maxX )
486  x = maxX;
487  }
488  else
489  {
490  y += m_scrollIncrementY;
491 
492  if( y > maxY )
493  y = maxY;
494  }
495  }
496  else
497 #endif
498  if( id == wxEVT_SCROLLWIN_THUMBTRACK )
499  {
500  if( dir == wxHORIZONTAL )
501  x = event.GetPosition();
502  else
503  y = event.GetPosition();
504  }
505  else
506  {
507  event.Skip();
508  return;
509  }
510 
511  wxLogTrace( kicadTraceCoords,
512  wxT( "Setting scroll bars ppuX=%d, ppuY=%d, unitsX=%d, unitsY=%d, posX=%d, posY=%d" ),
513  ppux, ppuy, unitsX, unitsY, x, y );
514 
515  double scale = GetParent()->GetScreen()->GetScalingFactor();
516 
518  center.x += KiROUND( (double) ( x - tmpX ) / scale );
519  center.y += KiROUND( (double) ( y - tmpY ) / scale );
520  GetParent()->SetScrollCenterPosition( center );
521 
522  Scroll( x, y );
523  event.Skip();
524 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:106
double GetScalingFactor() const
Function GetScalingFactor returns the inverse of the current scale used to draw items on screen...
Definition: base_screen.cpp:92
int m_scrollIncrementX
X axis scroll increment in pixels per unit.
void SetScrollCenterPosition(const wxPoint &aPoint)
const wxPoint & GetScrollCenterPosition() const
virtual BASE_SCREEN * GetScreen() const
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:369
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
const int scale
const wxChar *const kicadTraceCoords
Flag to enable draw panel coordinate debug tracing.
int m_scrollIncrementY
Y axis scroll increment in pixels per unit.
void EDA_DRAW_PANEL::OnScrollWin ( wxCommandEvent &  event)

Referenced by OnEraseBackground().

void EDA_DRAW_PANEL::OnTimer ( wxTimerEvent &  event)

Function OnTimer handle timer events.

The class will start a timer when a mouse-up event is handled. If a double-click event is not handled inside of a specified interval, the timer event will fire, causing the single-click event to be handled. Otherwise, the system will process the double-click.

Definition at line 420 of file draw_panel.cpp.

References GetParent(), INSTALL_UNBUFFERED_DC, m_CursorClickPos, and EDA_DRAW_FRAME::OnLeftClick().

Referenced by OnEraseBackground().

421 {
422  INSTALL_UNBUFFERED_DC( DC, this );
423  DC.SetBackground( *wxBLACK_BRUSH );
425 }
virtual void OnLeftClick(wxDC *DC, const wxPoint &MousePos)=0
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
wxPoint m_CursorClickPos
Used for maintaining click position.
#define INSTALL_UNBUFFERED_DC(name, parent)
void EDA_DRAW_PANEL::ReDraw ( wxDC *  aDC,
bool  aEraseBackground = true 
)

Definition at line 628 of file draw_panel.cpp.

References BLACK, EraseScreen(), g_GhostColor, g_XorMode, EDA_RECT::GetBottom(), KIGFX::COLOR4D::GetBrightness(), EDA_DRAW_FRAME::GetDrawBgColor(), GetParent(), EDA_RECT::GetRight(), GetScreen(), EDA_RECT::GetX(), EDA_RECT::GetY(), GR_NXOR, GR_XOR, GRResetPenAndBrush(), kicadTraceCoords, m_ClipBox, EDA_DRAW_FRAME::RedrawActiveWindow(), and WHITE.

Referenced by OnEraseBackground(), and OnPaint().

629 {
630  BASE_SCREEN* Screen = GetScreen();
631 
632  if( Screen == NULL )
633  return;
634 
635  COLOR4D bgColor = GetParent()->GetDrawBgColor();
636 
637  // TODO(JE): Is this correct?
638  if( bgColor.GetBrightness() > 0.5 )
639  {
640  g_XorMode = GR_NXOR;
642  }
643  else
644  {
645  g_XorMode = GR_XOR;
647  }
648 
649  GRResetPenAndBrush( DC );
650 
651  DC->SetBackground( wxBrush( bgColor.ToColour() ) );
652  DC->SetBackgroundMode( wxSOLID );
653 
654  if( erasebg )
655  EraseScreen( DC );
656 
657  GetParent()->RedrawActiveWindow( DC, erasebg );
658 
659  // Verfies that the clipping is working correctly. If these two sets of numbers are
660  // not the same or really close. The clipping algorithms are broken.
661  wxLogTrace( kicadTraceCoords,
662  wxT( "Clip box: (%d, %d, %d, %d), Draw extents (%d, %d, %d, %d)" ),
664  DC->MinX(), DC->MinY(), DC->MaxX(), DC->MaxY() );
665 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:73
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:218
EDA_RECT m_ClipBox
The drawing area used to redraw the screen which is usually the visible area of the drawing in intern...
virtual COLOR4D GetDrawBgColor() const
Definition: draw_frame.h:346
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
double GetBrightness() const
Function GetBrightness Returns the brightness value of the color ranged from 0.0 to 1...
Definition: color4d.h:259
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
int GetBottom() const
Definition: eda_rect.h:122
int GetRight() const
Definition: eda_rect.h:119
virtual void RedrawActiveWindow(wxDC *DC, bool EraseBg)=0
int GetX() const
Definition: eda_rect.h:109
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:193
Definition: colors.h:49
int GetY() const
Definition: eda_rect.h:110
Definition: colors.h:45
void EraseScreen(wxDC *DC)
Definition: draw_panel.cpp:574
const wxChar *const kicadTraceCoords
Flag to enable draw panel coordinate debug tracing.
COLOR4D g_GhostColor
Draw color for moving objects.
Definition: common.cpp:58
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void EDA_DRAW_PANEL::Refresh ( bool  eraseBackground = true,
const wxRect *  rect = NULL 
)
overridevirtual

Update the board display after modifying it bu a python script (note: it is automatically called by action plugins, after running the plugin, so call this function is usually not needed inside action plugins.

Could be deprecated because modifying a board (especially deleting items) outside a action plugin can crash Pcbnew.

Definition at line 338 of file draw_panel.cpp.

References EDA_DRAW_FRAME::GetGalCanvas(), GetParent(), Refresh(), and EDA_DRAW_PANEL_GAL::Refresh().

Referenced by Abort_Edit_Pcb_Text(), Abort_EditEdge(), Abort_MoveOrCopyModule(), Abort_MoveTrack(), Abort_Zone_Move_Corner_Or_Outlines(), AbortCreateNewLine(), abortMoveBitmap(), abortMoveItem(), AbortPinMove(), AbortSymbolTraceOn(), DIALOG_GLOBAL_DELETION::AcceptPcbDelete(), SCH_EDIT_FRAME::AddNoConnect(), SCH_EDIT_FRAME::AnnotateComponents(), SCH_EDIT_FRAME::AppendSchematic(), PCB_EDIT_FRAME::Block_Delete(), PCB_EDIT_FRAME::Block_Duplicate(), PCB_EDIT_FRAME::Block_Flip(), PL_EDITOR_FRAME::Block_Move(), GERBVIEW_FRAME::Block_Move(), PCB_EDIT_FRAME::Block_Move(), PCB_EDIT_FRAME::Block_Rotate(), PCB_EDIT_FRAME::Check_All_Zones(), FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList(), FOOTPRINT_WIZARD_FRAME::ClickOnPageList(), PCB_EDIT_FRAME::Delete_Module(), PCB_EDIT_FRAME::Delete_OldZone_Fill(), SCH_EDIT_FRAME::DeleteAnnotation(), LIB_EDIT_FRAME::deleteItem(), SCH_EDIT_FRAME::DeleteItemAtCrossHair(), PCB_EDIT_FRAME::Edit_Zone_Params(), SCH_EDIT_FRAME::EditComponent(), SCH_EDIT_FRAME::EditComponentFieldText(), LIB_EDIT_FRAME::EditField(), LIB_EDIT_FRAME::EditGraphicSymbol(), SCH_EDIT_FRAME::EditImage(), SCH_EDIT_FRAME::EditSheetPin(), PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines(), LIB_EDIT_FRAME::EndDrawGraphicItem(), GERBVIEW_FRAME::Erase_Current_DrawLayer(), SCH_EDIT_FRAME::ExecuteRemoteCommand(), PL_EDITOR_FRAME::Files_io(), GERBVIEW_FRAME::Files_io(), PCB_EDIT_FRAME::Files_io_from_id(), PCB_EDIT_FRAME::FlipTextePcb(), GERBVIEW_FRAME::GERBVIEW_FRAME(), LIB_EDIT_FRAME::GetComponentFromRedoList(), LIB_EDIT_FRAME::GetComponentFromUndoList(), SCH_EDIT_FRAME::GetSchematicFromRedoList(), SCH_EDIT_FRAME::GetSchematicFromUndoList(), FOOTPRINT_EDIT_FRAME::HandleBlockEnd(), LIB_EDIT_FRAME::HandleBlockEnd(), SCH_EDIT_FRAME::HandleBlockEnd(), FOOTPRINT_EDIT_FRAME::HandleBlockPlace(), LIB_EDIT_FRAME::HandleBlockPlace(), SCH_EDIT_FRAME::HandleBlockPlace(), SCH_EDIT_FRAME::HighlightConnectionAtPosition(), SCH_EDIT_FRAME::importFile(), DISPLAY_FOOTPRINTS_FRAME::InitDisplay(), SCH_EDIT_FRAME::KiwayMailIn(), LIB_EDIT_FRAME::LoadOneSymbol(), SCH_EDIT_FRAME::MirrorImage(), SCH_EDIT_FRAME::MirrorSheet(), PCB_EDIT_FRAME::moveExact(), moveItem(), PL_EDITOR_FRAME::MoveItem(), PROPERTIES_FRAME::OnAcceptPrms(), DIALOG_EDIT_COMPONENTS_LIBID::onApplyButton(), DIALOG_EXCHANGE_FOOTPRINTS::OnApplyClick(), DIALOG_ANNOTATE::OnApplyClick(), LIB_EDIT_FRAME::OnEditComponentProperties(), SCH_EDIT_FRAME::OnEditItem(), FOOTPRINT_EDIT_FRAME::OnEditItemRequest(), LIB_EDIT_FRAME::OnEditPin(), OnEraseBackground(), DIALOG_ERC::OnEraseDrcMarkersClick(), FOOTPRINT_EDIT_FRAME::OnHotKey(), PCB_EDIT_FRAME::OnHotKey(), GERBVIEW_FRAME::OnHotKey(), PCB_LAYER_WIDGET::OnLayerColorChange(), GERBER_LAYER_WIDGET::OnLayerColorChange(), PCB_LAYER_WIDGET::OnLayerSelect(), GERBER_LAYER_WIDGET::OnLayerSelect(), PCB_LAYER_WIDGET::OnLayerVisible(), GERBER_LAYER_WIDGET::OnLayerVisible(), FOOTPRINT_EDIT_FRAME::OnLeftClick(), PL_EDITOR_FRAME::OnLeftClick(), PCB_EDIT_FRAME::OnLeftClick(), FOOTPRINT_EDIT_FRAME::OnLeftDClick(), SCH_EDIT_FRAME::OnLeftDClick(), OnMouseEvent(), PL_EDITOR_FRAME::OnNewPageLayout(), DIALOG_DISPLAY_OPTIONS::OnOKBUttonClick(), DIALOG_GENERALOPTIONS::OnOkClick(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnOkClick(), DIALOG_PAGES_SETTINGS::OnOkClick(), SCH_EDIT_FRAME::OnOrient(), GERBER_LAYER_WIDGET::onPopupSelection(), LIB_EDIT_FRAME::OnPreferencesOptions(), SCH_EDIT_FRAME::OnPreferencesOptions(), PCB_LAYER_WIDGET::OnRenderColorChange(), GERBER_LAYER_WIDGET::OnRenderColorChange(), PCB_LAYER_WIDGET::OnRenderEnable(), GERBER_LAYER_WIDGET::OnRenderEnable(), PL_EDITOR_FRAME::OnRightClick(), SCH_EDIT_FRAME::OnRotate(), LIB_EDIT_FRAME::OnRotateItem(), GERBVIEW_FRAME::OnSelectActiveDCode(), LIB_EDIT_FRAME::OnSelectAlias(), LIB_EDIT_FRAME::OnSelectBodyStyle(), PL_EDITOR_FRAME::OnSelectCoordOriginCorner(), GERBVIEW_FRAME::OnSelectDisplayMode(), EDA_DRAW_FRAME::OnSelectGrid(), GERBVIEW_FRAME::OnSelectHighlightChoice(), DISPLAY_FOOTPRINTS_FRAME::OnSelectOptionToolbar(), FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar(), SCH_EDIT_FRAME::OnSelectOptionToolbar(), GERBVIEW_FRAME::OnSelectOptionToolbar(), PCB_EDIT_FRAME::OnSelectOptionToolbar(), LIB_EDIT_FRAME::OnSelectPart(), LIB_VIEW_FRAME::onSelectSymbolBodyStyle(), LIB_VIEW_FRAME::onSelectSymbolUnit(), PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode(), SCH_EDIT_FRAME::OnSelectUnit(), PROPERTIES_FRAME::OnSetDefaultValues(), LIB_VIEW_FRAME::OnShowElectricalType(), LIB_EDIT_FRAME::OnShowElectricalType(), PCB_BASE_FRAME::OnToggleEdgeDrawMode(), PCB_BASE_FRAME::OnToggleGraphicDrawMode(), EDA_DRAW_FRAME::OnToggleGridState(), PCB_BASE_FRAME::OnTogglePadDrawMode(), PCB_BASE_FRAME::OnToggleTextDrawMode(), PL_EDITOR_FRAME::OnTreeSelection(), EDA_DRAW_FRAME::OnZoom(), SCH_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::OrientComponent(), DIALOG_UPDATE_PCB::PerformUpdate(), FOOTPRINT_EDIT_FRAME::Place_EdgeMod(), PCB_EDIT_FRAME::Place_Texte_Pcb(), LIB_EDIT_FRAME::PlaceAnchor(), PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment(), PCB_BASE_FRAME::PlaceModule(), LIB_EDIT_FRAME::PlacePin(), SCH_EDIT_FRAME::PrepareMoveItem(), PL_EDITOR_FRAME::Process_Config(), PCB_EDIT_FRAME::Process_Config(), EDA_DRAW_FRAME::Process_PageSettings(), LIB_EDIT_FRAME::Process_Special_Functions(), SCH_EDIT_FRAME::Process_Special_Functions(), PCB_EDIT_FRAME::Process_Special_Functions(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), LIB_VIEW_FRAME::ReCreateListLib(), FOOTPRINT_WIZARD_FRAME::ReCreatePageList(), DIALOG_DRC_CONTROL::RedrawDrawPanel(), EDA_DRAW_FRAME::RedrawScreen(), EDA_DRAW_FRAME::RedrawScreen2(), Refresh(), FOOTPRINT_WIZARD_FRAME::ReloadFootprint(), SCH_EDIT_FRAME::RepeatDrawItem(), PCB_BASE_FRAME::ResetTextSize(), DIALOG_EDIT_COMPONENTS_LIBID::revertChanges(), PCB_BASE_FRAME::Rotate_Module(), PCB_EDIT_FRAME::Rotate_Texte_Pcb(), SCH_EDIT_FRAME::RotateHierarchicalSheet(), SCH_EDIT_FRAME::RotateImage(), FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint(), FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint(), PCB_BASE_FRAME::SetFastGrid1(), PCB_BASE_FRAME::SetFastGrid2(), PCB_BASE_FRAME::SetNextGrid(), PCB_BASE_FRAME::SetPrevGrid(), LIB_VIEW_FRAME::SetSelectedComponent(), LIB_VIEW_FRAME::SetSelectedLibrary(), PCB_BASE_FRAME::SetToolID(), PCB_EDIT_FRAME::Show_1_Ratsnest(), GERBVIEW_FRAME::SortLayersByX2Attributes(), LIB_EDIT_FRAME::StartMovePin(), PCB_EDIT_FRAME::StartMoveTextePcb(), PCB_BASE_FRAME::SwitchLayer(), PCB_EDIT_FRAME::SwitchLayer(), DIALOG_ERC::TestErc(), PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event(), WIDGET_EESCHEMA_COLOR_CONFIG::TransferDataFromControl(), DIALOG_DISPLAY_OPTIONS::TransferDataFromWindow(), DIALOG_MODEDIT_DISPLAY_OPTIONS::TransferDataFromWindow(), GERBVIEW_FRAME::UpdateDisplayOptions(), DIALOG_FOOTPRINTS_DISPLAY_OPTIONS::UpdateObjectSettings(), and GERBVIEW_FRAME::UseGalCanvas().

339 {
340  if( GetParent()->IsGalCanvasActive() )
341  {
343  }
344  else
345  {
346  wxScrolledWindow::Refresh( eraseBackground, rect );
347  }
348 }
void Refresh()
Update the board display after modifying it bu a python script (note: it is automatically called by a...
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
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...
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:903
void EDA_DRAW_PANEL::RefreshDrawingRect ( const EDA_RECT aRect,
bool  aEraseBackground = true 
)

Function RefreshDrawingRect redraws the contents of aRect in drawing units.

aRect is converted to screen coordinates and wxWindow::RefreshRect() is called to repaint the region.

Parameters
aRectThe rectangle to repaint.
aEraseBackgroundErases the background if true.

Definition at line 318 of file draw_panel.cpp.

References EDA_RECT::GetHeight(), EDA_RECT::GetWidth(), EDA_RECT::GetX(), EDA_RECT::GetY(), INSTALL_UNBUFFERED_DC, and kicadTraceCoords.

Referenced by AbortMoveTextModule(), PCB_BASE_FRAME::AddPad(), PCB_EDIT_FRAME::Change_Side_Module(), PCB_EDIT_FRAME::Delete_net(), PCB_EDIT_FRAME::Delete_Segment(), PCB_EDIT_FRAME::Delete_Zone_Contour(), SCH_EDIT_FRAME::DeleteItem(), PCB_BASE_FRAME::DeletePad(), PCB_BASE_FRAME::DeleteTextModule(), PCB_BASE_FRAME::GlobalChange_PadSettings(), PCB_BASE_FRAME::Import_Pad_Settings(), moveBitmap(), OnEraseBackground(), PCB_BASE_FRAME::PlaceTexteModule(), SCH_EDIT_FRAME::Process_Special_Functions(), PCB_EDIT_FRAME::Remove_One_Track(), PCB_EDIT_FRAME::Remove_Zone_Corner(), PCB_BASE_FRAME::Rotate_Module(), PCB_EDIT_FRAME::StartMoveModule(), DIALOG_LABEL_EDITOR::TextPropertiesAccept(), and DIALOG_PAD_PROPERTIES::TransferDataFromWindow().

319 {
320  INSTALL_UNBUFFERED_DC( dc, this );
321 
322  wxRect rect = aRect;
323 
324  rect.x = dc.LogicalToDeviceX( rect.x );
325  rect.y = dc.LogicalToDeviceY( rect.y );
326  rect.width = dc.LogicalToDeviceXRel( rect.width );
327  rect.height = dc.LogicalToDeviceYRel( rect.height );
328 
329  wxLogTrace( kicadTraceCoords,
330  wxT( "Refresh area: drawing (%d, %d, %d, %d), device (%d, %d, %d, %d)" ),
331  aRect.GetX(), aRect.GetY(), aRect.GetWidth(), aRect.GetHeight(),
332  rect.x, rect.y, rect.width, rect.height );
333 
334  RefreshRect( rect, aEraseBackground );
335 }
int GetHeight() const
Definition: eda_rect.h:118
#define INSTALL_UNBUFFERED_DC(name, parent)
int GetX() const
Definition: eda_rect.h:109
int GetWidth() const
Definition: eda_rect.h:117
int GetY() const
Definition: eda_rect.h:110
const wxChar *const kicadTraceCoords
Flag to enable draw panel coordinate debug tracing.
void EDA_DRAW_PANEL::SetCanStartBlock ( int  aStartBlock)
inline

Definition at line 170 of file class_drawpanel.h.

References DrawAuxiliaryAxis(), DrawBackGround(), DrawGrid(), and DrawGridAxis().

Referenced by EDA_DRAW_FRAME::OnActivate(), EDA_DRAW_FRAME::OnMenuOpen(), GERBVIEW_FRAME::OnRightClick(), SCH_EDIT_FRAME::OnRightClick(), and PCB_EDIT_FRAME::OnRightClick().

170 { m_canStartBlock = aStartBlock; }
int m_canStartBlock
useful to avoid false start block in certain cases (like switch from a sheet to another sheet >= 0 (o...
void EDA_DRAW_PANEL::SetClipBox ( const EDA_RECT aRect)
inline

Definition at line 141 of file class_drawpanel.h.

Referenced by DoPrepareDC(), GBR_LAYOUT::Draw(), PLEDITOR_PRINTOUT::DrawPage(), SCH_PRINTOUT::DrawPage(), BOARD_PRINTOUT_CONTROLLER::DrawPage(), DrawPageOnClipboard(), IsPointOnDisplay(), OnEraseBackground(), and OnPaint().

141 { m_ClipBox = aRect; }
EDA_RECT m_ClipBox
The drawing area used to redraw the screen which is usually the visible area of the drawing in intern...
void EDA_DRAW_PANEL::SetClipBox ( wxDC &  aDC,
const wxRect *  aRect = NULL 
)

Function SetClipBox sets the clip box in drawing (logical) units from aRect in device units.

If aRect is NULL, then the entire visible area of the screen is used as the clip area. The clip box is used when drawing to determine which objects are not visible and do not need to be drawn. Note that this is not the same as setting the device context clipping with wxDC::SetClippingRegion(). This is the rectangle used by the drawing functions in gr_basic.cpp used to determine if the item to draw is off screen and therefore not drawn.

Parameters
aDCThe device context use for drawing with the correct scale and offsets already configured. See DoPrepareDC().
aRectThe clip rectangle in device units or NULL for the entire visible area of the screen.

Definition at line 527 of file draw_panel.cpp.

References CLIP_BOX_PADDING, BASE_SCREEN::GetGridSize(), EDA_RECT::GetHeight(), BASE_SCREEN::GetScalingFactor(), GetScreen(), EDA_RECT::GetWidth(), EDA_RECT::GetX(), EDA_RECT::GetY(), kicadTraceCoords, KiROUND(), m_ClipBox, BASE_SCREEN::m_ScrollbarPos, m_scrollIncrementX, m_scrollIncrementY, BASE_SCREEN::m_StartVisu, max, EDA_RECT::SetOrigin(), EDA_RECT::SetSize(), wxPoint::x, and wxPoint::y.

528 {
529  wxRect clipBox;
530 
531  // Use the entire visible device area if no clip area was defined.
532  if( aRect == NULL )
533  {
534  BASE_SCREEN* Screen = GetScreen();
535 
536  if( !Screen )
537  return;
538 
539  Screen->m_StartVisu = CalcUnscrolledPosition( wxPoint( 0, 0 ) );
540  clipBox.SetSize( GetClientSize() );
541 
542  int scrollX, scrollY;
543 
544  double scalar = Screen->GetScalingFactor();
545  scrollX = KiROUND( Screen->GetGridSize().x * scalar );
546  scrollY = KiROUND( Screen->GetGridSize().y * scalar );
547 
548  m_scrollIncrementX = std::max( GetClientSize().x / 8, scrollX );
549  m_scrollIncrementY = std::max( GetClientSize().y / 8, scrollY );
550  Screen->m_ScrollbarPos.x = GetScrollPos( wxHORIZONTAL );
551  Screen->m_ScrollbarPos.y = GetScrollPos( wxVERTICAL );
552  }
553  else
554  {
555  clipBox = *aRect;
556  }
557 
558  // Pad clip box in device units.
559  clipBox.Inflate( CLIP_BOX_PADDING );
560 
561  // Convert from device units to drawing units.
562  m_ClipBox.SetOrigin( wxPoint( aDC.DeviceToLogicalX( clipBox.x ),
563  aDC.DeviceToLogicalY( clipBox.y ) ) );
564  m_ClipBox.SetSize( wxSize( aDC.DeviceToLogicalXRel( clipBox.width ),
565  aDC.DeviceToLogicalYRel( clipBox.height ) ) );
566 
567  wxLogTrace( kicadTraceCoords,
568  wxT( "Device clip box=(%d, %d, %d, %d), Logical clip box=(%d, %d, %d, %d)" ),
569  clipBox.x, clipBox.y, clipBox.width, clipBox.height,
571 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:106
double GetScalingFactor() const
Function GetScalingFactor returns the inverse of the current scale used to draw items on screen...
Definition: base_screen.cpp:92
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...
int GetHeight() const
Definition: eda_rect.h:118
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
wxPoint m_StartVisu
Coordinates in drawing units of the current view position (upper left corner of device) ...
Definition: base_screen.h:198
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
#define CLIP_BOX_PADDING
Definition: draw_panel.cpp:50
wxPoint m_ScrollbarPos
Current scroll bar position in scroll units.
Definition: base_screen.h:196
void SetSize(const wxSize &size)
Definition: eda_rect.h:126
#define max(a, b)
Definition: auxiliary.h:86
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:410
int GetX() const
Definition: eda_rect.h:109
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:193
int GetWidth() const
Definition: eda_rect.h:117
int GetY() const
Definition: eda_rect.h:110
const wxChar *const kicadTraceCoords
Flag to enable draw panel coordinate debug tracing.
int m_scrollIncrementY
Y axis scroll increment in pixels per unit.
void EDA_DRAW_PANEL::SetCurrentCursor ( int  aCursor)
inline

Function SetCurrentCursor Set the current cursor shape for drawpanel.

Definition at line 456 of file class_drawpanel.h.

Referenced by EDA_DRAW_FRAME::SetToolID().

457  {
458  m_currentCursor = aCursor;
459  SetCursor( (wxStockCursor) m_currentCursor );
460  }
int m_currentCursor
Current mouse cursor shape id.
void EDA_DRAW_PANEL::SetEnableAutoPan ( bool  aEnable)

Definition at line 676 of file draw_panel.cpp.

References KIGFX::VIEW_CONTROLS::EnableAutoPan(), EDA_DRAW_FRAME::GetGalCanvas(), GetParent(), EDA_DRAW_PANEL_GAL::GetViewControls(), and m_enableAutoPan.

Referenced by GetEnableAutoPan(), DIALOG_GENERALOPTIONS::OnOkClick(), SCH_EDIT_FRAME::OnPreferencesOptions(), EDA_DRAW_FRAME::PushPreferences(), and DIALOG_FOOTPRINTS_DISPLAY_OPTIONS::UpdateObjectSettings().

677 {
678  m_enableAutoPan = aEnable;
679 
680  if( GetParent()->IsGalCanvasActive() )
682 }
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
virtual void EnableAutoPan(bool aEnabled)
Function EnableAutoPan Turns on/off auto panning (user setting to disable it entirely).
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel...
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:903
bool m_enableAutoPan
True to enable automatic panning.
void EDA_DRAW_PANEL::SetEnableBlockCommands ( bool  aEnable)
inline

Definition at line 165 of file class_drawpanel.h.

Referenced by GERBVIEW_FRAME::GERBVIEW_FRAME(), and PL_EDITOR_FRAME::PL_EDITOR_FRAME().

165 { m_enableBlockCommands = aEnable; }
bool m_enableBlockCommands
True enables block commands.
void EDA_DRAW_PANEL::SetEnableMousewheelPan ( bool  aEnable)

Definition at line 668 of file draw_panel.cpp.

References KIGFX::VIEW_CONTROLS::EnableMousewheelPan(), EDA_DRAW_FRAME::GetGalCanvas(), GetParent(), EDA_DRAW_PANEL_GAL::GetViewControls(), and m_enableMousewheelPan.

Referenced by GetEnableMousewheelPan(), DIALOG_DISPLAY_OPTIONS::OnOKBUttonClick(), DIALOG_GENERALOPTIONS::OnOkClick(), SCH_EDIT_FRAME::OnPreferencesOptions(), and DIALOG_FOOTPRINTS_DISPLAY_OPTIONS::UpdateObjectSettings().

669 {
670  m_enableMousewheelPan = aEnable;
671 
672  if( GetParent()->IsGalCanvasActive() )
674 }
virtual void EnableMousewheelPan(bool aEnable)
Function EnableMousewheelPan() Enables or disables mousewheel panning.
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
bool m_enableMousewheelPan
True to enable mousewheel panning by default.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel...
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:903
void EDA_DRAW_PANEL::SetEnableZoomNoCenter ( bool  aEnable)

Definition at line 685 of file draw_panel.cpp.

References KIGFX::VIEW_CONTROLS::EnableCursorWarping(), EDA_DRAW_FRAME::GetGalCanvas(), GetParent(), EDA_DRAW_PANEL_GAL::GetViewControls(), and m_enableZoomNoCenter.

Referenced by GetEnableZoomNoCenter(), DIALOG_DISPLAY_OPTIONS::OnOKBUttonClick(), DIALOG_GENERALOPTIONS::OnOkClick(), SCH_EDIT_FRAME::OnPreferencesOptions(), EDA_DRAW_FRAME::PushPreferences(), and DIALOG_FOOTPRINTS_DISPLAY_OPTIONS::UpdateObjectSettings().

686 {
687  m_enableZoomNoCenter = aEnable;
688 
689  if( GetParent()->IsGalCanvasActive() )
691 }
bool m_enableZoomNoCenter
True to enable zooming around the crosshair instead of the center.
void EnableCursorWarping(bool aEnable)
Function EnableCursorWarping() Enables or disables warping the cursor.
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel...
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:903
void EDA_DRAW_PANEL::SetGrid ( const wxRealPoint &  size)

Referenced by OnEraseBackground().

void EDA_DRAW_PANEL::SetIgnoreLeftButtonReleaseEvent ( bool  aIgnore)
inline

Definition at line 163 of file class_drawpanel.h.

Referenced by EDA_DRAW_FRAME::SkipNextLeftButtonReleaseEvent().

163 { m_ignoreNextLeftButtonRelease = aIgnore; }
bool m_ignoreNextLeftButtonRelease
Ignore the next mouse left button release when true.
void EDA_DRAW_PANEL::SetMouseCapture ( MOUSE_CAPTURE_CALLBACK  aMouseCaptureCallback,
END_MOUSE_CAPTURE_CALLBACK  aEndMouseCaptureCallback 
)
inline

Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallback and aEndMouseCaptureCallback respectively.

Definition at line 400 of file class_drawpanel.h.

Referenced by Abort_Edit_Pcb_Text(), Abort_EditEdge(), Abort_Move_ModuleOutline(), Abort_Move_Pad(), Abort_MoveOrCopyModule(), Abort_MoveTrack(), Abort_Zone_Create_Outline(), Abort_Zone_Move_Corner_Or_Outlines(), AbortBlockCurrentCommand(), AbortMoveAndEditTarget(), AbortMoveDimensionText(), abortMoveItem(), AbortMoveTextModule(), PCB_EDIT_FRAME::Begin_DrawSegment(), FOOTPRINT_EDIT_FRAME::Begin_Edge_Module(), PCB_EDIT_FRAME::Begin_Route(), PCB_EDIT_FRAME::Begin_Self(), PCB_EDIT_FRAME::Begin_Zone(), SCH_EDIT_FRAME::BeginSegment(), LIB_EDIT_FRAME::CreateGraphicItem(), SCH_EDIT_FRAME::CreateNewImage(), LIB_EDIT_FRAME::CreatePin(), SCH_EDIT_FRAME::CreateSheet(), PCB_EDIT_FRAME::Delete_LastCreatedCorner(), PCB_EDIT_FRAME::Delete_Segment(), PCB_EDIT_FRAME::Delete_Texte_Pcb(), PCB_EDIT_FRAME::End_Edge(), FOOTPRINT_EDIT_FRAME::End_Edge_Module(), PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines(), PCB_EDIT_FRAME::End_Route(), PCB_EDIT_FRAME::End_Zone(), LIB_EDIT_FRAME::EndDrawGraphicItem(), Exit_Self(), LIB_EDIT_FRAME::HandleBlockEnd(), SCH_EDIT_FRAME::HandleBlockEnd(), BLOCK_SELECTOR::InitData(), moveBitmap(), SCH_EDIT_FRAME::MoveImage(), PL_EDITOR_FRAME::MoveItem(), SCH_FIELD::Place(), PCB_EDIT_FRAME::Place_DrawItem(), FOOTPRINT_EDIT_FRAME::Place_EdgeMod(), PCB_EDIT_FRAME::Place_Texte_Pcb(), PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment(), PL_EDITOR_FRAME::PlaceItem(), PCB_BASE_FRAME::PlaceModule(), PCB_BASE_FRAME::PlacePad(), LIB_EDIT_FRAME::PlacePin(), PCB_BASE_FRAME::PlaceTexteModule(), SCH_EDIT_FRAME::PrepareMoveItem(), SCH_EDIT_FRAME::ReSizeSheet(), PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope(), PCB_EDIT_FRAME::Start_Move_DrawItem(), FOOTPRINT_EDIT_FRAME::Start_Move_EdgeMod(), PCB_EDIT_FRAME::Start_Move_Zone_Corner(), PCB_EDIT_FRAME::Start_Move_Zone_Drag_Outline_Edge(), PCB_EDIT_FRAME::Start_Move_Zone_Outlines(), LIB_EDIT_FRAME::StartModifyDrawSymbol(), LIB_EDIT_FRAME::StartMoveDrawSymbol(), PCB_EDIT_FRAME::StartMoveModule(), PCB_EDIT_FRAME::StartMoveOneNodeOrSegment(), PCB_BASE_FRAME::StartMovePad(), LIB_EDIT_FRAME::StartMovePin(), PCB_BASE_FRAME::StartMoveTexteModule(), and PCB_EDIT_FRAME::StartMoveTextePcb().

402  {
403  m_mouseCaptureCallback = aMouseCaptureCallback;
404  m_endMouseCaptureCallback = aEndMouseCaptureCallback;
405  }
END_MOUSE_CAPTURE_CALLBACK m_endMouseCaptureCallback
Abort mouse capture callback function.
MOUSE_CAPTURE_CALLBACK m_mouseCaptureCallback
Mouse capture move callback function.
void EDA_DRAW_PANEL::SetPrintMirrored ( bool  aMirror)
inline

Definition at line 168 of file class_drawpanel.h.

Referenced by FOOTPRINT_EDIT_FRAME::PrintPage(), PCB_EDIT_FRAME::PrintPage(), and GERBVIEW_FRAME::PrintPage().

168 { m_PrintIsMirrored = aMirror; }
bool m_PrintIsMirrored
True when drawing in mirror mode.
void EDA_DRAW_PANEL::SetZoom ( double  mode)

Definition at line 288 of file draw_panel.cpp.

References GetScreen(), and BASE_SCREEN::SetZoom().

Referenced by OnEraseBackground(), OnMouseWheel(), and EDA_DRAW_FRAME::UseGalCanvas().

289 {
290  GetScreen()->SetZoom( zoom );
291 }
bool SetZoom(double iu_per_du)
Function SetZoom adjusts the current zoom factor.
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:193
wxPoint EDA_DRAW_PANEL::ToDeviceXY ( const wxPoint pos)

Function ToDeviceXY transforms logical to device coordinates.

Definition at line 201 of file draw_panel.cpp.

References INSTALL_UNBUFFERED_DC, wxPoint::x, and wxPoint::y.

Referenced by OnEraseBackground(), EDA_DRAW_FRAME::OnZoom(), and EDA_DRAW_FRAME::RedrawScreen2().

202 {
203  wxPoint ret;
204  INSTALL_UNBUFFERED_DC( dc, this );
205  ret.x = dc.LogicalToDeviceX( pos.x );
206  ret.y = dc.LogicalToDeviceY( pos.y );
207  return ret;
208 }
#define INSTALL_UNBUFFERED_DC(name, parent)
wxPoint EDA_DRAW_PANEL::ToLogicalXY ( const wxPoint pos)

Function ToLogicalXY transforms device to logical coordinates.

Definition at line 211 of file draw_panel.cpp.

References INSTALL_UNBUFFERED_DC, wxPoint::x, and wxPoint::y.

Referenced by OnEraseBackground(), and EDA_DRAW_FRAME::RedrawScreen2().

212 {
213  wxPoint ret;
214  INSTALL_UNBUFFERED_DC( dc, this );
215  ret.x = dc.DeviceToLogicalX( pos.x );
216  ret.y = dc.DeviceToLogicalY( pos.y );
217  return ret;
218 }
#define INSTALL_UNBUFFERED_DC(name, parent)

Member Data Documentation

bool EDA_DRAW_PANEL::m_abortRequest
private

Flag used to abort long commands.

Definition at line 76 of file class_drawpanel.h.

Referenced by EDA_DRAW_PANEL(), GetAbortRequest(), and OnKeyEvent().

int EDA_DRAW_PANEL::m_canStartBlock
private

useful to avoid false start block in certain cases (like switch from a sheet to another sheet >= 0 (or >= n) if a block can start

Definition at line 117 of file class_drawpanel.h.

Referenced by EDA_DRAW_PANEL(), OnActivate(), and OnMouseEvent().

wxTimer* EDA_DRAW_PANEL::m_ClickTimer
private

Definition at line 70 of file class_drawpanel.h.

Referenced by EDA_DRAW_PANEL(), OnMouseEvent(), and ~EDA_DRAW_PANEL().

EDA_RECT EDA_DRAW_PANEL::m_ClipBox
private

The drawing area used to redraw the screen which is usually the visible area of the drawing in internal units.

Definition at line 74 of file class_drawpanel.h.

Referenced by DrawAuxiliaryAxis(), DrawBackGround(), DrawCrossHair(), DrawGrid(), DrawGridAxis(), EDA_DRAW_PANEL(), EraseScreen(), GetClipBox(), IsPointOnDisplay(), ReDraw(), and SetClipBox().

int EDA_DRAW_PANEL::m_currentCursor
private

Current mouse cursor shape id.

Definition at line 58 of file class_drawpanel.h.

Referenced by EDA_DRAW_PANEL(), GetCurrentCursor(), and OnMouseEvent().

wxPoint EDA_DRAW_PANEL::m_CursorClickPos
private

Used for maintaining click position.

Definition at line 69 of file class_drawpanel.h.

Referenced by OnMouseEvent(), and OnTimer().

int EDA_DRAW_PANEL::m_cursorLevel
private

Index for cursor redraw in XOR mode.

Definition at line 61 of file class_drawpanel.h.

Referenced by CrossHairOff(), CrossHairOn(), DrawCrossHair(), EDA_DRAW_PANEL(), and OnMouseEntering().

wxPoint EDA_DRAW_PANEL::m_CursorStartPos
private

Used for testing the cursor movement.

Definition at line 65 of file class_drawpanel.h.

Referenced by OnMouseEvent().

int EDA_DRAW_PANEL::m_defaultCursor
private

The default mouse cursor shape id.

Definition at line 59 of file class_drawpanel.h.

Referenced by EDA_DRAW_PANEL(), GetDefaultCursor(), and OnKeyEvent().

int EDA_DRAW_PANEL::m_doubleClickInterval
private

Definition at line 119 of file class_drawpanel.h.

Referenced by EDA_DRAW_PANEL(), and OnMouseEvent().

bool EDA_DRAW_PANEL::m_enableAutoPan
private

True to enable automatic panning.

Definition at line 81 of file class_drawpanel.h.

Referenced by EDA_DRAW_PANEL(), GetEnableAutoPan(), OnMouseLeaving(), SetEnableAutoPan(), and ~EDA_DRAW_PANEL().

bool EDA_DRAW_PANEL::m_enableBlockCommands
private

True enables block commands.

Definition at line 94 of file class_drawpanel.h.

Referenced by EDA_DRAW_PANEL(), and OnMouseEvent().

bool EDA_DRAW_PANEL::m_enableMousewheelPan
private

True to enable mousewheel panning by default.

Definition at line 79 of file class_drawpanel.h.

Referenced by EDA_DRAW_PANEL(), GetEnableMousewheelPan(), OnMouseWheel(), SetEnableMousewheelPan(), and ~EDA_DRAW_PANEL().

bool EDA_DRAW_PANEL::m_enableZoomNoCenter
private

True to enable zooming around the crosshair instead of the center.

Definition at line 78 of file class_drawpanel.h.

Referenced by EDA_DRAW_PANEL(), GetEnableZoomNoCenter(), OnMouseWheel(), SetEnableZoomNoCenter(), and ~EDA_DRAW_PANEL().

END_MOUSE_CAPTURE_CALLBACK EDA_DRAW_PANEL::m_endMouseCaptureCallback
private

Abort mouse capture callback function.

Definition at line 112 of file class_drawpanel.h.

Referenced by CallEndMouseCapture(), EDA_DRAW_PANEL(), EndMouseCapture(), and OnMouseEvent().

bool EDA_DRAW_PANEL::m_ignoreMouseEvents
private

Ignore mouse events when true.

Definition at line 85 of file class_drawpanel.h.

Referenced by EDA_DRAW_PANEL(), OnMouseEvent(), OnMouseLeaving(), OnMouseWheel(), and OnRightClick().

bool EDA_DRAW_PANEL::m_ignoreNextLeftButtonRelease
private

Ignore the next mouse left button release when true.

Definition at line 92 of file class_drawpanel.h.

Referenced by EDA_DRAW_PANEL(), and OnMouseEvent().

int EDA_DRAW_PANEL::m_minDragEventCount
private

Count the drag events.

Used to filter mouse moves before starting a block command. A block command can be started only if MinDragEventCount > MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND in order to avoid spurious block commands.

Definition at line 102 of file class_drawpanel.h.

Referenced by EDA_DRAW_PANEL(), and OnMouseEvent().

MOUSE_CAPTURE_CALLBACK EDA_DRAW_PANEL::m_mouseCaptureCallback
private

Mouse capture move callback function.

Definition at line 109 of file class_drawpanel.h.

Referenced by CallMouseCapture(), EDA_DRAW_PANEL(), EndMouseCapture(), and OnMouseLeaving().

wxPoint EDA_DRAW_PANEL::m_PanStartCenter
private

Initial scroll center position when pan started.

Definition at line 66 of file class_drawpanel.h.

Referenced by OnMouseEvent().

wxPoint EDA_DRAW_PANEL::m_PanStartEventPosition
private

Initial position of mouse event when pan started.

Definition at line 67 of file class_drawpanel.h.

Referenced by OnMouseEvent().

bool EDA_DRAW_PANEL::m_PrintIsMirrored
private

True when drawing in mirror mode.

Used by the draw arc function, because arcs are oriented, and in mirror mode, orientations are reversed.

Definition at line 106 of file class_drawpanel.h.

Referenced by EDA_DRAW_PANEL(), and GetPrintMirrored().

bool EDA_DRAW_PANEL::m_requestAutoPan
private

true to request an auto pan. Valid only when m_enableAutoPan = true.

Definition at line 83 of file class_drawpanel.h.

Referenced by EDA_DRAW_PANEL(), EndMouseCapture(), OnMouseEvent(), and OnMouseLeaving().

int EDA_DRAW_PANEL::m_scrollIncrementX
private

X axis scroll increment in pixels per unit.

Definition at line 62 of file class_drawpanel.h.

Referenced by EDA_DRAW_PANEL(), MoveCursor(), OnPan(), OnScroll(), and SetClipBox().

int EDA_DRAW_PANEL::m_scrollIncrementY
private

Y axis scroll increment in pixels per unit.

Definition at line 63 of file class_drawpanel.h.

Referenced by EDA_DRAW_PANEL(), MoveCursor(), OnPan(), OnScroll(), and SetClipBox().

bool EDA_DRAW_PANEL::m_showCrossHair
private

Indicate if cross hair is to be shown.

Definition at line 60 of file class_drawpanel.h.

Referenced by DrawCrossHair(), and EDA_DRAW_PANEL().


The documentation for this class was generated from the following files: