162 const int newInterval =
m_options.m_gridShowMajor ? 10 : 0;
194 double aWidth,
const COLOR4D& aColor )
260 extents.
SetSize( halfSize * 2 );
276 std::stable_sort( aSources.begin(), aSources.end(),
279 return a.TakesPrecedenceOver( b );
314 const double threshold =
338 const double minPitch = std::min( aSrc.
pitch.
x, aSrc.
pitch.
y );
367 const double rMax = aSrc.
extent.
x;
368 const double phiMax = aSrc.
extent.
y;
380 else if( rMax > 0.0 && phiMax >= 2 *
M_PI - 1e-6 )
384 else if( rMax > 0.0 && phiMax > 0.0 )
386 const int segments = std::max( 16,
static_cast<int>( phiMax / (
M_PI / 16 ) ) );
387 std::deque<VECTOR2D> sector;
389 sector.emplace_back( 0.0, 0.0 );
391 for(
int ii = 0; ii <= segments; ++ii )
393 const double phi = phiMax * ii / segments;
394 sector.emplace_back( rMax * std::cos( phi ), rMax * std::sin( phi ) );
397 sector.emplace_back( 0.0, 0.0 );
411 if( src.snapCursor && src.Contains( aPoint ) )
412 return src.Snap( aPoint );
444 color.
a = color.
a * 0.5;
454 if( aText.IsEmpty() )
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
constexpr const Vec GetEnd() const
constexpr void SetOrigin(const Vec &pos)
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr void SetSize(const SizeVec &size)
constexpr coord_type GetLeft() const
constexpr const Vec & GetOrigin() const
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr coord_type GetBottom() const
GAL(GAL_DISPLAY_OPTIONS &aOptions)
FONT is an abstract base class for both outline and stroke fonts.
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttributes, const METRICS &aFontMetrics, std::optional< VECTOR2I > aMousePos=std::nullopt, wxString *aActiveUrl=nullptr) const
Draw a string.
static const METRICS & Default()
A color representation with 4 components: red, green, blue, alpha.
COLOR4D & Brighten(double aFactor)
Makes the color brighter by a given factor.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void DrawEllipseArc(const VECTOR2D &aCenterPoint, double aMajorRadius, double aMinorRadius, const EDA_ANGLE &aRotation, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aEndAngle)
Draw an elliptical arc in world coordinates.
bool m_isCursorEnabled
Is the cursor enabled?
virtual void Rotate(double aAngle)
Rotate the context.
BOX2D GetVisibleWorldExtents() const
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
MATRIX3x3D m_worldScreenMatrix
World transformation.
COLOR4D gridSourceColor(const GRID_SOURCE &aSrc) const
The colour a grid source is drawn in, brightened while it is being edited.
void SetVerticalJustify(const GR_TEXT_V_ALIGN_T aVerticalJustify)
void SetFontBold(const bool aBold)
MATRIX3x3D m_screenWorldMatrix
Screen transformation.
void SetFontUnderlined(bool aUnderlined)
virtual VECTOR2I GetLayoutPixelSize() const
Return the size the view is centred in and panned by.
void SetHorizontalJustify(const GR_TEXT_H_ALIGN_T aHorizontalJustify)
bool m_axesEnabled
Should the axes be drawn.
void SetRotation(double aRotation)
Get/set the rotation angle (in radians).
float m_gridLineWidth
Line width of the grid.
void SetFlip(bool xAxis, bool yAxis)
Sets flipping of the screen.
VECTOR2I m_screenSize
Screen size in screen (wx logical) coordinates.
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void OnGalDisplayOptionsChanged(const GAL_DISPLAY_OPTIONS &aOptions) override
Handler for observer settings changes.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
void SetCursorEnabled(bool aCursorEnabled)
Enable/disable cursor.
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
virtual bool SetNativeCursorStyle(KICURSOR aCursor, bool aHiDPI)
Set the cursor in the native panel.
GRID_STYLE m_gridStyle
Grid display style.
void SetCursorColor(const COLOR4D &aCursorColor)
Set the cursor color.
COLOR4D m_cursorColor
Cursor color.
int m_gridMinSpacing
Minimum screen size of the grid (pixels) below which the grid is not drawn.
const VECTOR2D & GetLookAtPoint() const
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
virtual void Restore()
Restore the context.
void SetZoomFactor(double aZoomFactor)
void computeWorldScale()
Compute the scaling factor for the world->screen matrix.
GRID_LATTICE gridLattice(const GRID_SOURCE &aSrc) const
Thin a grid source's pitch out until its lines are far enough apart on screen.
void drawGridCoverageShape(const GRID_SOURCE &aSrc)
Draw the area a grid source covers in its own frame with the current fill and stroke.
TEXT_ATTRIBUTES m_attributes
void ResetTextAttributes()
Reset text attributes to default styling.
static const int MIN_DEPTH
Possible depth range.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
double m_rotation
Rotation transformation (radians)
VECTOR2D m_gridSize
The grid size.
COLOR4D getCursorColor() const
Get the actual cursor color to draw.
void SetTextMirrored(const bool aMirrored)
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
void SetCoarseGrid(int aInterval)
Draw every tick line wider.
virtual bool updatedGalDisplayOptions(const GAL_DISPLAY_OPTIONS &aOptions)
Handle updating display options.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
BOX2D gridScreenBBox(const GRID_SOURCE &aSrc) const
VECTOR2D m_gridOffset
The grid offset to compensate cursor position.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
int m_gridTick
Every tick line gets the double width.
double m_worldScale
The scale factor world->screen.
void SetGridSources(std::vector< GRID_SOURCE > aSources)
Set the grid-source list rendered alongside the display grid.
void SetLookAtPoint(const VECTOR2D &aPoint)
Get/set the Point in world space to look at.
VECTOR2D GetGridPoint(const VECTOR2D &aPoint) const
For a given point it returns the nearest point belonging to the grid in world coordinates.
void SetWorldUnitLength(double aWorldUnitLength)
Set the unit length.
virtual void SetMinLineWidth(float aLineWidth)
Set the minimum line width in pixels.
KICURSOR m_currentNativeCursor
Current cursor.
bool m_globalFlipY
Flag for Y axis flipping.
static const int GRID_DEPTH
Depth level on which the grid is drawn.
void SetGlyphSize(const VECTOR2I aSize)
UTIL::LINK m_observerLink
virtual void ComputeWorldScreenMatrix()
Compute the world <-> screen transformation matrix.
virtual void DrawTrack(const VECTOR2D &aStart, const VECTOR2D &aEnd, double aWidth, const COLOR4D &aColor)
Draw a filled track capsule in aColor without touching the fill and stroke state.
COLOR4D m_gridColor
Color of the grid.
double computeMinGridSpacing() const
Compute minimum grid spacing from the grid settings.
void SetFontItalic(bool aItalic)
std::vector< GRID_SOURCE > m_gridSources
Sources overlayed on the display grid.
virtual void DrawEllipse(const VECTOR2D &aCenterPoint, double aMajorRadius, double aMinorRadius, const EDA_ANGLE &aRotation)
Draw a closed ellipse.
GAL_DISPLAY_OPTIONS & m_options
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
virtual void BitmapText(const wxString &aText, const VECTOR2I &aPosition, const EDA_ANGLE &aAngle)
Draw a text using a bitmap font.
void SetGridVisibility(bool aVisibility)
Set the visibility setting of the grid.
float GetLineWidth() const
Get the line width.
virtual void Save()
Save the context.
bool m_globalFlipX
Flag for X axis flipping.
KIGFX::CROSS_HAIR_MODE m_crossHairMode
Crosshair drawing mode.
void SetDepthRange(const VECTOR2D &aDepthRange)
Set the range of the layer depth.
VECTOR2D m_lookAtPoint
Point to be looked at in world space.
void SetScreenDPI(double aScreenDPI)
Set the dots per inch of the screen.
bool m_forceDisplayCursor
Always show cursor.
static const int MAX_DEPTH
void SetIdentity()
Set the matrix to the identity matrix.
void SetRotation(T aAngle)
Set the rotation components of the matrix.
void SetScale(VECTOR2< T > aScale)
Set the scale components of the matrix.
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
void SetTranslation(VECTOR2< T > aTranslation)
Set the translation components of the matrix.
SHAPE_LINE_CHAIN ConvertToPolyline(int aMaxError) const
Build a polyline approximation of the ellipse or arc.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
#define MAX_LAYERS_FOR_VIEW
MATRIX3x3< double > MATRIX3x3D
The Cairo implementation of the graphics abstraction layer.
@ SMALL_CROSS
Use small cross instead of dots for the grid.
@ LINES
Use lines for the grid.
constexpr double GRID_SELECTED_BRIGHTEN
How far the grid being edited is lifted above its own colour.
double AutoSparsePitch(double aPitch, unsigned aTick, double aThreshold)
Multiply aPitch by aTick until it exceeds aThreshold, so a sub-threshold grid still shows every Nth l...
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
double orientation
Rotation about origin, radians CCW.
VECTOR2D extent
Cartesian: (dx, dy) = size/2 from origin.
VECTOR2D pitch
Cartesian: (dx, dy); polar: (dr, dPhi rad).
The spacing of a grid source's lattice as it is drawn at the current zoom.
VECTOR2D extent
as GRID_SOURCE::extent, with an unbounded polar grid reaching past the screen
unsigned tick
every tick-th line is a major one
VECTOR2D pitch
along x and y, or of radius and angle for a polar grid
Render-time projection of a grid: GRID_GEOMETRY (kind/origin/pitch/orientation/extent) plus rendering...
unsigned tick
Major-tick interval (0 = inherit default).
bool highlighted
Render with edit-mode emphasis (selected grid).
bool unbounded
No extent; visible range derived from screen corners.
const SHAPE_LINE_CHAIN chain
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D