27#ifndef GRAPHICSABSTRACTIONLAYER_H_
28#define GRAPHICSABSTRACTIONLAYER_H_
125 virtual void DrawPolyline(
const std::deque<VECTOR2D>& aPointList ) {};
126 virtual void DrawPolyline(
const std::vector<VECTOR2D>& aPointList ) {};
135 virtual void DrawPolylines(
const std::vector<std::vector<VECTOR2D>>& aPointLists ){};
176 double aWidth,
double aMaxError ){};
199 virtual void DrawGlyphs(
const std::vector<std::unique_ptr<KIFONT::GLYPH>>& aGlyphs )
201 for(
size_t i = 0; i < aGlyphs.size(); i++ )
202 DrawGlyph( *aGlyphs[i], i, aGlyphs.size() );
211 virtual void DrawPolygon(
const std::deque<VECTOR2D>& aPointList ) {};
229 double aFilterValue = 0.0 ) {};
244 virtual bool Show(
bool aShow ) {
return true; };
260 m_clearColor = aColor;
286 m_isFillEnabled = aIsFillEnabled;
296 return m_isFillEnabled;
306 m_isStrokeEnabled = aIsStrokeEnabled;
316 return m_isStrokeEnabled;
326 m_fillColor = aColor;
346 m_strokeColor = aColor;
356 return m_strokeColor;
366 m_lineWidth = aLineWidth;
389 wxCHECK_MSG( aLayerDepth <= m_depthRange.y, , wxT(
"SetLayerDepth: below minimum" ) );
390 wxCHECK_MSG( aLayerDepth >= m_depthRange.x, , wxT(
"SetLayerDepth: above maximum" ) );
392 m_layerDepth = aLayerDepth;
404 SetLayerDepth( m_layerDepth - 0.1 );
419 virtual void BitmapText(
const wxString& aText,
const VECTOR2I& aPosition,
428 void ResetTextAttributes();
433 inline void SetFontBold(
const bool aBold ) { m_attributes.m_Bold = aBold; }
434 inline bool IsFontBold()
const {
return m_attributes.m_Bold; }
436 inline void SetFontItalic(
bool aItalic ) { m_attributes.m_Italic = aItalic; }
447 m_attributes.m_Halign = aHorizontalJustify;
454 m_attributes.m_Valign = aVerticalJustify;
555 virtual void ComputeWorldScreenMatrix();
564 return m_worldScreenMatrix;
574 return m_screenWorldMatrix;
584 m_worldScreenMatrix = aMatrix;
590 BOX2D GetVisibleWorldExtents()
const;
655 m_globalFlipX = xAxis;
656 m_globalFlipY = yAxis;
768 m_gridOrigin = aGridOrigin;
770 if( m_gridSize.x == 0.0 || m_gridSize.y == 0.0 )
776 m_gridOffset =
VECTOR2D( (
long) m_gridOrigin.x % (
long) m_gridSize.x,
777 (
long) m_gridOrigin.y % (
long) m_gridSize.y );
793 m_gridSize = aGridSize;
796 m_gridSize.
x = std::max( 1.0, m_gridSize.x );
797 m_gridSize.y = std::max( 1.0, m_gridSize.y );
799 m_gridOffset =
VECTOR2D( (
long) m_gridOrigin.x % (
long) m_gridSize.x,
800 (
long) m_gridOrigin.y % (
long) m_gridSize.y );
820 VECTOR2D gridScreenSize( m_gridSize );
822 double gridThreshold = computeMinGridSpacing() / m_worldScale;
824 if( m_gridStyle == GRID_STYLE::SMALL_CROSS )
825 gridThreshold *= 2.0;
829 while( std::min( gridScreenSize.
x, gridScreenSize.
y ) <= gridThreshold )
831 gridScreenSize = gridScreenSize *
static_cast<double>( m_gridTick );
834 return gridScreenSize;
844 m_gridColor = aGridColor;
854 m_axesColor = aAxesColor;
862 m_axesEnabled = aAxesEnabled;
872 m_gridTick = aInterval;
882 return m_gridLineWidth;
904 return VECTOR2D( m_screenWorldMatrix * aPoint );
915 return VECTOR2D( m_worldScreenMatrix * aPoint );
924 virtual bool SetNativeCursorStyle(
KICURSOR aCursor,
bool aHiDPI );
933 m_isCursorEnabled = aCursorEnabled;
943 return m_isCursorEnabled || m_forceDisplayCursor;
953 m_cursorColor = aCursorColor;
1006 m_worldScale = m_screenDPI * m_worldUnitLength * m_zoomFactor;
1014 double computeMinGridSpacing()
const;
1026 COLOR4D getCursorColor()
const;
1104 return m_layerDepth;
This class handle bitmap images in KiCad.
constexpr const Vec GetEnd() const
constexpr const Vec & GetOrigin() const
A color representation with 4 components: red, green, blue, alpha.
GAL_CONTEXT_LOCKER(GAL *aGal)
GAL_DRAWING_CONTEXT(GAL *aGal)
~GAL_DRAWING_CONTEXT() noexcept(false)
Attribute save/restore for GAL attributes.
GAL_SCOPED_ATTRS(KIGFX::GAL &aGal, int aFlags)
Instantiates a GAL_SCOPED_ATTRS object, saving the current attributes of the GAL.
GAL_UPDATE_CONTEXT(GAL *aGal)
Abstract interface for drawing on a 2D-surface.
const VECTOR2D & GetGridOrigin() const
virtual void ResizeScreen(int aWidth, int aHeight)
Resize the canvas.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
bool IsTextMirrored() const
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
float GetGridLineWidth() const
Get the grid line width.
virtual bool Show(bool aShow)
Show/hide the GAL canvas.
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)
const MATRIX3x3D & GetWorldScreenMatrix() const
Get the world <-> screen transformation matrix.
bool IsCursorEnabled() const
Return information about cursor visibility.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void EndDrawing()
End the drawing, needs to be called for every new frame.
virtual void StartDiffLayer()
Begins rendering of a differential layer.
bool m_isCursorEnabled
Is the cursor enabled?
virtual void DrawGlyph(const KIFONT::GLYPH &aGlyph, int aNth=0, int aTotal=1)
Draw a polygon representing a font glyph.
virtual void EndDiffLayer()
Ends rendering of a differential layer.
virtual void Rotate(double aAngle)
Rotate the context.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
MATRIX3x3D m_worldScreenMatrix
World transformation.
VECTOR2D GetVisibleGridSize() const
Return the visible grid size in x and y directions.
double m_layerDepth
The actual layer depth.
void SetVerticalJustify(const GR_TEXT_V_ALIGN_T aVerticalJustify)
bool GetIsFill() const
Get the fill status.
void AdvanceDepth()
Change the current depth to deeper, so it is possible to draw objects right beneath other.
const COLOR4D & GetFillColor() const
Get the fill color.
void SetFontBold(const bool aBold)
MATRIX3x3D m_screenWorldMatrix
Screen transformation.
void SetFontUnderlined(bool aUnderlined)
void SetHorizontalJustify(const GR_TEXT_H_ALIGN_T aHorizontalJustify)
virtual RENDER_TARGET GetTarget() const
Get the currently used target for rendering.
double GetMaxDepth() const
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 Flush()
Force all remaining objects to be drawn.
virtual int GetSwapInterval() const
Return the swap interval. -1 for adaptive, 0 for disabled/unknown.
virtual void DeleteGroup(int aGroupNumber)
Delete the group from the memory.
GR_TEXT_H_ALIGN_T GetHorizontalJustify() const
VECTOR2D m_depthRange
Range of the depth.
double GetZoomFactor() const
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
double m_zoomFactor
The zoom factor.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
VECTOR2D ToScreen(const VECTOR2D &aPoint) const
Compute the point position in screen coordinates from given world coordinates.
void SetCursorEnabled(bool aCursorEnabled)
Enable/disable cursor.
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
virtual void DrawPolylines(const std::vector< std::vector< VECTOR2D > > &aPointLists)
Draw multiple polylines.
virtual bool HasTarget(RENDER_TARGET aTarget)
Return true if the target exists.
GRID_STYLE m_gridStyle
Grid display style.
void SetCursorColor(const COLOR4D &aCursorColor)
Set the cursor color.
COLOR4D m_cursorColor
Cursor color.
COLOR4D m_axesColor
Color of the axes.
int m_gridMinSpacing
Minimum screen size of the grid (pixels) below which the grid is not drawn.
void SetGridSize(const VECTOR2D &aGridSize)
Set the grid size.
const VECTOR2D & GetLookAtPoint() const
double GetRotation() const
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
bool IsFontUnderlined() const
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
virtual void Restore()
Restore the context.
float m_lineWidth
The line width.
const COLOR4D & GetStrokeColor() const
Get the stroke color.
virtual void ClearTarget(RENDER_TARGET aTarget)
Clear the target for rendering.
void SetZoomFactor(double aZoomFactor)
virtual void BeginDrawing()
Start/end drawing functions, draw calls can be only made in between the calls to BeginDrawing()/EndDr...
void computeWorldScale()
Compute the scaling factor for the world->screen matrix.
virtual bool IsOpenGlEngine()
Return true if the GAL engine is a OpenGL based type.
virtual int BeginGroup()
Begin a group.
TEXT_ATTRIBUTES m_attributes
static const int MIN_DEPTH
Possible depth range.
const VECTOR2D & GetGridSize() const
Return the grid size.
virtual void DrawPolygon(const VECTOR2D aPointList[], int aListSize)
virtual void SetLineWidth(float aLineWidth)
Set the line width.
double m_rotation
Rotation transformation (radians)
VECTOR2D m_gridSize
The grid size.
virtual void DrawPolygon(const SHAPE_POLY_SET &aPolySet, bool aStrokeTriangulation=false)
virtual void ChangeGroupDepth(int aGroupNumber, int aDepth)
Change the depth (Z-axis position) of the group.
COLOR4D m_fillColor
The fill color.
virtual void EndNegativesLayer()
Ends rendering of a negatives layer and draws it to the main layer.
bool IsFontItalic() const
void DrawRectangle(const BOX2I &aRect)
double m_worldUnitLength
The unit length of the world coordinates [inch].
virtual void StartNegativesLayer()
Begins rendering in a new layer that will be copied to the main layer in EndNegativesLayer().
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.
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void ChangeGroupColor(int aGroupNumber, const COLOR4D &aNewColor)
Change the color used to draw the group.
virtual void DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aWidth, double aMaxError)
Draw an arc segment.
virtual bool IsContextLocked()
Checks the state of the context lock.
VECTOR2D m_cursorPosition
Current cursor position (world coordinates)
VECTOR2D m_gridOffset
The grid offset to compensate cursor position.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual void beginUpdate()
Enable item update mode.
virtual void DrawGroup(int aGroupNumber)
Draw the stored group.
double getLayerDepth() const
const VECTOR2I & GetGlyphSize() const
int m_gridTick
Every tick line gets the double width.
double m_worldScale
The scale factor world->screen.
void SetLookAtPoint(const VECTOR2D &aPoint)
Get/set the Point in world space to look at.
virtual void DrawPolygon(const SHAPE_LINE_CHAIN &aPolySet)
bool GetGridVisibility() const
void SetGridOrigin(const VECTOR2D &aGridOrigin)
Set the origin point for the grid.
virtual bool IsCairoEngine()
Return true if the GAL engine is a Cairo based type.
virtual void ClearScreen()
Clear the screen.
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
VECTOR2D m_gridOrigin
The grid origin.
virtual void endUpdate()
Disable item update mode.
void SetWorldUnitLength(double aWorldUnitLength)
Set the unit length.
virtual void DrawPolyline(const std::vector< VECTOR2D > &aPointList)
KICURSOR m_currentNativeCursor
Current cursor.
bool m_globalFlipY
Flag for Y axis flipping.
virtual void UnlockContext(int aClientCookie)
void SetClearColor(const COLOR4D &aColor)
void SetScreenSize(const VECTOR2I &aSize)
const COLOR4D & GetClearColor() const
bool m_fullscreenCursor
Shape of the cursor (fullscreen or small cross)
virtual void DrawSegmentChain(const SHAPE_LINE_CHAIN &aLineChain, double aWidth)
static const int GRID_DEPTH
Depth level on which the grid is drawn.
virtual bool IsInitialized() const
Return the initialization status for the canvas.
void SetGlyphSize(const VECTOR2I aSize)
UTIL::LINK m_observerLink
virtual void DrawGlyphs(const std::vector< std::unique_ptr< KIFONT::GLYPH > > &aGlyphs)
Draw polygons representing font glyphs.
virtual void Scale(const VECTOR2D &aScale)
Scale the context.
virtual void DrawCurve(const VECTOR2D &startPoint, const VECTOR2D &controlPointA, const VECTOR2D &controlPointB, const VECTOR2D &endPoint, double aFilterValue=0.0)
Draw a cubic bezier spline.
bool m_isFillEnabled
Is filling of graphic objects enabled ?
bool GetGridSnapping() const
virtual void EndGroup()
End the group.
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle)
Draw an arc.
virtual void Transform(const MATRIX3x3D &aTransformation)
Transform the context.
virtual void SetNegativeDrawMode(bool aSetting)
Set negative draw mode in the renderer.
COLOR4D m_gridColor
Color of the grid.
VECTOR2D ToWorld(const VECTOR2D &aPoint) const
Compute the point position in world coordinates from given screen coordinates.
COLOR4D m_strokeColor
The color of the outlines.
void SetFontItalic(bool aItalic)
bool m_isStrokeEnabled
Are the outlines stroked ?
virtual void DrawBitmap(const BITMAP_BASE &aBitmap, double alphaBlend=1.0)
Draw a bitmap image.
VECTOR2I m_bitmapSize
Bitmap size, in physical pixels.
GAL_DISPLAY_OPTIONS & m_options
bool m_gridVisibility
Should the grid be shown.
double GetMinDepth() const
virtual void ClearCache()
Delete all data created during caching of graphic items.
virtual void SetTarget(RENDER_TARGET aTarget)
Set the target for rendering.
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
double m_screenDPI
The dots per inch of the screen.
virtual void DrawPolyline(const SHAPE_LINE_CHAIN &aLineChain)
const VECTOR2I & GetScreenPixelSize() const
Return GAL canvas size in pixels.
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.
virtual void LockContext(int aClientCookie)
Use GAL_CONTEXT_LOCKER RAII object unless you know what you're doing.
virtual void DrawSegmentChain(const std::vector< VECTOR2D > &aPointList, double aWidth)
Draw a chain of rounded segments.
void SetWorldScreenMatrix(const MATRIX3x3D &aMatrix)
Set the world <-> screen transformation matrix.
GR_TEXT_V_ALIGN_T GetVerticalJustify() const
bool GetIsStroke() const
Get the stroke status.
virtual void DrawCursor(const VECTOR2D &aCursorPosition)
Draw the cursor.
void SetDepthRange(const VECTOR2D &aDepthRange)
Set the range of the layer depth.
double GetWorldScale() const
Get the world scale.
VECTOR2D m_lookAtPoint
Point to be looked at in world space.
virtual bool IsVisible() const
Return true if the GAL canvas is visible on the screen.
void SetScreenDPI(double aScreenDPI)
Set the dots per inch of the screen.
virtual void DrawPolyline(const VECTOR2D aPointList[], int aListSize)
virtual void EnableDepthTest(bool aEnabled=false)
bool m_forceDisplayCursor
Always show cursor.
static const int MAX_DEPTH
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a set of closed polygons.
Simple RAII-handle to a subscription.
The Cairo implementation of the graphics abstraction layer.
GRID_STYLE
GRID_STYLE: Type definition of the grid style.
RENDER_TARGET
RENDER_TARGET: Possible rendering targets.
@ TARGET_CACHED
Main rendering target (cached)
VECTOR2< double > VECTOR2D