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...
 
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...
 
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 an other sheet >= 0 (or >= n) if a block can start More...
 

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 98 of file draw_panel.cpp.

References ENBL_AUTO_PAN_KEY, ENBL_MOUSEWHEEL_PAN_KEY, ENBL_ZOOM_NO_CENTER_KEY, Kiface(), KIFACE_I::KifaceSettings(), m_abortRequest, m_canStartBlock, m_ClipBox, m_currentCursor, m_cursorLevel, m_defaultCursor, 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().

99  :
100  wxScrolledWindow( parent, id, pos, size, wxBORDER | wxHSCROLL | wxVSCROLL )
101 {
102  wxASSERT( parent );
103 
104  ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS );
105  DisableKeyboardScrolling();
106 
107  m_scrollIncrementX = std::min( size.x / 8, 10 );
108  m_scrollIncrementY = std::min( size.y / 8, 10 );
109 
110  SetLayoutDirection( wxLayout_LeftToRight );
111 
112  SetBackgroundColour( parent->GetDrawBgColor().ToColour() );
113 
114 #if KICAD_USE_BUFFERED_DC || KICAD_USE_BUFFERED_PAINTDC
115  SetBackgroundStyle( wxBG_STYLE_CUSTOM );
116 #endif
117 
118  m_ClipBox.SetSize( size );
119  m_ClipBox.SetX( 0 );
120  m_ClipBox.SetY( 0 );
121  m_canStartBlock = -1; // Command block can start if >= 0
122  m_abortRequest = false;
123  m_enableMousewheelPan = false;
124  m_enableZoomNoCenter = false;
125  m_enableAutoPan = true;
126  m_ignoreMouseEvents = false;
127  // Be sure a mouse release button event will be ignored when creating the canvas
128  // if the mouse click was not made inside the canvas (can happen sometimes, when
129  // launching an editor from a double click made in an other frame)
131 
132  m_mouseCaptureCallback = NULL;
134 
135  wxConfigBase* cfg = Kiface().KifaceSettings();
136 
137  if( cfg )
138  {
139  cfg->Read( ENBL_MOUSEWHEEL_PAN_KEY, &m_enableMousewheelPan, false );
140  cfg->Read( ENBL_ZOOM_NO_CENTER_KEY, &m_enableZoomNoCenter, false );
141  cfg->Read( ENBL_AUTO_PAN_KEY, &m_enableAutoPan, true );
142  }
143 
144  m_requestAutoPan = false;
145  m_enableBlockCommands = false;
147 
148 #ifdef __WXMAC__
149  m_defaultCursor = m_currentCursor = wxCURSOR_CROSS;
150  m_showCrossHair = false;
151 #else
152  m_defaultCursor = m_currentCursor = wxCURSOR_ARROW;
153  m_showCrossHair = true;
154 #endif
155 
156  m_cursorLevel = 0;
157  m_PrintIsMirrored = false;
158 }
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 an other sheet >= 0 (...
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.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
#define ENBL_ZOOM_NO_CENTER_KEY
Definition: draw_panel.cpp:53
MOUSE_CAPTURE_CALLBACK m_mouseCaptureCallback
Mouse capture move callback function.
#define ENBL_AUTO_PAN_KEY
Definition: draw_panel.cpp:57
virtual COLOR4D GetDrawBgColor() const
Definition: draw_frame.h:324
bool m_ignoreMouseEvents
Ignore mouse events when true.
#define ENBL_MOUSEWHEEL_PAN_KEY
Definition: draw_panel.cpp:54
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
void SetX(int val)
bool m_ignoreNextLeftButtonRelease
Ignore the next mouse left button release when true.
void SetY(int val)
bool m_showCrossHair
Indicate if cross hair is to be shown.
void SetSize(const wxSize &size)
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.
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 161 of file draw_panel.cpp.

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

162 {
163  wxConfigBase* cfg = Kiface().KifaceSettings();
164 
165  if( cfg )
166  {
169  cfg->Write( ENBL_AUTO_PAN_KEY, m_enableAutoPan );
170  }
171 }
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:53
#define ENBL_AUTO_PAN_KEY
Definition: draw_panel.cpp:57
#define ENBL_MOUSEWHEEL_PAN_KEY
Definition: draw_panel.cpp:54
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
bool m_enableMousewheelPan
True to enable mousewheel panning by default.
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 1523 of file draw_panel.cpp.

References m_endMouseCaptureCallback.

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

1524 {
1525  wxCHECK_RET( aDC != NULL, wxT( "Invalid device context." ) );
1526 
1527  // CallEndMouseCapture is sometimes called with m_endMouseCaptureCallback == NULL
1528  // for instance after an ABORT in block paste.
1530  m_endMouseCaptureCallback( this, aDC );
1531 }
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 1514 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(), PCB_EDIT_FRAME::BeginMoveDimensionText(), 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(), 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(), LIB_EDIT_FRAME::RedrawActiveWindow(), SCH_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().

1515 {
1516  wxCHECK_RET( aDC != NULL, wxT( "Invalid device context." ) );
1517  wxCHECK_RET( m_mouseCaptureCallback != NULL, wxT( "Mouse capture callback not set." ) );
1518 
1519  m_mouseCaptureCallback( this, aDC, aPosition, aErase );
1520 }
MOUSE_CAPTURE_CALLBACK m_mouseCaptureCallback
Mouse capture move callback function.
void EDA_DRAW_PANEL::CrossHairOn ( wxDC *  DC)

Definition at line 259 of file draw_panel.cpp.

References DrawCrossHair(), and m_cursorLevel.

Referenced by SCH_EDIT_FRAME::AddJunction(), PCB_EDIT_FRAME::Attribut_net(), PCB_EDIT_FRAME::Attribut_Segment(), PCB_EDIT_FRAME::Attribut_Track(), SCH_EDIT_FRAME::CreateSheet(), PCB_BASE_FRAME::CursorGoto(), LIB_EDIT_FRAME::deleteItem(), PCB_EDIT_FRAME::Edit_Track_Width(), PCB_EDIT_FRAME::Edit_TrackSegm_Width(), SCH_EDIT_FRAME::FindComponentAndItem(), SCH_EDIT_FRAME::MoveImage(), SCH_EDIT_FRAME::OnConvertTextType(), LIB_EDIT_FRAME::OnCreateNewPartFromExisting(), PCB_EDIT_FRAME::OnHotkeyPlaceItem(), FOOTPRINT_EDIT_FRAME::OnLeftClick(), PCB_EDIT_FRAME::OnLeftClick(), OnMouseEvent(), EDA_DRAW_FRAME::OnToggleCrossHairStyle(), SCH_EDIT_FRAME::OrientComponent(), LIB_EDIT_FRAME::Process_Special_Functions(), PCB_EDIT_FRAME::Process_Special_Functions(), EDA_DRAW_FRAME::RefreshCrossHair(), LIB_EDIT_FRAME::RepeatPinItem(), SCH_EDIT_FRAME::ReSizeSheet(), DIALOG_MODULE_BOARD_EDITOR::TransferDataFromWindow(), and EDA_CROSS_HAIR_MANAGER::~EDA_CROSS_HAIR_MANAGER().

260 {
261  ++m_cursorLevel;
262  DrawCrossHair( DC );
263 
264  if( m_cursorLevel > 0 ) // Shouldn't happen, but just in case ..
265  m_cursorLevel = 0;
266 }
void DrawCrossHair(wxDC *aDC, COLOR4D aColor=COLOR4D::WHITE)
Function DrawCrossHair draws the user cross hair.
Definition: draw_panel.cpp:215
int m_cursorLevel
Index for cursor redraw in XOR mode.
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.
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 572 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().

573 {
574  wxScrolledWindow::DoPrepareDC( dc );
575 
576  if( GetScreen() != NULL )
577  {
578  double scale = GetScreen()->GetScalingFactor();
579  dc.SetUserScale( scale, scale );
580 
581  wxPoint pt = GetScreen()->m_DrawOrg;
582  dc.SetLogicalOrigin( pt.x, pt.y );
583  }
584 
585  SetClipBox( dc ); // Reset the clip box to the entire screen.
586  GRResetPenAndBrush( &dc );
587  dc.SetBackgroundMode( wxTRANSPARENT );
588 }
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:196
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
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:187
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 795 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 PCB_EDIT_FRAME::OnLeftClick().

796 {
797  wxPoint origin = GetParent()->GetAuxOrigin();
798 
799  if( origin == wxPoint( 0, 0 ) )
800  return;
801 
802  COLOR4D color = COLOR4D( RED );
803 
804  GRSetDrawMode( aDC, aDrawMode );
805 
806 #if DRAW_AXIS_AS_LINES
807  wxSize pageSize = GetParent()->GetPageSizeIU();
808  // Draw the Y axis
809  GRLine( &m_ClipBox, aDC, origin.x, -pageSize.y,
810  origin.x, pageSize.y, 0, color );
811 
812  // Draw the X axis
813  GRLine( &m_ClipBox, aDC, -pageSize.x, origin.y,
814  pageSize.x, origin.y, 0, color );
815 #else
816  int radius = aDC->DeviceToLogicalXRel( AXIS_SIZE_IN_PIXELS );
817  int linewidth = aDC->DeviceToLogicalXRel( 1 );
818 
819  GRSetColorPen( aDC, color, linewidth );
820 
821  GRLine( &m_ClipBox, aDC, origin.x, origin.y-radius,
822  origin.x, origin.y+radius, 0, color );
823 
824  // Draw the + shape
825  GRLine( &m_ClipBox, aDC, origin.x-radius, origin.y,
826  origin.x+radius, origin.y, 0, color );
827 
828  GRCircle( &m_ClipBox, aDC, origin, radius, linewidth, color );
829 #endif
830 }
#define AXIS_SIZE_IN_PIXELS
Definition: draw_panel.cpp:793
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:290
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:352
EDA_RECT m_ClipBox
The drawing area used to redraw the screen which is usually the visible area of the drawing in intern...
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:174
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:791
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:209
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 665 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_VIEWER_FRAME::RedrawActiveWindow(), FOOTPRINT_EDIT_FRAME::RedrawActiveWindow(), PL_EDITOR_FRAME::RedrawActiveWindow(), FOOTPRINT_WIZARD_FRAME::RedrawActiveWindow(), GERBVIEW_FRAME::RedrawActiveWindow(), LIB_EDIT_FRAME::RedrawActiveWindow(), SCH_EDIT_FRAME::RedrawActiveWindow(), and PCB_EDIT_FRAME::RedrawActiveWindow().

666 {
667  COLOR4D axis_color = COLOR4D( BLUE );
668 
669  GRSetDrawMode( DC, GR_COPY );
670 
671  if( GetParent()->IsGridVisible() )
672  DrawGrid( DC );
673 
674  // Draw axis
675  if( GetParent()->m_showAxis )
676  {
677  wxSize pageSize = GetParent()->GetPageSizeIU();
678 
679  // Draw the Y axis
680  GRLine( &m_ClipBox, DC, 0, -pageSize.y, 0, pageSize.y, 0, axis_color );
681 
682  // Draw the X axis
683  GRLine( &m_ClipBox, DC, -pageSize.x, 0, pageSize.x, 0, 0, axis_color );
684  }
685 
686  if( GetParent()->m_showOriginAxis )
687  DrawAuxiliaryAxis( DC, GR_COPY );
688 
689  if( GetParent()->m_showGridAxis )
690  DrawGridAxis( DC, GR_COPY, GetParent()->GetGridOrigin() );
691 }
Definition: colors.h:57
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:290
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:352
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:694
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:833
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
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:795
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 215 of file draw_panel.cpp.

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

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

216 {
217  if( m_cursorLevel != 0 || aDC == NULL || !m_showCrossHair )
218  return;
219 
220  wxPoint cursor = GetParent()->GetCrossHairPosition();
221 
222  GRSetDrawMode( aDC, GR_XOR );
223 
224  if( GetParent()->GetGalDisplayOptions().m_fullscreenCursor )
225  {
226  wxSize clientSize = GetClientSize();
227 
228  // Y axis
229  wxPoint lineStart( cursor.x, aDC->DeviceToLogicalY( 0 ) );
230  wxPoint lineEnd( cursor.x, aDC->DeviceToLogicalY( clientSize.y ) );
231 
232  GRLine( &m_ClipBox, aDC, lineStart, lineEnd, 0, aColor );
233 
234  // X axis
235  lineStart = wxPoint( aDC->DeviceToLogicalX( 0 ), cursor.y );
236  lineEnd = wxPoint( aDC->DeviceToLogicalX( clientSize.x ), cursor.y );
237 
238  GRLine( &m_ClipBox, aDC, lineStart, lineEnd, 0, aColor );
239  }
240  else
241  {
242  int len = aDC->DeviceToLogicalXRel( CURSOR_SIZE );
243 
244  GRLine( &m_ClipBox, aDC, cursor.x - len, cursor.y,
245  cursor.x + len, cursor.y, 0, aColor );
246  GRLine( &m_ClipBox, aDC, cursor.x, cursor.y - len,
247  cursor.x, cursor.y + len, 0, aColor );
248  }
249 }
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:290
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:352
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:174
bool m_showCrossHair
Indicate if cross hair is to be shown.
static const int CURSOR_SIZE
Cursor size in pixels.
Definition: draw_panel.cpp:46
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 694 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().

695 {
696  #define MIN_GRID_SIZE 10 // min grid size in pixels to allow drawing
697  BASE_SCREEN* screen = GetScreen();
698  wxRealPoint gridSize;
699  wxSize screenSize;
700  wxPoint org;
701  wxRealPoint screenGridSize;
702 
703  /* The grid must be visible. this is possible only is grid value
704  * and zoom value are sufficient
705  */
706  gridSize = screen->GetGridSize();
707  screen->m_StartVisu = CalcUnscrolledPosition( wxPoint( 0, 0 ) );
708  screenSize = GetClientSize();
709 
710  screenGridSize.x = aDC->LogicalToDeviceXRel( KiROUND( gridSize.x ) );
711  screenGridSize.y = aDC->LogicalToDeviceYRel( KiROUND( gridSize.y ) );
712 
713  org = m_ClipBox.GetPosition();
714 
715  if( screenGridSize.x < MIN_GRID_SIZE || screenGridSize.y < MIN_GRID_SIZE )
716  {
717  screenGridSize.x *= 2.0;
718  screenGridSize.y *= 2.0;
719  gridSize.x *= 2.0;
720  gridSize.y *= 2.0;
721  }
722 
723  if( screenGridSize.x < MIN_GRID_SIZE || screenGridSize.y < MIN_GRID_SIZE )
724  return;
725 
726  org = GetParent()->GetNearestGridPosition( org, &gridSize );
727 
728  // Setting the nearest grid position can select grid points outside the clip box.
729  // Incrementing the start point by one grid step should prevent drawing grid points
730  // outside the clip box.
731  if( org.x < m_ClipBox.GetX() )
732  org.x += KiROUND( gridSize.x );
733 
734  if( org.y < m_ClipBox.GetY() )
735  org.y += KiROUND( gridSize.y );
736 
737  // Use a pixel based draw to display grid. There are a lot of calls, so the cost is
738  // high and grid is slowly drawn on some platforms. An other way using blit transfert was used,
739  // a long time ago, but it did not give very good results.
740  // The better way is highly dependent on the platform and the graphic card.
741  int xpos;
742  double right = ( double ) m_ClipBox.GetRight();
743  double bottom = ( double ) m_ClipBox.GetBottom();
744 
745 #if defined( __WXMAC__ ) && defined( USE_WX_GRAPHICS_CONTEXT )
746  wxGCDC *gcdc = wxDynamicCast( aDC, wxGCDC );
747  if( gcdc )
748  {
749  wxGraphicsContext *gc = gcdc->GetGraphicsContext();
750 
751  // Grid point size
752  const int gsz = 1;
753  const double w = aDC->DeviceToLogicalXRel( gsz );
754  const double h = aDC->DeviceToLogicalYRel( gsz );
755 
756  // Use our own pen
757  wxPen pen( GetParent()->GetGridColor().ToColour(), h );
758  pen.SetCap( wxCAP_BUTT );
759  gc->SetPen( pen );
760 
761  // draw grid
762  wxGraphicsPath path = gc->CreatePath();
763  for( double x = (double) org.x - w/2.0; x <= right - w/2.0; x += gridSize.x )
764  {
765  for( double y = (double) org.y; y <= bottom; y += gridSize.y )
766  {
767  path.MoveToPoint( x, y );
768  path.AddLineToPoint( x+w, y );
769  }
770  }
771  gc->StrokePath( path );
772  }
773  else
774 #endif
775  {
776  GRSetColorPen( aDC, GetParent()->GetGridColor() );
777 
778  for( double x = (double) org.x; x <= right; x += gridSize.x )
779  {
780  xpos = KiROUND( x );
781 
782  for( double y = (double) org.y; y <= bottom; y += gridSize.y )
783  {
784  aDC->DrawPoint( xpos, KiROUND( y ) );
785  }
786  }
787  }
788 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
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) ...
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
#define MIN_GRID_SIZE
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
int GetBottom() const
int GetRight() const
const wxPoint & GetPosition() const
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.
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:209
int GetX() const
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:187
int GetY() const
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 833 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(), FOOTPRINT_EDIT_FRAME::OnLeftClick(), and PCB_EDIT_FRAME::OnLeftClick().

834 {
835  if( !GetParent()->m_showGridAxis || ( !aGridOrigin.x && !aGridOrigin.y ) )
836  return;
837 
839 
840  GRSetDrawMode( aDC, aDrawMode );
841 
842 #if DRAW_AXIS_AS_LINES
843  wxSize pageSize = GetParent()->GetPageSizeIU();
844  // Draw the Y axis
845  GRLine( &m_ClipBox, aDC, aGridOrigin.x, -pageSize.y,
846  aGridOrigin.x, pageSize.y, 0, color );
847 
848  // Draw the X axis
849  GRLine( &m_ClipBox, aDC, -pageSize.x, aGridOrigin.y,
850  pageSize.x, aGridOrigin.y, 0, color );
851 #else
852  int radius = aDC->DeviceToLogicalXRel( AXIS_SIZE_IN_PIXELS );
853  int linewidth = aDC->DeviceToLogicalXRel( 1 );
854 
855  GRSetColorPen( aDC, GetParent()->GetGridColor(), linewidth );
856 
857  GRLine( &m_ClipBox, aDC, aGridOrigin.x-radius, aGridOrigin.y-radius,
858  aGridOrigin.x+radius, aGridOrigin.y+radius, 0, color );
859 
860  // Draw the X shape
861  GRLine( &m_ClipBox, aDC, aGridOrigin.x+radius, aGridOrigin.y-radius,
862  aGridOrigin.x-radius, aGridOrigin.y+radius, 0, color );
863 
864  GRCircle( &m_ClipBox, aDC, aGridOrigin, radius, linewidth, color );
865 #endif
866 }
#define AXIS_SIZE_IN_PIXELS
Definition: draw_panel.cpp:793
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:290
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:352
EDA_RECT m_ClipBox
The drawing area used to redraw the screen which is usually the visible area of the drawing in intern...
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:174
virtual COLOR4D GetGridColor()
Function GetGridColor() , virtual.
Definition: draw_frame.h:500
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:791
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:209
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 1493 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(), LIB_EDIT_FRAME::CreateNewLibraryPart(), LIB_EDIT_FRAME::DeleteOnePart(), 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(), LIB_EDIT_FRAME::InstallFieldsEditorDialog(), LIB_EDIT_FRAME::LoadOneLibraryPart(), SCH_EDIT_FRAME::OnCancelCurrentCommand(), 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(), and LIB_EDIT_FRAME::SaveActiveLibrary().

1495 {
1496  if( m_mouseCaptureCallback && m_endMouseCaptureCallback && aCallEndFunc )
1497  {
1498  INSTALL_UNBUFFERED_DC( dc, this );
1499  m_endMouseCaptureCallback( this, &dc );
1500  }
1501 
1502  m_mouseCaptureCallback = NULL;
1504  m_requestAutoPan = false;
1505 
1506  if( id != -1 && cursor != -1 )
1507  {
1508  wxASSERT( cursor > wxCURSOR_NONE && cursor < wxCURSOR_MAX );
1509  GetParent()->SetToolID( id, cursor, title );
1510  }
1511 }
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:174
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:546
#define INSTALL_UNBUFFERED_DC(name, parent)
void EDA_DRAW_PANEL::EraseScreen ( wxDC *  DC)

Definition at line 553 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(), ReDraw(), and PL_EDITOR_FRAME::RedrawActiveWindow().

554 {
555  GRSetDrawMode( DC, GR_COPY );
556 
557  COLOR4D bgColor = GetParent()->GetDrawBgColor();
558 
559  GRSFilledRect( NULL, DC, m_ClipBox.GetX(), m_ClipBox.GetY(),
561  0, bgColor, bgColor );
562 
563  // Set to one (1) to draw bounding box validate bounding box calculation.
564 #if DEBUG_SHOW_CLIP_RECT
565  EDA_RECT bBox = m_ClipBox;
566  GRRect( NULL, DC, bBox.GetOrigin().x, bBox.GetOrigin().y,
567  bBox.GetEnd().x, bBox.GetEnd().y, 0, LIGHTMAGENTA );
568 #endif
569 }
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:290
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:1152
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:1077
virtual COLOR4D GetDrawBgColor() const
Definition: draw_frame.h:324
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
int GetBottom() const
int GetRight() const
Class EDA_RECT handles the component boundary box.
int GetX() const
int GetY() const
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 134 of file class_drawpanel.h.

References m_ClipBox.

Referenced by Autoroute_One_Track(), DisplayRoutingMatrix(), SCH_NO_CONNECT::Draw(), SCH_JUNCTION::Draw(), TEXTE_PCB::Draw(), PCB_TARGET::Draw(), SCH_BUS_ENTRY_BASE::Draw(), SCH_LINE::Draw(), SCH_BITMAP::Draw(), EDGE_MODULE::Draw(), GBR_LAYOUT::Draw(), BLOCK_SELECTOR::Draw(), SCH_TEXT::Draw(), ZONE_CONTAINER::Draw(), SCH_FIELD::Draw(), TEXTE_MODULE::Draw(), TRACK::Draw(), DRAWSEGMENT::Draw(), DIMENSION::Draw(), LIB_ITEM::Draw(), GERBER_DRAW_ITEM::Draw(), SCH_GLOBALLABEL::Draw(), MODULE::Draw(), SCH_HIERLABEL::Draw(), SEGZONE::Draw(), VIA::Draw(), SCH_SHEET::Draw(), SCH_COMPONENT::Draw(), LIB_PART::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_EDIT_FRAME::Solve(), PCB_BASE_FRAME::TraceAirWiresToTargets(), and PCB_BASE_FRAME::TraceModuleRatsNest().

134 { 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 181 of file draw_panel.cpp.

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

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

182 {
183  return GetParent()->GetDisplayOptions();
184 }
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
virtual void * GetDisplayOptions()
Function GetDisplayOptions A way to pass info to draw functions.
Definition: draw_frame.h:885
bool EDA_DRAW_PANEL::GetEnableAutoPan ( void  ) const
inline

Definition at line 150 of file class_drawpanel.h.

References m_enableAutoPan.

Referenced by SCH_EDIT_FRAME::OnPreferencesOptions(), and EDA_DRAW_FRAME::PushPreferences().

150 { return m_enableAutoPan; }
bool m_enableAutoPan
True to enable automatic panning.
bool EDA_DRAW_PANEL::GetEnableMousewheelPan ( void  ) const
inline

Definition at line 142 of file class_drawpanel.h.

References m_enableMousewheelPan.

Referenced by DIALOG_DISPLAY_OPTIONS::initOptDialog(), SCH_EDIT_FRAME::OnPreferencesOptions(), and EDA_DRAW_FRAME::UseGalCanvas().

142 { return m_enableMousewheelPan; }
bool m_enableMousewheelPan
True to enable mousewheel panning by default.
bool EDA_DRAW_PANEL::GetEnableZoomNoCenter ( void  ) const
inline
wxRealPoint EDA_DRAW_PANEL::GetGrid ( )

Definition at line 281 of file draw_panel.cpp.

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

282 {
283  return GetScreen()->GetGridSize();
284 }
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:187
EDA_DRAW_FRAME * EDA_DRAW_PANEL::GetParent ( void  ) const

Definition at line 174 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(), DeleteItemsInList(), TEXTE_PCB::Draw(), PCB_TARGET::Draw(), EDGE_MODULE::Draw(), GBR_LAYOUT::Draw(), ZONE_CONTAINER::Draw(), TEXTE_MODULE::Draw(), TRACK::Draw(), DRAWSEGMENT::Draw(), DIMENSION::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(), PushTrack(), ReDraw(), RedrawWhileMovingCursor(), Refresh(), resizeSheetWithMouseCursor(), SetEnableMousewheelPan(), SetEnableZoomNoCenter(), EDA_DRAW_PANEL_GAL::SetFocus(), 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().

175 {
176  wxWindow* mom = wxScrolledWindow::GetParent();
177  return (EDA_DRAW_FRAME*) mom;
178 }
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:54
bool EDA_DRAW_PANEL::GetPrintMirrored ( ) const
inline

Definition at line 162 of file class_drawpanel.h.

References m_PrintIsMirrored.

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

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

Definition at line 187 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(), DeleteItemsInList(), DoPrepareDC(), TEXTE_PCB::Draw(), SCH_BUS_ENTRY_BASE::Draw(), EDGE_MODULE::Draw(), ZONE_CONTAINER::Draw(), TEXTE_MODULE::Draw(), TRACK::Draw(), DRAWSEGMENT::Draw(), SEGZONE::Draw(), VIA::Draw(), SCH_COMPONENT::Draw(), LIB_PART::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().

188 {
189  EDA_DRAW_FRAME* parentFrame = GetParent();
190 
191  return parentFrame->GetScreen();
192 }
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:54
virtual BASE_SCREEN * GetScreen() const
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:347
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
wxPoint EDA_DRAW_PANEL::GetScreenCenterLogicalPosition ( )

Function GetScreenCenterLogicalPosition.

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

Definition at line 338 of file draw_panel.cpp.

References INSTALL_UNBUFFERED_DC.

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

339 {
340  wxSize size = GetClientSize() / 2;
341  INSTALL_UNBUFFERED_DC( dc, this );
342 
343  return wxPoint( dc.DeviceToLogicalX( size.x ), dc.DeviceToLogicalY( size.y ) );
344 }
#define INSTALL_UNBUFFERED_DC(name, parent)
double EDA_DRAW_PANEL::GetZoom ( )

Definition at line 269 of file draw_panel.cpp.

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

Referenced by EDA_DRAW_FRAME::UseGalCanvas().

270 {
271  return GetScreen()->GetZoom();
272 }
double GetZoom() const
Function GetZoom returns the current "zoom factor", which is a measure of "internal units per device ...
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:187
bool EDA_DRAW_PANEL::IsMouseCaptured ( ) const
inline

Definition at line 414 of file class_drawpanel.h.

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(), LIB_EDIT_FRAME::RedrawActiveWindow(), SCH_EDIT_FRAME::RedrawActiveWindow(), PCB_EDIT_FRAME::RedrawActiveWindow(), EDA_DRAW_FRAME::RefreshCrossHair(), and PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event().

414 { 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 287 of file draw_panel.cpp.

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

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

288 {
289  wxPoint pos;
290  EDA_RECT display_rect;
291 
292  INSTALL_UNBUFFERED_DC( dc, this ); // Refresh the clip box to the entire screen size.
293  SetClipBox( dc );
294 
295  display_rect = m_ClipBox;
296 
297  // Slightly decreased the size of the useful screen area to avoid drawing limits.
298  #define PIXEL_MARGIN 8
299  display_rect.Inflate( -PIXEL_MARGIN );
300 
301  return display_rect.Contains( aPosition );
302 }
#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.
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 353 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(), and MoveCursorToCrossHair().

354 {
355  if( GetParent()->IsGalCanvasActive() )
356  return;
357 
358  int x, y, xPpu, yPpu;
359  wxPoint screenPos, drawingPos;
360  wxRect clientRect( wxPoint( 0, 0 ), GetClientSize() );
361 
362  INSTALL_UNBUFFERED_DC( dc, this );
363  screenPos.x = dc.LogicalToDeviceX( aPosition.x );
364  screenPos.y = dc.LogicalToDeviceY( aPosition.y );
365 
366  // Scroll if the requested mouse position cursor is outside the drawing area.
367  if( !clientRect.Contains( screenPos ) )
368  {
369  GetViewStart( &x, &y );
370  GetScrollPixelsPerUnit( &xPpu, &yPpu );
371  CalcUnscrolledPosition( screenPos.x, screenPos.y, &drawingPos.x, &drawingPos.y );
372 
373  wxLogTrace( kicadTraceCoords,
374  wxT( "MoveCursor() initial screen position(%d, %d) " ) \
375  wxT( "rectangle(%d, %d, %d, %d) view(%d, %d)" ),
376  screenPos.x, screenPos.y, clientRect.x, clientRect.y,
377  clientRect.width, clientRect.height, x, y );
378 
379  if( screenPos.y < clientRect.GetTop() )
380  y -= m_scrollIncrementY * yPpu;
381  else if( screenPos.y > clientRect.GetBottom() )
382  y += m_scrollIncrementY * yPpu;
383  else if( clientRect.GetRight() < screenPos.x )
384  x += m_scrollIncrementX * xPpu;
385  else
386  x -= m_scrollIncrementX * xPpu;
387 
388  Scroll( x, y );
389  CalcScrolledPosition( drawingPos.x, drawingPos.y, &screenPos.x, &screenPos.y );
390 
391  wxLogTrace( kicadTraceCoords,
392  wxT( "MoveCursor() scrolled screen position(%d, %d) view(%d, %d)" ),
393  screenPos.x, screenPos.y, x, y );
394  }
395 
396  WarpPointer( screenPos.x, screenPos.y );
397 }
static const wxString kicadTraceCoords
Flag to enable draw panel coordinate debug tracing.
Definition: draw_panel.cpp:72
int m_scrollIncrementX
X axis scroll increment in pixels per unit.
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
#define INSTALL_UNBUFFERED_DC(name, parent)
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 347 of file draw_panel.cpp.

References GetParent(), and MoveCursor().

Referenced by PCB_EDIT_FRAME::Begin_Zone(), PCB_EDIT_FRAME::BeginMoveDimensionText(), 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_FRAME::CursorGoto(), SCH_EDIT_FRAME::DisplayCurrentSheet(), 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(), LIB_EDIT_FRAME::HandleBlockEnd(), SCH_EDIT_FRAME::HandleBlockEnd(), InstallBlockCmdFrame(), FOOTPRINT_EDIT_FRAME::InstallFootprintBodyItemPropertiesDlg(), PCB_EDIT_FRAME::InstallGraphicItemPropertiesDialog(), PCB_EDIT_FRAME::InstallTextPCBOptionsFrame(), 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(), LIB_EDIT_FRAME::OnCreateNewPartFromExisting(), SCH_EDIT_FRAME::OnDragItem(), FOOTPRINT_EDIT_FRAME::OnEditItemRequest(), PCB_EDIT_FRAME::OnLeftClick(), LIB_EDIT_FRAME::OnLeftDClick(), SCH_EDIT_FRAME::OnLeftDClick(), PCB_EDIT_FRAME::OnLeftDClick(), LIB_EDIT_FRAME::OnOrient(), SCH_EDIT_FRAME::OnOrient(), OnRightClick(), 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(), PCB_BASE_FRAME::SelectCopperLayerPair(), 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().

348 {
349  MoveCursor( GetParent()->GetCrossHairPosition() );
350 }
void MoveCursor(const wxPoint &aPosition)
Function MoveCursor moves the mouse pointer to aPosition in logical (drawing) units.
Definition: draw_panel.cpp:353
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
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 400 of file draw_panel.cpp.

References m_canStartBlock.

401 {
402  m_canStartBlock = -1; // Block Command can't start
403  event.Skip();
404 }
int m_canStartBlock
useful to avoid false start block in certain cases (like switch from a sheet to an other sheet >= 0 (...
void EDA_DRAW_PANEL::OnCharHook ( wxKeyEvent &  event)

Definition at line 1339 of file draw_panel.cpp.

1340 {
1341  event.Skip();
1342 }
void EDA_DRAW_PANEL::OnEraseBackground ( wxEraseEvent &  event)
inline

Definition at line 206 of file class_drawpanel.h.

206 { }
void EDA_DRAW_PANEL::OnKeyEvent ( wxKeyEvent &  event)

Definition at line 1344 of file draw_panel.cpp.

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

1345 {
1346  int localkey;
1347  wxPoint pos;
1348 
1349  localkey = event.GetKeyCode();
1350 
1351  switch( localkey )
1352  {
1353  default:
1354  break;
1355 
1356  case WXK_ESCAPE:
1357  m_abortRequest = true;
1358 
1359  if( IsMouseCaptured() )
1360  EndMouseCapture();
1361  else
1363  break;
1364  }
1365 
1366  /* Normalize keys code to easily handle keys from Ctrl+A to Ctrl+Z
1367  * They have an ascii code from 1 to 27 remapped
1368  * to GR_KB_CTRL + 'A' to GR_KB_CTRL + 'Z'
1369  */
1370  if( event.ControlDown() && localkey >= WXK_CONTROL_A && localkey <= WXK_CONTROL_Z )
1371  localkey += 'A' - 1;
1372 
1373  /* Disallow shift for keys that have two keycodes on them (e.g. number and
1374  * punctuation keys) leaving only the "letter keys" of A-Z.
1375  * Then, you can have, e.g. Ctrl-5 and Ctrl-% (GB layout)
1376  * and Ctrl-( and Ctrl-5 (FR layout).
1377  * Otherwise, you'd have to have to say Ctrl-Shift-5 on a FR layout
1378  */
1379  bool keyIsLetter = ( localkey >= 'A' && localkey <= 'Z' ) ||
1380  ( localkey >= 'a' && localkey <= 'z' );
1381 
1382  if( event.ShiftDown() && ( keyIsLetter || localkey > 256 ) )
1383  localkey |= GR_KB_SHIFT;
1384 
1385  if( event.ControlDown() )
1386  localkey |= GR_KB_CTRL;
1387 
1388  if( event.AltDown() )
1389  localkey |= GR_KB_ALT;
1390 
1391  INSTALL_UNBUFFERED_DC( DC, this );
1392 
1393  // Some key commands use the current mouse position: refresh it.
1394  pos = wxGetMousePosition() - GetScreenPosition();
1395 
1396  // Compute the cursor position in drawing units. Also known as logical units to wxDC.
1397  pos = wxPoint( DC.DeviceToLogicalX( pos.x ), DC.DeviceToLogicalY( pos.y ) );
1398 
1399  GetParent()->SetMousePosition( pos );
1400 
1401  if( !GetParent()->GeneralControl( &DC, pos, localkey ) )
1402  event.Skip();
1403 }
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
#define GR_KB_SHIFT
Definition: common.h:66
bool IsMouseCaptured() const
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
void SetMousePosition(const wxPoint &aPosition)
#define INSTALL_UNBUFFERED_DC(name, parent)
int m_defaultCursor
The default mouse cursor shape id.
#define GR_KB_CTRL
Definition: common.h:64
void EDA_DRAW_PANEL::OnMouseEntering ( wxMouseEvent &  aEvent)

Definition at line 904 of file draw_panel.cpp.

References m_cursorLevel.

905 {
906  // This is an ugly hack that fixes some cross hair display bugs when the mouse leaves the
907  // canvas area during middle button mouse panning.
908  if( m_cursorLevel != 0 )
909  m_cursorLevel = 0;
910 
911  aEvent.Skip();
912 }
int m_cursorLevel
Index for cursor redraw in XOR mode.
void EDA_DRAW_PANEL::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 1069 of file draw_panel.cpp.

References abs, BLOCK_MINSIZE_LIMIT, BLOCK_ZOOM, CrossHairOff(), CrossHairOn(), EDA_DRAW_FRAME::DisplayToolMsg(), EDA_DRAW_FRAME::GeneralControl(), BLOCK_SELECTOR::GetCommand(), EDA_DRAW_FRAME::GetCrossHairPosition(), 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_ZOOM_SELECTION, INSTALL_UNBUFFERED_DC, BASE_SCREEN::IsBlockActive(), IsMouseCaptured(), KiROUND(), BASE_SCREEN::m_BlockLocate, m_canStartBlock, m_currentCursor, m_CursorStartPos, 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_BASE_FRAME::PrintMsg(), EDA_DRAW_FRAME::RedrawScreen(), scale, EDA_DRAW_FRAME::SetMousePosition(), EDA_RECT::SetOrigin(), STATE_BLOCK_END, STATE_BLOCK_MOVE, STATE_NO_BLOCK, wxPoint::x, and wxPoint::y.

1070 {
1071  int localbutt = 0;
1072  BASE_SCREEN* screen = GetScreen();
1073 
1074  if( !screen )
1075  return;
1076 
1077  /* Adjust value to filter mouse displacement before consider the drag
1078  * mouse is really a drag command, not just a movement while click
1079  */
1080 #define MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND 5
1081 
1082  if( event.Leaving() )
1083  m_canStartBlock = -1;
1084 
1085  if( !IsMouseCaptured() ) // No mouse capture in progress.
1086  m_requestAutoPan = false;
1087 
1088  if( GetParent()->IsActive() )
1089  SetFocus();
1090  else
1091  return;
1092 
1093  if( !event.IsButton() && !event.Moving() && !event.Dragging() )
1094  return;
1095 
1096  if( event.RightDown() )
1097  {
1098  OnRightClick( event );
1099  return;
1100  }
1101 
1102  if( m_ignoreMouseEvents )
1103  return;
1104 
1105  if( event.LeftDown() )
1106  localbutt = GR_M_LEFT_DOWN;
1107 
1108  if( event.ButtonDClick( 1 ) )
1109  localbutt = GR_M_LEFT_DOWN | GR_M_DCLICK;
1110 
1111  if( event.MiddleDown() )
1112  localbutt = GR_M_MIDDLE_DOWN;
1113 
1114  INSTALL_UNBUFFERED_DC( DC, this );
1115  DC.SetBackground( *wxBLACK_BRUSH );
1116 
1117  // Compute the cursor position in drawing (logical) units.
1118  GetParent()->SetMousePosition( event.GetLogicalPosition( DC ) );
1119 
1120  int kbstat = 0;
1121 
1122  if( event.ShiftDown() )
1123  kbstat |= GR_KB_SHIFT;
1124 
1125  if( event.ControlDown() )
1126  kbstat |= GR_KB_CTRL;
1127 
1128  if( event.AltDown() )
1129  kbstat |= GR_KB_ALT;
1130 
1131  // Calling Double Click and Click functions :
1132  if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) )
1133  {
1134  GetParent()->OnLeftDClick( &DC, GetParent()->RefPos( true ) );
1135 
1136  // inhibit a response to the mouse left button release,
1137  // because we have a double click, and we do not want a new
1138  // OnLeftClick command at end of this Double Click
1140  }
1141  else if( event.LeftUp() )
1142  {
1143  // A block command is in progress: a left up is the end of block
1144  // or this is the end of a double click, already seen
1145  // Note also m_ignoreNextLeftButtonRelease can be set by
1146  // the call to OnLeftClick(), so do not change it after calling OnLeftClick
1147  bool ignoreEvt = m_ignoreNextLeftButtonRelease;
1149 
1150  if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK && !ignoreEvt )
1151  GetParent()->OnLeftClick( &DC, GetParent()->RefPos( true ) );
1152 
1153  }
1154  else if( !event.LeftIsDown() )
1155  {
1156  /* be sure there is a response to a left button release command
1157  * even when a LeftUp event is not seen. This happens when a
1158  * double click opens a dialog box, and the release mouse button
1159  * is made when the dialog box is opened.
1160  */
1162  }
1163 
1164  if( event.ButtonDown( wxMOUSE_BTN_MIDDLE ) )
1165  {
1167  m_PanStartEventPosition = event.GetPosition();
1168 
1169  INSTALL_UNBUFFERED_DC( dc, this );
1170  CrossHairOff( &dc );
1171  SetCursor( wxCURSOR_SIZING );
1172  }
1173 
1174  if( event.ButtonUp( wxMOUSE_BTN_MIDDLE ) )
1175  {
1176  INSTALL_UNBUFFERED_DC( dc, this );
1177  CrossHairOn( &dc );
1178  SetCursor( (wxStockCursor) m_currentCursor );
1179  }
1180 
1181  if( event.MiddleIsDown() )
1182  {
1183  wxPoint currentPosition = event.GetPosition();
1184 
1185  double scale = GetParent()->GetScreen()->GetScalingFactor();
1186  int x = m_PanStartCenter.x +
1187  KiROUND( (double) ( m_PanStartEventPosition.x - currentPosition.x ) / scale );
1188  int y = m_PanStartCenter.y +
1189  KiROUND( (double) ( m_PanStartEventPosition.y - currentPosition.y ) / scale );
1190 
1191  GetParent()->RedrawScreen( wxPoint( x, y ), false );
1192  }
1193 
1194  // Calling the general function on mouse changes (and pseudo key commands)
1195  GetParent()->GeneralControl( &DC, event.GetLogicalPosition( DC ), 0 );
1196 
1197  /*******************************/
1198  /* Control of block commands : */
1199  /*******************************/
1200 
1201  // Command block can't start if mouse is dragging a new panel
1202  static EDA_DRAW_PANEL* lastPanel;
1203  if( lastPanel != this )
1204  {
1205  m_minDragEventCount = 0;
1206  m_canStartBlock = -1;
1207  }
1208 
1209  /* A new command block can start after a release buttons
1210  * and if the drag is enough
1211  * This is to avoid a false start block when a dialog box is dismissed,
1212  * or when changing panels in hierarchy navigation
1213  * or when clicking while and moving mouse
1214  */
1215  if( !event.LeftIsDown() && !event.MiddleIsDown() )
1216  {
1217  m_minDragEventCount = 0;
1218  m_canStartBlock = 0;
1219 
1220  /* Remember the last cursor position when a drag mouse starts
1221  * this is the last position ** before ** clicking a button
1222  * this is useful to start a block command from the point where the
1223  * mouse was clicked first
1224  * (a filter creates a delay for the real block command start, and
1225  * we must remember this point)
1226  */
1228  }
1229 
1230  if( m_enableBlockCommands && !(localbutt & GR_M_DCLICK) )
1231  {
1232  if( !screen->IsBlockActive() )
1233  {
1235  }
1236 
1237  if( event.LeftDown() )
1238  {
1239  if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE )
1240  {
1241  m_requestAutoPan = false;
1242  GetParent()->HandleBlockPlace( &DC );
1244  }
1245  }
1246  else if( ( m_canStartBlock >= 0 ) && event.LeftIsDown() && !IsMouseCaptured() )
1247  {
1248  // Mouse is dragging: if no block in progress, start a block command.
1249  if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK )
1250  {
1251  // Start a block command
1252  int cmd_type = kbstat;
1253 
1254  // A block command is started if the drag is enough. A small
1255  // drag is ignored (it is certainly a little mouse move when
1256  // clicking) not really a drag mouse
1259  else
1260  {
1261  auto cmd = (GetParent()->GetToolId() == ID_ZOOM_SELECTION) ? BLOCK_ZOOM : 0;
1262 
1263  if( !GetParent()->HandleBlockBegin( &DC, cmd_type, m_CursorStartPos, cmd ) )
1264  {
1265  // should not occur: error
1267  wxT( "EDA_DRAW_PANEL::OnMouseEvent() Block Error" ) );
1268  }
1269  else
1270  {
1271  m_requestAutoPan = true;
1272  SetCursor( wxCURSOR_SIZING );
1273  }
1274  }
1275  }
1276  }
1277 
1278  if( event.ButtonUp( wxMOUSE_BTN_LEFT ) )
1279  {
1280  /* Release the mouse button: end of block.
1281  * The command can finish (DELETE) or have a next command (MOVE,
1282  * COPY). However the block command is canceled if the block
1283  * size is small because a block command filtering is already
1284  * made, this case happens, but only when the on grid cursor has
1285  * not moved.
1286  */
1287  #define BLOCK_MINSIZE_LIMIT 1
1288  bool BlockIsSmall =
1290  && ( std::abs( screen->m_BlockLocate.GetHeight() ) < BLOCK_MINSIZE_LIMIT );
1291 
1292  if( (screen->m_BlockLocate.GetState() != STATE_NO_BLOCK) && BlockIsSmall )
1293  {
1295  {
1296  m_endMouseCaptureCallback( this, &DC );
1297  m_requestAutoPan = false;
1298  }
1299 
1300  SetCursor( (wxStockCursor) m_currentCursor );
1301  }
1302  else if( screen->m_BlockLocate.GetState() == STATE_BLOCK_END )
1303  {
1304  m_requestAutoPan = false;
1305  GetParent()->HandleBlockEnd( &DC );
1306  SetCursor( (wxStockCursor) m_currentCursor );
1307  if( screen->m_BlockLocate.GetState() == STATE_BLOCK_MOVE )
1308  {
1309  m_requestAutoPan = true;
1310  SetCursor( wxCURSOR_HAND );
1311  }
1312  }
1313  }
1314  }
1315 
1316  // End of block command on a double click
1317  // To avoid an unwanted block move command if the mouse is moved while double clicking
1318  if( localbutt == (int) ( GR_M_LEFT_DOWN | GR_M_DCLICK ) )
1319  {
1320  if( !screen->IsBlockActive() && IsMouseCaptured() )
1321  {
1322  m_endMouseCaptureCallback( this, &DC );
1323  }
1324  }
1325 
1326 #if 0
1327  wxString msg_debug;
1328  msg_debug.Printf( " block state %d, cmd %d",
1329  screen->m_BlockLocate.GetState(),
1330  screen->m_BlockLocate.GetCommand() );
1331  GetParent()->PrintMsg( msg_debug );
1332 #endif
1333 
1334  lastPanel = this;
1335 }
#define GR_M_DCLICK
Definition: gr_basic.h:81
void PrintMsg(const wxString &text)
Definition: basicframe.cpp:401
int m_canStartBlock
useful to avoid false start block in certain cases (like switch from a sheet to an other sheet >= 0 (...
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
#define GR_M_MIDDLE_DOWN
Definition: gr_basic.h:80
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
virtual void HandleBlockPlace(wxDC *DC)
Function HandleBlockPlace( ) Called after HandleBlockEnd, when a block command needs to be executed a...
Definition: draw_frame.cpp:669
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
END_MOUSE_CAPTURE_CALLBACK m_endMouseCaptureCallback
Abort mouse capture callback function.
void SetOrigin(const wxPoint &pos)
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:834
bool IsBlockActive() const
virtual BASE_SCREEN * GetScreen() const
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:347
#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 ...)
#define BLOCK_MINSIZE_LIMIT
bool m_ignoreMouseEvents
Ignore mouse events when true.
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
#define MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND
void CrossHairOff(wxDC *DC)
Definition: draw_panel.cpp:252
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:674
wxPoint m_PanStartCenter
Initial scroll center position when pan started.
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:78
void CrossHairOn(wxDC *DC)
Definition: draw_panel.cpp:259
const int scale
void DisplayToolMsg(const wxString &msg)
Definition: draw_frame.cpp:508
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:471
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:187
int GetWidth() const
bool OnRightClick(wxMouseEvent &event)
Function OnRightClick builds and displays a context menu on a right mouse button click.
Definition: draw_panel.cpp:869
int m_minDragEventCount
Count the drag events.
BLOCK_COMMAND_T GetCommand() const
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:589
virtual void OnLeftDClick(wxDC *DC, const wxPoint &MousePos)
Definition: draw_frame.cpp:503
#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 915 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.

916 {
917  if( m_mouseCaptureCallback == NULL ) // No command in progress.
918  m_requestAutoPan = false;
919 
921  return;
922 
923  // Auto pan when mouse has left the client window
924  // Ensure the cross_hair position is updated,
925  // because it will be used to center the screen.
926  // We use a position inside the client window
927  wxRect area( wxPoint( 0, 0 ), GetClientSize() );
928  wxPoint cross_hair_pos = event.GetPosition();
929 
930  // Certain window managers (e.g. awesome wm) incorrectly trigger "on leave" event,
931  // therefore test if the cursor has really left the panel area
932  if( !area.Contains( cross_hair_pos ) )
933  {
934  INSTALL_UNBUFFERED_DC( dc, this );
935  cross_hair_pos.x = dc.DeviceToLogicalX( cross_hair_pos.x );
936  cross_hair_pos.y = dc.DeviceToLogicalY( cross_hair_pos.y );
937 
938  GetParent()->SetCrossHairPosition( cross_hair_pos );
939 
940  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_POPUP_ZOOM_CENTER );
941  cmd.SetEventObject( this );
942  GetEventHandler()->ProcessEvent( cmd );
943  }
944 
945  event.Skip();
946 }
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:174
#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 949 of file draw_panel.cpp.

References GetParent(), GetScreenCenterLogicalPosition(), ID_OFFCENTER_ZOOM_IN, ID_OFFCENTER_ZOOM_OUT, ID_PAN_DOWN, ID_PAN_LEFT, ID_PAN_RIGHT, ID_PAN_UP, ID_POPUP_ZOOM_IN, ID_POPUP_ZOOM_OUT, INSTALL_UNBUFFERED_DC, kicadTraceCoords, m_enableMousewheelPan, m_enableZoomNoCenter, m_ignoreMouseEvents, EDA_DRAW_FRAME::SetCrossHairPosition(), EDA_DRAW_FRAME::SetScrollCenterPosition(), wxPoint::x, and wxPoint::y.

950 {
951  if( m_ignoreMouseEvents )
952  return;
953 
954  wxRect rect = wxRect( wxPoint( 0, 0 ), GetClientSize() );
955 
956  // Ignore scroll events if the cursor is outside the drawing area.
957  if( event.GetWheelRotation() == 0 || !GetParent()->IsEnabled()
958  || !rect.Contains( event.GetPosition() ) )
959  {
960  wxLogTrace( kicadTraceCoords,
961  wxT( "OnMouseWheel() position(%d, %d) rectangle(%d, %d, %d, %d)" ),
962  event.GetPosition().x, event.GetPosition().y,
963  rect.x, rect.y, rect.width, rect.height );
964  event.Skip();
965  return;
966  }
967 
968  INSTALL_UNBUFFERED_DC( dc, this );
969  GetParent()->SetCrossHairPosition( event.GetLogicalPosition( dc ) );
970 
971  wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
972  cmd.SetEventObject( this );
973 
974  bool offCenterReq = event.ControlDown() && event.ShiftDown();
975  offCenterReq = offCenterReq || m_enableZoomNoCenter;
976 
977  int axis = event.GetWheelAxis();
978  int wheelRotation = event.GetWheelRotation();
979 
981  {
982  // MousewheelPAN + Ctrl = zooming
983  if( event.ControlDown() && !event.ShiftDown() )
984  {
985  if( wheelRotation > 0 )
986  cmd.SetId( ID_POPUP_ZOOM_IN );
987  else if( wheelRotation < 0)
988  cmd.SetId( ID_POPUP_ZOOM_OUT );
989  }
990  // MousewheelPAN + Shift = horizontal scrolling
991  else if( event.ShiftDown() && !event.ControlDown() )
992  {
993  if( wheelRotation > 0 )
994  cmd.SetId( ID_PAN_LEFT );
995  else if( wheelRotation < 0)
996  cmd.SetId( ID_PAN_RIGHT );
997  }
998  // Without modifiers MousewheelPAN - just pan
999  else
1000  {
1001  wxPoint newStart = GetViewStart();
1002  if( axis == wxMOUSE_WHEEL_HORIZONTAL )
1003  newStart.x += wheelRotation;
1004  else
1005  newStart.y -= wheelRotation;
1006 
1008  GetParent()->SetScrollCenterPosition( center );
1009  Scroll( newStart );
1010  }
1011  }
1012  else if( wheelRotation > 0 )
1013  {
1014  if( event.ShiftDown() && !event.ControlDown() )
1015  cmd.SetId( ID_PAN_UP );
1016  else if( event.ControlDown() && !event.ShiftDown() )
1017  cmd.SetId( ID_PAN_LEFT );
1018  else if( offCenterReq )
1019  cmd.SetId( ID_OFFCENTER_ZOOM_IN );
1020  else
1021  cmd.SetId( ID_POPUP_ZOOM_IN );
1022  }
1023  else if( wheelRotation < 0 )
1024  {
1025  if( event.ShiftDown() && !event.ControlDown() )
1026  cmd.SetId( ID_PAN_DOWN );
1027  else if( event.ControlDown() && !event.ShiftDown() )
1028  cmd.SetId( ID_PAN_RIGHT );
1029  else if( offCenterReq )
1030  cmd.SetId( ID_OFFCENTER_ZOOM_OUT );
1031  else
1032  cmd.SetId( ID_POPUP_ZOOM_OUT );
1033  }
1034 
1035  if( cmd.GetId() )
1036  GetEventHandler()->ProcessEvent( cmd );
1037  event.Skip();
1038 }
wxPoint GetScreenCenterLogicalPosition()
Function GetScreenCenterLogicalPosition.
Definition: draw_panel.cpp:338
static const wxString kicadTraceCoords
Flag to enable draw panel coordinate debug tracing.
Definition: draw_panel.cpp:72
bool m_enableZoomNoCenter
True to enable zooming around the crosshair instead of the center.
void SetScrollCenterPosition(const wxPoint &aPoint)
bool m_ignoreMouseEvents
Ignore mouse events when true.
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
bool m_enableMousewheelPan
True to enable mousewheel panning by default.
#define INSTALL_UNBUFFERED_DC(name, parent)
Definition: id.h:246
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::OnPaint ( wxPaintEvent &  event)

Definition at line 591 of file draw_panel.cpp.

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

592 {
593  if( GetScreen() == NULL )
594  {
595  event.Skip();
596  return;
597  }
598 
599  INSTALL_PAINTDC( paintDC, this );
600 
601  wxRect region = GetUpdateRegion().GetBox();
602  SetClipBox( paintDC, &region );
603  ReDraw( &paintDC, true );
604 }
#define INSTALL_PAINTDC(name, parent)
void SetClipBox(const EDA_RECT &aRect)
void ReDraw(wxDC *aDC, bool aEraseBackground=true)
Definition: draw_panel.cpp:607
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:187
void EDA_DRAW_PANEL::OnPan ( wxCommandEvent &  event)

Definition at line 1406 of file draw_panel.cpp.

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

1407 {
1408  int x, y;
1409  int ppux, ppuy;
1410  int unitsX, unitsY;
1411  int maxX, maxY;
1412  int tmpX, tmpY;
1413 
1414  GetViewStart( &x, &y );
1415  GetScrollPixelsPerUnit( &ppux, &ppuy );
1416  GetVirtualSize( &unitsX, &unitsY );
1417  tmpX = x;
1418  tmpY = y;
1419  maxX = unitsX;
1420  maxY = unitsY;
1421  unitsX /= ppux;
1422  unitsY /= ppuy;
1423 
1424  wxLogTrace( kicadTraceCoords,
1425  wxT( "Scroll center position before pan: (%d, %d)" ), tmpX, tmpY );
1426 
1427  switch( event.GetId() )
1428  {
1429  case ID_PAN_UP:
1430  y -= m_scrollIncrementY;
1431  break;
1432 
1433  case ID_PAN_DOWN:
1434  y += m_scrollIncrementY;
1435  break;
1436 
1437  case ID_PAN_LEFT:
1438  x -= m_scrollIncrementX;
1439  break;
1440 
1441  case ID_PAN_RIGHT:
1442  x += m_scrollIncrementX;
1443  break;
1444 
1445  default:
1446  wxLogDebug( wxT( "Unknown ID %d in EDA_DRAW_PANEL::OnPan()." ), event.GetId() );
1447  }
1448 
1449  bool updateCenterScrollPos = true;
1450 
1451  if( x < 0 )
1452  {
1453  x = 0;
1454  updateCenterScrollPos = false;
1455  }
1456 
1457  if( y < 0 )
1458  {
1459  y = 0;
1460  updateCenterScrollPos = false;
1461  }
1462 
1463  if( x > maxX )
1464  {
1465  x = maxX;
1466  updateCenterScrollPos = false;
1467  }
1468 
1469  if( y > maxY )
1470  {
1471  y = maxY;
1472  updateCenterScrollPos = false;
1473  }
1474 
1475  // Don't update the scroll position beyond the scroll limits.
1476  if( updateCenterScrollPos )
1477  {
1478  double scale = GetParent()->GetScreen()->GetScalingFactor();
1479 
1481  center.x += KiROUND( (double) ( x - tmpX ) / scale );
1482  center.y += KiROUND( (double) ( y - tmpY ) / scale );
1483  GetParent()->SetScrollCenterPosition( center );
1484 
1485  wxLogTrace( kicadTraceCoords,
1486  wxT( "Scroll center position after pan: (%d, %d)" ), center.x, center.y );
1487  }
1488 
1489  Scroll( x/ppux, y/ppuy );
1490 }
static const wxString kicadTraceCoords
Flag to enable draw panel coordinate debug tracing.
Definition: draw_panel.cpp:72
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
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:347
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
const int scale
Definition: id.h:246
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 869 of file draw_panel.cpp.

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

Referenced by OnMouseEvent().

870 {
871  wxPoint pos;
872  wxMenu MasterMenu;
873 
874  INSTALL_UNBUFFERED_DC( dc, this );
875 
876  pos = event.GetLogicalPosition( dc );
877 
878  if( !GetParent()->OnRightClick( pos, &MasterMenu ) )
879  return false;
880 
881  GetParent()->AddMenuZoomAndGrid( &MasterMenu );
882 
883  pos = event.GetPosition();
884  m_ignoreMouseEvents = true;
885  PopupMenu( &MasterMenu, pos );
886  // here, we are waiting for popup menu closing.
887  // Among different ways, it can be closed by clicking on the left mouse button.
888  // The expected behavior is to move the mouse cursor to its initial
889  // location, where the right click was made.
890  // However there is a case where the move cursor does not work as expected:
891  // when the user left clicks on the caption frame: the entire window is moved.
892  // Calling wxSafeYield avoid this behavior because it allows the left click
893  // to be proceeded before moving the mouse
894  wxSafeYield();
895 
896  // Move the mouse cursor to its initial position:
898  m_ignoreMouseEvents = false;
899 
900  return true;
901 }
void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
Definition: draw_panel.cpp:347
bool m_ignoreMouseEvents
Ignore mouse events when true.
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
#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:869
virtual void AddMenuZoomAndGrid(wxMenu *aMasterMenu)
Function AddMenuZoomAndGrid (virtual) Add standard zoom commands and submenu zoom and grid selection ...
Definition: zoom.cpp:239
void EDA_DRAW_PANEL::OnScroll ( wxScrollWinEvent &  event)

Definition at line 407 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.

408 {
409  int id = event.GetEventType();
410  int x, y;
411  int ppux, ppuy;
412  int csizeX, csizeY;
413  int unitsX, unitsY;
414 
415  GetViewStart( &x, &y );
416  GetScrollPixelsPerUnit( &ppux, &ppuy );
417  GetClientSize( &csizeX, &csizeY );
418  GetVirtualSize( &unitsX, &unitsY );
419 
420  int tmpX = x;
421  int tmpY = y;
422 
423  csizeX /= ppux;
424  csizeY /= ppuy;
425 
426  unitsX /= ppux;
427  unitsY /= ppuy;
428 
429  int dir = event.GetOrientation(); // wxHORIZONTAL or wxVERTICAL
430 
431  // On windows and on wxWidgets >= 2.9.5 and < 3.1,
432  // there is a bug in mousewheel event which always generates 2 scroll events
433  // (should be the case only for the default mousewheel event)
434  // with id = wxEVT_SCROLLWIN_LINEUP or wxEVT_SCROLLWIN_LINEDOWN
435  // so we skip these events.
436  // Note they are here just in case, because they are not actually used
437  // in Kicad
438 #if wxCHECK_VERSION( 3, 1, 0 ) || !wxCHECK_VERSION( 2, 9, 5 ) || ( !defined (__WINDOWS__) && !defined (__WXMAC__) )
439  int maxX = unitsX - csizeX;
440  int maxY = unitsY - csizeY;
441 
442  if( id == wxEVT_SCROLLWIN_LINEUP )
443  {
444  if( dir == wxHORIZONTAL )
445  {
446  x -= m_scrollIncrementX;
447 
448  if( x < 0 )
449  x = 0;
450  }
451  else
452  {
453  y -= m_scrollIncrementY;
454 
455  if( y < 0 )
456  y = 0;
457  }
458  }
459  else if( id == wxEVT_SCROLLWIN_LINEDOWN )
460  {
461  if( dir == wxHORIZONTAL )
462  {
463  x += m_scrollIncrementX;
464  if( x > maxX )
465  x = maxX;
466  }
467  else
468  {
469  y += m_scrollIncrementY;
470 
471  if( y > maxY )
472  y = maxY;
473  }
474  }
475  else
476 #endif
477  if( id == wxEVT_SCROLLWIN_THUMBTRACK )
478  {
479  if( dir == wxHORIZONTAL )
480  x = event.GetPosition();
481  else
482  y = event.GetPosition();
483  }
484  else
485  {
486  event.Skip();
487  return;
488  }
489 
490  wxLogTrace( kicadTraceCoords,
491  wxT( "Setting scroll bars ppuX=%d, ppuY=%d, unitsX=%d, unitsY=%d, posX=%d, posY=%d" ),
492  ppux, ppuy, unitsX, unitsY, x, y );
493 
494  double scale = GetParent()->GetScreen()->GetScalingFactor();
495 
497  center.x += KiROUND( (double) ( x - tmpX ) / scale );
498  center.y += KiROUND( (double) ( y - tmpY ) / scale );
499  GetParent()->SetScrollCenterPosition( center );
500 
501  Scroll( x, y );
502  event.Skip();
503 }
static const wxString kicadTraceCoords
Flag to enable draw panel coordinate debug tracing.
Definition: draw_panel.cpp:72
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
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:347
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
const int scale
int m_scrollIncrementY
Y axis scroll increment in pixels per unit.
void EDA_DRAW_PANEL::OnScrollWin ( wxCommandEvent &  event)
void EDA_DRAW_PANEL::ReDraw ( wxDC *  aDC,
bool  aEraseBackground = true 
)

Definition at line 607 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 PCB_EDIT_FRAME::AutoPlaceModule(), and OnPaint().

608 {
609  BASE_SCREEN* Screen = GetScreen();
610 
611  if( Screen == NULL )
612  return;
613 
614  COLOR4D bgColor = GetParent()->GetDrawBgColor();
615 
616  // TODO(JE): Is this correct?
617  if( bgColor.GetBrightness() > 0.5 )
618  {
619  g_XorMode = GR_NXOR;
621  }
622  else
623  {
624  g_XorMode = GR_XOR;
626  }
627 
628  GRResetPenAndBrush( DC );
629 
630  DC->SetBackground( wxBrush( bgColor.ToColour() ) );
631  DC->SetBackgroundMode( wxSOLID );
632 
633  if( erasebg )
634  EraseScreen( DC );
635 
636  GetParent()->RedrawActiveWindow( DC, erasebg );
637 
638  // Verfies that the clipping is working correctly. If these two sets of numbers are
639  // not the same or really close. The clipping algorithms are broken.
640  wxLogTrace( kicadTraceCoords,
641  wxT( "Clip box: (%d, %d, %d, %d), Draw extents (%d, %d, %d, %d)" ),
643  DC->MinX(), DC->MinY(), DC->MaxX(), DC->MaxY() );
644 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:51
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:196
static const wxString kicadTraceCoords
Flag to enable draw panel coordinate debug tracing.
Definition: draw_panel.cpp:72
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:324
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
double GetBrightness() const
Function GetBrightness Returns the brightness value of the color ranged from 0.0 to 1...
Definition: color4d.h:254
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
int GetBottom() const
int GetRight() const
virtual void RedrawActiveWindow(wxDC *DC, bool EraseBg)=0
int GetX() const
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:187
Definition: colors.h:49
int GetY() const
Definition: colors.h:45
void EraseScreen(wxDC *DC)
Definition: draw_panel.cpp:553
COLOR4D g_GhostColor
Draw color for moving objects.
Definition: common.cpp:57
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 325 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::AppendOneEEProject(), 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::Clean_Pcb(), FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList(), FOOTPRINT_WIZARD_FRAME::ClickOnPageList(), LIB_EDIT_FRAME::CreateNewLibraryPart(), PCB_EDIT_FRAME::Delete_Module(), PCB_EDIT_FRAME::Delete_OldZone_Fill(), SCH_EDIT_FRAME::DeleteAnnotation(), LIB_EDIT_FRAME::deleteItem(), SCH_EDIT_FRAME::DeleteItemAtCrossHair(), LIB_EDIT_FRAME::DeleteOnePart(), SCH_EDIT_FRAME::DisplayCurrentSheet(), 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(), SCH_EDIT_FRAME::EndSegment(), GERBVIEW_FRAME::Erase_Current_DrawLayer(), PL_EDITOR_FRAME::Files_io(), GERBVIEW_FRAME::Files_io(), PCB_EDIT_FRAME::Files_io_from_id(), LEGACY_ARRAY_CREATOR::finalise(), PCB_EDIT_FRAME::FlipTextePcb(), GERBVIEW_FRAME::GERBVIEW_FRAME(), LIB_EDIT_FRAME::GetComponentFromRedoList(), LIB_EDIT_FRAME::GetComponentFromUndoList(), PL_EDITOR_FRAME::GetLayoutFromRedoList(), PL_EDITOR_FRAME::GetLayoutFromUndoList(), 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::InstallConfigFrame(), GERBVIEW_FRAME::InstallGerberOptionsDialog(), PCB_EDIT_FRAME::InstallModuleOptionsFrame(), SCH_EDIT_FRAME::KiwayMailIn(), GERBVIEW_FRAME::LoadGerberJobFile(), 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_ANNOTATE::OnApplyClick(), SCH_EDIT_FRAME::OnAutoplaceFields(), LIB_EDIT_FRAME::OnEditComponentProperties(), SCH_EDIT_FRAME::OnEditItem(), FOOTPRINT_EDIT_FRAME::OnEditItemRequest(), LIB_EDIT_FRAME::OnEditPin(), 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(), FOOTPRINT_EDIT_FRAME::OnLeftDClick(), SCH_EDIT_FRAME::OnLeftDClick(), PL_EDITOR_FRAME::OnNewPageLayout(), DIALOG_DISPLAY_OPTIONS::OnOKBUttonClick(), DIALOG_GENERALOPTIONS::OnOkClick(), DIALOG_EXCHANGE_MODULE::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(), GERBVIEW_FRAME::OnSelectActiveLayer(), 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(), EDA_DRAW_FRAME::OnToggleGridState(), PCB_BASE_FRAME::OnTogglePadDrawMode(), 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(), PCB_EDIT_FRAME::RemoveMisConnectedTracks(), FOOTPRINT_EDIT_FRAME::RemoveStruct(), SCH_EDIT_FRAME::RepeatDrawItem(), SCH_EDIT_FRAME::RescueProject(), PCB_BASE_FRAME::ResetModuleTextSizes(), PCB_BASE_FRAME::ResetTextSize(), 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(), PCB_EDIT_FRAME::SpreadFootprints(), LIB_EDIT_FRAME::StartMovePin(), PCB_EDIT_FRAME::StartMoveTextePcb(), PCB_EDIT_FRAME::Swap_Layers(), 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(), DIALOG_FOOTPRINTS_DISPLAY_OPTIONS::UpdateObjectSettings(), and GERBVIEW_FRAME::UseGalCanvas().

326 {
327  if( GetParent()->IsGalCanvasActive() )
328  {
330  }
331  else
332  {
333  wxScrolledWindow::Refresh( eraseBackground, rect );
334  }
335 }
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:174
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:870
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 305 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(), 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().

306 {
307  INSTALL_UNBUFFERED_DC( dc, this );
308 
309  wxRect rect = aRect;
310 
311  rect.x = dc.LogicalToDeviceX( rect.x );
312  rect.y = dc.LogicalToDeviceY( rect.y );
313  rect.width = dc.LogicalToDeviceXRel( rect.width );
314  rect.height = dc.LogicalToDeviceYRel( rect.height );
315 
316  wxLogTrace( kicadTraceCoords,
317  wxT( "Refresh area: drawing (%d, %d, %d, %d), device (%d, %d, %d, %d)" ),
318  aRect.GetX(), aRect.GetY(), aRect.GetWidth(), aRect.GetHeight(),
319  rect.x, rect.y, rect.width, rect.height );
320 
321  RefreshRect( rect, aEraseBackground );
322 }
static const wxString kicadTraceCoords
Flag to enable draw panel coordinate debug tracing.
Definition: draw_panel.cpp:72
int GetHeight() const
#define INSTALL_UNBUFFERED_DC(name, parent)
int GetX() const
int GetWidth() const
int GetY() const
void EDA_DRAW_PANEL::SetCanStartBlock ( int  aStartBlock)
inline

Definition at line 165 of file class_drawpanel.h.

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

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

Definition at line 136 of file class_drawpanel.h.

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

136 { 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 506 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.

507 {
508  wxRect clipBox;
509 
510  // Use the entire visible device area if no clip area was defined.
511  if( aRect == NULL )
512  {
513  BASE_SCREEN* Screen = GetScreen();
514 
515  if( !Screen )
516  return;
517 
518  Screen->m_StartVisu = CalcUnscrolledPosition( wxPoint( 0, 0 ) );
519  clipBox.SetSize( GetClientSize() );
520 
521  int scrollX, scrollY;
522 
523  double scalar = Screen->GetScalingFactor();
524  scrollX = KiROUND( Screen->GetGridSize().x * scalar );
525  scrollY = KiROUND( Screen->GetGridSize().y * scalar );
526 
527  m_scrollIncrementX = std::max( GetClientSize().x / 8, scrollX );
528  m_scrollIncrementY = std::max( GetClientSize().y / 8, scrollY );
529  Screen->m_ScrollbarPos.x = GetScrollPos( wxHORIZONTAL );
530  Screen->m_ScrollbarPos.y = GetScrollPos( wxVERTICAL );
531  }
532  else
533  {
534  clipBox = *aRect;
535  }
536 
537  // Pad clip box in device units.
538  clipBox.Inflate( CLIP_BOX_PADDING );
539 
540  // Convert from device units to drawing units.
541  m_ClipBox.SetOrigin( wxPoint( aDC.DeviceToLogicalX( clipBox.x ),
542  aDC.DeviceToLogicalY( clipBox.y ) ) );
543  m_ClipBox.SetSize( wxSize( aDC.DeviceToLogicalXRel( clipBox.width ),
544  aDC.DeviceToLogicalYRel( clipBox.height ) ) );
545 
546  wxLogTrace( kicadTraceCoords,
547  wxT( "Device clip box=(%d, %d, %d, %d), Logical clip box=(%d, %d, %d, %d)" ),
548  clipBox.x, clipBox.y, clipBox.width, clipBox.height,
550 }
static const wxString kicadTraceCoords
Flag to enable draw panel coordinate debug tracing.
Definition: draw_panel.cpp:72
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
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
void SetOrigin(const wxPoint &pos)
wxPoint m_StartVisu
Coordinates in drawing units of the current view position (upper left corner of device) ...
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
#define CLIP_BOX_PADDING
Definition: draw_panel.cpp:48
wxPoint m_ScrollbarPos
Current scroll bar position in scroll units.
void SetSize(const wxSize &size)
#define max(a, b)
Definition: auxiliary.h:86
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
int GetX() const
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:187
int GetWidth() const
int GetY() const
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 440 of file class_drawpanel.h.

Referenced by EDA_DRAW_FRAME::SetToolID().

441  {
442  m_currentCursor = aCursor;
443  SetCursor( (wxStockCursor) m_currentCursor );
444  }
int m_currentCursor
Current mouse cursor shape id.
void EDA_DRAW_PANEL::SetEnableAutoPan ( bool  aEnable)
inline

Definition at line 152 of file class_drawpanel.h.

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

152 { m_enableAutoPan = aEnable; }
bool m_enableAutoPan
True to enable automatic panning.
void EDA_DRAW_PANEL::SetEnableBlockCommands ( bool  aEnable)
inline

Definition at line 160 of file class_drawpanel.h.

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

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

Definition at line 647 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 DIALOG_DISPLAY_OPTIONS::OnOKBUttonClick(), DIALOG_GENERALOPTIONS::OnOkClick(), and SCH_EDIT_FRAME::OnPreferencesOptions().

648 {
649  m_enableMousewheelPan = aEnable;
650 
651  if( GetParent()->IsGalCanvasActive() )
653 }
virtual void EnableMousewheelPan(bool aEnable)
Function EnableMousewheelPan() Enables or disables mousewheel panning.
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
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:870
void EDA_DRAW_PANEL::SetEnableZoomNoCenter ( bool  aEnable)

Definition at line 656 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 DIALOG_DISPLAY_OPTIONS::OnOKBUttonClick(), DIALOG_GENERALOPTIONS::OnOkClick(), SCH_EDIT_FRAME::OnPreferencesOptions(), EDA_DRAW_FRAME::PushPreferences(), and DIALOG_FOOTPRINTS_DISPLAY_OPTIONS::UpdateObjectSettings().

657 {
658  m_enableZoomNoCenter = aEnable;
659 
660  if( GetParent()->IsGalCanvasActive() )
662 }
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:174
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:870
void EDA_DRAW_PANEL::SetGrid ( const wxRealPoint &  size)
void EDA_DRAW_PANEL::SetIgnoreLeftButtonReleaseEvent ( bool  aIgnore)
inline

Definition at line 158 of file class_drawpanel.h.

Referenced by EDA_DRAW_FRAME::SkipNextLeftButtonReleaseEvent().

158 { 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 384 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(), PCB_EDIT_FRAME::BeginMoveDimensionText(), PCB_EDIT_FRAME::BeginMoveTarget(), 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::EditDimension(), 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::PlaceDimensionText(), PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment(), PL_EDITOR_FRAME::PlaceItem(), PCB_BASE_FRAME::PlaceModule(), PCB_BASE_FRAME::PlacePad(), LIB_EDIT_FRAME::PlacePin(), PCB_EDIT_FRAME::PlaceTarget(), 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().

386  {
387  m_mouseCaptureCallback = aMouseCaptureCallback;
388  m_endMouseCaptureCallback = aEndMouseCaptureCallback;
389  }
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 163 of file class_drawpanel.h.

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

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

Definition at line 275 of file draw_panel.cpp.

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

Referenced by EDA_DRAW_FRAME::UseGalCanvas().

276 {
277  GetScreen()->SetZoom( zoom );
278 }
bool SetZoom(double iu_per_du)
Function SetZoom adjusts the current zoom factor.
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:187
wxPoint EDA_DRAW_PANEL::ToDeviceXY ( const wxPoint pos)

Function ToDeviceXY transforms logical to device coordinates.

Definition at line 195 of file draw_panel.cpp.

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

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

196 {
197  wxPoint ret;
198  INSTALL_UNBUFFERED_DC( dc, this );
199  ret.x = dc.LogicalToDeviceX( pos.x );
200  ret.y = dc.LogicalToDeviceY( pos.y );
201  return ret;
202 }
#define INSTALL_UNBUFFERED_DC(name, parent)
wxPoint EDA_DRAW_PANEL::ToLogicalXY ( const wxPoint pos)

Function ToLogicalXY transforms device to logical coordinates.

Definition at line 205 of file draw_panel.cpp.

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

Referenced by EDA_DRAW_FRAME::RedrawScreen2().

206 {
207  wxPoint ret;
208  INSTALL_UNBUFFERED_DC( dc, this );
209  ret.x = dc.DeviceToLogicalX( pos.x );
210  ret.y = dc.DeviceToLogicalY( pos.y );
211  return ret;
212 }
#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 73 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 an other sheet >= 0 (or >= n) if a block can start

Definition at line 114 of file class_drawpanel.h.

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

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 71 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().

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().

bool EDA_DRAW_PANEL::m_enableAutoPan
private

True to enable automatic panning.

Definition at line 78 of file class_drawpanel.h.

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

bool EDA_DRAW_PANEL::m_enableBlockCommands
private

True enables block commands.

Definition at line 91 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 76 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 75 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 109 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 82 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 89 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 99 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 106 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 103 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 80 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: