55 m_frame = getEditFrame<EDA_DRAW_FRAME>();
62 for(
const wxString& gridDef : settings.
sizes )
67 m_grids.emplace_back( KiROUND<double, int>( gridSize ), KiROUND<double, int>( gridSize ) );
75 m_grids.emplace_back( KiROUND<double, int>( userGridX ), KiROUND<double, int>( userGridY ) );
88 wxASSERT_MSG(
false, wxS(
"Invalid unit" ) );
105 long type = aEvent.
Parameter<intptr_t>();
114 gridSize = gridSize * 10;
142 modifiers |= wxGetKeyState( WXK_SHIFT ) ?
MD_SHIFT : 0;
143 modifiers |= wxGetKeyState( WXK_CONTROL ) ?
MD_CTRL : 0;
144 modifiers |= wxGetKeyState( WXK_ALT ) ?
MD_ALT : 0;
160 wxFAIL_MSG( wxS(
"CursorControl(): unexpected request" ) );
172 long type = aEvent.
Parameter<intptr_t>();
174 VECTOR2D center = view->GetCenter();
176 bool mirroredX = view->IsMirroredX();
189 center -=
VECTOR2D( mirroredX ? -gridSize.
x : gridSize.
x, 0 );
193 center +=
VECTOR2D( mirroredX ? -gridSize.
x : gridSize.
x, 0 );
201 view->SetCenter( center );
244 for( idx = 0; idx < int( zoomList.size() ); ++idx )
246 if( zoomList[idx] >=
zoom )
250 if( idx >=
int( zoomList.size() ) )
251 idx = (
int) zoomList.size() - 1;
255 for( idx =
int( zoomList.size() ) - 1; idx >= 0; --idx )
257 if( zoomList[idx] <=
zoom )
323 double scale = view->
GetScale() / std::max( fabs( vsize.
x / screenSize.
x ),
324 fabs( vsize.
y / screenSize.
y ) );
328 if( !std::isfinite(
scale ) )
336 double margin_scale_factor = 1.04;
338 if( canvas->GetClientSize().y < 768 )
339 margin_scale_factor = 1.10;
348 margin_scale_factor = 1.30;
353 margin_scale_factor = 1.48;
367 BOX2I bBox = getModel<EDA_ITEM>()->ViewBBox();
385 unsigned int idx = aEvent.
Parameter<intptr_t>();
405 double scale = zoomList[idx];
407 if( aCenterOnCursor )
430 if( currentGrid >=
int(
m_grids.size() ) )
443 if( currentGrid < 0 )
444 currentGrid = (int)
m_grids.size() - 1;
460 currentGrid = std::max( 0, std::min( idx, (
int)
m_grids.size() - 1 ) );
470 currentGrid = std::max( 0, std::min( currentGrid,
static_cast<int>(
m_grids.size() ) - 1 ) );
473 wxUpdateUIEvent
dummy;
511 wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
529 wxASSERT_MSG(
false, wxS(
"Invalid unit for the frame" ) );
547 m_frame->SetStatusText( wxEmptyString );
560 if( vcSettings.m_forceCursorPosition )
577 galOpts.NotifyChanged();
BASE_SCREEN class implementation.
Gather all the actions that are shared by tools.
static TOOL_ACTION gridProperties
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 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 gridFast2
static TOOL_ACTION cursorUp
Cursor control with keyboard.
static TOOL_ACTION refreshPreview
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
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void ChangeUserUnits(EDA_UNITS aUnits)
bool ProcessEvent(wxEvent &aEvent) override
Override the default process event handler to implement the auto save feature.
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.
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
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
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.
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
@ FRAME_FOOTPRINT_VIEWER_MODAL
@ FRAME_SCH_SYMBOL_EDITOR
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.
bool IsImperialUnit(EDA_UNITS aUnit)
bool IsMetricUnit(EDA_UNITS aUnit)
@ ALL
All except INITIAL_ADD.
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
std::vector< FAB_LAYER_COLOR > dummy
Common grid settings, available to every frame.
std::vector< wxString > sizes
std::vector< double > zoom_factors
VECTOR2< double > VECTOR2D
VECTOR2I ToVECTOR2I(const wxSize &aSize)
VECTOR2D ToVECTOR2D(const wxPoint &aPoint)