60 m_frame = getEditFrame<EDA_DRAW_FRAME>();
76 m_grids.emplace_back( KiROUND<double, int>( gridSizeX ),
77 KiROUND<double, int>( gridSizeY ) );
91 wxASSERT_MSG(
false, wxS(
"Invalid unit" ) );
158 modifiers |= wxGetKeyState( WXK_SHIFT ) ?
MD_SHIFT : 0;
159 modifiers |= wxGetKeyState( WXK_CONTROL ) ?
MD_CTRL : 0;
160 modifiers |= wxGetKeyState( WXK_ALT ) ?
MD_ALT : 0;
175 wxFAIL_MSG( wxS(
"CursorControl(): unexpected request" ) );
189 VECTOR2D center = view->GetCenter();
191 bool mirroredX = view->IsMirroredX();
204 center -=
VECTOR2D( mirroredX ? -gridSize.
x : gridSize.
x, 0 );
208 center +=
VECTOR2D( mirroredX ? -gridSize.
x : gridSize.
x, 0 );
216 view->SetCenter( center );
259 for( idx = 0; idx < int( zoomList.size() ); ++idx )
261 if( zoomList[idx] >=
zoom )
265 if( idx >=
int( zoomList.size() ) )
266 idx = (
int) zoomList.size() - 1;
270 for( idx =
int( zoomList.size() ) - 1; idx >= 0; --idx )
272 if( zoomList[idx] <=
zoom )
348 if( selection.
Empty() )
360 double scale = view->
GetScale() / std::max( fabs( vsize.
x / screenSize.
x ),
361 fabs( vsize.
y / screenSize.
y ) );
365 if( !std::isfinite(
scale ) )
374 double margin_scale_factor = 1.04;
376 if( canvas->GetClientSize().y < 768 )
377 margin_scale_factor = 1.10;
386 margin_scale_factor = 1.30;
391 margin_scale_factor = 1.48;
425 if( selection.
Empty() )
432 bBox = getModel<EDA_ITEM>()->ViewBBox();
472 double scale = zoomList[idx];
474 if( aCenterOnCursor )
499 if( currentGrid >=
int(
m_grids.size() ) )
512 if( currentGrid < 0 )
513 currentGrid = (int)
m_grids.size() - 1;
529 currentGrid = std::clamp( idx, 0, (
int)
m_grids.size() - 1 );
539 currentGrid = std::max( 0, std::min( currentGrid,
static_cast<int>(
m_grids.size() ) - 1 ) );
542 wxUpdateUIEvent
dummy;
603 [
this](
const wxString& aParentName )
606 [
this, aParentName]()
614 case FRAME_SCH: showGridPrefs(
_(
"Schematic Editor" ) );
break;
619 case FRAME_GERBER: showGridPrefs(
_(
"Gerber Viewer" ) );
break;
620 default: wxFAIL_MSG(
"Unknown frame: " +
GetName() );
break;
654 wxASSERT_MSG(
false, wxS(
"Invalid unit for the frame" ) );
672 m_frame->SetStatusText( wxEmptyString );
702 galOpts.NotifyChanged();
BASE_SCREEN class implementation.
static TOOL_ACTION gridProperties
static TOOL_ACTION gridFastCycle
static TOOL_ACTION toggleGrid
static TOOL_ACTION zoomRedraw
static TOOL_ACTION millimetersUnits
static TOOL_ACTION gridFast1
static TOOL_ACTION gridPrev
static TOOL_ACTION cursorLeft
static TOOL_ACTION zoomOutCenter
static TOOL_ACTION togglePolarCoords
static TOOL_ACTION zoomIn
static TOOL_ACTION cursorLeftFast
static TOOL_ACTION gridPreset
static TOOL_ACTION zoomFitSelection
static TOOL_ACTION centerSelection
static TOOL_ACTION cursorDown
static TOOL_ACTION zoomOut
static TOOL_ACTION milsUnits
static TOOL_ACTION cursorRightFast
static TOOL_ACTION toggleBoundingBoxes
static TOOL_ACTION showContextMenu
static TOOL_ACTION toggleCursor
static TOOL_ACTION centerContents
static TOOL_ACTION zoomCenter
static TOOL_ACTION panDown
static TOOL_ACTION cursorDblClick
static TOOL_ACTION cursorDownFast
static TOOL_ACTION inchesUnits
static TOOL_ACTION cursorUpFast
static TOOL_ACTION toggleCursorStyle
static TOOL_ACTION gridOrigin
static TOOL_ACTION panLeft
static TOOL_ACTION selectionTool
static TOOL_ACTION cursorClick
static TOOL_ACTION zoomFitScreen
static TOOL_ACTION zoomPreset
static TOOL_ACTION zoomFitObjects
static TOOL_ACTION toggleUnits
static TOOL_ACTION zoomInCenter
static TOOL_ACTION panRight
static TOOL_ACTION gridSetOrigin
static TOOL_ACTION gridFast2
static TOOL_ACTION cursorUp
Cursor control with keyboard.
static TOOL_ACTION refreshPreview
static TOOL_ACTION toggleGridOverrides
static TOOL_ACTION gridNext
static TOOL_ACTION cursorRight
static TOOL_ACTION resetLocalCoords
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr size_type GetHeight() const
constexpr const SizeVec & GetSize() const
FRAME_T GetFrameType() const
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void ShowPreferences(wxString aStartPage, wxString aStartParentPage)
Displays the preferences and settings of all opened editors paged dialog, starting with a particular ...
void ChangeUserUnits(EDA_UNITS aUnits)
bool IsType(FRAME_T aType) const
The base class for create windows for drawing purpose.
virtual const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const
Returns bbox of document with option to not include some items.
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
virtual void HardRedraw()
Rebuild the GAL and redraws the screen.
virtual void SetGridOrigin(const VECTOR2I &aPosition)=0
bool IsGridOverridden() const
GAL_DISPLAY_OPTIONS_IMPL & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
virtual const VECTOR2I & GetGridOrigin() const =0
Return the absolute coordinates of the origin of the snap grid.
void SetShowPolarCoords(bool aShow)
virtual void SetGridVisibility(bool aVisible)
void UpdateStatusBar() override
Update the status bar information.
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
bool IsGridVisible() const
virtual std::unique_ptr< GRID_HELPER > MakeGridHelper()
virtual void SetGridOverrides(bool aOverride)
void OnUpdateSelectGrid(wxUpdateUIEvent &aEvent)
Update the checked item in the grid wxchoice.
bool GetShowPolarCoords() const
For those frames that support polar coordinates.
virtual BOX2I GetDefaultViewBBox() const
Return the bounding box of the view that should be used if model is not valid.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
void ForceRefresh()
Force a redraw.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
static const TOOL_EVENT GridChangedByKeyEvent
void WriteConfig(WINDOW_SETTINGS &aCfg)
bool m_forceDisplayCursor
The pixel scale factor (>1 for hi-DPI scaled displays)
bool m_fullscreenCursor
Force cursor display.
double GetZoomFactor() const
void SetGridSize(const VECTOR2D &aGridSize)
Set the grid size.
const VECTOR2D & GetGridSize() const
Return the grid size.
void SetGridVisibility(bool aVisibility)
Set the visibility setting of the grid.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void SetDrawBoundingBoxes(bool aEnabled)
bool GetDrawBoundingBoxes() const
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual VECTOR2D GetRawCursorPosition(bool aSnappingEnabled=true) const =0
Return the current cursor position in world coordinates ignoring the cursorUp position force mode.
virtual void CenterOnCursor()=0
Set the viewport center to the current cursor position and warps the cursor to the screen center.
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
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.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
bool IsMirroredX() const
Return true if view is flipped across the X axis.
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
bool Empty() const
Checks if there is anything selected.
virtual BOX2I GetBoundingBox() const
const EDA_IU_SCALE & GetIuScale() const
EDA_UNITS GetUserUnits() const
VECTOR2I GetValue()
Returns the value in internal units.
@ FRAME_SCH_SYMBOL_EDITOR
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
KICOMMON_API double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Function DoubleValueFromString converts aTextValue to a double.
KICOMMON_API bool IsImperialUnit(EDA_UNITS aUnit)
KICOMMON_API bool IsMetricUnit(EDA_UNITS aUnit)
@ ALL
All except INITIAL_ADD.
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
std::vector< FAB_LAYER_COLOR > dummy
std::vector< GRID > grids
Common grid settings, available to every frame.
Structure to keep VIEW_CONTROLS settings for easy store/restore operations.
VECTOR2D m_forcedPosition
Is the forced cursor position enabled.
bool m_forceCursorPosition
Should the cursor be locked within the parent window area.
std::vector< double > zoom_factors
VECTOR2< double > VECTOR2D
VECTOR2I ToVECTOR2I(const wxSize &aSize)
VECTOR2D ToVECTOR2D(const wxPoint &aPoint)