58 m_frame = getEditFrame<EDA_DRAW_FRAME>();
72 m_grids.emplace_back( KiROUND<double, int>( gridSizeX ),
73 KiROUND<double, int>( gridSizeY ) );
87 wxASSERT_MSG(
false, wxS(
"Invalid unit" ) );
148 modifiers |= wxGetKeyState( WXK_SHIFT ) ?
MD_SHIFT : 0;
149 modifiers |= wxGetKeyState( WXK_CONTROL ) ?
MD_CTRL : 0;
150 modifiers |= wxGetKeyState( WXK_ALT ) ?
MD_ALT : 0;
165 wxFAIL_MSG( wxS(
"CursorControl(): unexpected request" ) );
179 VECTOR2D center = view->GetCenter();
181 bool mirroredX = view->IsMirroredX();
194 center -=
VECTOR2D( mirroredX ? -gridSize.
x : gridSize.
x, 0 );
198 center +=
VECTOR2D( mirroredX ? -gridSize.
x : gridSize.
x, 0 );
206 view->SetCenter( center );
249 for( idx = 0; idx < int( zoomList.size() ); ++idx )
251 if( zoomList[idx] >=
zoom )
255 if( idx >=
int( zoomList.size() ) )
256 idx = (
int) zoomList.size() - 1;
260 for( idx =
int( zoomList.size() ) - 1; idx >= 0; --idx )
262 if( zoomList[idx] <=
zoom )
334 double scale = view->
GetScale() / std::max( fabs( vsize.
x / screenSize.
x ),
335 fabs( vsize.
y / screenSize.
y ) );
339 if( !std::isfinite(
scale ) )
348 double margin_scale_factor = 1.04;
350 if( canvas->GetClientSize().y < 768 )
351 margin_scale_factor = 1.10;
360 margin_scale_factor = 1.30;
365 margin_scale_factor = 1.48;
380 BOX2I bBox = getModel<EDA_ITEM>()->ViewBBox();
419 double scale = zoomList[idx];
421 if( aCenterOnCursor )
446 if( currentGrid >=
int(
m_grids.size() ) )
459 if( currentGrid < 0 )
460 currentGrid = (int)
m_grids.size() - 1;
486 currentGrid = std::max( 0, std::min( currentGrid,
static_cast<int>(
m_grids.size() ) - 1 ) );
489 wxUpdateUIEvent
dummy;
550 [
this]( wxString aParentName )
553 [
this, aParentName]()
561 case FRAME_SCH: showGridPrefs(
_(
"Schematic Editor" ) );
break;
566 default: wxFAIL_MSG(
"Unknown frame: " +
GetName() );
break;
578 if( dlg.ShowModal() == wxID_OK )
600 wxASSERT_MSG(
false, wxS(
"Invalid unit for the frame" ) );
618 m_frame->SetStatusText( wxEmptyString );
631 if( vcSettings.m_forceCursorPosition )
648 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 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.
coord_type GetHeight() const
coord_type GetWidth() const
const Vec & 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 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.
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)
T clamp(T min, T value, T max)
std::vector< FAB_LAYER_COLOR > dummy
std::vector< GRID > grids
Common grid settings, available to every frame.
std::vector< double > zoom_factors
VECTOR2< double > VECTOR2D
VECTOR2I ToVECTOR2I(const wxSize &aSize)
VECTOR2D ToVECTOR2D(const wxPoint &aPoint)