66 if( settings.
grids.empty() )
67 settings.
grids =
m_frame->config()->DefaultGridSizeList();
90 wxASSERT_MSG(
false, wxS(
"Invalid unit" ) );
107 std::unique_ptr<GRID_HELPER>
grid =
m_frame->MakeGridHelper();
111 gridSize =
grid->GetGridSize(
grid->GetSelectionGrid(
m_frame->GetCurrentSelection() ) );
163 modifiers |= wxGetKeyState( WXK_SHIFT ) ?
MD_SHIFT : 0;
164 modifiers |= wxGetKeyState( WXK_CONTROL ) ?
MD_CTRL : 0;
165 modifiers |= wxGetKeyState( WXK_ALT ) ?
MD_ALT : 0;
180 wxFAIL_MSG( wxS(
"CursorControl(): unexpected request" ) );
196 bool mirroredX = view->IsMirroredX();
221 view->SetCenter(
center );
259 std::vector<double>& zoomList =
m_frame->GetWindowSettings(
m_toolMgr->GetSettings() )->zoom_factors;
264 for( idx = 0; idx < int( zoomList.size() ); ++idx )
266 if( zoomList[idx] >=
zoom )
270 if( idx >=
int( zoomList.size() ) )
271 idx = (int) zoomList.size() - 1;
275 for( idx =
int( zoomList.size() ) - 1; idx >= 0; --idx )
277 if( zoomList[idx] <=
zoom )
338 bBox =
m_frame->GetDocumentExtents(
false );
344 bBox =
m_frame->GetDocumentExtents(
false );
353 if( selection.
Empty() )
365 double scale = view->
GetScale() / std::max( fabs( vsize.
x / screenSize.
x ),
366 fabs( vsize.
y / screenSize.
y ) );
370 if( !std::isfinite(
scale ) )
379 double margin_scale_factor = 1.04;
381 if( canvas->GetClientSize().y < 768 )
382 margin_scale_factor = 1.10;
391 margin_scale_factor = 1.30;
396 margin_scale_factor = 1.48;
431 if( selection.
Empty() )
466 std::vector<double>& zoomList =
m_frame->GetWindowSettings(
m_toolMgr->GetSettings() )->zoom_factors;
478 double scale = zoomList[idx];
480 if( aCenterOnCursor )
492 m_frame->GetCanvas()->Refresh();
500 int& currentGrid =
m_frame->GetWindowSettings(
m_toolMgr->GetSettings() )->grid.last_size_idx;
504 if( currentGrid >=
int(
m_grids.size() ) )
513 int& currentGrid =
m_frame->GetWindowSettings(
m_toolMgr->GetSettings() )->grid.last_size_idx;
517 if( currentGrid < 0 )
518 currentGrid = (int)
m_grids.size() - 1;
532 int& currentGrid =
m_frame->GetWindowSettings(
m_toolMgr->GetSettings() )->grid.last_size_idx;
534 currentGrid = std::clamp( idx, 0, (
int)
m_grids.size() - 1 );
542 int& currentGrid =
m_frame->GetWindowSettings(
m_toolMgr->GetSettings() )->grid.last_size_idx;
544 currentGrid = std::max( 0, std::min( currentGrid,
static_cast<int>(
m_grids.size() ) - 1 ) );
547 wxUpdateUIEvent
dummy;
581 if(
m_frame->GetWindowSettings(
m_toolMgr->GetSettings() )->grid.last_size_idx
582 ==
m_frame->GetWindowSettings(
m_toolMgr->GetSettings() )->grid.fast_grid_1 )
608 [
this](
const wxString& aParentName )
611 [
this, aParentName]()
613 m_frame->ShowPreferences(
_(
"Grids" ), aParentName );
617 switch(
m_frame->GetFrameType() )
619 case FRAME_SCH: showGridPrefs(
_(
"Schematic Editor" ) );
break;
625 case FRAME_GERBER: showGridPrefs(
_(
"Gerber Viewer" ) );
break;
626 default: wxFAIL_MSG(
"Unknown frame: " +
GetName() );
break;
644 m_frame->GetCanvas()->ForceRefresh();
660 wxASSERT_MSG(
false, wxS(
"Invalid unit for the frame" ) );
662 m_frame->ChangeUserUnits( newUnit );
678 m_frame->SetStatusText( wxEmptyString );
707 auto& galOpts =
m_frame->GetGalDisplayOptions();
709 galOpts.m_forceDisplayCursor = !galOpts.m_forceDisplayCursor;
710 galOpts.WriteConfig( *
m_frame->GetWindowSettings(
m_toolMgr->GetSettings() ) );
711 galOpts.NotifyChanged();
BASE_SCREEN class implementation.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
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 cursorSmallCrosshairs
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 gridOrigin
static TOOL_ACTION panLeft
static TOOL_ACTION selectionTool
static TOOL_ACTION cursorClick
static TOOL_ACTION zoomFitScreen
static TOOL_ACTION zoomPreset
static TOOL_ACTION cursor45Crosshairs
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 cursorFullCrosshairs
static TOOL_ACTION resetLocalCoords
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr size_type GetHeight() const
constexpr const SizeVec & GetSize() const
bool IsType(FRAME_T aType) const
The base class for create windows for drawing purpose.
virtual const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const
Return bounding box of document with option to not include some items.
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)
void SetCursorMode(CROSS_HAIR_MODE aMode)
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 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.
VECTOR2I GetReferencePoint() const
bool Empty() const
Checks if there is anything selected.
bool HasReferencePoint() const
virtual BOX2I GetBoundingBox() const
VECTOR2I GetValue()
Return 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)
Convert 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
Forced cursor position (world coordinates).
bool m_forceCursorPosition
Is the forced cursor position enabled.
static const long long MM
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
VECTOR2I ToVECTOR2I(const wxSize &aSize)
VECTOR2D ToVECTOR2D(const wxPoint &aPoint)