KiCad PCB EDA Suite
KIGFX::GAL Class Reference

Abstract interface for drawing on a 2D-surface. More...

#include <graphics_abstraction_layer.h>

Inheritance diagram for KIGFX::GAL:
KIGFX::GAL_DISPLAY_OPTIONS_OBSERVER CALLBACK_GAL KIGFX::CAIRO_GAL_BASE KIGFX::OPENGL_GAL KIGFX::CAIRO_GAL KIGFX::CAIRO_PRINT_GAL

Public Member Functions

 GAL (GAL_DISPLAY_OPTIONS &aOptions)
 
virtual ~GAL ()
 
virtual bool IsInitialized () const
 Return the initialization status for the canvas. More...
 
virtual bool IsVisible () const
 Return true if the GAL canvas is visible on the screen. More...
 
virtual bool IsCairoEngine ()
 Return true if the GAL engine is a Cairo based type. More...
 
virtual bool IsOpenGlEngine ()
 Return true if the GAL engine is a OpenGL based type. More...
 
virtual void DrawLine (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
 Draw a line. More...
 
virtual void DrawSegment (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
 Draw a rounded segment. More...
 
virtual void DrawSegmentChain (const std::vector< VECTOR2D > &aPointList, double aWidth)
 Draw a chain of rounded segments. More...
 
virtual void DrawSegmentChain (const SHAPE_LINE_CHAIN &aLineChain, double aWidth)
 
virtual void DrawPolyline (const std::deque< VECTOR2D > &aPointList)
 Draw a polyline. More...
 
virtual void DrawPolyline (const std::vector< VECTOR2D > &aPointList)
 
virtual void DrawPolyline (const VECTOR2D aPointList[], int aListSize)
 
virtual void DrawPolyline (const SHAPE_LINE_CHAIN &aLineChain)
 
virtual void DrawPolylines (const std::vector< std::vector< VECTOR2D > > &aPointLists)
 Draw multiple polylines. More...
 
virtual void DrawCircle (const VECTOR2D &aCenterPoint, double aRadius)
 Draw a circle using world coordinates. More...
 
virtual void DrawArc (const VECTOR2D &aCenterPoint, double aRadius, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aEndAngle)
 Draw an arc. More...
 
virtual void DrawArcSegment (const VECTOR2D &aCenterPoint, double aRadius, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aEndAngle, double aWidth, double aMaxError)
 Draw an arc segment. More...
 
virtual void DrawRectangle (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
 Draw a rectangle. More...
 
void DrawRectangle (const BOX2I &aRect)
 
virtual void DrawGlyph (const KIFONT::GLYPH &aGlyph, int aNth=0, int aTotal=1)
 Draw a polygon representing a font glyph. More...
 
virtual void DrawGlyphs (const std::vector< std::unique_ptr< KIFONT::GLYPH > > &aGlyphs)
 Draw polygons representing font glyphs. More...
 
virtual void DrawPolygon (const std::deque< VECTOR2D > &aPointList)
 Draw a polygon. More...
 
virtual void DrawPolygon (const VECTOR2D aPointList[], int aListSize)
 
virtual void DrawPolygon (const SHAPE_POLY_SET &aPolySet, bool aStrokeTriangulation=false)
 
virtual void DrawPolygon (const SHAPE_LINE_CHAIN &aPolySet)
 
virtual void DrawCurve (const VECTOR2D &startPoint, const VECTOR2D &controlPointA, const VECTOR2D &controlPointB, const VECTOR2D &endPoint, double aFilterValue=0.0)
 Draw a cubic bezier spline. More...
 
virtual void DrawBitmap (const BITMAP_BASE &aBitmap, double alphaBlend=1.0)
 Draw a bitmap image. More...
 
virtual void ResizeScreen (int aWidth, int aHeight)
 Resize the canvas. More...
 
virtual bool Show (bool aShow)
 Show/hide the GAL canvas. More...
 
const VECTOR2IGetScreenPixelSize () const
 Return GAL canvas size in pixels. More...
 
virtual int GetSwapInterval () const
 Return the swap interval. -1 for adaptive, 0 for disabled/unknown. More...
 
virtual void Flush ()
 Force all remaining objects to be drawn. More...
 
void SetClearColor (const COLOR4D &aColor)
 
const COLOR4DGetClearColor () const
 
virtual void ClearScreen ()
 Clear the screen. More...
 
virtual void SetIsFill (bool aIsFillEnabled)
 Enable/disable fill. More...
 
virtual void SetIsStroke (bool aIsStrokeEnabled)
 Enable/disable stroked outlines. More...
 
virtual void SetFillColor (const COLOR4D &aColor)
 Set the fill color. More...
 
const COLOR4DGetFillColor () const
 Get the fill color. More...
 
virtual void SetStrokeColor (const COLOR4D &aColor)
 Set the stroke color. More...
 
const COLOR4DGetStrokeColor () const
 Get the stroke color. More...
 
virtual void SetLineWidth (float aLineWidth)
 Set the line width. More...
 
float GetLineWidth () const
 Get the line width. More...
 
virtual void SetLayerDepth (double aLayerDepth)
 Set the depth of the layer (position on the z-axis) More...
 
virtual void BitmapText (const wxString &aText, const VECTOR2I &aPosition, const EDA_ANGLE &aAngle)
 Draw a text using a bitmap font. More...
 
void ResetTextAttributes ()
 Reset text attributes to default styling. More...
 
void SetGlyphSize (const VECTOR2I aSize)
 
const VECTOR2IGetGlyphSize () const
 
void SetFontBold (const bool aBold)
 
bool IsFontBold () const
 
void SetFontItalic (bool aItalic)
 
bool IsFontItalic () const
 
void SetFontUnderlined (bool aUnderlined)
 
bool IsFontUnderlined () const
 
void SetTextMirrored (const bool aMirrored)
 
bool IsTextMirrored () const
 
void SetHorizontalJustify (const GR_TEXT_H_ALIGN_T aHorizontalJustify)
 
GR_TEXT_H_ALIGN_T GetHorizontalJustify () const
 
void SetVerticalJustify (const GR_TEXT_V_ALIGN_T aVerticalJustify)
 
GR_TEXT_V_ALIGN_T GetVerticalJustify () const
 
virtual void Transform (const MATRIX3x3D &aTransformation)
 Transform the context. More...
 
virtual void Rotate (double aAngle)
 Rotate the context. More...
 
virtual void Translate (const VECTOR2D &aTranslation)
 Translate the context. More...
 
virtual void Scale (const VECTOR2D &aScale)
 Scale the context. More...
 
virtual void Save ()
 Save the context. More...
 
virtual void Restore ()
 Restore the context. More...
 
virtual int BeginGroup ()
 Begin a group. More...
 
virtual void EndGroup ()
 End the group. More...
 
virtual void DrawGroup (int aGroupNumber)
 Draw the stored group. More...
 
virtual void ChangeGroupColor (int aGroupNumber, const COLOR4D &aNewColor)
 Change the color used to draw the group. More...
 
virtual void ChangeGroupDepth (int aGroupNumber, int aDepth)
 Change the depth (Z-axis position) of the group. More...
 
virtual void DeleteGroup (int aGroupNumber)
 Delete the group from the memory. More...
 
virtual void ClearCache ()
 Delete all data created during caching of graphic items. More...
 
virtual void ComputeWorldScreenMatrix ()
 Compute the world <-> screen transformation matrix. More...
 
const MATRIX3x3DGetWorldScreenMatrix () const
 Get the world <-> screen transformation matrix. More...
 
const MATRIX3x3DGetScreenWorldMatrix () const
 Get the screen <-> world transformation matrix. More...
 
void SetWorldScreenMatrix (const MATRIX3x3D &aMatrix)
 Set the world <-> screen transformation matrix. More...
 
BOX2D GetVisibleWorldExtents () const
 
void SetWorldUnitLength (double aWorldUnitLength)
 Set the unit length. More...
 
void SetScreenSize (const VECTOR2I &aSize)
 
void SetScreenDPI (double aScreenDPI)
 Set the dots per inch of the screen. More...
 
void SetLookAtPoint (const VECTOR2D &aPoint)
 Get/set the Point in world space to look at. More...
 
const VECTOR2DGetLookAtPoint () const
 
void SetZoomFactor (double aZoomFactor)
 
double GetZoomFactor () const
 
void SetRotation (double aRotation)
 Get/set the rotation angle (in radians). More...
 
double GetRotation () const
 
void SetDepthRange (const VECTOR2D &aDepthRange)
 Set the range of the layer depth. More...
 
double GetMinDepth () const
 
double GetMaxDepth () const
 
double GetWorldScale () const
 Get the world scale. More...
 
void SetFlip (bool xAxis, bool yAxis)
 Sets flipping of the screen. More...
 
bool IsFlippedX () const
 
bool IsFlippedY () const
 
virtual void SetTarget (RENDER_TARGET aTarget)
 Set the target for rendering. More...
 
virtual RENDER_TARGET GetTarget () const
 Get the currently used target for rendering. More...
 
virtual void ClearTarget (RENDER_TARGET aTarget)
 Clear the target for rendering. More...
 
virtual bool HasTarget (RENDER_TARGET aTarget)
 Return true if the target exists. More...
 
virtual void SetNegativeDrawMode (bool aSetting)
 Set negative draw mode in the renderer. More...
 
virtual void StartDiffLayer ()
 Begins rendering of a differential layer. More...
 
virtual void EndDiffLayer ()
 Ends rendering of a differential layer. More...
 
virtual void StartNegativesLayer ()
 Begins rendering in a new layer that will be copied to the main layer in EndNegativesLayer(). More...
 
virtual void EndNegativesLayer ()
 Ends rendering of a negatives layer and draws it to the main layer. More...
 
void SetGridVisibility (bool aVisibility)
 Set the visibility setting of the grid. More...
 
bool GetGridVisibility () const
 
bool GetGridSnapping () const
 
void SetGridOrigin (const VECTOR2D &aGridOrigin)
 Set the origin point for the grid. More...
 
const VECTOR2DGetGridOrigin () const
 
void SetGridSize (const VECTOR2D &aGridSize)
 Set the grid size. More...
 
const VECTOR2DGetGridSize () const
 Return the grid size. More...
 
void SetGridColor (const COLOR4D &aGridColor)
 Set the grid color. More...
 
void SetAxesColor (const COLOR4D &aAxesColor)
 Set the axes color. More...
 
void SetAxesEnabled (bool aAxesEnabled)
 Enable drawing the axes. More...
 
void SetCoarseGrid (int aInterval)
 Draw every tick line wider. More...
 
float GetGridLineWidth () const
 Get the grid line width. More...
 
virtual void DrawGrid ()
 
VECTOR2D GetGridPoint (const VECTOR2D &aPoint) const
 For a given point it returns the nearest point belonging to the grid in world coordinates. More...
 
VECTOR2D ToWorld (const VECTOR2D &aPoint) const
 Compute the point position in world coordinates from given screen coordinates. More...
 
VECTOR2D ToScreen (const VECTOR2D &aPoint) const
 Compute the point position in screen coordinates from given world coordinates. More...
 
virtual bool SetNativeCursorStyle (KICURSOR aCursor)
 Set the cursor in the native panel. More...
 
void SetCursorEnabled (bool aCursorEnabled)
 Enable/disable cursor. More...
 
bool IsCursorEnabled () const
 Return information about cursor visibility. More...
 
void SetCursorColor (const COLOR4D &aCursorColor)
 Set the cursor color. More...
 
virtual void DrawCursor (const VECTOR2D &aCursorPosition)
 Draw the cursor. More...
 
void AdvanceDepth ()
 Change the current depth to deeper, so it is possible to draw objects right beneath other. More...
 
void PushDepth ()
 Store current drawing depth on the depth stack. More...
 
void PopDepth ()
 Restore previously stored drawing depth for the depth stack. More...
 
virtual void EnableDepthTest (bool aEnabled=false)
 
virtual bool IsContextLocked ()
 Checks the state of the context lock. More...
 
virtual void LockContext (int aClientCookie)
 Use GAL_CONTEXT_LOCKER RAII object unless you know what you're doing. More...
 
virtual void UnlockContext (int aClientCookie)
 
virtual void BeginDrawing ()
 Start/end drawing functions, draw calls can be only made in between the calls to BeginDrawing()/EndDrawing(). More...
 
virtual void EndDrawing ()
 End the drawing, needs to be called for every new frame. More...
 

Protected Member Functions

virtual void beginUpdate ()
 Enable item update mode. More...
 
virtual void endUpdate ()
 Disable item update mode. More...
 
void computeWorldScale ()
 Compute the scaling factor for the world->screen matrix. More...
 
double computeMinGridSpacing () const
 compute minimum grid spacing from the grid settings More...
 
COLOR4D getCursorColor () const
 Get the actual cursor color to draw. More...
 
void OnGalDisplayOptionsChanged (const GAL_DISPLAY_OPTIONS &aOptions) override
 Handler for observer settings changes. More...
 
virtual bool updatedGalDisplayOptions (const GAL_DISPLAY_OPTIONS &aOptions)
 Handle updating display options. More...
 

Protected Attributes

GAL_DISPLAY_OPTIONSm_options
 
UTIL::LINK m_observerLink
 
std::stack< double > m_depthStack
 Stored depth values. More...
 
VECTOR2I m_screenSize
 Screen size in screen coordinates. More...
 
double m_worldUnitLength
 The unit length of the world coordinates [inch]. More...
 
double m_screenDPI
 The dots per inch of the screen. More...
 
VECTOR2D m_lookAtPoint
 Point to be looked at in world space. More...
 
double m_zoomFactor
 The zoom factor. More...
 
double m_rotation
 Rotation transformation (radians) More...
 
MATRIX3x3D m_worldScreenMatrix
 World transformation. More...
 
MATRIX3x3D m_screenWorldMatrix
 Screen transformation. More...
 
double m_worldScale
 The scale factor world->screen. More...
 
bool m_globalFlipX
 Flag for X axis flipping. More...
 
bool m_globalFlipY
 Flag for Y axis flipping. More...
 
float m_lineWidth
 The line width. More...
 
bool m_isFillEnabled
 Is filling of graphic objects enabled ? More...
 
bool m_isStrokeEnabled
 Are the outlines stroked ? More...
 
COLOR4D m_fillColor
 The fill color. More...
 
COLOR4D m_strokeColor
 The color of the outlines. More...
 
COLOR4D m_clearColor
 
double m_layerDepth
 The actual layer depth. More...
 
VECTOR2D m_depthRange
 Range of the depth. More...
 
bool m_gridVisibility
 Should the grid be shown. More...
 
GRID_STYLE m_gridStyle
 Grid display style. More...
 
VECTOR2D m_gridSize
 The grid size. More...
 
VECTOR2D m_gridOrigin
 The grid origin. More...
 
VECTOR2D m_gridOffset
 The grid offset to compensate cursor position. More...
 
COLOR4D m_gridColor
 Color of the grid. More...
 
COLOR4D m_axesColor
 Color of the axes. More...
 
bool m_axesEnabled
 Should the axes be drawn. More...
 
int m_gridTick
 Every tick line gets the double width. More...
 
float m_gridLineWidth
 Line width of the grid. More...
 
int m_gridMinSpacing
 Minimum screen size of the grid (pixels) below which the grid is not drawn. More...
 
bool m_isCursorEnabled
 Is the cursor enabled? More...
 
bool m_forceDisplayCursor
 Always show cursor. More...
 
COLOR4D m_cursorColor
 Cursor color. More...
 
bool m_fullscreenCursor
 Shape of the cursor (fullscreen or small cross) More...
 
VECTOR2D m_cursorPosition
 Current cursor position (world coordinates) More...
 
KICURSOR m_currentNativeCursor
 Current cursor. More...
 

Static Protected Attributes

static const int MIN_DEPTH = -1024
 Possible depth range. More...
 
static const int MAX_DEPTH = 1023
 
static const int GRID_DEPTH = MAX_DEPTH - 1
 Depth level on which the grid is drawn. More...
 

Private Attributes

TEXT_ATTRIBUTES m_attributes
 

Friends

class GAL_CONTEXT_LOCKER
 
class GAL_UPDATE_CONTEXT
 
class GAL_DRAWING_CONTEXT
 

Detailed Description

Abstract interface for drawing on a 2D-surface.

The functions are optimized for drawing shapes of an EDA-program such as KiCad. Most methods are abstract and need to be implemented by a lower layer, for example by a Cairo or OpenGL implementation. Almost all methods use world coordinates as arguments. The board design is defined in world space units for drawing purposes these are transformed to screen units with this layer. So zooming is handled here as well.

Definition at line 60 of file graphics_abstraction_layer.h.

Constructor & Destructor Documentation

◆ GAL()

GAL::GAL ( GAL_DISPLAY_OPTIONS aOptions)

Definition at line 40 of file graphics_abstraction_layer.cpp.

40 :
41 m_options( aDisplayOptions ),
42 // m_currentNativeCursor is initialized with KICURSOR::DEFAULT value to avoid
43 // if comparison with uninitialized value on SetNativeCursorStyle method.
44 // Some classes inheriting from GAL has different SetNativeCursorStyle method
45 // implementation and therefore it's called also on constructor
46 // to change the value from DEFAULT to KICURSOR::ARROW
48{
49 // Set the default values for the internal variables
50 SetIsFill( false );
51 SetIsStroke( true );
52 SetFillColor( COLOR4D( 0.0, 0.0, 0.0, 0.0 ) );
53 SetStrokeColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
54 SetLookAtPoint( VECTOR2D( 0, 0 ) );
55 SetZoomFactor( 1.0 );
56 SetRotation( 0.0 );
57 // this value for SetWorldUnitLength is only suitable for Pcbnew.
58 // Other editors/viewer must call SetWorldUnitLength with their internal units
59 SetWorldUnitLength( 1e-9 /* 1 nm */ / 0.0254 /* 1 inch in meters */ );
60 // wxDC::GetPPI() reports 96 DPI, but somehow this value
61 // is the closest match to the legacy renderer
62 SetScreenDPI( 91 );
64 SetLayerDepth( 0.0 );
65 SetFlip( false, false );
66 SetLineWidth( 1.0f );
68 SetAxesEnabled( false );
69
70 // Set grid defaults
71 SetGridVisibility( true );
72 SetCoarseGrid( 10 );
73 m_gridLineWidth = 0.5f;
76
77 // Initialize the cursor shape
78 SetCursorColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) );
79 m_fullscreenCursor = false;
81 SetCursorEnabled( false );
82
83 // Initialize the native widget to an arrow cursor
85
86 // Initialize text properties
88
89 // subscribe for settings updates
91}
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
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.
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void SetCursorEnabled(bool aCursorEnabled)
Enable/disable cursor.
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
GRID_STYLE m_gridStyle
Grid display style.
void SetCursorColor(const COLOR4D &aCursorColor)
Set the cursor color.
int m_gridMinSpacing
Minimum screen size of the grid (pixels) below which the grid is not drawn.
void SetZoomFactor(double aZoomFactor)
void computeWorldScale()
Compute the scaling factor for the world->screen matrix.
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.
void SetCoarseGrid(int aInterval)
Draw every tick line wider.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
void SetLookAtPoint(const VECTOR2D &aPoint)
Get/set the Point in world space to look at.
virtual bool SetNativeCursorStyle(KICURSOR aCursor)
Set the cursor in the native panel.
void SetWorldUnitLength(double aWorldUnitLength)
Set the unit length.
KICURSOR m_currentNativeCursor
Current cursor.
bool m_fullscreenCursor
Shape of the cursor (fullscreen or small cross)
GAL_DISPLAY_OPTIONS & m_options
void SetGridVisibility(bool aVisibility)
Set the visibility setting of the grid.
void SetDepthRange(const VECTOR2D &aDepthRange)
Set the range of the layer depth.
void SetScreenDPI(double aScreenDPI)
Set the dots per inch of the screen.
bool m_forceDisplayCursor
Always show cursor.
static const int MAX_DEPTH
LINK Subscribe(ObserverInterface *aObserver)
Add a subscription returning an RAII link.
Definition: observable.h:157
@ LINES
Use lines for the grid.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:617

References ARROW, computeWorldScale(), DEFAULT, KIGFX::LINES, m_forceDisplayCursor, m_fullscreenCursor, m_gridLineWidth, m_gridMinSpacing, m_gridStyle, m_observerLink, m_options, MAX_DEPTH, MIN_DEPTH, ResetTextAttributes(), SetAxesEnabled(), SetCoarseGrid(), SetCursorColor(), SetCursorEnabled(), SetDepthRange(), SetFillColor(), SetFlip(), SetGridVisibility(), SetIsFill(), SetIsStroke(), SetLayerDepth(), SetLineWidth(), SetLookAtPoint(), SetNativeCursorStyle(), SetRotation(), SetScreenDPI(), SetStrokeColor(), SetWorldUnitLength(), SetZoomFactor(), and UTIL::OBSERVABLE< ObserverInterface >::Subscribe().

◆ ~GAL()

GAL::~GAL ( )
virtual

Definition at line 94 of file graphics_abstraction_layer.cpp.

95{
96}

Member Function Documentation

◆ AdvanceDepth()

void KIGFX::GAL::AdvanceDepth ( )
inline

Change the current depth to deeper, so it is possible to draw objects right beneath other.

Definition at line 908 of file graphics_abstraction_layer.h.

909 {
910 m_layerDepth -= 0.05;
911 }
double m_layerDepth
The actual layer depth.

References m_layerDepth.

Referenced by KIGFX::VIEW_GROUP::ViewDraw().

◆ BeginDrawing()

virtual void KIGFX::GAL::BeginDrawing ( )
inlinevirtual

Start/end drawing functions, draw calls can be only made in between the calls to BeginDrawing()/EndDrawing().

Normally you should create a GAL_DRAWING_CONTEXT RAII object, but I'm leaving these functions public for more precise (i.e. timing/profiling) control of the drawing process - Tom Begin the drawing, needs to be called for every new frame. Use GAL_DRAWING_CONTEXT RAII object unless you know what you're doing.

Reimplemented in KIGFX::CAIRO_GAL_BASE, KIGFX::CAIRO_GAL, and KIGFX::OPENGL_GAL.

Definition at line 954 of file graphics_abstraction_layer.h.

954{};

Referenced by KIGFX::GAL_DRAWING_CONTEXT::GAL_DRAWING_CONTEXT().

◆ BeginGroup()

virtual int KIGFX::GAL::BeginGroup ( )
inlinevirtual

Begin a group.

A group is a collection of graphic items. Hierarchical groups are possible, attributes and transformations can be used.

Returns
the number of the group.

Reimplemented in KIGFX::CAIRO_GAL_BASE, KIGFX::CAIRO_GAL, and KIGFX::OPENGL_GAL.

Definition at line 475 of file graphics_abstraction_layer.h.

475{ return 0; };

Referenced by KIGFX::VIEW::updateItemGeometry().

◆ beginUpdate()

virtual void KIGFX::GAL::beginUpdate ( )
inlineprotectedvirtual

Enable item update mode.

Private: use GAL_UPDATE_CONTEXT RAII object

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 963 of file graphics_abstraction_layer.h.

963{}

Referenced by KIGFX::GAL_UPDATE_CONTEXT::GAL_UPDATE_CONTEXT().

◆ BitmapText()

void GAL::BitmapText ( const wxString &  aText,
const VECTOR2I aPosition,
const EDA_ANGLE aAngle 
)
virtual

Draw a text using a bitmap font.

It should be faster than StrokeText(), but can be used only for non-Gerber elements.

Parameters
aTextis the text to be drawn.
aPositionis the text position in world coordinates.
aAngleis the text rotation angle.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 260 of file graphics_abstraction_layer.cpp.

261{
263
264 if( aText.IsEmpty() )
265 return;
266
268 attrs.m_Angle = aAngle;
269 attrs.m_Mirrored = m_globalFlipX; // Prevent text flipping when view is flipped
270
271 // Bitmap font has different metrics than the stroke font so we compensate a bit before
272 // stroking
274 attrs.m_StrokeWidth = GetLineWidth() * 0.74;
275
276 font->Draw( this, aText, aPosition, attrs );
277}
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:105
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
Definition: font.cpp:65
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttrs) const
Draw a string.
Definition: font.cpp:159
TEXT_ATTRIBUTES m_attributes
float GetLineWidth() const
Get the line width.
bool m_globalFlipX
Flag for X axis flipping.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References KIFONT::FONT::Draw(), KIFONT::FONT::GetFont(), GetLineWidth(), TEXT_ATTRIBUTES::m_Angle, m_attributes, m_globalFlipX, TEXT_ATTRIBUTES::m_Mirrored, TEXT_ATTRIBUTES::m_Size, TEXT_ATTRIBUTES::m_StrokeWidth, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by KIGFX::OPENGL_GAL::BitmapText(), KIGFX::PCB_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::draw(), and KIGFX::VIEW_OVERLAY::COMMAND_BITMAP_TEXT::Execute().

◆ ChangeGroupColor()

virtual void KIGFX::GAL::ChangeGroupColor ( int  aGroupNumber,
const COLOR4D aNewColor 
)
inlinevirtual

Change the color used to draw the group.

Parameters
aGroupNumberis the group number.
aNewColoris the new color.

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 493 of file graphics_abstraction_layer.h.

493{};

Referenced by KIGFX::VIEW::UPDATE_COLOR_VISITOR::operator()(), KIGFX::VIEW::UpdateAllLayersColor(), and KIGFX::VIEW::updateItemColor().

◆ ChangeGroupDepth()

virtual void KIGFX::GAL::ChangeGroupDepth ( int  aGroupNumber,
int  aDepth 
)
inlinevirtual

Change the depth (Z-axis position) of the group.

Parameters
aGroupNumberis the group number.
aDepthis the new depth.

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 501 of file graphics_abstraction_layer.h.

501{};

Referenced by KIGFX::VIEW::UPDATE_DEPTH_VISITOR::operator()(), and KIGFX::VIEW::UpdateAllLayersOrder().

◆ ClearCache()

virtual void KIGFX::GAL::ClearCache ( )
inlinevirtual

Delete all data created during caching of graphic items.

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 513 of file graphics_abstraction_layer.h.

513{};

Referenced by KIGFX::VIEW::Clear().

◆ ClearScreen()

virtual void KIGFX::GAL::ClearScreen ( )
inlinevirtual

Clear the screen.

Parameters
aColoris the color used for clearing.

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 273 of file graphics_abstraction_layer.h.

273{};

Referenced by EDA_DRAW_PANEL_GAL::DoRePaint(), and BOARD_PRINTOUT::DrawPage().

◆ ClearTarget()

virtual void KIGFX::GAL::ClearTarget ( RENDER_TARGET  aTarget)
inlinevirtual

Clear the target for rendering.

Parameters
aTargetis the target to be cleared.

Reimplemented in KIGFX::CAIRO_GAL, and KIGFX::OPENGL_GAL.

Definition at line 650 of file graphics_abstraction_layer.h.

650{};

Referenced by KIGFX::VIEW::ClearTargets().

◆ computeMinGridSpacing()

double GAL::computeMinGridSpacing ( ) const
protected

compute minimum grid spacing from the grid settings

Returns
the minimum spacing to use for drawing the grid

Definition at line 214 of file graphics_abstraction_layer.cpp.

215{
216 // just return the current value. This could be cleverer and take
217 // into account other settings in future
218 return m_gridMinSpacing;
219}

References m_gridMinSpacing.

Referenced by KIGFX::CAIRO_GAL_BASE::DrawGrid(), and KIGFX::OPENGL_GAL::DrawGrid().

◆ computeWorldScale()

void KIGFX::GAL::computeWorldScale ( )
inlineprotected

Compute the scaling factor for the world->screen matrix.

Definition at line 971 of file graphics_abstraction_layer.h.

972 {
974 }
double m_zoomFactor
The zoom factor.
double m_worldUnitLength
The unit length of the world coordinates [inch].
double m_worldScale
The scale factor world->screen.
double m_screenDPI
The dots per inch of the screen.

References m_screenDPI, m_worldScale, m_worldUnitLength, and m_zoomFactor.

Referenced by ComputeWorldScreenMatrix(), KIGFX::OPENGL_GAL::ComputeWorldScreenMatrix(), and GAL().

◆ ComputeWorldScreenMatrix()

void GAL::ComputeWorldScreenMatrix ( )
virtual

Compute the world <-> screen transformation matrix.

Reimplemented in KIGFX::CAIRO_PRINT_GAL, and KIGFX::OPENGL_GAL.

Definition at line 169 of file graphics_abstraction_layer.cpp.

170{
172
173 MATRIX3x3D translation;
174 translation.SetIdentity();
175 // We're deliberately dividing integers to avoid fractional pixel offsets.
176 translation.SetTranslation( VECTOR2D( m_screenSize.x/2, m_screenSize.y/2 ) );
177
178 MATRIX3x3D rotate;
179 rotate.SetIdentity();
180 rotate.SetRotation( m_rotation );
181
183 scale.SetIdentity();
184 scale.SetScale( VECTOR2D( m_worldScale, m_worldScale ) );
185
186 MATRIX3x3D flip;
187 flip.SetIdentity();
188 flip.SetScale( VECTOR2D( m_globalFlipX ? -1.0 : 1.0, m_globalFlipY ? -1.0 : 1.0 ) );
189
190 MATRIX3x3D lookat;
191 lookat.SetIdentity();
192 lookat.SetTranslation( -m_lookAtPoint );
193
194 m_worldScreenMatrix = translation * rotate * flip * scale * lookat;
196}
MATRIX3x3D m_worldScreenMatrix
World transformation.
MATRIX3x3D m_screenWorldMatrix
Screen transformation.
VECTOR2I m_screenSize
Screen size in screen coordinates.
double m_rotation
Rotation transformation (radians)
bool m_globalFlipY
Flag for Y axis flipping.
VECTOR2D m_lookAtPoint
Point to be looked at in world space.
void SetIdentity()
Set the matrix to the identity matrix.
Definition: matrix3x3.h:210
void SetRotation(T aAngle)
Set the rotation components of the matrix.
Definition: matrix3x3.h:245
void SetScale(VECTOR2< T > aScale)
Set the scale components of the matrix.
Definition: matrix3x3.h:257
void SetTranslation(VECTOR2< T > aTranslation)
Set the translation components of the matrix.
Definition: matrix3x3.h:226
MATRIX3x3 Inverse() const
Determine the inverse of the matrix.
Definition: matrix3x3.h:339
const int scale

References computeWorldScale(), MATRIX3x3< T >::Inverse(), m_globalFlipX, m_globalFlipY, m_lookAtPoint, m_rotation, m_screenSize, m_screenWorldMatrix, m_worldScale, m_worldScreenMatrix, scale, MATRIX3x3< T >::SetIdentity(), MATRIX3x3< T >::SetRotation(), MATRIX3x3< T >::SetScale(), MATRIX3x3< T >::SetTranslation(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by KIGFX::OPENGL_GAL::ComputeWorldScreenMatrix(), KIGFX::CAIRO_GAL_BASE::resetContext(), KIGFX::VIEW::SetCenter(), and KIGFX::VIEW::SetScale().

◆ DeleteGroup()

virtual void KIGFX::GAL::DeleteGroup ( int  aGroupNumber)
inlinevirtual

Delete the group from the memory.

Parameters
aGroupNumberis the group number.

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 508 of file graphics_abstraction_layer.h.

508{};

Referenced by KIGFX::VIEW::RECACHE_ITEM_VISITOR::operator()(), KIGFX::VIEW::Remove(), KIGFX::VIEW::updateItemGeometry(), and KIGFX::VIEW::updateLayers().

◆ DrawArc()

virtual void KIGFX::GAL::DrawArc ( const VECTOR2D aCenterPoint,
double  aRadius,
const EDA_ANGLE aStartAngle,
const EDA_ANGLE aEndAngle 
)
inlinevirtual

Draw an arc.

Parameters
aCenterPointis the center point of the arc.
aRadiusis the arc radius.
aStartAngleis the start angle of the arc.
aEndAngleis the end angle of the arc.

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 153 of file graphics_abstraction_layer.h.

154 {};

Referenced by KIGFX::PCB_PAINTER::draw(), ROUTER_PREVIEW_ITEM::drawLineChain(), ROUTER_PREVIEW_ITEM::drawShape(), and KIGFX::VIEW_OVERLAY::COMMAND_ARC::Execute().

◆ DrawArcSegment()

virtual void KIGFX::GAL::DrawArcSegment ( const VECTOR2D aCenterPoint,
double  aRadius,
const EDA_ANGLE aStartAngle,
const EDA_ANGLE aEndAngle,
double  aWidth,
double  aMaxError 
)
inlinevirtual

Draw an arc segment.

This method differs from DrawArc() in what happens when fill/stroke are on or off. DrawArc() draws a "pie piece" when fill is turned on, and a thick stroke when fill is off. DrawArcSegment() with fill on behaves like DrawArc() with fill off. DrawArcSegment() with fill off draws the outline of what it would have drawn with fill on.

TODO: Unify Arc routines

Parameters
aCenterPointis the center point of the arc.
aRadiusis the arc radius.
aStartAngleis the start angle of the arc.
aEndAngleis the end angle of the arc.
aWidthis the thickness of the arc (pen size).
aMaxErroris the max allowed error to create segments to approximate a circle. It has meaning only for back ends that can't draw a true arc, and use segments to approximate.

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 174 of file graphics_abstraction_layer.h.

176 {};

Referenced by KIGFX::PCB_PAINTER::draw(), and KIGFX::GERBVIEW_PAINTER::draw().

◆ DrawBitmap()

virtual void KIGFX::GAL::DrawBitmap ( const BITMAP_BASE aBitmap,
double  alphaBlend = 1.0 
)
inlinevirtual

Draw a bitmap image.

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 234 of file graphics_abstraction_layer.h.

234{};

Referenced by KIGFX::PCB_PAINTER::draw().

◆ DrawCircle()

virtual void KIGFX::GAL::DrawCircle ( const VECTOR2D aCenterPoint,
double  aRadius 
)
inlinevirtual

◆ DrawCursor()

virtual void KIGFX::GAL::DrawCursor ( const VECTOR2D aCursorPosition)
inlinevirtual

Draw the cursor.

Parameters
aCursorPositionis the cursor position in screen coordinates.

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 902 of file graphics_abstraction_layer.h.

902{};

Referenced by EDA_DRAW_PANEL_GAL::DoRePaint().

◆ DrawCurve()

virtual void KIGFX::GAL::DrawCurve ( const VECTOR2D startPoint,
const VECTOR2D controlPointA,
const VECTOR2D controlPointB,
const VECTOR2D endPoint,
double  aFilterValue = 0.0 
)
inlinevirtual

Draw a cubic bezier spline.

Parameters
startPointis the start point of the spline.
controlPointAis the first control point.
controlPointBis the second control point.
endPointis the end point of the spline.
aFilterValueis used by Bezier to segments approximation, if the Bezier curve is not supported and needs a curve to polyline conversion. aFilterValue = 0 means no filtering.

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 227 of file graphics_abstraction_layer.h.

229 {};

Referenced by KIGFX::PCB_PAINTER::draw().

◆ DrawGlyph()

virtual void KIGFX::GAL::DrawGlyph ( const KIFONT::GLYPH aGlyph,
int  aNth = 0,
int  aTotal = 1 
)
inlinevirtual

Draw a polygon representing a font glyph.

Reimplemented in CALLBACK_GAL, KIGFX::OPENGL_GAL, and KIGFX::CAIRO_GAL_BASE.

Definition at line 194 of file graphics_abstraction_layer.h.

194{};

Referenced by KIGFX::PCB_PAINTER::draw(), and DrawGlyphs().

◆ DrawGlyphs()

virtual void KIGFX::GAL::DrawGlyphs ( const std::vector< std::unique_ptr< KIFONT::GLYPH > > &  aGlyphs)
inlinevirtual

Draw polygons representing font glyphs.

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 199 of file graphics_abstraction_layer.h.

200 {
201 for( size_t i = 0; i < aGlyphs.size(); i++ )
202 DrawGlyph( *aGlyphs[i], i, aGlyphs.size() );
203 }
virtual void DrawGlyph(const KIFONT::GLYPH &aGlyph, int aNth=0, int aTotal=1)
Draw a polygon representing a font glyph.

References DrawGlyph().

Referenced by KIGFX::PCB_PAINTER::draw(), and KIFONT::FONT::drawSingleLineText().

◆ DrawGrid()

virtual void KIGFX::GAL::DrawGrid ( )
inlinevirtual

◆ DrawGroup()

virtual void KIGFX::GAL::DrawGroup ( int  aGroupNumber)
inlinevirtual

Draw the stored group.

Parameters
aGroupNumberis the group number.

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 485 of file graphics_abstraction_layer.h.

485{};

Referenced by KIGFX::VIEW::draw().

◆ DrawLine()

virtual void KIGFX::GAL::DrawLine ( const VECTOR2D aStartPoint,
const VECTOR2D aEndPoint 
)
inlinevirtual

◆ DrawPolygon() [1/4]

virtual void KIGFX::GAL::DrawPolygon ( const SHAPE_LINE_CHAIN aPolySet)
inlinevirtual

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 214 of file graphics_abstraction_layer.h.

214{};

◆ DrawPolygon() [2/4]

virtual void KIGFX::GAL::DrawPolygon ( const SHAPE_POLY_SET aPolySet,
bool  aStrokeTriangulation = false 
)
inlinevirtual

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 213 of file graphics_abstraction_layer.h.

213{};

◆ DrawPolygon() [3/4]

◆ DrawPolygon() [4/4]

virtual void KIGFX::GAL::DrawPolygon ( const VECTOR2D  aPointList[],
int  aListSize 
)
inlinevirtual

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 212 of file graphics_abstraction_layer.h.

212{};

◆ DrawPolyline() [1/4]

virtual void KIGFX::GAL::DrawPolyline ( const SHAPE_LINE_CHAIN aLineChain)
inlinevirtual

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 128 of file graphics_abstraction_layer.h.

128{};

◆ DrawPolyline() [2/4]

virtual void KIGFX::GAL::DrawPolyline ( const std::deque< VECTOR2D > &  aPointList)
inlinevirtual

◆ DrawPolyline() [3/4]

virtual void KIGFX::GAL::DrawPolyline ( const std::vector< VECTOR2D > &  aPointList)
inlinevirtual

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 126 of file graphics_abstraction_layer.h.

126{};

◆ DrawPolyline() [4/4]

virtual void KIGFX::GAL::DrawPolyline ( const VECTOR2D  aPointList[],
int  aListSize 
)
inlinevirtual

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 127 of file graphics_abstraction_layer.h.

127{};

◆ DrawPolylines()

virtual void KIGFX::GAL::DrawPolylines ( const std::vector< std::vector< VECTOR2D > > &  aPointLists)
inlinevirtual

Draw multiple polylines.

Parameters
aPointListsare lists of 2D-Vectors containing the polyline points.

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 135 of file graphics_abstraction_layer.h.

135{};

◆ DrawRectangle() [1/2]

void KIGFX::GAL::DrawRectangle ( const BOX2I aRect)
inline

Definition at line 186 of file graphics_abstraction_layer.h.

187 {
188 DrawRectangle( aRect.GetOrigin(), aRect.GetEnd() );
189 }
const Vec & GetOrigin() const
Definition: box2.h:183
const Vec GetEnd() const
Definition: box2.h:185
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.

References DrawRectangle(), BOX2< Vec >::GetEnd(), and BOX2< Vec >::GetOrigin().

◆ DrawRectangle() [2/2]

virtual void KIGFX::GAL::DrawRectangle ( const VECTOR2D aStartPoint,
const VECTOR2D aEndPoint 
)
inlinevirtual

◆ DrawSegment()

virtual void KIGFX::GAL::DrawSegment ( const VECTOR2D aStartPoint,
const VECTOR2D aEndPoint,
double  aWidth 
)
inlinevirtual

Draw a rounded segment.

Start and end points are defined as 2D-Vectors.

Parameters
aStartPointis the start point of the segment.
aEndPointis the end point of the segment.
aWidthis a width of the segment

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 108 of file graphics_abstraction_layer.h.

109 {};

Referenced by KIGFX::PCB_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::drawFlashedShape(), and ROUTER_PREVIEW_ITEM::drawShape().

◆ DrawSegmentChain() [1/2]

virtual void KIGFX::GAL::DrawSegmentChain ( const SHAPE_LINE_CHAIN aLineChain,
double  aWidth 
)
inlinevirtual

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 118 of file graphics_abstraction_layer.h.

118{};

◆ DrawSegmentChain() [2/2]

virtual void KIGFX::GAL::DrawSegmentChain ( const std::vector< VECTOR2D > &  aPointList,
double  aWidth 
)
inlinevirtual

Draw a chain of rounded segments.

Parameters
aPointListis a list of 2D-Vectors containing the chain points.
aWidthis a width of the segments

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 117 of file graphics_abstraction_layer.h.

117{};

Referenced by KIGFX::PCB_PAINTER::draw().

◆ EnableDepthTest()

virtual void KIGFX::GAL::EnableDepthTest ( bool  aEnabled = false)
inlinevirtual

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 930 of file graphics_abstraction_layer.h.

930{};

◆ EndDiffLayer()

virtual void KIGFX::GAL::EndDiffLayer ( )
inlinevirtual

Ends rendering of a differential layer.

Objects drawn after the StartDiffLayer() will be drawn and composited with a differential blend mode, then drawing is returned to normal.

Reimplemented in KIGFX::CAIRO_GAL, and KIGFX::OPENGL_GAL.

Definition at line 689 of file graphics_abstraction_layer.h.

689{};

Referenced by KIGFX::VIEW::redrawRect().

◆ EndDrawing()

virtual void KIGFX::GAL::EndDrawing ( )
inlinevirtual

End the drawing, needs to be called for every new frame.

Use GAL_DRAWING_CONTEXT RAII object unless you know what you're doing.

Reimplemented in KIGFX::CAIRO_GAL_BASE, KIGFX::CAIRO_GAL, and KIGFX::OPENGL_GAL.

Definition at line 958 of file graphics_abstraction_layer.h.

958{};

Referenced by KIGFX::GAL_DRAWING_CONTEXT::~GAL_DRAWING_CONTEXT().

◆ EndGroup()

virtual void KIGFX::GAL::EndGroup ( )
inlinevirtual

End the group.

Reimplemented in KIGFX::CAIRO_GAL_BASE, KIGFX::CAIRO_GAL, and KIGFX::OPENGL_GAL.

Definition at line 478 of file graphics_abstraction_layer.h.

478{};

Referenced by KIGFX::VIEW::updateItemGeometry().

◆ EndNegativesLayer()

virtual void KIGFX::GAL::EndNegativesLayer ( )
inlinevirtual

Ends rendering of a negatives layer and draws it to the main layer.

No-op in OpenGL.

Reimplemented in KIGFX::CAIRO_GAL.

Definition at line 705 of file graphics_abstraction_layer.h.

705{};

Referenced by KIGFX::VIEW::redrawRect().

◆ endUpdate()

virtual void KIGFX::GAL::endUpdate ( )
inlineprotectedvirtual

Disable item update mode.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 966 of file graphics_abstraction_layer.h.

966{}

Referenced by KIGFX::GAL_UPDATE_CONTEXT::~GAL_UPDATE_CONTEXT().

◆ Flush()

virtual void KIGFX::GAL::Flush ( )
inlinevirtual

Force all remaining objects to be drawn.

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 256 of file graphics_abstraction_layer.h.

256{};

◆ GetClearColor()

const COLOR4D & KIGFX::GAL::GetClearColor ( ) const
inline

Definition at line 263 of file graphics_abstraction_layer.h.

264 {
265 return m_clearColor;
266 }

References m_clearColor.

Referenced by EDIT_POINTS::ViewDraw().

◆ getCursorColor()

COLOR4D GAL::getCursorColor ( ) const
protected

Get the actual cursor color to draw.

Definition at line 244 of file graphics_abstraction_layer.cpp.

245{
247
248 // dim the cursor if it's only on because it was forced
249 // (this helps to provide a hint for active tools)
250 if( !m_isCursorEnabled )
251 color.a = color.a * 0.5;
252
253 return color;
254}
int color
Definition: DXF_plotter.cpp:57
bool m_isCursorEnabled
Is the cursor enabled?
COLOR4D m_cursorColor
Cursor color.

References color, m_cursorColor, and m_isCursorEnabled.

Referenced by KIGFX::OPENGL_GAL::blitCursor(), and KIGFX::CAIRO_GAL_BASE::blitCursor().

◆ GetFillColor()

const COLOR4D & KIGFX::GAL::GetFillColor ( ) const
inline

Get the fill color.

Returns
the color for filling a outline.

Definition at line 314 of file graphics_abstraction_layer.h.

315 {
316 return m_fillColor;
317 }
COLOR4D m_fillColor
The fill color.

References m_fillColor.

◆ GetGlyphSize()

const VECTOR2I & KIGFX::GAL::GetGlyphSize ( ) const
inline

Definition at line 396 of file graphics_abstraction_layer.h.

396{ return m_attributes.m_Size; }

References m_attributes, and TEXT_ATTRIBUTES::m_Size.

Referenced by KIGFX::OPENGL_GAL::BitmapText().

◆ GetGridLineWidth()

float KIGFX::GAL::GetGridLineWidth ( ) const
inline

Get the grid line width.

Returns
the grid line width Draw the grid

Definition at line 821 of file graphics_abstraction_layer.h.

References m_gridLineWidth.

◆ GetGridOrigin()

const VECTOR2D & KIGFX::GAL::GetGridOrigin ( ) const
inline

Definition at line 746 of file graphics_abstraction_layer.h.

747 {
748 return m_gridOrigin;
749 }
VECTOR2D m_gridOrigin
The grid origin.

References m_gridOrigin.

Referenced by GRID_HELPER::GetOrigin().

◆ GetGridPoint()

VECTOR2D GAL::GetGridPoint ( const VECTOR2D aPoint) const

For a given point it returns the nearest point belonging to the grid in world coordinates.

Parameters
aPointis the point for which the grid point is searched.
Returns
The nearest grid point in world coordinates.

Definition at line 222 of file graphics_abstraction_layer.cpp.

223{
224#if 0
225 // This old code expects a non zero grid size, which can be wrong here.
226 return VECTOR2D( KiROUND( ( aPoint.x - m_gridOffset.x ) / m_gridSize.x ) * m_gridSize.x + m_gridOffset.x,
227 KiROUND( ( aPoint.y - m_gridOffset.y ) / m_gridSize.y ) * m_gridSize.y + m_gridOffset.y );
228#else
229 // if grid size == 0.0 there is no grid, so use aPoint as grid reference position
230 double cx = m_gridSize.x > 0.0 ? KiROUND( ( aPoint.x - m_gridOffset.x ) / m_gridSize.x ) * m_gridSize.x + m_gridOffset.x
231 : aPoint.x;
232 double cy = m_gridSize.y > 0.0 ? KiROUND( ( aPoint.y - m_gridOffset.y ) / m_gridSize.y ) * m_gridSize.y + m_gridOffset.y
233 : aPoint.y;
234
235 return VECTOR2D( cx, cy );
236#endif
237}
VECTOR2D m_gridSize
The grid size.
VECTOR2D m_gridOffset
The grid offset to compensate cursor position.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85

References KiROUND(), m_gridOffset, m_gridSize, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by KIGFX::WX_VIEW_CONTROLS::GetRawCursorPosition().

◆ GetGridSize()

◆ GetGridSnapping()

◆ GetGridVisibility()

bool KIGFX::GAL::GetGridVisibility ( ) const
inline

Definition at line 718 of file graphics_abstraction_layer.h.

718{ return m_gridVisibility; }

References m_gridVisibility.

Referenced by EDA_DRAW_PANEL_GAL::SwitchBackend().

◆ GetHorizontalJustify()

GR_TEXT_H_ALIGN_T KIGFX::GAL::GetHorizontalJustify ( ) const
inline

Definition at line 415 of file graphics_abstraction_layer.h.

415{ return m_attributes.m_Halign; }
GR_TEXT_H_ALIGN_T m_Halign

References m_attributes, and TEXT_ATTRIBUTES::m_Halign.

Referenced by KIGFX::OPENGL_GAL::BitmapText().

◆ GetLineWidth()

float KIGFX::GAL::GetLineWidth ( ) const
inline

Get the line width.

Returns
the actual line width.

Definition at line 354 of file graphics_abstraction_layer.h.

355 {
356 return m_lineWidth;
357 }
float m_lineWidth
The line width.

References m_lineWidth.

Referenced by BitmapText(), CALLBACK_GAL::DrawGlyph(), and KIGFX::OPENGL_GAL::DrawGrid().

◆ GetLookAtPoint()

const VECTOR2D & KIGFX::GAL::GetLookAtPoint ( ) const
inline

Definition at line 582 of file graphics_abstraction_layer.h.

582{ return m_lookAtPoint; }

References m_lookAtPoint.

Referenced by GetVisibleWorldExtents().

◆ GetMaxDepth()

double KIGFX::GAL::GetMaxDepth ( ) const
inline

Definition at line 603 of file graphics_abstraction_layer.h.

603{ return m_depthRange.y; }
VECTOR2D m_depthRange
Range of the depth.

References m_depthRange, and VECTOR2< T >::y.

Referenced by NL_SCHEMATIC_PLUGIN_IMPL::GetViewExtents(), and NL_PCBNEW_PLUGIN_IMPL::GetViewExtents().

◆ GetMinDepth()

◆ GetRotation()

double KIGFX::GAL::GetRotation ( ) const
inline

Definition at line 591 of file graphics_abstraction_layer.h.

591{ return m_rotation; }

References m_rotation.

◆ GetScreenPixelSize()

◆ GetScreenWorldMatrix()

const MATRIX3x3D & KIGFX::GAL::GetScreenWorldMatrix ( ) const
inline

Get the screen <-> world transformation matrix.

Returns
the transformation matrix.

Definition at line 537 of file graphics_abstraction_layer.h.

538 {
539 return m_screenWorldMatrix;
540 }

References m_screenWorldMatrix.

Referenced by KIGFX::PCB_PAINTER::draw(), KIGFX::SCH_PAINTER::getShadowWidth(), GetVisibleWorldExtents(), KIGFX::OPENGL_GAL::getWorldPixelSize(), screenSpaceCircle(), screenSpaceLine(), and KIGFX::VIEW::ToWorld().

◆ GetStrokeColor()

const COLOR4D & KIGFX::GAL::GetStrokeColor ( ) const
inline

Get the stroke color.

Returns
the color for stroking the outline.

Definition at line 334 of file graphics_abstraction_layer.h.

335 {
336 return m_strokeColor;
337 }
COLOR4D m_strokeColor
The color of the outlines.

References m_strokeColor.

Referenced by KIGFX::PREVIEW::DrawTextNextToCursor(), and KIGFX::PREVIEW::RULER_ITEM::ViewDraw().

◆ GetSwapInterval()

virtual int KIGFX::GAL::GetSwapInterval ( ) const
inlinevirtual

Return the swap interval. -1 for adaptive, 0 for disabled/unknown.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 253 of file graphics_abstraction_layer.h.

253{ return 0; };

Referenced by EDA_DRAW_PANEL_GAL::SwitchBackend().

◆ GetTarget()

virtual RENDER_TARGET KIGFX::GAL::GetTarget ( ) const
inlinevirtual

Get the currently used target for rendering.

Returns
The current rendering target.

Reimplemented in KIGFX::CAIRO_GAL, and KIGFX::OPENGL_GAL.

Definition at line 643 of file graphics_abstraction_layer.h.

643{ return TARGET_CACHED; };
@ TARGET_CACHED
Main rendering target (cached)
Definition: definitions.h:48

References KIGFX::TARGET_CACHED.

◆ GetVerticalJustify()

GR_TEXT_V_ALIGN_T KIGFX::GAL::GetVerticalJustify ( ) const
inline

Definition at line 422 of file graphics_abstraction_layer.h.

422{ return m_attributes.m_Valign; }
GR_TEXT_V_ALIGN_T m_Valign

References m_attributes, and TEXT_ATTRIBUTES::m_Valign.

Referenced by KIGFX::OPENGL_GAL::BitmapText().

◆ GetVisibleWorldExtents()

BOX2D GAL::GetVisibleWorldExtents ( ) const
Returns
the bounding box of the world that is displayed on screen at the moment

Definition at line 199 of file graphics_abstraction_layer.cpp.

200{
201 const MATRIX3x3D& matrix = GetScreenWorldMatrix();
202
203 VECTOR2D halfSize = VECTOR2D( matrix.GetScale().x * m_screenSize.x * 0.5,
204 matrix.GetScale().y * m_screenSize.y * 0.5 );
205
206 BOX2D extents;
207 extents.SetOrigin( GetLookAtPoint() - halfSize );
208 extents.SetSize( halfSize * 2 );
209
210 return extents;
211}
void SetOrigin(const Vec &pos)
Definition: box2.h:202
void SetSize(const Vec &size)
Definition: box2.h:213
const VECTOR2D & GetLookAtPoint() const
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:265

References GetLookAtPoint(), MATRIX3x3< T >::GetScale(), GetScreenWorldMatrix(), m_screenSize, BOX2< Vec >::SetOrigin(), BOX2< Vec >::SetSize(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by ROUTER_TOOL::handleCommonEvents(), and ROUTER_TOOL::InlineDrag().

◆ GetWorldScale()

◆ GetWorldScreenMatrix()

const MATRIX3x3D & KIGFX::GAL::GetWorldScreenMatrix ( ) const
inline

Get the world <-> screen transformation matrix.

Returns
the transformation matrix.

Definition at line 527 of file graphics_abstraction_layer.h.

528 {
529 return m_worldScreenMatrix;
530 }

References m_worldScreenMatrix.

Referenced by KIGFX::VIEW::ToScreen().

◆ GetZoomFactor()

◆ HasTarget()

virtual bool KIGFX::GAL::HasTarget ( RENDER_TARGET  aTarget)
inlinevirtual

Return true if the target exists.

Parameters
aTargetis the target to be checked.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 657 of file graphics_abstraction_layer.h.

658 {
659 return true;
660 };

Referenced by EDA_DRAW_PANEL_GAL::DoRePaint().

◆ IsCairoEngine()

virtual bool KIGFX::GAL::IsCairoEngine ( )
inlinevirtual

Return true if the GAL engine is a Cairo based type.

Reimplemented in KIGFX::CAIRO_GAL_BASE.

Definition at line 80 of file graphics_abstraction_layer.h.

80{ return false; }

Referenced by getShadowLayer().

◆ IsContextLocked()

virtual bool KIGFX::GAL::IsContextLocked ( )
inlinevirtual

Checks the state of the context lock.

Returns
True if the context is currently locked

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 936 of file graphics_abstraction_layer.h.

937 {
938 return false;
939 }

Referenced by EDA_DRAW_PANEL_GAL::onSize().

◆ IsCursorEnabled()

bool KIGFX::GAL::IsCursorEnabled ( ) const
inline

Return information about cursor visibility.

Returns
True if cursor is visible.

Definition at line 882 of file graphics_abstraction_layer.h.

883 {
885 }

References m_forceDisplayCursor, and m_isCursorEnabled.

Referenced by KIGFX::OPENGL_GAL::blitCursor(), and KIGFX::CAIRO_GAL_BASE::blitCursor().

◆ IsFlippedX()

◆ IsFlippedY()

bool KIGFX::GAL::IsFlippedY ( ) const
inline

Definition at line 625 of file graphics_abstraction_layer.h.

625{ return m_globalFlipY; }

References m_globalFlipY.

◆ IsFontBold()

bool KIGFX::GAL::IsFontBold ( ) const
inline

Definition at line 399 of file graphics_abstraction_layer.h.

399{ return m_attributes.m_Bold; }

References m_attributes, and TEXT_ATTRIBUTES::m_Bold.

◆ IsFontItalic()

bool KIGFX::GAL::IsFontItalic ( ) const
inline

Definition at line 402 of file graphics_abstraction_layer.h.

402{ return m_attributes.m_Italic; }

References m_attributes, and TEXT_ATTRIBUTES::m_Italic.

◆ IsFontUnderlined()

bool KIGFX::GAL::IsFontUnderlined ( ) const
inline

Definition at line 405 of file graphics_abstraction_layer.h.

References m_attributes, and TEXT_ATTRIBUTES::m_Underlined.

◆ IsInitialized()

virtual bool KIGFX::GAL::IsInitialized ( ) const
inlinevirtual

Return the initialization status for the canvas.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 74 of file graphics_abstraction_layer.h.

74{ return true; }

Referenced by SCH_DRAW_PANEL::onPaint(), and EDA_DRAW_PANEL_GAL::onRefreshTimer().

◆ IsOpenGlEngine()

virtual bool KIGFX::GAL::IsOpenGlEngine ( )
inlinevirtual

Return true if the GAL engine is a OpenGL based type.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 83 of file graphics_abstraction_layer.h.

83{ return false; }

Referenced by KIGFX::PCB_PAINTER::draw(), and KIGFX::GERBVIEW_PAINTER::draw().

◆ IsTextMirrored()

bool KIGFX::GAL::IsTextMirrored ( ) const
inline

Definition at line 408 of file graphics_abstraction_layer.h.

408{ return m_attributes.m_Mirrored; }

References m_attributes, and TEXT_ATTRIBUTES::m_Mirrored.

Referenced by KIGFX::OPENGL_GAL::BitmapText().

◆ IsVisible()

virtual bool KIGFX::GAL::IsVisible ( ) const
inlinevirtual

◆ LockContext()

virtual void KIGFX::GAL::LockContext ( int  aClientCookie)
inlinevirtual

Use GAL_CONTEXT_LOCKER RAII object unless you know what you're doing.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 943 of file graphics_abstraction_layer.h.

943{}

Referenced by KIGFX::GAL_CONTEXT_LOCKER::GAL_CONTEXT_LOCKER().

◆ OnGalDisplayOptionsChanged()

void GAL::OnGalDisplayOptionsChanged ( const GAL_DISPLAY_OPTIONS aOptions)
overrideprotectedvirtual

Handler for observer settings changes.

Implements KIGFX::GAL_DISPLAY_OPTIONS_OBSERVER.

Definition at line 99 of file graphics_abstraction_layer.cpp.

100{
101 // defer to the child class first
102 updatedGalDisplayOptions( aOptions );
103
104 // there is no refresh to do at this level
105}
virtual bool updatedGalDisplayOptions(const GAL_DISPLAY_OPTIONS &aOptions)
Handle updating display options.

References updatedGalDisplayOptions().

◆ PopDepth()

void KIGFX::GAL::PopDepth ( )
inline

Restore previously stored drawing depth for the depth stack.

Definition at line 924 of file graphics_abstraction_layer.h.

925 {
927 m_depthStack.pop();
928 }
std::stack< double > m_depthStack
Stored depth values.

References m_depthStack, and m_layerDepth.

Referenced by EDIT_POINTS::ViewDraw(), KIGFX::PREVIEW::RULER_ITEM::ViewDraw(), and KIGFX::VIEW_GROUP::ViewDraw().

◆ PushDepth()

void KIGFX::GAL::PushDepth ( )
inline

Store current drawing depth on the depth stack.

Definition at line 916 of file graphics_abstraction_layer.h.

917 {
919 }

References m_depthStack, and m_layerDepth.

Referenced by EDIT_POINTS::ViewDraw(), KIGFX::PREVIEW::RULER_ITEM::ViewDraw(), KIGFX::VIEW_GROUP::ViewDraw(), and KIGFX::VIEW_OVERLAY::ViewDraw().

◆ ResetTextAttributes()

void GAL::ResetTextAttributes ( )

Reset text attributes to default styling.

FONT TODO: do we need any of this in GAL anymore?

Normally, custom attributes will be set individually after this, otherwise you can use SetTextAttributes()

Definition at line 153 of file graphics_abstraction_layer.cpp.

154{
155 // Tiny but non-zero - this will always need setting
156 // there is no built-in default
157 SetGlyphSize( { 1, 1 } );
158
161
162 SetFontBold( false );
163 SetFontItalic( false );
164 SetFontUnderlined( false );
165 SetTextMirrored( false );
166}
void SetVerticalJustify(const GR_TEXT_V_ALIGN_T aVerticalJustify)
void SetFontBold(const bool aBold)
void SetFontUnderlined(bool aUnderlined)
void SetHorizontalJustify(const GR_TEXT_H_ALIGN_T aHorizontalJustify)
void SetTextMirrored(const bool aMirrored)
void SetGlyphSize(const VECTOR2I aSize)
void SetFontItalic(bool aItalic)
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_CENTER

References GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, SetFontBold(), SetFontItalic(), SetFontUnderlined(), SetGlyphSize(), SetHorizontalJustify(), SetTextMirrored(), and SetVerticalJustify().

Referenced by KIGFX::PCB_PAINTER::draw(), GAL(), KIGFX::PREVIEW::ARC_ASSISTANT::ViewDraw(), KIGFX::PREVIEW::RULER_ITEM::ViewDraw(), and KIGFX::PREVIEW::TWO_POINT_ASSISTANT::ViewDraw().

◆ ResizeScreen()

virtual void KIGFX::GAL::ResizeScreen ( int  aWidth,
int  aHeight 
)
inlinevirtual

◆ Restore()

virtual void KIGFX::GAL::Restore ( )
inlinevirtual

Restore the context.

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 461 of file graphics_abstraction_layer.h.

461{};

Referenced by KIGFX::PCB_PAINTER::draw(), and DS_PROXY_VIEW_ITEM::ViewDraw().

◆ Rotate()

virtual void KIGFX::GAL::Rotate ( double  aAngle)
inlinevirtual

Rotate the context.

Parameters
aAngleis the rotation angle in radians.

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 441 of file graphics_abstraction_layer.h.

441{};

Referenced by KIGFX::PCB_PAINTER::draw().

◆ Save()

virtual void KIGFX::GAL::Save ( )
inlinevirtual

Save the context.

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 458 of file graphics_abstraction_layer.h.

458{};

Referenced by KIGFX::PCB_PAINTER::draw(), and DS_PROXY_VIEW_ITEM::ViewDraw().

◆ Scale()

virtual void KIGFX::GAL::Scale ( const VECTOR2D aScale)
inlinevirtual

Scale the context.

Parameters
aScaleis the scale factor for the x- and y-axis.

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 455 of file graphics_abstraction_layer.h.

455{};

Referenced by KIGFX::PCB_PAINTER::draw(), and DS_PROXY_VIEW_ITEM::ViewDraw().

◆ SetAxesColor()

void KIGFX::GAL::SetAxesColor ( const COLOR4D aAxesColor)
inline

◆ SetAxesEnabled()

void KIGFX::GAL::SetAxesEnabled ( bool  aAxesEnabled)
inline

◆ SetClearColor()

◆ SetCoarseGrid()

void KIGFX::GAL::SetCoarseGrid ( int  aInterval)
inline

Draw every tick line wider.

Parameters
aIntervalincrease the width of every aInterval line, if 0 do not use this feature.

Definition at line 811 of file graphics_abstraction_layer.h.

812 {
813 m_gridTick = aInterval;
814 }
int m_gridTick
Every tick line gets the double width.

References m_gridTick.

Referenced by GAL().

◆ SetCursorColor()

void KIGFX::GAL::SetCursorColor ( const COLOR4D aCursorColor)
inline

Set the cursor color.

Parameters
aCursorColoris the color of the cursor.

Definition at line 892 of file graphics_abstraction_layer.h.

893 {
894 m_cursorColor = aCursorColor;
895 }

References m_cursorColor.

Referenced by EDA_DRAW_PANEL_GAL::DoRePaint(), GAL(), and PCB_DRAW_PANEL_GAL::UpdateColors().

◆ SetCursorEnabled()

void KIGFX::GAL::SetCursorEnabled ( bool  aCursorEnabled)
inline

Enable/disable cursor.

Parameters
aCursorEnabledis true if the cursor should be drawn, else false.

Definition at line 872 of file graphics_abstraction_layer.h.

873 {
874 m_isCursorEnabled = aCursorEnabled;
875 }

References m_isCursorEnabled.

Referenced by GAL(), SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL(), and KIGFX::VIEW_CONTROLS::ShowCursor().

◆ SetDepthRange()

void KIGFX::GAL::SetDepthRange ( const VECTOR2D aDepthRange)
inline

Set the range of the layer depth.

Usually required for the OpenGL implementation, any object outside this range is not drawn.

The MinDepth (x) is closest to the clipping plane (top) while the MaxDepth (y) is farthest from the clipping plane (bottom).

Definition at line 601 of file graphics_abstraction_layer.h.

601{ m_depthRange = aDepthRange; }

References m_depthRange.

Referenced by GAL().

◆ SetFillColor()

◆ SetFlip()

void KIGFX::GAL::SetFlip ( bool  xAxis,
bool  yAxis 
)
inline

Sets flipping of the screen.

Parameters
xAxisis the flip flag for the X axis.
yAxisis the flip flag for the Y axis.

Definition at line 618 of file graphics_abstraction_layer.h.

619 {
620 m_globalFlipX = xAxis;
621 m_globalFlipY = yAxis;
622 }

References m_globalFlipX, and m_globalFlipY.

Referenced by GAL(), KIGFX::VIEW::SetMirror(), and BOARD_PRINTOUT::setupGal().

◆ SetFontBold()

void KIGFX::GAL::SetFontBold ( const bool  aBold)
inline

◆ SetFontItalic()

void KIGFX::GAL::SetFontItalic ( bool  aItalic)
inline

◆ SetFontUnderlined()

void KIGFX::GAL::SetFontUnderlined ( bool  aUnderlined)
inline

◆ SetGlyphSize()

◆ SetGridColor()

void KIGFX::GAL::SetGridColor ( const COLOR4D aGridColor)
inline

Set the grid color.

Parameters
aGridColoris the grid color, it should have a low alpha value for the best effect.

Definition at line 783 of file graphics_abstraction_layer.h.

784 {
785 m_gridColor = aGridColor;
786 }
COLOR4D m_gridColor
Color of the grid.

References m_gridColor.

Referenced by GERBVIEW_FRAME::ActivateGalCanvas(), KIGFX::CAIRO_GAL_BASE::CAIRO_GAL_BASE(), EDA_DRAW_PANEL_GAL::DoRePaint(), KIGFX::OPENGL_GAL::OPENGL_GAL(), SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL(), GERBVIEW_FRAME::SetGridColor(), PCB_EDIT_FRAME::SetGridColor(), and PCB_DRAW_PANEL_GAL::UpdateColors().

◆ SetGridOrigin()

void KIGFX::GAL::SetGridOrigin ( const VECTOR2D aGridOrigin)
inline

Set the origin point for the grid.

Parameters
aGridOriginis a vector containing the grid origin point, in world coordinates.

Definition at line 731 of file graphics_abstraction_layer.h.

732 {
733 m_gridOrigin = aGridOrigin;
734
735 if( m_gridSize.x == 0.0 || m_gridSize.y == 0.0 )
736 {
737 m_gridOffset = VECTOR2D( 0.0, 0.0);
738 }
739 else
740 {
741 m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x,
742 (long) m_gridOrigin.y % (long) m_gridSize.y );
743 }
744 }

References m_gridOffset, m_gridOrigin, m_gridSize, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PCB_CONTROL::DoSetGridOrigin(), Refresh(), and PCB_BASE_EDIT_FRAME::SetBoard().

◆ SetGridSize()

void KIGFX::GAL::SetGridSize ( const VECTOR2D aGridSize)
inline

Set the grid size.

Parameters
aGridSizeis a vector containing the grid size in x and y direction.

Definition at line 756 of file graphics_abstraction_layer.h.

757 {
758 m_gridSize = aGridSize;
759
760 // Avoid stupid grid size values: a grid size should be >= 1 in internal units
761 m_gridSize.x = std::max( 1.0, m_gridSize.x );
762 m_gridSize.y = std::max( 1.0, m_gridSize.y );
763
764 m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x,
765 (long) m_gridOrigin.y % (long) m_gridSize.y );
766 }

References m_gridOffset, m_gridOrigin, m_gridSize, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by COMMON_TOOLS::OnGridChanged(), DIALOG_PAD_PROPERTIES::prepareCanvas(), SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL(), and EDA_DRAW_PANEL_GAL::SwitchBackend().

◆ SetGridVisibility()

void KIGFX::GAL::SetGridVisibility ( bool  aVisibility)
inline

Set the visibility setting of the grid.

Parameters
aVisibilityis the new visibility setting of the grid.

Definition at line 716 of file graphics_abstraction_layer.h.

716{ m_gridVisibility = aVisibility; }

References m_gridVisibility.

Referenced by GAL(), COMMON_TOOLS::OnGridChanged(), GERBER_LAYER_WIDGET::OnRenderEnable(), DIALOG_PAD_PROPERTIES::prepareCanvas(), EDA_DRAW_FRAME::SetGridVisibility(), EDA_DRAW_PANEL_GAL::SwitchBackend(), and SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET().

◆ SetHorizontalJustify()

void KIGFX::GAL::SetHorizontalJustify ( const GR_TEXT_H_ALIGN_T  aHorizontalJustify)
inline

◆ SetIsFill()

◆ SetIsStroke()

◆ SetLayerDepth()

virtual void KIGFX::GAL::SetLayerDepth ( double  aLayerDepth)
inlinevirtual

Set the depth of the layer (position on the z-axis)

Parameters
aLayerDepththe layer depth for the objects.

Reimplemented in KIGFX::CAIRO_GAL_BASE.

Definition at line 364 of file graphics_abstraction_layer.h.

365 {
366 assert( aLayerDepth <= m_depthRange.y );
367 assert( aLayerDepth >= m_depthRange.x );
368
369 m_layerDepth = aLayerDepth;
370 }

References m_depthRange, m_layerDepth, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by KIGFX::VIEW::draw(), ROUTER_PREVIEW_ITEM::drawShape(), KIGFX::OPENGL_GAL::drawTriangulatedPolyset(), GAL(), KIGFX::VIEW::redrawRect(), KIGFX::CAIRO_GAL_BASE::SetLayerDepth(), KIGFX::VIEW::updateItemGeometry(), EDIT_POINTS::ViewDraw(), ROUTER_PREVIEW_ITEM::ViewDraw(), and KIGFX::PREVIEW::RULER_ITEM::ViewDraw().

◆ SetLineWidth()

◆ SetLookAtPoint()

void KIGFX::GAL::SetLookAtPoint ( const VECTOR2D aPoint)
inline

Get/set the Point in world space to look at.

This point corresponds with the center of the actual drawing area.

Definition at line 581 of file graphics_abstraction_layer.h.

581{ m_lookAtPoint = aPoint; }

References m_lookAtPoint.

Referenced by BOARD_PRINTOUT::DrawPage(), GAL(), and KIGFX::VIEW::SetCenter().

◆ SetNativeCursorStyle()

bool GAL::SetNativeCursorStyle ( KICURSOR  aCursor)
virtual

Set the cursor in the native panel.

Parameters
aCursoris the cursor to use in the native panel
Returns
true if the cursor was updated, false if the cursor given was already set

Reimplemented in KIGFX::CAIRO_GAL, and KIGFX::OPENGL_GAL.

Definition at line 280 of file graphics_abstraction_layer.cpp.

281{
282 if( m_currentNativeCursor == aCursor )
283 return false;
284
285 m_currentNativeCursor = aCursor;
286
287 return true;
288}

References m_currentNativeCursor.

Referenced by GAL(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), KIGFX::CAIRO_GAL::SetNativeCursorStyle(), and KIGFX::OPENGL_GAL::SetNativeCursorStyle().

◆ SetNegativeDrawMode()

virtual void KIGFX::GAL::SetNegativeDrawMode ( bool  aSetting)
inlinevirtual

Set negative draw mode in the renderer.

When negative mode is enabled, drawn items will subtract from previously drawn items. This is mainly needed for Gerber negative item support in Cairo, since unlike in OpenGL, objects drawn with zero opacity on top of other objects would not normally mask objects in Cairo. This method is a no-op in OpenGL.

Parameters
aSettingis true if negative mode should be enabled

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 673 of file graphics_abstraction_layer.h.

673{};

Referenced by KIGFX::GERBVIEW_PAINTER::draw().

◆ SetRotation()

void KIGFX::GAL::SetRotation ( double  aRotation)
inline

Get/set the rotation angle (in radians).

Definition at line 590 of file graphics_abstraction_layer.h.

590{ m_rotation = aRotation; }

References m_rotation.

Referenced by GAL().

◆ SetScreenDPI()

void KIGFX::GAL::SetScreenDPI ( double  aScreenDPI)
inline

Set the dots per inch of the screen.

This value depends on the user screen, it should be configurable by the application. For instance a typical notebook with HD+ resolution (1600x900) has 106 DPI.

Definition at line 574 of file graphics_abstraction_layer.h.

574{ m_screenDPI = aScreenDPI; }

References m_screenDPI.

Referenced by KIGFX::CAIRO_PRINT_GAL::CAIRO_PRINT_GAL(), and GAL().

◆ SetScreenSize()

void KIGFX::GAL::SetScreenSize ( const VECTOR2I aSize)
inline

Definition at line 566 of file graphics_abstraction_layer.h.

566{ m_screenSize = aSize; }

References m_screenSize.

Referenced by KIGFX::CAIRO_PRINT_GAL::SetSheetSize().

◆ SetStrokeColor()

◆ SetTarget()

virtual void KIGFX::GAL::SetTarget ( RENDER_TARGET  aTarget)
inlinevirtual

Set the target for rendering.

Parameters
aTargetis the new target for rendering.

Reimplemented in KIGFX::CAIRO_GAL, and KIGFX::OPENGL_GAL.

Definition at line 636 of file graphics_abstraction_layer.h.

636{};

Referenced by KIGFX::CAIRO_GAL_BASE::DrawGrid(), KIGFX::VIEW::redrawRect(), KIGFX::VIEW::updateItemGeometry(), and MY_DRAWING::ViewDraw().

◆ SetTextMirrored()

void KIGFX::GAL::SetTextMirrored ( const bool  aMirrored)
inline

◆ SetVerticalJustify()

void KIGFX::GAL::SetVerticalJustify ( const GR_TEXT_V_ALIGN_T  aVerticalJustify)
inline

◆ SetWorldScreenMatrix()

void KIGFX::GAL::SetWorldScreenMatrix ( const MATRIX3x3D aMatrix)
inline

Set the world <-> screen transformation matrix.

Parameters
aMatrixis the 3x3 world <-> screen transformation matrix.

Definition at line 547 of file graphics_abstraction_layer.h.

548 {
549 m_worldScreenMatrix = aMatrix;
550 }

References m_worldScreenMatrix.

◆ SetWorldUnitLength()

void KIGFX::GAL::SetWorldUnitLength ( double  aWorldUnitLength)
inline

Set the unit length.

This defines the length [inch] per one integer. For instance a value 0.001 means that the coordinate [1000, 1000] corresponds with a point at (1 inch, 1 inch) or 1 mil resolution per integer.

Definition at line 564 of file graphics_abstraction_layer.h.

564{ m_worldUnitLength = aWorldUnitLength; }

References m_worldUnitLength.

Referenced by GAL(), GERBVIEW_DRAW_PANEL_GAL::GERBVIEW_DRAW_PANEL_GAL(), PL_DRAW_PANEL_GAL::PL_DRAW_PANEL_GAL(), SCH_DRAW_PANEL::SCH_DRAW_PANEL(), SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL(), GERBVIEW_PRINTOUT::setupGal(), PCBNEW_PRINTOUT::setupGal(), SCH_DRAW_PANEL::SwitchBackend(), GERBVIEW_DRAW_PANEL_GAL::SwitchBackend(), PL_DRAW_PANEL_GAL::SwitchBackend(), and PCB_DRAW_PANEL_GAL::SwitchBackend().

◆ SetZoomFactor()

void KIGFX::GAL::SetZoomFactor ( double  aZoomFactor)
inline

Definition at line 584 of file graphics_abstraction_layer.h.

584{ m_zoomFactor = aZoomFactor; }

References m_zoomFactor.

Referenced by BOARD_PRINTOUT::DrawPage(), GAL(), and KIGFX::VIEW::SetScale().

◆ Show()

virtual bool KIGFX::GAL::Show ( bool  aShow)
inlinevirtual

Show/hide the GAL canvas.

Reimplemented in KIGFX::CAIRO_GAL, and KIGFX::OPENGL_GAL.

Definition at line 244 of file graphics_abstraction_layer.h.

244{ return true; };

◆ StartDiffLayer()

virtual void KIGFX::GAL::StartDiffLayer ( )
inlinevirtual

Begins rendering of a differential layer.

Used by gerbview's differential mode.

Differential layers have their drawn objects blended onto the lower layers differently so we need to end drawing of current objects and start a new set to be completed with a different blend mode.

Reimplemented in KIGFX::CAIRO_GAL, and KIGFX::OPENGL_GAL.

Definition at line 682 of file graphics_abstraction_layer.h.

682{};

Referenced by KIGFX::VIEW::redrawRect().

◆ StartNegativesLayer()

virtual void KIGFX::GAL::StartNegativesLayer ( )
inlinevirtual

Begins rendering in a new layer that will be copied to the main layer in EndNegativesLayer().

For Cairo, layers with negative items need a new layer so when negative layers _CLEAR sections it doesn't delete drawings on layers below them. No-op in OpenGL

Reimplemented in KIGFX::CAIRO_GAL.

Definition at line 699 of file graphics_abstraction_layer.h.

699{};

Referenced by KIGFX::VIEW::redrawRect().

◆ ToScreen()

VECTOR2D KIGFX::GAL::ToScreen ( const VECTOR2D aPoint) const
inline

Compute the point position in screen coordinates from given world coordinates.

Parameters
aPointthe point position in world coordinates.
Returns
the point position in screen coordinates.

Definition at line 854 of file graphics_abstraction_layer.h.

855 {
856 return VECTOR2D( m_worldScreenMatrix * aPoint );
857 }

References m_worldScreenMatrix.

Referenced by KIGFX::CAIRO_GAL_BASE::blitCursor().

◆ ToWorld()

VECTOR2D KIGFX::GAL::ToWorld ( const VECTOR2D aPoint) const
inline

Compute the point position in world coordinates from given screen coordinates.

Parameters
aPointthe point position in screen coordinates.
Returns
the point position in world coordinates.

Definition at line 843 of file graphics_abstraction_layer.h.

844 {
845 return VECTOR2D( m_screenWorldMatrix * aPoint );
846 }

References m_screenWorldMatrix.

◆ Transform()

virtual void KIGFX::GAL::Transform ( const MATRIX3x3D aTransformation)
inlinevirtual

Transform the context.

Parameters
aTransformationis the transformation matrix.

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 434 of file graphics_abstraction_layer.h.

434{};

◆ Translate()

virtual void KIGFX::GAL::Translate ( const VECTOR2D aTranslation)
inlinevirtual

Translate the context.

Parameters
aTranslationis the translation vector.

Reimplemented in KIGFX::CAIRO_GAL_BASE, and KIGFX::OPENGL_GAL.

Definition at line 448 of file graphics_abstraction_layer.h.

448{};

Referenced by KIGFX::PCB_PAINTER::draw(), and DS_PROXY_VIEW_ITEM::ViewDraw().

◆ UnlockContext()

virtual void KIGFX::GAL::UnlockContext ( int  aClientCookie)
inlinevirtual

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 945 of file graphics_abstraction_layer.h.

945{}

Referenced by KIGFX::GAL_CONTEXT_LOCKER::~GAL_CONTEXT_LOCKER().

◆ updatedGalDisplayOptions()

bool GAL::updatedGalDisplayOptions ( const GAL_DISPLAY_OPTIONS aOptions)
protectedvirtual

Handle updating display options.

Derived classes should call up to this to set base-class methods.

Returns
true if the new settings changed something. Derived classes can use this information to refresh themselves

Reimplemented in KIGFX::CAIRO_GAL, and KIGFX::OPENGL_GAL.

Definition at line 108 of file graphics_abstraction_layer.cpp.

109{
110 bool refresh = false;
111
113 {
115 refresh = true;
116 }
117
119 {
120 m_gridLineWidth = std::floor( m_options.m_gridLineWidth + 0.5 );
121 refresh = true;
122 }
123
125 {
127 refresh = true;
128 }
129
131 {
133 refresh = true;
134 }
135
137 {
139 refresh = true;
140 }
141
143 {
145 refresh = true;
146 }
147
148 // tell the derived class if the base class needs an update or not
149 return refresh;
150}
double m_gridLineWidth
Minimum pixel distance between displayed grid lines.
double m_gridMinSpacing
Whether or not to draw the coordinate system axes.
bool m_forceDisplayCursor
The pixel scale factor (>1 for hi-DPI scaled displays)
KIGFX::GRID_STYLE m_gridStyle
Snapping options for the grid.
bool m_axesEnabled
Fullscreen crosshair or small cross.
bool m_fullscreenCursor
Force cursor display.

References KIGFX::GAL_DISPLAY_OPTIONS::m_axesEnabled, m_axesEnabled, KIGFX::GAL_DISPLAY_OPTIONS::m_forceDisplayCursor, m_forceDisplayCursor, KIGFX::GAL_DISPLAY_OPTIONS::m_fullscreenCursor, m_fullscreenCursor, KIGFX::GAL_DISPLAY_OPTIONS::m_gridLineWidth, m_gridLineWidth, KIGFX::GAL_DISPLAY_OPTIONS::m_gridMinSpacing, m_gridMinSpacing, KIGFX::GAL_DISPLAY_OPTIONS::m_gridStyle, m_gridStyle, m_options, and refresh.

Referenced by OnGalDisplayOptionsChanged(), KIGFX::CAIRO_GAL::updatedGalDisplayOptions(), and KIGFX::OPENGL_GAL::updatedGalDisplayOptions().

Friends And Related Function Documentation

◆ GAL_CONTEXT_LOCKER

friend class GAL_CONTEXT_LOCKER
friend

Definition at line 64 of file graphics_abstraction_layer.h.

◆ GAL_DRAWING_CONTEXT

friend class GAL_DRAWING_CONTEXT
friend

Definition at line 66 of file graphics_abstraction_layer.h.

◆ GAL_UPDATE_CONTEXT

friend class GAL_UPDATE_CONTEXT
friend

Definition at line 65 of file graphics_abstraction_layer.h.

Member Data Documentation

◆ GRID_DEPTH

const int GAL::GRID_DEPTH = MAX_DEPTH - 1
staticprotected

Depth level on which the grid is drawn.

Definition at line 988 of file graphics_abstraction_layer.h.

◆ m_attributes

◆ m_axesColor

COLOR4D KIGFX::GAL::m_axesColor
protected

Color of the axes.

Definition at line 1051 of file graphics_abstraction_layer.h.

Referenced by KIGFX::CAIRO_GAL_BASE::drawAxes(), KIGFX::OPENGL_GAL::DrawGrid(), and SetAxesColor().

◆ m_axesEnabled

bool KIGFX::GAL::m_axesEnabled
protected

◆ m_clearColor

◆ m_currentNativeCursor

KICURSOR KIGFX::GAL::m_currentNativeCursor
protected

◆ m_cursorColor

COLOR4D KIGFX::GAL::m_cursorColor
protected

Cursor color.

Definition at line 1061 of file graphics_abstraction_layer.h.

Referenced by getCursorColor(), and SetCursorColor().

◆ m_cursorPosition

VECTOR2D KIGFX::GAL::m_cursorPosition
protected

◆ m_depthRange

VECTOR2D KIGFX::GAL::m_depthRange
protected

◆ m_depthStack

std::stack<double> KIGFX::GAL::m_depthStack
protected

Stored depth values.

Definition at line 1016 of file graphics_abstraction_layer.h.

Referenced by PopDepth(), and PushDepth().

◆ m_fillColor

◆ m_forceDisplayCursor

bool KIGFX::GAL::m_forceDisplayCursor
protected

Always show cursor.

Definition at line 1060 of file graphics_abstraction_layer.h.

Referenced by GAL(), IsCursorEnabled(), and updatedGalDisplayOptions().

◆ m_fullscreenCursor

bool KIGFX::GAL::m_fullscreenCursor
protected

Shape of the cursor (fullscreen or small cross)

Definition at line 1062 of file graphics_abstraction_layer.h.

Referenced by KIGFX::OPENGL_GAL::blitCursor(), KIGFX::CAIRO_GAL_BASE::blitCursor(), GAL(), and updatedGalDisplayOptions().

◆ m_globalFlipX

bool KIGFX::GAL::m_globalFlipX
protected

◆ m_globalFlipY

bool KIGFX::GAL::m_globalFlipY
protected

◆ m_gridColor

◆ m_gridLineWidth

float KIGFX::GAL::m_gridLineWidth
protected

◆ m_gridMinSpacing

int KIGFX::GAL::m_gridMinSpacing
protected

Minimum screen size of the grid (pixels) below which the grid is not drawn.

Definition at line 1055 of file graphics_abstraction_layer.h.

Referenced by computeMinGridSpacing(), GAL(), and updatedGalDisplayOptions().

◆ m_gridOffset

VECTOR2D KIGFX::GAL::m_gridOffset
protected

The grid offset to compensate cursor position.

Definition at line 1049 of file graphics_abstraction_layer.h.

Referenced by GetGridPoint(), SetGridOrigin(), and SetGridSize().

◆ m_gridOrigin

VECTOR2D KIGFX::GAL::m_gridOrigin
protected

◆ m_gridSize

VECTOR2D KIGFX::GAL::m_gridSize
protected

◆ m_gridStyle

GRID_STYLE KIGFX::GAL::m_gridStyle
protected

◆ m_gridTick

int KIGFX::GAL::m_gridTick
protected

Every tick line gets the double width.

Definition at line 1053 of file graphics_abstraction_layer.h.

Referenced by KIGFX::CAIRO_GAL_BASE::DrawGrid(), KIGFX::OPENGL_GAL::DrawGrid(), and SetCoarseGrid().

◆ m_gridVisibility

bool KIGFX::GAL::m_gridVisibility
protected

◆ m_isCursorEnabled

bool KIGFX::GAL::m_isCursorEnabled
protected

Is the cursor enabled?

Definition at line 1059 of file graphics_abstraction_layer.h.

Referenced by getCursorColor(), IsCursorEnabled(), and SetCursorEnabled().

◆ m_isFillEnabled

◆ m_isStrokeEnabled

◆ m_layerDepth

◆ m_lineWidth

◆ m_lookAtPoint

VECTOR2D KIGFX::GAL::m_lookAtPoint
protected

◆ m_observerLink

UTIL::LINK KIGFX::GAL::m_observerLink
protected

Definition at line 1014 of file graphics_abstraction_layer.h.

Referenced by GAL().

◆ m_options

◆ m_rotation

double KIGFX::GAL::m_rotation
protected

Rotation transformation (radians)

Definition at line 1024 of file graphics_abstraction_layer.h.

Referenced by ComputeWorldScreenMatrix(), GetRotation(), and SetRotation().

◆ m_screenDPI

double KIGFX::GAL::m_screenDPI
protected

◆ m_screenSize

◆ m_screenWorldMatrix

◆ m_strokeColor

◆ m_worldScale

◆ m_worldScreenMatrix

◆ m_worldUnitLength

double KIGFX::GAL::m_worldUnitLength
protected

◆ m_zoomFactor

double KIGFX::GAL::m_zoomFactor
protected

◆ MAX_DEPTH

const int GAL::MAX_DEPTH = 1023
staticprotected

Definition at line 985 of file graphics_abstraction_layer.h.

Referenced by GAL().

◆ MIN_DEPTH

const int GAL::MIN_DEPTH = -1024
staticprotected

Possible depth range.

Definition at line 984 of file graphics_abstraction_layer.h.

Referenced by GAL().


The documentation for this class was generated from the following files: