55 m_frame = getEditFrame<EDA_DRAW_FRAME>();
61 for(
const wxString& gridDef : settings.
sizes )
64 m_grids.emplace_back( gridSize, gridSize );
81 wxASSERT_MSG(
false,
"Invalid unit" );
100 type &= ~
ACTIONS::CURSOR_FAST_MOVE;
107 gridSize = gridSize * 10;
120 cursor -=
VECTOR2D( mirroredX ? -gridSize.
x : gridSize.
x, 0 );
124 cursor +=
VECTOR2D( mirroredX ? -gridSize.
x : gridSize.
x, 0 );
135 modifiers |= wxGetKeyState( WXK_SHIFT ) ?
MD_SHIFT : 0;
136 modifiers |= wxGetKeyState( WXK_CONTROL ) ?
MD_CTRL : 0;
137 modifiers |= wxGetKeyState( WXK_ALT ) ?
MD_ALT : 0;
152 wxFAIL_MSG(
"CursorControl(): unexpected request" );
164 long type = aEvent.
Parameter<intptr_t>();
166 VECTOR2D center = view->GetCenter();
168 bool mirroredX = view->IsMirroredX();
181 center -=
VECTOR2D( mirroredX ? -gridSize.
x : gridSize.
x, 0 );
185 center +=
VECTOR2D( mirroredX ? -gridSize.
x : gridSize.
x, 0 );
193 view->SetCenter( center );
236 for( idx = 0; idx < int( zoomList.size() ); ++idx )
238 if( zoomList[idx] >= zoom )
242 if( idx >=
int( zoomList.size() ) )
243 idx = (int) zoomList.size() - 1;
247 for( idx =
int( zoomList.size() ) - 1; idx >= 0; --idx )
249 if( zoomList[idx] <= zoom )
315 double scale = view->
GetScale() / std::max( fabs( vsize.
x / screenSize.
x ),
316 fabs( vsize.
y / screenSize.
y ) );
320 if( !std::isfinite(
scale ) )
327 double margin_scale_factor = 1.02;
337 margin_scale_factor = 1.4;
342 margin_scale_factor = 2;
348 margin_scale_factor = 1.02;
352 margin_scale_factor = 1.02;
365 BOX2I bBox = getModel<EDA_ITEM>()->ViewBBox();
373 VECTOR2D scrollbarSize =
VECTOR2D( canvas->GetSize() - canvas->GetClientSize() );
383 unsigned int idx = aEvent.
Parameter<intptr_t>();
403 double scale = zoomList[idx];
405 if( aCenterOnCursor )
426 if( currentGrid + 1 <
int(
m_grids.size() ) )
437 if( currentGrid > 0 )
454 currentGrid = std::max( 0, std::min( idx, (
int)
m_grids.size() - 1 ) );
464 currentGrid = std::max( 0, std::min( currentGrid, static_cast<int>(
m_grids.size() ) - 1 ) );
467 wxUpdateUIEvent
dummy;
505 wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
523 wxASSERT_MSG(
false,
"Invalid unit for the frame" );
541 m_frame->SetStatusText( wxEmptyString );
554 if( vcSettings.m_forceCursorPosition )
570 galOpts.NotifyChanged();
static TOOL_ACTION zoomPreset
static TOOL_ACTION zoomInCenter
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
Implementation of conversion functions that require both schematic and board internal units.
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
void SetShowPolarCoords(bool aShow)
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
static TOOL_ACTION cursorRight
static TOOL_ACTION zoomFitScreen
static TOOL_ACTION millimetersUnits
static TOOL_ACTION cursorRightFast
static TOOL_ACTION gridFast1
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
void ChangeUserUnits(EDA_UNITS aUnits)
static TOOL_ACTION zoomFitObjects
static TOOL_ACTION panLeft
bool m_forceDisplayCursor
The pixel scale factor (>1 for hi-DPI scaled displays)
The base class for create windows for drawing purpose.
std::vector< double > zoom_factors
bool IsImperialUnit(EDA_UNITS aUnit)
static TOOL_ACTION zoomOutCenter
Auxiliary rendering target (noncached)
virtual void CenterOnCursor() const =0
Set the viewport center to the current cursor position and warps the cursor to the screen center.
static TOOL_ACTION centerContents
static TOOL_ACTION gridFast2
std::vector< wxString > sizes
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
static TOOL_ACTION toggleCursor
static TOOL_ACTION gridPreset
bool IsMetricUnit(EDA_UNITS aUnit)
static TOOL_ACTION gridPrev
VECTOR2< double > VECTOR2D
static TOOL_ACTION panDown
long long int ValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
bool IsGridVisible() const
static TOOL_ACTION toggleGrid
void OnUpdateSelectGrid(wxUpdateUIEvent &aEvent)
Update the checked item in the grid combobox.
static TOOL_ACTION inchesUnits
coord_type GetWidth() const
static TOOL_ACTION cursorUpFast
static TOOL_ACTION cursorDownFast
static TOOL_ACTION cursorLeft
static TOOL_ACTION panRight
static TOOL_ACTION togglePolarCoords
An interface for classes handling user events controlling the view behavior such as zooming,...
double GetZoomFactor() const
Get the zoom factor.
static TOOL_ACTION cursorLeftFast
virtual const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const
Returns bbox of document with option to not include some items.
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
void SetGridSize(const VECTOR2D &aGridSize)
Set the grid size.
static TOOL_ACTION milsUnits
virtual void HardRedraw()
Rebuild the GAL and redraws the screen.
bool IsMirroredX() const
Return true if view is flipped across the X axis.
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
const VECTOR2D & GetGridSize() const
Return the grid size.
virtual VECTOR2D GetRawCursorPosition(bool aSnappingEnabled=true) const =0
Return the current cursor position in world coordinates ignoring the cursorUp position force mode.
bool GetShowPolarCoords() const
For those frames that support polar coordinates.
bool IsType(FRAME_T aType) const
static TOOL_ACTION zoomCenter
static TOOL_ACTION cursorUp
Cursor control with keyboard.
static TOOL_ACTION zoomRedraw
static TOOL_ACTION cursorDblClick
static TOOL_ACTION resetLocalCoords
coord_type GetHeight() const
static TOOL_ACTION gridNext
void SetGridVisibility(bool aVisibility)
Set the visibility setting of the grid.
static TOOL_ACTION gridProperties
Gather all the actions that are shared by tools.
static TOOL_ACTION zoomIn
static TOOL_ACTION zoomOut
const Vec & GetSize() const
static TOOL_ACTION toggleCursorStyle
void UpdateStatusBar() override
Update the status bar information.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
BASE_SCREEN class implementation.
static TOOL_ACTION showContextMenu
static TOOL_ACTION cursorDown
virtual BOX2I GetDefaultViewBBox() const
Return the bounding box of the view that should be used if model is not valid.
static TOOL_ACTION toggleUnits
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool m_fullscreenCursor
Force cursor display.
virtual void SetGridVisibility(bool aVisible)
bool ProcessEvent(wxEvent &aEvent) override
Override the default process event handler to implement the auto save feature.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
static TOOL_ACTION selectionTool
static TOOL_ACTION refreshPreview
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
static TOOL_ACTION cursorClick
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Common grid settings, available to every frame.