KiCad PCB EDA Suite
KIGFX::CAIRO_GAL_BASE Class Reference

#include <cairo_gal.h>

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

Classes

struct  GROUP_ELEMENT
 Type definition for an graphics group element. More...
 

Public Member Functions

 CAIRO_GAL_BASE (GAL_DISPLAY_OPTIONS &aDisplayOptions)
 
 ~CAIRO_GAL_BASE ()
 
bool IsCairoEngine () override
 Return true if the GAL engine is a Cairo based type. More...
 
void DrawLine (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint) override
 Draw a line. More...
 
void DrawSegment (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth) override
 Draw a rounded segment. More...
 
void DrawCircle (const VECTOR2D &aCenterPoint, double aRadius) override
 Draw a circle using world coordinates. More...
 
void DrawArc (const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle) override
 Draw an arc. More...
 
void DrawArcSegment (const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth) override
 Draw an arc segment. More...
 
void DrawRectangle (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint) override
 Draw a rectangle. More...
 
void DrawPolyline (const std::deque< VECTOR2D > &aPointList) override
 Draw a polyline. More...
 
void DrawPolyline (const VECTOR2D aPointList[], int aListSize) override
 
void DrawPolyline (const SHAPE_LINE_CHAIN &aLineChain) override
 
void DrawPolygon (const std::deque< VECTOR2D > &aPointList) override
 Draw a polygon. More...
 
void DrawPolygon (const VECTOR2D aPointList[], int aListSize) override
 
void DrawPolygon (const SHAPE_POLY_SET &aPolySet, bool aStrokeTriangulation=false) override
 
void DrawPolygon (const SHAPE_LINE_CHAIN &aPolySet) override
 
void DrawCurve (const VECTOR2D &startPoint, const VECTOR2D &controlPointA, const VECTOR2D &controlPointB, const VECTOR2D &endPoint, double aFilterValue=0.0) override
 Draw a cubic bezier spline. More...
 
void DrawBitmap (const BITMAP_BASE &aBitmap) override
 Draw a bitmap image. More...
 
void ResizeScreen (int aWidth, int aHeight) override
 Resizes the canvas. More...
 
void Flush () override
 Force all remaining objects to be drawn. More...
 
void ClearScreen () override
 Clear the screen. More...
 
void SetIsFill (bool aIsFillEnabled) override
 Enable/disable fill. More...
 
void SetIsStroke (bool aIsStrokeEnabled) override
 Enable/disable stroked outlines. More...
 
void SetStrokeColor (const COLOR4D &aColor) override
 Set the stroke color. More...
 
void SetFillColor (const COLOR4D &aColor) override
 Set the fill color. More...
 
void SetLineWidth (float aLineWidth) override
 Set the line width. More...
 
void SetLayerDepth (double aLayerDepth) override
 Set the depth of the layer (position on the z-axis) More...
 
void Transform (const MATRIX3x3D &aTransformation) override
 Transform the context. More...
 
void Rotate (double aAngle) override
 Rotate the context. More...
 
void Translate (const VECTOR2D &aTranslation) override
 Translate the context. More...
 
void Scale (const VECTOR2D &aScale) override
 Scale the context. More...
 
void Save () override
 Save the context. More...
 
void Restore () override
 Restore the context. More...
 
int BeginGroup () override
 Begin a group. More...
 
void EndGroup () override
 End the group. More...
 
void DrawGroup (int aGroupNumber) override
 Draw the stored group. More...
 
void ChangeGroupColor (int aGroupNumber, const COLOR4D &aNewColor) override
 Change the color used to draw the group. More...
 
void ChangeGroupDepth (int aGroupNumber, int aDepth) override
 Change the depth (Z-axis position) of the group. More...
 
void DeleteGroup (int aGroupNumber) override
 Delete the group from the memory. More...
 
void ClearCache () override
 Delete all data created during caching of graphic items. More...
 
void SetNegativeDrawMode (bool aSetting) override
 Set negative draw mode in the renderer. More...
 
void DrawCursor (const VECTOR2D &aCursorPosition) override
 Draw the cursor. More...
 
void EnableDepthTest (bool aEnabled=false) override
 
void DrawGrid () override
 
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 IsOpenGlEngine ()
 Return true if the GAL engine is a OpenGL based type. More...
 
virtual bool Show (bool aShow)
 Show/hide the GAL canvas. More...
 
const VECTOR2IGetScreenPixelSize () const
 Return GAL canvas size in pixels. More...
 
void SetClearColor (const COLOR4D &aColor)
 
const COLOR4DGetClearColor () const
 
const COLOR4DGetFillColor () const
 Get the fill color. More...
 
const COLOR4DGetStrokeColor () const
 Get the stroke color. More...
 
float GetLineWidth () const
 Get the line width. More...
 
const STROKE_FONTGetStrokeFont () const
 
virtual void StrokeText (const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
 Draw a vector type text using preloaded Newstroke font. More...
 
virtual void BitmapText (const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
 Draw a text using a bitmap font. More...
 
VECTOR2D GetTextLineSize (const UTF8 &aText) const
 Compute the X and Y size of a given text. More...
 
virtual void SetTextAttributes (const EDA_TEXT *aText)
 Loads attributes of the given text (bold/italic/underline/mirrored and so on). More...
 
void ResetTextAttributes ()
 Reset text attributes to default styling. More...
 
void SetGlyphSize (const VECTOR2D &aSize)
 Set the font glyph size. More...
 
const VECTOR2DGetGlyphSize () const
 
void SetFontBold (bool aBold)
 Set bold property of current font. More...
 
bool IsFontBold () const
 
void SetFontItalic (bool aItalic)
 Set italic property of current font. More...
 
bool IsFontItalic () const
 
void SetFontUnderlined (bool aUnderlined)
 
bool IsFontUnderlined () const
 
void SetTextMirrored (bool aMirrored)
 Set a mirrored property of text. More...
 
bool IsTextMirrored () const
 
void SetHorizontalJustify (const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
 Set the horizontal justify for text drawing. More...
 
EDA_TEXT_HJUSTIFY_T GetHorizontalJustify () const
 Return current text horizontal justification setting. More...
 
void SetVerticalJustify (const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
 Set the vertical justify for text drawing. More...
 
EDA_TEXT_VJUSTIFY_T GetVerticalJustify () const
 Returns current text vertical justification setting. 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)
 Set the Point in world space to look at. More...
 
const VECTOR2DGetLookAtPoint () const
 Get the look at point. More...
 
void SetZoomFactor (double aZoomFactor)
 Set the zoom factor of the scene. More...
 
double GetZoomFactor () const
 Get the zoom factor. More...
 
void SetRotation (double aRotation)
 Set the rotation angle. More...
 
double GetRotation () const
 Get the rotation angle. More...
 
void SetDepthRange (const VECTOR2D &aDepthRange)
 Set the range of the layer depth. More...
 
double GetMinDepth () const
 Return the minimum depth in the currently used range (the top). More...
 
double GetMaxDepth () const
 Return the maximum depth in the currently used range (the bottom). More...
 
double GetWorldScale () const
 Get the world scale. More...
 
void SetFlip (bool xAxis, bool yAxis)
 Sets flipping of the screen. More...
 
bool IsFlippedX () const
 Return true if flip flag for the X axis is set. More...
 
bool IsFlippedY () const
 Return true if flip flag for the Y axis is set. More...
 
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...
 
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...
 
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...
 
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 bool IsContextLocked ()
 Checks the state of the context lock. More...
 

Protected Types

enum  GRAPHICS_COMMAND {
  CMD_SET_FILL, CMD_SET_STROKE, CMD_SET_FILLCOLOR, CMD_SET_STROKECOLOR,
  CMD_SET_LINE_WIDTH, CMD_STROKE_PATH, CMD_FILL_PATH, CMD_ROTATE,
  CMD_TRANSLATE, CMD_SCALE, CMD_SAVE, CMD_RESTORE,
  CMD_CALL_GROUP
}
 Definitions for the command recorder. More...
 
typedef GAL super
 Super class definition. More...
 
typedef std::deque< GROUP_ELEMENTGROUP
 A graphic group type definition. More...
 

Protected Member Functions

const double xform (double x)
 
const VECTOR2D xform (double x, double y)
 
const VECTOR2D xform (const VECTOR2D &aP)
 
const double angle_xform (const double aAngle)
 Transform according to the rotation from m_currentWorld2Screen transform matrix. More...
 
void arc_angles_xform_and_normalize (double &aStartAngle, double &aEndAngle)
 Transform according to the rotation from m_currentWorld2Screen transform matrix for the start angle and the end angle of an arc. More...
 
void beginDrawing () override
 
void endDrawing () override
 
void resetContext ()
 
void drawGridLine (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
 Draw a grid line (usually a simplified line function). More...
 
void drawGridCross (const VECTOR2D &aPoint)
 
void drawGridPoint (const VECTOR2D &aPoint, double aWidth, double aHeight)
 
void drawAxes (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
 
void flushPath ()
 
void storePath ()
 Store the actual path. More...
 
void blitCursor (wxMemoryDC &clientDC)
 Blit cursor into the current screen. More...
 
void drawPoly (const std::deque< VECTOR2D > &aPointList)
 Drawing polygons & polylines is the same in Cairo, so here is the common code. More...
 
void drawPoly (const VECTOR2D aPointList[], int aListSize)
 
void drawPoly (const SHAPE_LINE_CHAIN &aLineChain)
 
unsigned int getNewGroupNumber ()
 Return a valid key that can be used as a new group number. More...
 
void syncLineWidth (bool aForceWidth=false, double aWidth=0.0)
 
void updateWorldScreenMatrix ()
 
const VECTOR2D roundp (const VECTOR2D &v)
 
virtual void lockContext (int aClientCookie)
 Use GAL_CONTEXT_LOCKER RAII object. More...
 
virtual void unlockContext (int aClientCookie)
 
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

bool m_isGrouping
 Is grouping enabled ? More...
 
bool m_isElementAdded
 Was an graphic element added ? More...
 
std::map< int, GROUPm_groups
 List of graphic groups. More...
 
unsigned int m_groupCounter
 Counter used for generating group keys. More...
 
GROUPm_currentGroup
 Currently used group. More...
 
double m_lineWidthInPixels
 
bool m_lineWidthIsOdd
 
cairo_matrix_t m_cairoWorldScreenMatrix
 Cairo world to screen transform matrix. More...
 
cairo_matrix_t m_currentXform
 
cairo_matrix_t m_currentWorld2Screen
 
cairo_t * m_currentContext
 Currently used Cairo context for drawing. More...
 
cairo_t * m_context
 Cairo image. More...
 
cairo_surface_t * m_surface
 Cairo surface. More...
 
std::vector< cairo_surface_t * > m_imageSurfaces
 List of surfaces that were created by painting images, to be cleaned up later. More...
 
std::vector< cairo_matrix_t > m_xformStack
 
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...
 
STROKE_FONT m_strokeFont
 Instance of object that stores information about how to draw texts. More...
 
KICURSOR m_currentNativeCursor
 Current cursor. More...
 

Static Protected Attributes

static const int MAX_CAIRO_ARGUMENTS = 4
 Maximum number of arguments for one command. More...
 
static constexpr cairo_format_t GAL_FORMAT = CAIRO_FORMAT_ARGB32
 Format used to store pixels. More...
 
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...
 

Detailed Description

Definition at line 57 of file cairo_gal.h.

Member Typedef Documentation

◆ GROUP

typedef std::deque<GROUP_ELEMENT> KIGFX::CAIRO_GAL_BASE::GROUP
protected

A graphic group type definition.

Definition at line 324 of file cairo_gal.h.

◆ super

typedef GAL KIGFX::CAIRO_GAL_BASE::super
protected

Super class definition.

Definition at line 288 of file cairo_gal.h.

Member Enumeration Documentation

◆ GRAPHICS_COMMAND

Definitions for the command recorder.

Enumerator
CMD_SET_FILL 

Enable/disable filling.

CMD_SET_STROKE 

Enable/disable stroking.

CMD_SET_FILLCOLOR 

Set the fill color.

CMD_SET_STROKECOLOR 

Set the stroke color.

CMD_SET_LINE_WIDTH 

Set the line width.

CMD_STROKE_PATH 

Set the stroke path.

CMD_FILL_PATH 

Set the fill path.

CMD_ROTATE 

Rotate the context.

CMD_TRANSLATE 

Translate the context.

CMD_SCALE 

Scale the context.

CMD_SAVE 

Save the transformation matrix.

CMD_RESTORE 

Restore the transformation matrix.

CMD_CALL_GROUP 

Call a group.

Definition at line 294 of file cairo_gal.h.

295  {
296  CMD_SET_FILL,
302  CMD_FILL_PATH,
303  //CMD_TRANSFORM, ///< Transform the actual context
304  CMD_ROTATE,
305  CMD_TRANSLATE,
306  CMD_SCALE,
307  CMD_SAVE,
308  CMD_RESTORE,
310  };
Enable/disable filling.
Definition: cairo_gal.h:296
Save the transformation matrix.
Definition: cairo_gal.h:307
Translate the context.
Definition: cairo_gal.h:305
Enable/disable stroking.
Definition: cairo_gal.h:297
Restore the transformation matrix.
Definition: cairo_gal.h:308

Constructor & Destructor Documentation

◆ CAIRO_GAL_BASE()

CAIRO_GAL_BASE::CAIRO_GAL_BASE ( GAL_DISPLAY_OPTIONS aDisplayOptions)

Definition at line 49 of file cairo_gal.cpp.

49  : GAL( aDisplayOptions )
50 {
51  // Initialise grouping
52  m_isGrouping = false;
53  m_isElementAdded = false;
54  m_groupCounter = 0;
55  m_currentGroup = nullptr;
56 
57  m_lineWidth = 1.0;
58  m_lineWidthInPixels = 1.0;
59  m_lineWidthIsOdd = true;
60 
61  // Initialise Cairo state
62  cairo_matrix_init_identity( &m_cairoWorldScreenMatrix );
63  m_currentContext = nullptr;
64  m_context = nullptr;
65  m_surface = nullptr;
66 
67  // Grid color settings are different in Cairo and OpenGL
68  SetGridColor( COLOR4D( 0.1, 0.1, 0.1, 0.8 ) );
70 
71  // Avoid uninitialized variables:
72  cairo_matrix_init_identity( &m_currentXform );
73  cairo_matrix_init_identity( &m_currentWorld2Screen );
74 }
double m_lineWidthInPixels
Definition: cairo_gal.h:333
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:331
cairo_matrix_t m_cairoWorldScreenMatrix
Cairo world to screen transform matrix.
Definition: cairo_gal.h:336
unsigned int m_groupCounter
Counter used for generating group keys.
Definition: cairo_gal.h:330
GAL(GAL_DISPLAY_OPTIONS &aOptions)
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:328
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
cairo_t * m_context
Cairo image.
Definition: cairo_gal.h:340
cairo_matrix_t m_currentWorld2Screen
Definition: cairo_gal.h:338
cairo_matrix_t m_currentXform
Definition: cairo_gal.h:337
Definition: color4d.h:56
float m_lineWidth
The line width.
cairo_surface_t * m_surface
Cairo surface.
Definition: cairo_gal.h:341
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:327
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References BLUE, m_cairoWorldScreenMatrix, m_context, m_currentContext, m_currentGroup, m_currentWorld2Screen, m_currentXform, m_groupCounter, m_isElementAdded, m_isGrouping, KIGFX::GAL::m_lineWidth, m_lineWidthInPixels, m_lineWidthIsOdd, m_surface, KIGFX::GAL::SetAxesColor(), and KIGFX::GAL::SetGridColor().

◆ ~CAIRO_GAL_BASE()

CAIRO_GAL_BASE::~CAIRO_GAL_BASE ( )

Definition at line 77 of file cairo_gal.cpp.

78 {
79  ClearCache();
80 
81  if( m_surface )
82  cairo_surface_destroy( m_surface );
83 
84  if( m_context )
85  cairo_destroy( m_context );
86 
87  for( _cairo_surface* imageSurface : m_imageSurfaces )
88  cairo_surface_destroy( imageSurface );
89 }
void ClearCache() override
Delete all data created during caching of graphic items.
Definition: cairo_gal.cpp:915
cairo_t * m_context
Cairo image.
Definition: cairo_gal.h:340
cairo_surface_t * m_surface
Cairo surface.
Definition: cairo_gal.h:341
std::vector< cairo_surface_t * > m_imageSurfaces
List of surfaces that were created by painting images, to be cleaned up later.
Definition: cairo_gal.h:344

References ClearCache(), m_context, m_imageSurfaces, and m_surface.

Member Function Documentation

◆ AdvanceDepth()

void KIGFX::GAL::AdvanceDepth ( )
inlineinherited

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

Definition at line 1022 of file graphics_abstraction_layer.h.

1023  {
1024  m_layerDepth -= 0.05;
1025  }
double m_layerDepth
The actual layer depth.

References KIGFX::GAL::m_layerDepth.

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

◆ angle_xform()

const double CAIRO_GAL_BASE::angle_xform ( const double  aAngle)
protected

Transform according to the rotation from m_currentWorld2Screen transform matrix.

Parameters
aAngleis the angle in radians to transform.
Returns
the modified angle.

Definition at line 127 of file cairo_gal.cpp.

128 {
129  // calculate rotation angle due to the rotation transform
130  // and if flipped on X axis.
131  double world_rotation = -std::atan2( m_currentWorld2Screen.xy, m_currentWorld2Screen.xx );
132 
133  // When flipped on X axis, the rotation angle is M_PI - initial angle:
134  if( IsFlippedX() )
135  world_rotation = M_PI - world_rotation;
136 
137  return std::fmod( aAngle + world_rotation, 2.0 * M_PI );
138 }
bool IsFlippedX() const
Return true if flip flag for the X axis is set.
cairo_matrix_t m_currentWorld2Screen
Definition: cairo_gal.h:338

References KIGFX::GAL::IsFlippedX(), and m_currentWorld2Screen.

Referenced by arc_angles_xform_and_normalize().

◆ arc_angles_xform_and_normalize()

void CAIRO_GAL_BASE::arc_angles_xform_and_normalize ( double &  aStartAngle,
double &  aEndAngle 
)
protected

Transform according to the rotation from m_currentWorld2Screen transform matrix for the start angle and the end angle of an arc.

Parameters
aStartAngleis the arc starting point in radians to transform
aEndAngleis the arc ending point in radians to transform

Definition at line 141 of file cairo_gal.cpp.

142 {
143  double startAngle = aStartAngle;
144  double endAngle = aEndAngle;
145 
146  // When the view is flipped, the coordinates are flipped by the matrix transform
147  // However, arc angles need to be "flipped": the flipped angle is M_PI - initial angle.
148  if( IsFlippedX() )
149  {
150  startAngle = M_PI - startAngle;
151  endAngle = M_PI - endAngle;
152  }
153 
154  // Normalize arc angles
155  SWAP( startAngle, >, endAngle );
156 
157  // now rotate arc according to the rotation transform matrix
158  // Remark:
159  // We call angle_xform() to calculate angles according to the flip/rotation
160  // transform and normalize between -2M_PI and +2M_PI.
161  // Therefore, if aStartAngle = aEndAngle + 2*n*M_PI, the transform gives
162  // aEndAngle = aStartAngle
163  // So, if this is the case, force the aEndAngle value to draw a circle.
164  aStartAngle = angle_xform( startAngle );
165 
166  if( std::abs( aEndAngle - aStartAngle ) >= 2 * M_PI ) // arc is a full circle
167  aEndAngle = aStartAngle + 2 * M_PI;
168  else
169  aEndAngle = angle_xform( endAngle );
170 }
bool IsFlippedX() const
Return true if flip flag for the X axis is set.
const double angle_xform(const double aAngle)
Transform according to the rotation from m_currentWorld2Screen transform matrix.
Definition: cairo_gal.cpp:127
#define SWAP(varA, condition, varB)
Swap the variables if a condition is met.
Definition: definitions.h:31

References angle_xform(), KIGFX::GAL::IsFlippedX(), and SWAP.

Referenced by DrawArc(), and DrawArcSegment().

◆ beginDrawing()

void CAIRO_GAL_BASE::beginDrawing ( )
overrideprotectedvirtual

Reimplemented from KIGFX::GAL.

Reimplemented in KIGFX::CAIRO_GAL.

Definition at line 92 of file cairo_gal.cpp.

93 {
94  resetContext();
95 }

References resetContext().

Referenced by KIGFX::CAIRO_GAL::beginDrawing().

◆ BeginGroup()

int CAIRO_GAL_BASE::BeginGroup ( )
overridevirtual

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 from KIGFX::GAL.

Reimplemented in KIGFX::CAIRO_GAL.

Definition at line 757 of file cairo_gal.cpp.

758 {
759  // If the grouping is started: the actual path is stored in the group, when
760  // a attribute was changed or when grouping stops with the end group method.
761  storePath();
762 
763  GROUP group;
764  int groupNumber = getNewGroupNumber();
765  m_groups.insert( std::make_pair( groupNumber, group ) );
766  m_currentGroup = &m_groups[groupNumber];
767  m_isGrouping = true;
768 
769  return groupNumber;
770 }
std::map< int, GROUP > m_groups
List of graphic groups.
Definition: cairo_gal.h:329
std::deque< GROUP_ELEMENT > GROUP
A graphic group type definition.
Definition: cairo_gal.h:324
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1062
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:331
unsigned int getNewGroupNumber()
Return a valid key that can be used as a new group number.
Definition: cairo_gal.cpp:1204
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:327

References getNewGroupNumber(), group, m_currentGroup, m_groups, m_isGrouping, and storePath().

Referenced by KIGFX::CAIRO_GAL::BeginGroup().

◆ beginUpdate()

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

Enable item update mode.

Private: use GAL_UPDATE_CONTEXT RAII object

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1063 of file graphics_abstraction_layer.h.

1063 {}

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

◆ BitmapText()

virtual void KIGFX::GAL::BitmapText ( const wxString &  aText,
const VECTOR2D aPosition,
double  aRotationAngle 
)
inlinevirtualinherited

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.
aRotationAngleis the text rotation angle.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 359 of file graphics_abstraction_layer.h.

361  {
362  // Fallback: use stroke font
363 
364  // Handle flipped view
365  if( m_globalFlipX )
367 
368  // Bitmap font is slightly smaller and slightly heavier than the stroke font so we
369  // compensate a bit before stroking
370  float saveLineWidth = m_lineWidth;
371  VECTOR2D saveGlyphSize = textProperties.m_glyphSize;
372  {
373  m_lineWidth *= 1.2f;
375 
376  StrokeText( aText, aPosition, aRotationAngle );
377  }
378  m_lineWidth = saveLineWidth;
379  textProperties.m_glyphSize = saveGlyphSize;
380 
381  if( m_globalFlipX )
383  }
bool m_globalFlipX
Flag for X axis flipping.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draw a vector type text using preloaded Newstroke font.
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
VECTOR2D m_glyphSize
Size of the glyphs.
float m_lineWidth
The line width.

References KIGFX::GAL::m_globalFlipX, KIGFX::GAL::TEXT_PROPERTIES::m_glyphSize, KIGFX::GAL::m_lineWidth, KIGFX::GAL::TEXT_PROPERTIES::m_mirrored, KIGFX::GAL::StrokeText(), and KIGFX::GAL::textProperties.

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

◆ blitCursor()

void CAIRO_GAL_BASE::blitCursor ( wxMemoryDC &  clientDC)
protected

Blit cursor into the current screen.

Definition at line 1111 of file cairo_gal.cpp.

1112 {
1113  if( !IsCursorEnabled() )
1114  return;
1115 
1117  const COLOR4D cColor = getCursorColor();
1118  const int cursorSize = m_fullscreenCursor ? 8000 : 80;
1119 
1120  wxColour color( cColor.r * cColor.a * 255, cColor.g * cColor.a * 255, cColor.b * cColor.a * 255,
1121  255 );
1122  clientDC.SetPen( wxPen( color ) );
1123  clientDC.DrawLine( p.x - cursorSize / 2, p.y, p.x + cursorSize / 2, p.y );
1124  clientDC.DrawLine( p.x, p.y - cursorSize / 2, p.x, p.y + cursorSize / 2 );
1125 }
VECTOR2D ToScreen(const VECTOR2D &aPoint) const
Compute the point position in screen coordinates from given world coordinates.
int color
Definition: DXF_plotter.cpp:60
double g
Green component.
Definition: color4d.h:364
double b
Blue component.
Definition: color4d.h:365
VECTOR2D m_cursorPosition
Current cursor position (world coordinates)
double a
Alpha component.
Definition: color4d.h:366
COLOR4D getCursorColor() const
Get the actual cursor color to draw.
bool m_fullscreenCursor
Shape of the cursor (fullscreen or small cross)
double r
Red component.
Definition: color4d.h:363
bool IsCursorEnabled() const
Return information about cursor visibility.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, color, KIGFX::COLOR4D::g, KIGFX::GAL::getCursorColor(), KIGFX::GAL::IsCursorEnabled(), KIGFX::GAL::m_cursorPosition, KIGFX::GAL::m_fullscreenCursor, KIGFX::COLOR4D::r, KIGFX::GAL::ToScreen(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by KIGFX::CAIRO_GAL::endDrawing().

◆ ChangeGroupColor()

void CAIRO_GAL_BASE::ChangeGroupColor ( int  aGroupNumber,
const COLOR4D aNewColor 
)
overridevirtual

Change the color used to draw the group.

Parameters
aGroupNumberis the group number.
aNewColoris the new color.

Reimplemented from KIGFX::GAL.

Definition at line 873 of file cairo_gal.cpp.

874 {
875  storePath();
876 
877  for( auto it = m_groups[aGroupNumber].begin(); it != m_groups[aGroupNumber].end(); ++it )
878  {
879  if( it->m_Command == CMD_SET_FILLCOLOR || it->m_Command == CMD_SET_STROKECOLOR )
880  {
881  it->m_Argument.DblArg[0] = aNewColor.r;
882  it->m_Argument.DblArg[1] = aNewColor.g;
883  it->m_Argument.DblArg[2] = aNewColor.b;
884  it->m_Argument.DblArg[3] = aNewColor.a;
885  }
886  }
887 }
std::map< int, GROUP > m_groups
List of graphic groups.
Definition: cairo_gal.h:329
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1062
double g
Green component.
Definition: color4d.h:364
double b
Blue component.
Definition: color4d.h:365
double a
Alpha component.
Definition: color4d.h:366
double r
Red component.
Definition: color4d.h:363

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, CMD_SET_FILLCOLOR, CMD_SET_STROKECOLOR, KIGFX::COLOR4D::g, m_groups, KIGFX::COLOR4D::r, and storePath().

◆ ChangeGroupDepth()

void CAIRO_GAL_BASE::ChangeGroupDepth ( int  aGroupNumber,
int  aDepth 
)
overridevirtual

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

Parameters
aGroupNumberis the group number.
aDepthis the new depth.

Reimplemented from KIGFX::GAL.

Definition at line 890 of file cairo_gal.cpp.

891 {
892  // Cairo does not have any possibilities to change the depth coordinate of stored items,
893  // it depends only on the order of drawing
894 }

◆ ClearCache()

void CAIRO_GAL_BASE::ClearCache ( )
overridevirtual

Delete all data created during caching of graphic items.

Reimplemented from KIGFX::GAL.

Definition at line 915 of file cairo_gal.cpp.

916 {
917  for( auto it = m_groups.begin(); it != m_groups.end(); )
918  DeleteGroup( ( it++ )->first );
919 }
std::map< int, GROUP > m_groups
List of graphic groups.
Definition: cairo_gal.h:329
void DeleteGroup(int aGroupNumber) override
Delete the group from the memory.
Definition: cairo_gal.cpp:897

References DeleteGroup(), and m_groups.

Referenced by ~CAIRO_GAL_BASE().

◆ ClearScreen()

void CAIRO_GAL_BASE::ClearScreen ( )
overridevirtual

Clear the screen.

Parameters
aColoris the color used for clearing.

Reimplemented from KIGFX::GAL.

Definition at line 543 of file cairo_gal.cpp.

544 {
545  cairo_set_source_rgb( m_currentContext, m_clearColor.r, m_clearColor.g, m_clearColor.b );
546  cairo_rectangle( m_currentContext, 0.0, 0.0, m_screenSize.x, m_screenSize.y );
547  cairo_fill( m_currentContext );
548 }
double g
Green component.
Definition: color4d.h:364
double b
Blue component.
Definition: color4d.h:365
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
double r
Red component.
Definition: color4d.h:363
VECTOR2I m_screenSize
Screen size in screen coordinates.

References KIGFX::COLOR4D::b, KIGFX::COLOR4D::g, KIGFX::GAL::m_clearColor, m_currentContext, KIGFX::GAL::m_screenSize, KIGFX::COLOR4D::r, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by resetContext().

◆ ClearTarget()

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

Clear the target for rendering.

Parameters
aTargetis the target to be cleared.

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

Definition at line 796 of file graphics_abstraction_layer.h.

796 {};

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

◆ computeMinGridSpacing()

double GAL::computeMinGridSpacing ( ) const
protectedinherited

compute minimum grid spacing from the grid settings

Returns
the minimum spacing to use for drawing the grid

Definition at line 237 of file graphics_abstraction_layer.cpp.

238 {
239  // just return the current value. This could be cleverer and take
240  // into account other settings in future
241  return m_gridMinSpacing;
242 }
int m_gridMinSpacing
Minimum screen size of the grid (pixels) below which the grid is not drawn.

References KIGFX::GAL::m_gridMinSpacing.

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

◆ computeWorldScale()

void KIGFX::GAL::computeWorldScale ( )
inlineprotectedinherited

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

Definition at line 1077 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_screenDPI, KIGFX::GAL::m_worldScale, KIGFX::GAL::m_worldUnitLength, and KIGFX::GAL::m_zoomFactor.

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

◆ ComputeWorldScreenMatrix()

void GAL::ComputeWorldScreenMatrix ( )
virtualinherited

Compute the world <-> screen transformation matrix.

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

Definition at line 192 of file graphics_abstraction_layer.cpp.

193 {
195 
196  MATRIX3x3D translation;
197  translation.SetIdentity();
198  // We're deliberately dividing integers to avoid fractional pixel offsets.
199  translation.SetTranslation( VECTOR2D( m_screenSize.x/2, m_screenSize.y/2 ) );
200 
201  MATRIX3x3D rotate;
202  rotate.SetIdentity();
203  rotate.SetRotation( m_rotation );
204 
206  scale.SetIdentity();
207  scale.SetScale( VECTOR2D( m_worldScale, m_worldScale ) );
208 
209  MATRIX3x3D flip;
210  flip.SetIdentity();
211  flip.SetScale( VECTOR2D( m_globalFlipX ? -1.0 : 1.0, m_globalFlipY ? -1.0 : 1.0 ) );
212 
213  MATRIX3x3D lookat;
214  lookat.SetIdentity();
215  lookat.SetTranslation( -m_lookAtPoint );
216 
217  m_worldScreenMatrix = translation * rotate * flip * scale * lookat;
219 }
void SetRotation(T aAngle)
Set the rotation components of the matrix.
Definition: matrix3x3.h:245
MATRIX3x3D m_screenWorldMatrix
Screen transformation.
MATRIX3x3 Inverse() const
Determine the inverse of the matrix.
Definition: matrix3x3.h:339
VECTOR2D m_lookAtPoint
Point to be looked at in world space.
void SetIdentity()
Set the matrix to the identity matrix.
Definition: matrix3x3.h:210
MATRIX3x3D m_worldScreenMatrix
World transformation.
double m_worldScale
The scale factor world->screen.
bool m_globalFlipX
Flag for X axis flipping.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
void computeWorldScale()
Compute the scaling factor for the world->screen matrix.
double m_rotation
Rotation transformation (radians)
const int scale
void SetScale(VECTOR2< T > aScale)
Set the scale components of the matrix.
Definition: matrix3x3.h:257
bool m_globalFlipY
Flag for Y axis flipping.
void SetTranslation(VECTOR2< T > aTranslation)
Set the translation components of the matrix.
Definition: matrix3x3.h:226
VECTOR2I m_screenSize
Screen size in screen coordinates.

References KIGFX::GAL::computeWorldScale(), MATRIX3x3< T >::Inverse(), KIGFX::GAL::m_globalFlipX, KIGFX::GAL::m_globalFlipY, KIGFX::GAL::m_lookAtPoint, KIGFX::GAL::m_rotation, KIGFX::GAL::m_screenSize, KIGFX::GAL::m_screenWorldMatrix, KIGFX::GAL::m_worldScale, KIGFX::GAL::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(), resetContext(), KIGFX::VIEW::SetCenter(), and KIGFX::VIEW::SetScale().

◆ DeleteGroup()

void CAIRO_GAL_BASE::DeleteGroup ( int  aGroupNumber)
overridevirtual

Delete the group from the memory.

Parameters
aGroupNumberis the group number.

Reimplemented from KIGFX::GAL.

Definition at line 897 of file cairo_gal.cpp.

898 {
899  storePath();
900 
901  // Delete the Cairo paths
902  std::deque<GROUP_ELEMENT>::iterator it, end;
903 
904  for( it = m_groups[aGroupNumber].begin(), end = m_groups[aGroupNumber].end(); it != end; ++it )
905  {
906  if( it->m_Command == CMD_FILL_PATH || it->m_Command == CMD_STROKE_PATH )
907  cairo_path_destroy( it->m_CairoPath );
908  }
909 
910  // Delete the group
911  m_groups.erase( aGroupNumber );
912 }
std::map< int, GROUP > m_groups
List of graphic groups.
Definition: cairo_gal.h:329
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1062

References CMD_FILL_PATH, CMD_STROKE_PATH, m_groups, and storePath().

Referenced by ClearCache().

◆ DrawArc()

void CAIRO_GAL_BASE::DrawArc ( const VECTOR2D aCenterPoint,
double  aRadius,
double  aStartAngle,
double  aEndAngle 
)
overridevirtual

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 from KIGFX::GAL.

Definition at line 308 of file cairo_gal.cpp.

310 {
311  syncLineWidth();
312 
313  // calculate start and end arc angles according to the rotation transform matrix
314  // and normalize:
315  arc_angles_xform_and_normalize( aStartAngle, aEndAngle );
316 
317  double r = xform( aRadius );
318 
319  // N.B. This is backwards. We set this because we want to adjust the center
320  // point that changes both endpoints. In the worst case, this is twice as far.
321  // We cannot adjust radius or center based on the other because this causes the
322  // whole arc to change position/size
323  m_lineWidthIsOdd = !( static_cast<int>( aRadius ) % 2 );
324 
325  auto mid = roundp( xform( aCenterPoint ) );
326 
327  cairo_set_line_width( m_currentContext, m_lineWidthInPixels );
328  cairo_new_sub_path( m_currentContext );
329 
330  if( m_isFillEnabled )
331  cairo_move_to( m_currentContext, mid.x, mid.y );
332 
333  cairo_arc( m_currentContext, mid.x, mid.y, r, aStartAngle, aEndAngle );
334 
335  if( m_isFillEnabled )
336  cairo_close_path( m_currentContext );
337 
338  flushPath();
339 
340  m_isElementAdded = true;
341 }
bool m_isFillEnabled
Is filling of graphic objects enabled ?
double m_lineWidthInPixels
Definition: cairo_gal.h:333
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:328
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
void arc_angles_xform_and_normalize(double &aStartAngle, double &aEndAngle)
Transform according to the rotation from m_currentWorld2Screen transform matrix for the start angle a...
Definition: cairo_gal.cpp:141
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:210

References arc_angles_xform_and_normalize(), flushPath(), m_currentContext, m_isElementAdded, KIGFX::GAL::m_isFillEnabled, m_lineWidthInPixels, m_lineWidthIsOdd, roundp(), syncLineWidth(), and xform().

Referenced by DrawArcSegment().

◆ DrawArcSegment()

void CAIRO_GAL_BASE::DrawArcSegment ( const VECTOR2D aCenterPoint,
double  aRadius,
double  aStartAngle,
double  aEndAngle,
double  aWidth 
)
overridevirtual

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).

Reimplemented from KIGFX::GAL.

Definition at line 344 of file cairo_gal.cpp.

346 {
347  if( m_isFillEnabled )
348  {
349  m_lineWidth = aWidth;
350  m_isStrokeEnabled = true;
351  m_isFillEnabled = false;
352  DrawArc( aCenterPoint, aRadius, aStartAngle, aEndAngle );
353  m_isFillEnabled = true;
354  m_isStrokeEnabled = false;
355  return;
356  }
357 
358  syncLineWidth();
359 
360  // calculate start and end arc angles according to the rotation transform matrix
361  // and normalize:
362  double startAngleS = aStartAngle;
363  double endAngleS = aEndAngle;
364  arc_angles_xform_and_normalize( startAngleS, endAngleS );
365 
366  double r = xform( aRadius );
367 
368  // N.B. This is backwards. We set this because we want to adjust the center
369  // point that changes both endpoints. In the worst case, this is twice as far.
370  // We cannot adjust radius or center based on the other because this causes the
371  // whole arc to change position/size
372  m_lineWidthIsOdd = !( static_cast<int>( aRadius ) % 2 );
373 
374  VECTOR2D mid = roundp( xform( aCenterPoint ) );
375  double width = xform( aWidth / 2.0 );
376  VECTOR2D startPointS = VECTOR2D( r, 0.0 ).Rotate( startAngleS );
377  VECTOR2D endPointS = VECTOR2D( r, 0.0 ).Rotate( endAngleS );
378 
379  cairo_save( m_currentContext );
380 
381  cairo_set_source_rgba( m_currentContext, m_strokeColor.r, m_strokeColor.g, m_strokeColor.b,
382  m_strokeColor.a );
383 
384  cairo_translate( m_currentContext, mid.x, mid.y );
385 
386  cairo_new_sub_path( m_currentContext );
387  cairo_arc( m_currentContext, 0, 0, r - width, startAngleS, endAngleS );
388 
389  cairo_new_sub_path( m_currentContext );
390  cairo_arc( m_currentContext, 0, 0, r + width, startAngleS, endAngleS );
391 
392  cairo_new_sub_path( m_currentContext );
393  cairo_arc_negative( m_currentContext, startPointS.x, startPointS.y, width, startAngleS,
394  startAngleS + M_PI );
395 
396  cairo_new_sub_path( m_currentContext );
397  cairo_arc( m_currentContext, endPointS.x, endPointS.y, width, endAngleS, endAngleS + M_PI );
398 
399  cairo_restore( m_currentContext );
400  flushPath();
401 
402  m_isElementAdded = true;
403 }
bool m_isFillEnabled
Is filling of graphic objects enabled ?
double g
Green component.
Definition: color4d.h:364
double b
Blue component.
Definition: color4d.h:365
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:328
double a
Alpha component.
Definition: color4d.h:366
bool m_isStrokeEnabled
Are the outlines stroked ?
COLOR4D m_strokeColor
The color of the outlines.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle) override
Draw an arc.
Definition: cairo_gal.cpp:308
VECTOR2< T > Rotate(double aAngle) const
Rotate the vector by a given angle.
Definition: vector2d.h:371
void arc_angles_xform_and_normalize(double &aStartAngle, double &aEndAngle)
Transform according to the rotation from m_currentWorld2Screen transform matrix for the start angle a...
Definition: cairo_gal.cpp:141
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:210
double r
Red component.
Definition: color4d.h:363
float m_lineWidth
The line width.

References KIGFX::COLOR4D::a, arc_angles_xform_and_normalize(), KIGFX::COLOR4D::b, DrawArc(), flushPath(), KIGFX::COLOR4D::g, m_currentContext, m_isElementAdded, KIGFX::GAL::m_isFillEnabled, KIGFX::GAL::m_isStrokeEnabled, KIGFX::GAL::m_lineWidth, m_lineWidthIsOdd, KIGFX::GAL::m_strokeColor, KIGFX::COLOR4D::r, VECTOR2< T >::Rotate(), roundp(), syncLineWidth(), VECTOR2< T >::x, xform(), and VECTOR2< T >::y.

◆ drawAxes()

void CAIRO_GAL_BASE::drawAxes ( const VECTOR2D aStartPoint,
const VECTOR2D aEndPoint 
)
protected

Definition at line 971 of file cairo_gal.cpp.

972 {
973  syncLineWidth();
974 
975  VECTOR2D p0 = roundp( xform( aStartPoint ) );
976  VECTOR2D p1 = roundp( xform( aEndPoint ) );
977  VECTOR2D org = roundp( xform( VECTOR2D( 0.0, 0.0 ) ) ); // Axis origin = 0,0 coord
978 
979  cairo_set_source_rgba( m_currentContext, m_axesColor.r, m_axesColor.g, m_axesColor.b,
980  m_axesColor.a );
981  cairo_move_to( m_currentContext, p0.x, org.y );
982  cairo_line_to( m_currentContext, p1.x, org.y );
983  cairo_move_to( m_currentContext, org.x, p0.y );
984  cairo_line_to( m_currentContext, org.x, p1.y );
985  cairo_stroke( m_currentContext );
986 }
double g
Green component.
Definition: color4d.h:364
double b
Blue component.
Definition: color4d.h:365
double a
Alpha component.
Definition: color4d.h:366
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
COLOR4D m_axesColor
Color of the axes.
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:210
double r
Red component.
Definition: color4d.h:363

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, KIGFX::COLOR4D::g, KIGFX::GAL::m_axesColor, m_currentContext, KIGFX::COLOR4D::r, roundp(), syncLineWidth(), VECTOR2< T >::x, xform(), and VECTOR2< T >::y.

Referenced by DrawGrid().

◆ DrawBitmap()

void CAIRO_GAL_BASE::DrawBitmap ( const BITMAP_BASE aBitmap)
overridevirtual

Draw a bitmap image.

Reimplemented from KIGFX::GAL.

Definition at line 463 of file cairo_gal.cpp.

464 {
465  cairo_save( m_currentContext );
466 
467  // We have to calculate the pixel size in users units to draw the image.
468  // m_worldUnitLength is a factor used for converting IU to inches
469  double scale = 1.0 / ( aBitmap.GetPPI() * m_worldUnitLength );
470 
471  // The position of the bitmap is the bitmap center.
472  // move the draw origin to the top left bitmap corner:
473  int w = aBitmap.GetSizePixels().x;
474  int h = aBitmap.GetSizePixels().y;
475 
476  cairo_set_matrix( m_currentContext, &m_currentWorld2Screen );
477  cairo_scale( m_currentContext, scale, scale );
478  cairo_translate( m_currentContext, -w / 2.0, -h / 2.0 );
479 
480  cairo_new_path( m_currentContext );
481  cairo_surface_t* image = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, w, h );
482  cairo_surface_flush( image );
483 
484  unsigned char* pix_buffer = cairo_image_surface_get_data( image );
485 
486  // The pixel buffer of the initial bitmap:
487  const wxImage& bm_pix_buffer = *aBitmap.GetImageData();
488 
489  uint32_t mask_color = ( bm_pix_buffer.GetMaskRed() << 16 )
490  + ( bm_pix_buffer.GetMaskGreen() << 8 ) + ( bm_pix_buffer.GetMaskBlue() );
491 
492  // Copy the source bitmap to the cairo bitmap buffer.
493  // In cairo bitmap buffer, a ARGB32 bitmap is an ARGB pixel packed into a uint_32
494  // 24 low bits only are used for color, top 8 are transparency.
495  for( int row = 0; row < h; row++ )
496  {
497  for( int col = 0; col < w; col++ )
498  {
499  // Build the RGB24 pixel:
500  uint32_t pixel = bm_pix_buffer.GetRed( col, row ) << 16;
501  pixel += bm_pix_buffer.GetGreen( col, row ) << 8;
502  pixel += bm_pix_buffer.GetBlue( col, row );
503 
504  if( bm_pix_buffer.HasAlpha() )
505  pixel += bm_pix_buffer.GetAlpha( col, row ) << 24;
506  else if( bm_pix_buffer.HasMask() && pixel == mask_color )
507  pixel += ( wxALPHA_TRANSPARENT << 24 );
508  else
509  pixel += ( wxALPHA_OPAQUE << 24 );
510 
511  // Write the pixel to the cairo image buffer:
512  uint32_t* pix_ptr = (uint32_t*) pix_buffer;
513  *pix_ptr = pixel;
514  pix_buffer += 4;
515  }
516  }
517 
518  cairo_surface_mark_dirty( image );
519  cairo_set_source_surface( m_currentContext, image, 0, 0 );
520  cairo_paint( m_currentContext );
521 
522  // store the image handle so it can be destroyed later
523  m_imageSurfaces.push_back( image );
524 
525  m_isElementAdded = true;
526 
527  cairo_restore( m_currentContext );
528 }
wxImage * GetImageData()
Definition: bitmap_base.h:70
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:328
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
cairo_matrix_t m_currentWorld2Screen
Definition: cairo_gal.h:338
const int scale
wxSize GetSizePixels() const
Definition: bitmap_base.h:124
double m_worldUnitLength
The unit length of the world coordinates [inch].
std::vector< cairo_surface_t * > m_imageSurfaces
List of surfaces that were created by painting images, to be cleaned up later.
Definition: cairo_gal.h:344
int GetPPI() const
Definition: bitmap_base.h:135

References BITMAP_BASE::GetImageData(), BITMAP_BASE::GetPPI(), BITMAP_BASE::GetSizePixels(), image, m_currentContext, m_currentWorld2Screen, m_imageSurfaces, m_isElementAdded, KIGFX::GAL::m_worldUnitLength, and scale.

◆ DrawCircle()

void CAIRO_GAL_BASE::DrawCircle ( const VECTOR2D aCenterPoint,
double  aRadius 
)
overridevirtual

Draw a circle using world coordinates.

Parameters
aCenterPointis the center point of the circle.
aRadiusis the radius of the circle.

Reimplemented from KIGFX::GAL.

Definition at line 292 of file cairo_gal.cpp.

293 {
294  syncLineWidth();
295 
296  VECTOR2D c = roundp( xform( aCenterPoint ) );
297  double r = ::roundp( xform( aRadius ) );
298 
299  cairo_set_line_width( m_currentContext, std::min( 2.0 * r, m_lineWidthInPixels ) );
300  cairo_new_sub_path( m_currentContext );
301  cairo_arc( m_currentContext, c.x, c.y, r, 0.0, 2 * M_PI );
302  cairo_close_path( m_currentContext );
303  flushPath();
304  m_isElementAdded = true;
305 }
double m_lineWidthInPixels
Definition: cairo_gal.h:333
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:328
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:210

References flushPath(), m_currentContext, m_isElementAdded, m_lineWidthInPixels, roundp(), syncLineWidth(), VECTOR2< T >::x, xform(), and VECTOR2< T >::y.

◆ DrawCursor()

void CAIRO_GAL_BASE::DrawCursor ( const VECTOR2D aCursorPosition)
overridevirtual

Draw the cursor.

Parameters
aCursorPositionis the cursor position in screen coordinates.

Reimplemented from KIGFX::GAL.

Definition at line 928 of file cairo_gal.cpp.

929 {
930  m_cursorPosition = aCursorPosition;
931 }
VECTOR2D m_cursorPosition
Current cursor position (world coordinates)

References KIGFX::GAL::m_cursorPosition.

◆ DrawCurve()

void CAIRO_GAL_BASE::DrawCurve ( const VECTOR2D startPoint,
const VECTOR2D controlPointA,
const VECTOR2D controlPointB,
const VECTOR2D endPoint,
double  aFilterValue = 0.0 
)
overridevirtual

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 from KIGFX::GAL.

Definition at line 441 of file cairo_gal.cpp.

444 {
445  // Note: aFilterValue is not used because the cubic Bezier curve is
446  // supported by Cairo.
447  syncLineWidth();
448 
449  const VECTOR2D sp = roundp( xform( aStartPoint ) );
450  const VECTOR2D cpa = roundp( xform( aControlPointA ) );
451  const VECTOR2D cpb = roundp( xform( aControlPointB ) );
452  const VECTOR2D ep = roundp( xform( aEndPoint ) );
453 
454  cairo_move_to( m_currentContext, sp.x, sp.y );
455  cairo_curve_to( m_currentContext, cpa.x, cpa.y, cpb.x, cpb.y, ep.x, ep.y );
456  cairo_line_to( m_currentContext, ep.x, ep.y );
457 
458  flushPath();
459  m_isElementAdded = true;
460 }
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:328
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:210

References flushPath(), m_currentContext, m_isElementAdded, roundp(), syncLineWidth(), VECTOR2< T >::x, xform(), and VECTOR2< T >::y.

◆ DrawGrid()

void CAIRO_GAL_BASE::DrawGrid ( )
overridevirtual

Reimplemented from KIGFX::GAL.

Definition at line 1565 of file cairo_gal.cpp.

1566 {
1568 
1569  // Draw the grid
1570  // For the drawing the start points, end points and increments have
1571  // to be calculated in world coordinates
1572  VECTOR2D worldStartPoint = m_screenWorldMatrix * VECTOR2D( 0.0, 0.0 );
1573  VECTOR2D worldEndPoint = m_screenWorldMatrix * VECTOR2D( m_screenSize );
1574 
1575  // Compute the line marker or point radius of the grid
1576  // Note: generic grids can't handle sub-pixel lines without
1577  // either losing fine/course distinction or having some dots
1578  // fail to render
1579  float marker = std::fmax( 1.0f, m_gridLineWidth ) / m_worldScale;
1580  float doubleMarker = 2.0f * marker;
1581 
1582  // Draw axes if desired
1583  if( m_axesEnabled )
1584  {
1585  SetLineWidth( marker );
1586  drawAxes( worldStartPoint, worldEndPoint );
1587  }
1588 
1589  if( !m_gridVisibility || m_gridSize.x == 0 || m_gridSize.y == 0 )
1590  return;
1591 
1592  VECTOR2D gridScreenSize( m_gridSize );
1593 
1594  double gridThreshold = KiROUND( computeMinGridSpacing() / m_worldScale );
1595 
1597  gridThreshold *= 2.0;
1598 
1599  // If we cannot display the grid density, scale down by a tick size and
1600  // try again. Eventually, we get some representation of the grid
1601  while( std::min( gridScreenSize.x, gridScreenSize.y ) <= gridThreshold )
1602  {
1603  gridScreenSize = gridScreenSize * static_cast<double>( m_gridTick );
1604  }
1605 
1606  // Compute grid starting and ending indexes to draw grid points on the
1607  // visible screen area
1608  // Note: later any point coordinate will be offsetted by m_gridOrigin
1609  int gridStartX = KiROUND( ( worldStartPoint.x - m_gridOrigin.x ) / gridScreenSize.x );
1610  int gridEndX = KiROUND( ( worldEndPoint.x - m_gridOrigin.x ) / gridScreenSize.x );
1611  int gridStartY = KiROUND( ( worldStartPoint.y - m_gridOrigin.y ) / gridScreenSize.y );
1612  int gridEndY = KiROUND( ( worldEndPoint.y - m_gridOrigin.y ) / gridScreenSize.y );
1613 
1614  // Ensure start coordinate > end coordinate
1615 
1616  SWAP( gridStartX, >, gridEndX );
1617  SWAP( gridStartY, >, gridEndY );
1618 
1619  // Ensure the grid fills the screen
1620  --gridStartX;
1621  ++gridEndX;
1622  --gridStartY;
1623  ++gridEndY;
1624 
1625  // Draw the grid behind all other layers
1626  SetLayerDepth( m_depthRange.y * 0.75 );
1627 
1629  {
1630  // Now draw the grid, every coarse grid line gets the double width
1631 
1632  // Vertical lines
1633  for( int j = gridStartY; j <= gridEndY; j++ )
1634  {
1635  const double y = j * gridScreenSize.y + m_gridOrigin.y;
1636 
1637  if( m_axesEnabled && y == 0.0 )
1638  continue;
1639 
1640  SetLineWidth( ( j % m_gridTick ) ? marker : doubleMarker );
1641  drawGridLine( VECTOR2D( gridStartX * gridScreenSize.x + m_gridOrigin.x, y ),
1642  VECTOR2D( gridEndX * gridScreenSize.x + m_gridOrigin.x, y ) );
1643  }
1644 
1645  // Horizontal lines
1646  for( int i = gridStartX; i <= gridEndX; i++ )
1647  {
1648  const double x = i * gridScreenSize.x + m_gridOrigin.x;
1649 
1650  if( m_axesEnabled && x == 0.0 )
1651  continue;
1652 
1653  SetLineWidth( ( i % m_gridTick ) ? marker : doubleMarker );
1654  drawGridLine( VECTOR2D( x, gridStartY * gridScreenSize.y + m_gridOrigin.y ),
1655  VECTOR2D( x, gridEndY * gridScreenSize.y + m_gridOrigin.y ) );
1656  }
1657  }
1658  else // Dots or Crosses grid
1659  {
1660  m_lineWidthIsOdd = true;
1661  m_isStrokeEnabled = true;
1662  for( int j = gridStartY; j <= gridEndY; j++ )
1663  {
1664  bool tickY = ( j % m_gridTick == 0 );
1665 
1666  for( int i = gridStartX; i <= gridEndX; i++ )
1667  {
1668  bool tickX = ( i % m_gridTick == 0 );
1669  VECTOR2D pos{ i * gridScreenSize.x + m_gridOrigin.x,
1670  j * gridScreenSize.y + m_gridOrigin.y };
1671 
1673  {
1674  SetLineWidth( ( tickX && tickY ) ? doubleMarker : marker );
1675  drawGridCross( pos );
1676  }
1677  else if( m_gridStyle == GRID_STYLE::DOTS )
1678  {
1679  double doubleGridLineWidth = m_gridLineWidth * 2.0f;
1680  drawGridPoint( pos, ( tickX ) ? doubleGridLineWidth : m_gridLineWidth,
1681  ( tickY ) ? doubleGridLineWidth : m_gridLineWidth );
1682  }
1683  }
1684  }
1685  }
1686 }
Use lines for the grid.
bool m_axesEnabled
Should the axes be drawn.
double computeMinGridSpacing() const
compute minimum grid spacing from the grid settings
MATRIX3x3D m_screenWorldMatrix
Screen transformation.
VECTOR2D m_gridSize
The grid size.
void drawAxes(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Definition: cairo_gal.cpp:971
void SetLayerDepth(double aLayerDepth) override
Set the depth of the layer (position on the z-axis)
Definition: cairo_gal.cpp:636
int m_gridTick
Every tick line gets the double width.
float m_gridLineWidth
Line width of the grid.
Auxiliary rendering target (noncached)
Definition: definitions.h:49
double m_worldScale
The scale factor world->screen.
void drawGridPoint(const VECTOR2D &aPoint, double aWidth, double aHeight)
Definition: cairo_gal.cpp:1024
bool m_isStrokeEnabled
Are the outlines stroked ?
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
bool m_gridVisibility
Should the grid be shown.
Use dots for the grid.
Use small cross instead of dots for the grid.
GRID_STYLE m_gridStyle
Grid display style.
VECTOR2D m_depthRange
Range of the depth.
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:73
#define SWAP(varA, condition, varB)
Swap the variables if a condition is met.
Definition: definitions.h:31
void drawGridLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a grid line (usually a simplified line function).
Definition: cairo_gal.cpp:989
void SetLineWidth(float aLineWidth) override
Set the line width.
Definition: cairo_gal.cpp:617
VECTOR2D m_gridOrigin
The grid origin.
VECTOR2I m_screenSize
Screen size in screen coordinates.
virtual void SetTarget(RENDER_TARGET aTarget)
Set the target for rendering.
void drawGridCross(const VECTOR2D &aPoint)
Definition: cairo_gal.cpp:1003

References KIGFX::GAL::computeMinGridSpacing(), KIGFX::DOTS, drawAxes(), drawGridCross(), drawGridLine(), drawGridPoint(), KiROUND(), KIGFX::LINES, KIGFX::GAL::m_axesEnabled, KIGFX::GAL::m_depthRange, KIGFX::GAL::m_gridLineWidth, KIGFX::GAL::m_gridOrigin, KIGFX::GAL::m_gridSize, KIGFX::GAL::m_gridStyle, KIGFX::GAL::m_gridTick, KIGFX::GAL::m_gridVisibility, KIGFX::GAL::m_isStrokeEnabled, m_lineWidthIsOdd, KIGFX::GAL::m_screenSize, KIGFX::GAL::m_screenWorldMatrix, KIGFX::GAL::m_worldScale, SetLayerDepth(), SetLineWidth(), KIGFX::GAL::SetTarget(), KIGFX::SMALL_CROSS, SWAP, KIGFX::TARGET_NONCACHED, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ drawGridCross()

void CAIRO_GAL_BASE::drawGridCross ( const VECTOR2D aPoint)
protected

Definition at line 1003 of file cairo_gal.cpp.

1004 {
1005  syncLineWidth();
1006  VECTOR2D offset( 0, 0 );
1007  double size = 2.0 * m_lineWidthInPixels + 0.5;
1008 
1009  VECTOR2D p0 = roundp( xform( aPoint ) ) - VECTOR2D( size, 0 ) + offset;
1010  VECTOR2D p1 = roundp( xform( aPoint ) ) + VECTOR2D( size, 0 ) + offset;
1011  VECTOR2D p2 = roundp( xform( aPoint ) ) - VECTOR2D( 0, size ) + offset;
1012  VECTOR2D p3 = roundp( xform( aPoint ) ) + VECTOR2D( 0, size ) + offset;
1013 
1014  cairo_set_source_rgba( m_currentContext, m_gridColor.r, m_gridColor.g, m_gridColor.b,
1015  m_gridColor.a );
1016  cairo_move_to( m_currentContext, p0.x, p0.y );
1017  cairo_line_to( m_currentContext, p1.x, p1.y );
1018  cairo_move_to( m_currentContext, p2.x, p2.y );
1019  cairo_line_to( m_currentContext, p3.x, p3.y );
1020  cairo_stroke( m_currentContext );
1021 }
double m_lineWidthInPixels
Definition: cairo_gal.h:333
double g
Green component.
Definition: color4d.h:364
double b
Blue component.
Definition: color4d.h:365
COLOR4D m_gridColor
Color of the grid.
double a
Alpha component.
Definition: color4d.h:366
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:210
double r
Red component.
Definition: color4d.h:363

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, KIGFX::COLOR4D::g, m_currentContext, KIGFX::GAL::m_gridColor, m_lineWidthInPixels, KIGFX::COLOR4D::r, roundp(), syncLineWidth(), VECTOR2< T >::x, xform(), and VECTOR2< T >::y.

Referenced by DrawGrid().

◆ drawGridLine()

void CAIRO_GAL_BASE::drawGridLine ( const VECTOR2D aStartPoint,
const VECTOR2D aEndPoint 
)
protected

Draw a grid line (usually a simplified line function).

Parameters
aStartPointis the start point of the line.
aEndPointis the end point of the line.

Definition at line 989 of file cairo_gal.cpp.

990 {
991  syncLineWidth();
992  VECTOR2D p0 = roundp( xform( aStartPoint ) );
993  VECTOR2D p1 = roundp( xform( aEndPoint ) );
994 
995  cairo_set_source_rgba( m_currentContext, m_gridColor.r, m_gridColor.g, m_gridColor.b,
996  m_gridColor.a );
997  cairo_move_to( m_currentContext, p0.x, p0.y );
998  cairo_line_to( m_currentContext, p1.x, p1.y );
999  cairo_stroke( m_currentContext );
1000 }
double g
Green component.
Definition: color4d.h:364
double b
Blue component.
Definition: color4d.h:365
COLOR4D m_gridColor
Color of the grid.
double a
Alpha component.
Definition: color4d.h:366
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:210
double r
Red component.
Definition: color4d.h:363

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, KIGFX::COLOR4D::g, m_currentContext, KIGFX::GAL::m_gridColor, KIGFX::COLOR4D::r, roundp(), syncLineWidth(), VECTOR2< T >::x, xform(), and VECTOR2< T >::y.

Referenced by DrawGrid().

◆ drawGridPoint()

void CAIRO_GAL_BASE::drawGridPoint ( const VECTOR2D aPoint,
double  aWidth,
double  aHeight 
)
protected

Definition at line 1024 of file cairo_gal.cpp.

1025 {
1026  VECTOR2D p = roundp( xform( aPoint ) );
1027 
1028  double sw = std::max( 1.0, aWidth );
1029  double sh = std::max( 1.0, aHeight );
1030 
1031  cairo_set_source_rgba( m_currentContext, m_gridColor.r, m_gridColor.g, m_gridColor.b,
1032  m_gridColor.a );
1033  cairo_rectangle( m_currentContext, p.x - std::floor( sw / 2 ) - 0.5,
1034  p.y - std::floor( sh / 2 ) - 0.5, sw, sh );
1035 
1036  cairo_fill( m_currentContext );
1037 }
double g
Green component.
Definition: color4d.h:364
double b
Blue component.
Definition: color4d.h:365
COLOR4D m_gridColor
Color of the grid.
double a
Alpha component.
Definition: color4d.h:366
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
double r
Red component.
Definition: color4d.h:363

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, KIGFX::COLOR4D::g, m_currentContext, KIGFX::GAL::m_gridColor, KIGFX::COLOR4D::r, roundp(), VECTOR2< T >::x, xform(), and VECTOR2< T >::y.

Referenced by DrawGrid().

◆ DrawGroup()

void CAIRO_GAL_BASE::DrawGroup ( int  aGroupNumber)
overridevirtual

Draw the stored group.

Parameters
aGroupNumberis the group number.

Reimplemented from KIGFX::GAL.

Definition at line 780 of file cairo_gal.cpp.

781 {
782  // This method implements a small Virtual Machine - all stored commands
783  // are executed; nested calling is also possible
784 
785  storePath();
786 
787  for( auto it = m_groups[aGroupNumber].begin(); it != m_groups[aGroupNumber].end(); ++it )
788  {
789  switch( it->m_Command )
790  {
791  case CMD_SET_FILL:
792  m_isFillEnabled = it->m_Argument.BoolArg;
793  break;
794 
795  case CMD_SET_STROKE:
796  m_isStrokeEnabled = it->m_Argument.BoolArg;
797  break;
798 
799  case CMD_SET_FILLCOLOR:
800  m_fillColor = COLOR4D( it->m_Argument.DblArg[0], it->m_Argument.DblArg[1],
801  it->m_Argument.DblArg[2], it->m_Argument.DblArg[3] );
802  break;
803 
804  case CMD_SET_STROKECOLOR:
805  m_strokeColor = COLOR4D( it->m_Argument.DblArg[0], it->m_Argument.DblArg[1],
806  it->m_Argument.DblArg[2], it->m_Argument.DblArg[3] );
807  break;
808 
809  case CMD_SET_LINE_WIDTH:
810  {
811  // Make lines appear at least 1 pixel wide, no matter of zoom
812  double x = 1.0, y = 1.0;
813  cairo_device_to_user_distance( m_currentContext, &x, &y );
814  double minWidth = std::min( fabs( x ), fabs( y ) );
815  cairo_set_line_width( m_currentContext,
816  std::max( it->m_Argument.DblArg[0], minWidth ) );
817  break;
818  }
819 
820 
821  case CMD_STROKE_PATH:
822  cairo_set_source_rgba( m_currentContext, m_strokeColor.r, m_strokeColor.g,
824  cairo_append_path( m_currentContext, it->m_CairoPath );
825  cairo_stroke( m_currentContext );
826  break;
827 
828  case CMD_FILL_PATH:
829  cairo_set_source_rgba( m_currentContext, m_fillColor.r, m_fillColor.g, m_fillColor.b,
830  m_strokeColor.a );
831  cairo_append_path( m_currentContext, it->m_CairoPath );
832  cairo_fill( m_currentContext );
833  break;
834 
835  /*
836  case CMD_TRANSFORM:
837  cairo_matrix_t matrix;
838  cairo_matrix_init( &matrix, it->argument.DblArg[0], it->argument.DblArg[1],
839  it->argument.DblArg[2], it->argument.DblArg[3],
840  it->argument.DblArg[4], it->argument.DblArg[5] );
841  cairo_transform( m_currentContext, &matrix );
842  break;
843  */
844 
845  case CMD_ROTATE:
846  cairo_rotate( m_currentContext, it->m_Argument.DblArg[0] );
847  break;
848 
849  case CMD_TRANSLATE:
850  cairo_translate( m_currentContext, it->m_Argument.DblArg[0], it->m_Argument.DblArg[1] );
851  break;
852 
853  case CMD_SCALE:
854  cairo_scale( m_currentContext, it->m_Argument.DblArg[0], it->m_Argument.DblArg[1] );
855  break;
856 
857  case CMD_SAVE:
858  cairo_save( m_currentContext );
859  break;
860 
861  case CMD_RESTORE:
862  cairo_restore( m_currentContext );
863  break;
864 
865  case CMD_CALL_GROUP:
866  DrawGroup( it->m_Argument.IntArg );
867  break;
868  }
869  }
870 }
std::map< int, GROUP > m_groups
List of graphic groups.
Definition: cairo_gal.h:329
bool m_isFillEnabled
Is filling of graphic objects enabled ?
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1062
double g
Green component.
Definition: color4d.h:364
Enable/disable filling.
Definition: cairo_gal.h:296
double b
Blue component.
Definition: color4d.h:365
double a
Alpha component.
Definition: color4d.h:366
bool m_isStrokeEnabled
Are the outlines stroked ?
COLOR4D m_strokeColor
The color of the outlines.
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
Save the transformation matrix.
Definition: cairo_gal.h:307
COLOR4D m_fillColor
The fill color.
Translate the context.
Definition: cairo_gal.h:305
void DrawGroup(int aGroupNumber) override
Draw the stored group.
Definition: cairo_gal.cpp:780
double r
Red component.
Definition: color4d.h:363
Enable/disable stroking.
Definition: cairo_gal.h:297
Restore the transformation matrix.
Definition: cairo_gal.h:308
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, CMD_CALL_GROUP, CMD_FILL_PATH, CMD_RESTORE, CMD_ROTATE, CMD_SAVE, CMD_SCALE, CMD_SET_FILL, CMD_SET_FILLCOLOR, CMD_SET_LINE_WIDTH, CMD_SET_STROKE, CMD_SET_STROKECOLOR, CMD_STROKE_PATH, CMD_TRANSLATE, KIGFX::COLOR4D::g, m_currentContext, KIGFX::GAL::m_fillColor, m_groups, KIGFX::GAL::m_isFillEnabled, KIGFX::GAL::m_isStrokeEnabled, KIGFX::GAL::m_strokeColor, KIGFX::COLOR4D::r, and storePath().

◆ DrawLine()

void CAIRO_GAL_BASE::DrawLine ( const VECTOR2D aStartPoint,
const VECTOR2D aEndPoint 
)
overridevirtual

Draw a line.

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

Parameters
aStartPointis the start point of the line.
aEndPointis the end point of the line.

Reimplemented from KIGFX::GAL.

Definition at line 196 of file cairo_gal.cpp.

197 {
198  syncLineWidth();
199 
200  VECTOR2D p0 = roundp( xform( aStartPoint ) );
201  VECTOR2D p1 = roundp( xform( aEndPoint ) );
202 
203  cairo_move_to( m_currentContext, p0.x, p0.y );
204  cairo_line_to( m_currentContext, p1.x, p1.y );
205  flushPath();
206  m_isElementAdded = true;
207 }
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:328
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:210

References flushPath(), m_currentContext, m_isElementAdded, roundp(), syncLineWidth(), VECTOR2< T >::x, xform(), and VECTOR2< T >::y.

◆ drawPoly() [1/3]

void CAIRO_GAL_BASE::drawPoly ( const std::deque< VECTOR2D > &  aPointList)
protected

Drawing polygons & polylines is the same in Cairo, so here is the common code.

Definition at line 1128 of file cairo_gal.cpp.

1129 {
1130  wxCHECK( aPointList.size() > 1, /* void */ );
1131 
1132  // Iterate over the point list and draw the segments
1133  std::deque<VECTOR2D>::const_iterator it = aPointList.begin();
1134 
1135  syncLineWidth();
1136 
1137  const VECTOR2D p = roundp( xform( it->x, it->y ) );
1138 
1139  cairo_move_to( m_currentContext, p.x, p.y );
1140 
1141  for( ++it; it != aPointList.end(); ++it )
1142  {
1143  const VECTOR2D p2 = roundp( xform( it->x, it->y ) );
1144 
1145  cairo_line_to( m_currentContext, p2.x, p2.y );
1146  }
1147 
1148  flushPath();
1149  m_isElementAdded = true;
1150 }
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:328
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:210

References flushPath(), m_currentContext, m_isElementAdded, roundp(), syncLineWidth(), VECTOR2< T >::x, xform(), and VECTOR2< T >::y.

Referenced by DrawPolygon(), and DrawPolyline().

◆ drawPoly() [2/3]

void CAIRO_GAL_BASE::drawPoly ( const VECTOR2D  aPointList[],
int  aListSize 
)
protected

Definition at line 1153 of file cairo_gal.cpp.

1154 {
1155  wxCHECK( aListSize > 1, /* void */ );
1156 
1157  // Iterate over the point list and draw the segments
1158  const VECTOR2D* ptr = aPointList;
1159 
1160  syncLineWidth();
1161 
1162  const VECTOR2D p = roundp( xform( ptr->x, ptr->y ) );
1163  cairo_move_to( m_currentContext, p.x, p.y );
1164 
1165  for( int i = 1; i < aListSize; ++i )
1166  {
1167  ++ptr;
1168  const VECTOR2D p2 = roundp( xform( ptr->x, ptr->y ) );
1169  cairo_line_to( m_currentContext, p2.x, p2.y );
1170  }
1171 
1172  flushPath();
1173  m_isElementAdded = true;
1174 }
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:328
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:210

References flushPath(), m_currentContext, m_isElementAdded, roundp(), syncLineWidth(), VECTOR2< T >::x, xform(), and VECTOR2< T >::y.

◆ drawPoly() [3/3]

void CAIRO_GAL_BASE::drawPoly ( const SHAPE_LINE_CHAIN aLineChain)
protected

Definition at line 1177 of file cairo_gal.cpp.

1178 {
1179  wxCHECK( aLineChain.PointCount() > 1, /* void */ );
1180 
1181  syncLineWidth();
1182 
1183  auto numPoints = aLineChain.PointCount();
1184 
1185  if( aLineChain.IsClosed() )
1186  numPoints += 1;
1187 
1188  const VECTOR2I start = aLineChain.CPoint( 0 );
1189  const VECTOR2D p = roundp( xform( start.x, start.y ) );
1190  cairo_move_to( m_currentContext, p.x, p.y );
1191 
1192  for( int i = 1; i < numPoints; ++i )
1193  {
1194  const VECTOR2I& pw = aLineChain.CPoint( i );
1195  const VECTOR2D ps = roundp( xform( pw.x, pw.y ) );
1196  cairo_line_to( m_currentContext, ps.x, ps.y );
1197  }
1198 
1199  flushPath();
1200  m_isElementAdded = true;
1201 }
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:328
bool IsClosed() const override
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:210

References SHAPE_LINE_CHAIN::CPoint(), flushPath(), SHAPE_LINE_CHAIN::IsClosed(), m_currentContext, m_isElementAdded, SHAPE_LINE_CHAIN::PointCount(), roundp(), syncLineWidth(), VECTOR2< T >::x, xform(), and VECTOR2< T >::y.

◆ DrawPolygon() [1/4]

void KIGFX::CAIRO_GAL_BASE::DrawPolygon ( const std::deque< VECTOR2D > &  aPointList)
inlineoverridevirtual

Draw a polygon.

Parameters
aPointListis the list of the polygon points.

Reimplemented from KIGFX::GAL.

Definition at line 101 of file cairo_gal.h.

101 { drawPoly( aPointList ); }
void drawPoly(const std::deque< VECTOR2D > &aPointList)
Drawing polygons & polylines is the same in Cairo, so here is the common code.
Definition: cairo_gal.cpp:1128

References drawPoly().

◆ DrawPolygon() [2/4]

void KIGFX::CAIRO_GAL_BASE::DrawPolygon ( const VECTOR2D  aPointList[],
int  aListSize 
)
inlineoverridevirtual

Reimplemented from KIGFX::GAL.

Definition at line 102 of file cairo_gal.h.

103  {
104  drawPoly( aPointList, aListSize );
105  }
void drawPoly(const std::deque< VECTOR2D > &aPointList)
Drawing polygons & polylines is the same in Cairo, so here is the common code.
Definition: cairo_gal.cpp:1128

References drawPoly().

◆ DrawPolygon() [3/4]

void CAIRO_GAL_BASE::DrawPolygon ( const SHAPE_POLY_SET aPolySet,
bool  aStrokeTriangulation = false 
)
overridevirtual

Reimplemented from KIGFX::GAL.

Definition at line 428 of file cairo_gal.cpp.

429 {
430  for( int i = 0; i < aPolySet.OutlineCount(); ++i )
431  drawPoly( aPolySet.COutline( i ) );
432 }
int OutlineCount() const
Return the number of vertices in a given outline/hole.
void drawPoly(const std::deque< VECTOR2D > &aPointList)
Drawing polygons & polylines is the same in Cairo, so here is the common code.
Definition: cairo_gal.cpp:1128
const SHAPE_LINE_CHAIN & COutline(int aIndex) const

References SHAPE_POLY_SET::COutline(), drawPoly(), and SHAPE_POLY_SET::OutlineCount().

◆ DrawPolygon() [4/4]

void CAIRO_GAL_BASE::DrawPolygon ( const SHAPE_LINE_CHAIN aPolySet)
overridevirtual

Reimplemented from KIGFX::GAL.

Definition at line 435 of file cairo_gal.cpp.

436 {
437  drawPoly( aPolygon );
438 }
void drawPoly(const std::deque< VECTOR2D > &aPointList)
Drawing polygons & polylines is the same in Cairo, so here is the common code.
Definition: cairo_gal.cpp:1128

References drawPoly().

◆ DrawPolyline() [1/3]

void KIGFX::CAIRO_GAL_BASE::DrawPolyline ( const std::deque< VECTOR2D > &  aPointList)
inlineoverridevirtual

Draw a polyline.

Parameters
aPointListis a list of 2D-Vectors containing the polyline points.

Reimplemented from KIGFX::GAL.

Definition at line 92 of file cairo_gal.h.

92 { drawPoly( aPointList ); }
void drawPoly(const std::deque< VECTOR2D > &aPointList)
Drawing polygons & polylines is the same in Cairo, so here is the common code.
Definition: cairo_gal.cpp:1128

References drawPoly().

◆ DrawPolyline() [2/3]

void KIGFX::CAIRO_GAL_BASE::DrawPolyline ( const VECTOR2D  aPointList[],
int  aListSize 
)
inlineoverridevirtual

Reimplemented from KIGFX::GAL.

Definition at line 93 of file cairo_gal.h.

94  {
95  drawPoly( aPointList, aListSize );
96  }
void drawPoly(const std::deque< VECTOR2D > &aPointList)
Drawing polygons & polylines is the same in Cairo, so here is the common code.
Definition: cairo_gal.cpp:1128

References drawPoly().

◆ DrawPolyline() [3/3]

void KIGFX::CAIRO_GAL_BASE::DrawPolyline ( const SHAPE_LINE_CHAIN aLineChain)
inlineoverridevirtual

Reimplemented from KIGFX::GAL.

Definition at line 98 of file cairo_gal.h.

98 { drawPoly( aLineChain ); }
void drawPoly(const std::deque< VECTOR2D > &aPointList)
Drawing polygons & polylines is the same in Cairo, so here is the common code.
Definition: cairo_gal.cpp:1128

References drawPoly().

◆ DrawRectangle()

void CAIRO_GAL_BASE::DrawRectangle ( const VECTOR2D aStartPoint,
const VECTOR2D aEndPoint 
)
overridevirtual

Draw a rectangle.

Parameters
aStartPointis the start point of the rectangle.
aEndPointis the end point of the rectangle.

Reimplemented from KIGFX::GAL.

Definition at line 406 of file cairo_gal.cpp.

407 {
408  // Calculate the diagonal points
409  syncLineWidth();
410 
411  const VECTOR2D p0 = roundp( xform( aStartPoint ) );
412  const VECTOR2D p1 = roundp( xform( VECTOR2D( aEndPoint.x, aStartPoint.y ) ) );
413  const VECTOR2D p2 = roundp( xform( aEndPoint ) );
414  const VECTOR2D p3 = roundp( xform( VECTOR2D( aStartPoint.x, aEndPoint.y ) ) );
415 
416  // The path is composed from 4 segments
417  cairo_move_to( m_currentContext, p0.x, p0.y );
418  cairo_line_to( m_currentContext, p1.x, p1.y );
419  cairo_line_to( m_currentContext, p2.x, p2.y );
420  cairo_line_to( m_currentContext, p3.x, p3.y );
421  cairo_close_path( m_currentContext );
422  flushPath();
423 
424  m_isElementAdded = true;
425 }
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:328
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:210

References flushPath(), m_currentContext, m_isElementAdded, roundp(), syncLineWidth(), VECTOR2< T >::x, xform(), and VECTOR2< T >::y.

◆ DrawSegment()

void CAIRO_GAL_BASE::DrawSegment ( const VECTOR2D aStartPoint,
const VECTOR2D aEndPoint,
double  aWidth 
)
overridevirtual

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 from KIGFX::GAL.

Definition at line 234 of file cairo_gal.cpp.

236 {
237  if( m_isFillEnabled )
238  {
239  syncLineWidth( true, aWidth );
240 
241  VECTOR2D p0 = roundp( xform( aStartPoint ) );
242  VECTOR2D p1 = roundp( xform( aEndPoint ) );
243 
244  cairo_move_to( m_currentContext, p0.x, p0.y );
245  cairo_line_to( m_currentContext, p1.x, p1.y );
246  cairo_set_source_rgba( m_currentContext, m_fillColor.r, m_fillColor.g, m_fillColor.b,
247  m_fillColor.a );
248  cairo_stroke( m_currentContext );
249  }
250  else
251  {
252  aWidth /= 2.0;
253  SetLineWidth( 1.0 );
254  syncLineWidth();
255 
256  // Outline mode for tracks
257  VECTOR2D startEndVector = aEndPoint - aStartPoint;
258  double lineAngle = atan2( startEndVector.y, startEndVector.x );
259 
260  double sa = sin( lineAngle + M_PI / 2.0 );
261  double ca = cos( lineAngle + M_PI / 2.0 );
262 
263  auto pa0 = xform( aStartPoint + VECTOR2D( aWidth * ca, aWidth * sa ) );
264  auto pa1 = xform( aStartPoint - VECTOR2D( aWidth * ca, aWidth * sa ) );
265  auto pb0 = xform( aEndPoint + VECTOR2D( aWidth * ca, aWidth * sa ) );
266  auto pb1 = xform( aEndPoint - VECTOR2D( aWidth * ca, aWidth * sa ) );
267  auto pa = xform( aStartPoint );
268  auto pb = xform( aEndPoint );
269  auto rb = ( pa0 - pa ).EuclideanNorm();
270 
271  cairo_set_source_rgba( m_currentContext, m_strokeColor.r, m_strokeColor.g, m_strokeColor.b,
272  m_strokeColor.a );
273 
274  cairo_move_to( m_currentContext, pa0.x, pa0.y );
275  cairo_line_to( m_currentContext, pb0.x, pb0.y );
276 
277  cairo_move_to( m_currentContext, pa1.x, pa1.y );
278  cairo_line_to( m_currentContext, pb1.x, pb1.y );
279 
280  cairo_arc( m_currentContext, pb.x, pb.y, rb, lineAngle - M_PI / 2.0,
281  lineAngle + M_PI / 2.0 );
282  cairo_arc( m_currentContext, pa.x, pa.y, rb, lineAngle + M_PI / 2.0,
283  lineAngle + 3.0 * M_PI / 2.0 );
284 
285  flushPath();
286  }
287 
288  m_isElementAdded = true;
289 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:146
bool m_isFillEnabled
Is filling of graphic objects enabled ?
double g
Green component.
Definition: color4d.h:364
double b
Blue component.
Definition: color4d.h:365
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:328
double a
Alpha component.
Definition: color4d.h:366
COLOR4D m_strokeColor
The color of the outlines.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
COLOR4D m_fillColor
The fill color.
void SetLineWidth(float aLineWidth) override
Set the line width.
Definition: cairo_gal.cpp:617
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:210
double r
Red component.
Definition: color4d.h:363

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, EuclideanNorm(), flushPath(), KIGFX::COLOR4D::g, m_currentContext, KIGFX::GAL::m_fillColor, m_isElementAdded, KIGFX::GAL::m_isFillEnabled, KIGFX::GAL::m_strokeColor, KIGFX::COLOR4D::r, roundp(), SetLineWidth(), syncLineWidth(), VECTOR2< T >::x, xform(), and VECTOR2< T >::y.

◆ EnableDepthTest()

void CAIRO_GAL_BASE::EnableDepthTest ( bool  aEnabled = false)
overridevirtual

Reimplemented from KIGFX::GAL.

Definition at line 934 of file cairo_gal.cpp.

935 {
936 }

◆ endDrawing()

void CAIRO_GAL_BASE::endDrawing ( )
overrideprotectedvirtual

Reimplemented from KIGFX::GAL.

Reimplemented in KIGFX::CAIRO_GAL.

Definition at line 98 of file cairo_gal.cpp.

99 {
100  // Force remaining objects to be drawn
101  Flush();
102 }
void Flush() override
Force all remaining objects to be drawn.
Definition: cairo_gal.cpp:537

References Flush().

Referenced by KIGFX::CAIRO_GAL::endDrawing().

◆ EndGroup()

void CAIRO_GAL_BASE::EndGroup ( )
overridevirtual

End the group.

Reimplemented from KIGFX::GAL.

Reimplemented in KIGFX::CAIRO_GAL.

Definition at line 773 of file cairo_gal.cpp.

774 {
775  storePath();
776  m_isGrouping = false;
777 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1062
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:327

References m_isGrouping, and storePath().

Referenced by KIGFX::CAIRO_GAL::EndGroup().

◆ endUpdate()

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

Disable item update mode.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1066 of file graphics_abstraction_layer.h.

1066 {}

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

◆ Flush()

void CAIRO_GAL_BASE::Flush ( )
overridevirtual

Force all remaining objects to be drawn.

Reimplemented from KIGFX::GAL.

Definition at line 537 of file cairo_gal.cpp.

538 {
539  storePath();
540 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1062

References storePath().

Referenced by endDrawing().

◆ flushPath()

void CAIRO_GAL_BASE::flushPath ( )
protected

Definition at line 1040 of file cairo_gal.cpp.

1041 {
1042  if( m_isFillEnabled )
1043  {
1044  cairo_set_source_rgba( m_currentContext, m_fillColor.r, m_fillColor.g, m_fillColor.b,
1045  m_fillColor.a );
1046 
1047  if( m_isStrokeEnabled )
1048  cairo_fill_preserve( m_currentContext );
1049  else
1050  cairo_fill( m_currentContext );
1051  }
1052 
1053  if( m_isStrokeEnabled )
1054  {
1055  cairo_set_source_rgba( m_currentContext, m_strokeColor.r, m_strokeColor.g, m_strokeColor.b,
1056  m_strokeColor.a );
1057  cairo_stroke( m_currentContext );
1058  }
1059 }
bool m_isFillEnabled
Is filling of graphic objects enabled ?
double g
Green component.
Definition: color4d.h:364
double b
Blue component.
Definition: color4d.h:365
double a
Alpha component.
Definition: color4d.h:366
bool m_isStrokeEnabled
Are the outlines stroked ?
COLOR4D m_strokeColor
The color of the outlines.
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
COLOR4D m_fillColor
The fill color.
double r
Red component.
Definition: color4d.h:363

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, KIGFX::COLOR4D::g, m_currentContext, KIGFX::GAL::m_fillColor, KIGFX::GAL::m_isFillEnabled, KIGFX::GAL::m_isStrokeEnabled, KIGFX::GAL::m_strokeColor, and KIGFX::COLOR4D::r.

Referenced by DrawArc(), DrawArcSegment(), DrawCircle(), DrawCurve(), DrawLine(), drawPoly(), DrawRectangle(), and DrawSegment().

◆ GetClearColor()

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

Definition at line 220 of file graphics_abstraction_layer.h.

221  {
222  return m_clearColor;
223  }

References KIGFX::GAL::m_clearColor.

◆ getCursorColor()

COLOR4D GAL::getCursorColor ( ) const
protectedinherited

Get the actual cursor color to draw.

Definition at line 267 of file graphics_abstraction_layer.cpp.

268 {
270 
271  // dim the cursor if it's only on because it was forced
272  // (this helps to provide a hint for active tools)
273  if( !m_isCursorEnabled )
274  color.a = color.a * 0.5;
275 
276  return color;
277 }
int color
Definition: DXF_plotter.cpp:60
bool m_isCursorEnabled
Is the cursor enabled?
COLOR4D m_cursorColor
Cursor color.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References color, KIGFX::GAL::m_cursorColor, and KIGFX::GAL::m_isCursorEnabled.

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

◆ GetFillColor()

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

Get the fill color.

Returns
the color for filling a outline.

Definition at line 271 of file graphics_abstraction_layer.h.

272  {
273  return m_fillColor;
274  }
COLOR4D m_fillColor
The fill color.

References KIGFX::GAL::m_fillColor.

◆ GetGlyphSize()

◆ GetGridLineWidth()

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

Get the grid line width.

Returns
the grid line widthDraw the grid

Definition at line 935 of file graphics_abstraction_layer.h.

References KIGFX::GAL::m_gridLineWidth.

◆ GetGridOrigin()

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

Definition at line 860 of file graphics_abstraction_layer.h.

861  {
862  return m_gridOrigin;
863  }
VECTOR2D m_gridOrigin
The grid origin.

References KIGFX::GAL::m_gridOrigin.

Referenced by GRID_HELPER::GetOrigin().

◆ GetGridPoint()

VECTOR2D GAL::GetGridPoint ( const VECTOR2D aPoint) const
inherited

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 245 of file graphics_abstraction_layer.cpp.

246 {
247 #if 0
248  // This old code expects a non zero grid size, which can be wrong here.
249  return VECTOR2D( KiROUND( ( aPoint.x - m_gridOffset.x ) / m_gridSize.x ) * m_gridSize.x + m_gridOffset.x,
250  KiROUND( ( aPoint.y - m_gridOffset.y ) / m_gridSize.y ) * m_gridSize.y + m_gridOffset.y );
251 #else
252  // if grid size == 0.0 there is no grid, so use aPoint as grid reference position
253  double cx = m_gridSize.x > 0.0 ? KiROUND( ( aPoint.x - m_gridOffset.x ) / m_gridSize.x ) * m_gridSize.x + m_gridOffset.x
254  : aPoint.x;
255  double cy = m_gridSize.y > 0.0 ? KiROUND( ( aPoint.y - m_gridOffset.y ) / m_gridSize.y ) * m_gridSize.y + m_gridOffset.y
256  : aPoint.y;
257 
258  return VECTOR2D( cx, cy );
259 #endif
260 }
VECTOR2D m_gridSize
The grid size.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
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:73

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

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

◆ GetGridSize()

const VECTOR2D& KIGFX::GAL::GetGridSize ( ) const
inlineinherited

◆ GetGridSnapping()

◆ GetGridVisibility()

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

Definition at line 832 of file graphics_abstraction_layer.h.

832 { return m_gridVisibility; }
bool m_gridVisibility
Should the grid be shown.

References KIGFX::GAL::m_gridVisibility.

Referenced by EDA_DRAW_PANEL_GAL::SwitchBackend().

◆ GetHorizontalJustify()

EDA_TEXT_HJUSTIFY_T KIGFX::GAL::GetHorizontalJustify ( ) const
inlineinherited

Return current text horizontal justification setting.

Definition at line 456 of file graphics_abstraction_layer.h.

457  {
459  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
EDA_TEXT_HJUSTIFY_T m_horizontalJustify
Horizontal justification.

References KIGFX::GAL::TEXT_PROPERTIES::m_horizontalJustify, and KIGFX::GAL::textProperties.

Referenced by KIGFX::OPENGL_GAL::BitmapText(), and KIGFX::STROKE_FONT::drawSingleLineText().

◆ GetLineWidth()

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

◆ GetLookAtPoint()

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

Get the look at point.

Returns
the look at point.

Definition at line 661 of file graphics_abstraction_layer.h.

662  {
663  return m_lookAtPoint;
664  }
VECTOR2D m_lookAtPoint
Point to be looked at in world space.

References KIGFX::GAL::m_lookAtPoint.

Referenced by KIGFX::GAL::GetVisibleWorldExtents().

◆ GetMaxDepth()

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

Return the maximum depth in the currently used range (the bottom).

Definition at line 730 of file graphics_abstraction_layer.h.

731  {
732  return m_depthRange.y;
733  }
VECTOR2D m_depthRange
Range of the depth.

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

◆ GetMinDepth()

double KIGFX::GAL::GetMinDepth ( ) const
inlineinherited

Return the minimum depth in the currently used range (the top).

Definition at line 722 of file graphics_abstraction_layer.h.

723  {
724  return m_depthRange.x;
725  }
VECTOR2D m_depthRange
Range of the depth.

References KIGFX::GAL::m_depthRange, and VECTOR2< T >::x.

Referenced by KIGFX::PREVIEW::RULER_ITEM::ViewDraw().

◆ getNewGroupNumber()

unsigned int CAIRO_GAL_BASE::getNewGroupNumber ( )
protected

Return a valid key that can be used as a new group number.

Returns
An unique group number that is not used by any other group.

Definition at line 1204 of file cairo_gal.cpp.

1205 {
1206  wxASSERT_MSG( m_groups.size() < std::numeric_limits<unsigned int>::max(),
1207  wxT( "There are no free slots to store a group" ) );
1208 
1209  while( m_groups.find( m_groupCounter ) != m_groups.end() )
1210  m_groupCounter++;
1211 
1212  return m_groupCounter++;
1213 }
std::map< int, GROUP > m_groups
List of graphic groups.
Definition: cairo_gal.h:329
unsigned int m_groupCounter
Counter used for generating group keys.
Definition: cairo_gal.h:330

References m_groupCounter, and m_groups.

Referenced by BeginGroup().

◆ GetRotation()

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

Get the rotation angle.

Returns
The rotation angle (radians).

Definition at line 701 of file graphics_abstraction_layer.h.

702  {
703  return m_rotation;
704  }
double m_rotation
Rotation transformation (radians)

References KIGFX::GAL::m_rotation.

◆ GetScreenPixelSize()

◆ GetScreenWorldMatrix()

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

Get the screen <-> world transformation matrix.

Returns
the transformation matrix.

Definition at line 592 of file graphics_abstraction_layer.h.

593  {
594  return m_screenWorldMatrix;
595  }
MATRIX3x3D m_screenWorldMatrix
Screen transformation.

References KIGFX::GAL::m_screenWorldMatrix.

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

◆ GetStrokeColor()

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

Get the stroke color.

Returns
the color for stroking the outline.

Definition at line 291 of file graphics_abstraction_layer.h.

292  {
293  return m_strokeColor;
294  }
COLOR4D m_strokeColor
The color of the outlines.

References KIGFX::GAL::m_strokeColor.

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

◆ GetStrokeFont()

const STROKE_FONT& KIGFX::GAL::GetStrokeFont ( ) const
inlineinherited

Definition at line 333 of file graphics_abstraction_layer.h.

334  {
335  return m_strokeFont;
336  }
STROKE_FONT m_strokeFont
Instance of object that stores information about how to draw texts.

References KIGFX::GAL::m_strokeFont.

Referenced by EDA_TEXT::GetTextBox().

◆ GetTarget()

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

Get the currently used target for rendering.

Returns
The current rendering target.

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

Definition at line 789 of file graphics_abstraction_layer.h.

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

References KIGFX::TARGET_CACHED.

◆ GetTextLineSize()

VECTOR2D GAL::GetTextLineSize ( const UTF8 aText) const
inherited

Compute the X and Y size of a given text.

The text is expected to be a only one line text.

Parameters
aTextis the text string (one line).
Returns
is the text size.

Definition at line 183 of file graphics_abstraction_layer.cpp.

184 {
185  // Compute the X and Y size of a given text.
186  // Because computeTextLineSize expects a one line text,
187  // aText is expected to be only one line text.
188  return m_strokeFont.computeTextLineSize( aText );
189 }
STROKE_FONT m_strokeFont
Instance of object that stores information about how to draw texts.
VECTOR2D computeTextLineSize(const UTF8 &aText) const
Compute the X and Y size of a given text.

References KIGFX::STROKE_FONT::computeTextLineSize(), and KIGFX::GAL::m_strokeFont.

Referenced by LABEL_MANAGER::Add(), GraphicTextWidth(), and EDA_TEXT::LenSize().

◆ GetVerticalJustify()

EDA_TEXT_VJUSTIFY_T KIGFX::GAL::GetVerticalJustify ( ) const
inlineinherited

Returns current text vertical justification setting.

Definition at line 474 of file graphics_abstraction_layer.h.

475  {
477  }
EDA_TEXT_VJUSTIFY_T m_verticalJustify
Vertical justification.
struct KIGFX::GAL::TEXT_PROPERTIES textProperties

References KIGFX::GAL::TEXT_PROPERTIES::m_verticalJustify, and KIGFX::GAL::textProperties.

Referenced by KIGFX::OPENGL_GAL::BitmapText(), and KIGFX::STROKE_FONT::Draw().

◆ GetVisibleWorldExtents()

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

Definition at line 222 of file graphics_abstraction_layer.cpp.

223 {
224  const MATRIX3x3D& matrix = GetScreenWorldMatrix();
225 
226  VECTOR2D halfSize = VECTOR2D( matrix.GetScale().x * m_screenSize.x * 0.5,
227  matrix.GetScale().y * m_screenSize.y * 0.5 );
228 
229  BOX2D extents;
230  extents.SetOrigin( GetLookAtPoint() - halfSize );
231  extents.SetSize( halfSize * 2 );
232 
233  return extents;
234 }
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
Define a general 2D-vector/point.
Definition: vector2d.h:61
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:265
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
const VECTOR2D & GetLookAtPoint() const
Get the look at point.
void SetOrigin(const Vec &pos)
Definition: box2.h:193
VECTOR2I m_screenSize
Screen size in screen coordinates.

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

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

◆ GetWorldScale()

double KIGFX::GAL::GetWorldScale ( ) const
inlineinherited

◆ GetWorldScreenMatrix()

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

Get the world <-> screen transformation matrix.

Returns
the transformation matrix.

Definition at line 582 of file graphics_abstraction_layer.h.

583  {
584  return m_worldScreenMatrix;
585  }
MATRIX3x3D m_worldScreenMatrix
World transformation.

References KIGFX::GAL::m_worldScreenMatrix.

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

◆ GetZoomFactor()

double KIGFX::GAL::GetZoomFactor ( ) const
inlineinherited

Get the zoom factor.

Returns
the zoom factor.

Definition at line 681 of file graphics_abstraction_layer.h.

682  {
683  return m_zoomFactor;
684  }
double m_zoomFactor
The zoom factor.

References KIGFX::GAL::m_zoomFactor.

Referenced by COMMON_TOOLS::doZoomInOut(), EDA_DRAW_FRAME::GetZoomLevelIndicator(), EDA_DRAW_FRAME::OnUpdateSelectZoom(), ZOOM_MENU::update(), and EDA_DRAW_FRAME::UpdateZoomSelectBox().

◆ HasTarget()

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

Return true if the target exists.

Parameters
aTargetis the target to be checked.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 803 of file graphics_abstraction_layer.h.

804  {
805  return true;
806  };

Referenced by EDA_DRAW_PANEL_GAL::DoRePaint().

◆ IsCairoEngine()

bool KIGFX::CAIRO_GAL_BASE::IsCairoEngine ( )
inlineoverridevirtual

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

Reimplemented from KIGFX::GAL.

Definition at line 64 of file cairo_gal.h.

64 { return true; }

◆ IsContextLocked()

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

Checks the state of the context lock.

Returns
True if the context is currently locked

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1050 of file graphics_abstraction_layer.h.

1051  {
1052  return false;
1053  }

Referenced by EDA_DRAW_PANEL_GAL::onSize().

◆ IsCursorEnabled()

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

Return information about cursor visibility.

Returns
True if cursor is visible.

Definition at line 996 of file graphics_abstraction_layer.h.

997  {
999  }
bool m_isCursorEnabled
Is the cursor enabled?
bool m_forceDisplayCursor
Always show cursor.

References KIGFX::GAL::m_forceDisplayCursor, and KIGFX::GAL::m_isCursorEnabled.

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

◆ IsFlippedX()

bool KIGFX::GAL::IsFlippedX ( ) const
inlineinherited

Return true if flip flag for the X axis is set.

Definition at line 760 of file graphics_abstraction_layer.h.

761  {
762  return m_globalFlipX;
763  }
bool m_globalFlipX
Flag for X axis flipping.

References KIGFX::GAL::m_globalFlipX.

Referenced by angle_xform(), arc_angles_xform_and_normalize(), KIGFX::PCB_PAINTER::draw(), KIGFX::PREVIEW::DrawTextNextToCursor(), and DS_PROXY_VIEW_ITEM::ViewDraw().

◆ IsFlippedY()

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

Return true if flip flag for the Y axis is set.

Definition at line 768 of file graphics_abstraction_layer.h.

769  {
770  return m_globalFlipY;
771  }
bool m_globalFlipY
Flag for Y axis flipping.

References KIGFX::GAL::m_globalFlipY.

◆ IsFontBold()

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

Definition at line 422 of file graphics_abstraction_layer.h.

422 { return textProperties.m_bold; }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties

References KIGFX::GAL::TEXT_PROPERTIES::m_bold, and KIGFX::GAL::textProperties.

Referenced by KIGFX::STROKE_FONT::Draw().

◆ IsFontItalic()

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

◆ IsFontUnderlined()

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

◆ IsInitialized()

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

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 ( )
inlinevirtualinherited

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::GERBVIEW_PAINTER::draw(), and KIGFX::PCB_PAINTER::draw().

◆ IsTextMirrored()

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

◆ IsVisible()

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

◆ lockContext()

virtual void KIGFX::GAL::lockContext ( int  aClientCookie)
inlineprotectedvirtualinherited

Use GAL_CONTEXT_LOCKER RAII object.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1057 of file graphics_abstraction_layer.h.

1057 {}

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

◆ OnGalDisplayOptionsChanged()

void GAL::OnGalDisplayOptionsChanged ( const GAL_DISPLAY_OPTIONS aOptions)
overrideprotectedvirtualinherited

Handler for observer settings changes.

Implements KIGFX::GAL_DISPLAY_OPTIONS_OBSERVER.

Definition at line 101 of file graphics_abstraction_layer.cpp.

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

References KIGFX::GAL::updatedGalDisplayOptions().

◆ PopDepth()

void KIGFX::GAL::PopDepth ( )
inlineinherited

Restore previously stored drawing depth for the depth stack.

Definition at line 1038 of file graphics_abstraction_layer.h.

1039  {
1040  m_layerDepth = m_depthStack.top();
1041  m_depthStack.pop();
1042  }
double m_layerDepth
The actual layer depth.
std::stack< double > m_depthStack
Stored depth values.

References KIGFX::GAL::m_depthStack, and KIGFX::GAL::m_layerDepth.

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

◆ PushDepth()

void KIGFX::GAL::PushDepth ( )
inlineinherited

Store current drawing depth on the depth stack.

Definition at line 1030 of file graphics_abstraction_layer.h.

1031  {
1032  m_depthStack.push( m_layerDepth );
1033  }
double m_layerDepth
The actual layer depth.
std::stack< double > m_depthStack
Stored depth values.

References KIGFX::GAL::m_depthStack, and KIGFX::GAL::m_layerDepth.

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

◆ resetContext()

void CAIRO_GAL_BASE::resetContext ( )
protected

Definition at line 939 of file cairo_gal.cpp.

940 {
941  for( _cairo_surface* imageSurface : m_imageSurfaces )
942  cairo_surface_destroy( imageSurface );
943 
944  m_imageSurfaces.clear();
945 
946  ClearScreen();
947 
948  // Compute the world <-> screen transformations
950 
951  cairo_matrix_init( &m_cairoWorldScreenMatrix, m_worldScreenMatrix.m_data[0][0],
954  m_worldScreenMatrix.m_data[1][2] );
955 
956  // we work in screen-space coordinates and do the transforms outside.
957  cairo_identity_matrix( m_context );
958 
959  cairo_matrix_init_identity( &m_currentXform );
960 
961  // Start drawing with a new path
962  cairo_new_path( m_context );
963  m_isElementAdded = true;
964 
966 
967  m_lineWidth = 0;
968 }
cairo_matrix_t m_cairoWorldScreenMatrix
Cairo world to screen transform matrix.
Definition: cairo_gal.h:336
virtual void ComputeWorldScreenMatrix()
Compute the world <-> screen transformation matrix.
MATRIX3x3D m_worldScreenMatrix
World transformation.
T m_data[3][3]
Definition: matrix3x3.h:64
void ClearScreen() override
Clear the screen.
Definition: cairo_gal.cpp:543
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:328
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:105
cairo_t * m_context
Cairo image.
Definition: cairo_gal.h:340
cairo_matrix_t m_currentXform
Definition: cairo_gal.h:337
float m_lineWidth
The line width.
std::vector< cairo_surface_t * > m_imageSurfaces
List of surfaces that were created by painting images, to be cleaned up later.
Definition: cairo_gal.h:344

References ClearScreen(), KIGFX::GAL::ComputeWorldScreenMatrix(), m_cairoWorldScreenMatrix, m_context, m_currentXform, MATRIX3x3< T >::m_data, m_imageSurfaces, m_isElementAdded, KIGFX::GAL::m_lineWidth, KIGFX::GAL::m_worldScreenMatrix, and updateWorldScreenMatrix().

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

◆ ResetTextAttributes()

void GAL::ResetTextAttributes ( )
inherited

Reset text attributes to default styling.

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

Definition at line 167 of file graphics_abstraction_layer.cpp.

168 {
169  // Tiny but non-zero - this will always need setting
170  // there is no built-in default
171  SetGlyphSize( { 1.0, 1.0 } );
172 
175 
176  SetFontBold( false );
177  SetFontItalic( false );
178  SetFontUnderlined( false );
179  SetTextMirrored( false );
180 }
void SetFontBold(bool aBold)
Set bold property of current font.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
void SetFontItalic(bool aItalic)
Set italic property of current font.
void SetGlyphSize(const VECTOR2D &aSize)
Set the font glyph size.
void SetTextMirrored(bool aMirrored)
Set a mirrored property of text.
void SetFontUnderlined(bool aUnderlined)
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.

References GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetFontUnderlined(), KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetTextMirrored(), and KIGFX::GAL::SetVerticalJustify().

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

◆ ResizeScreen()

void CAIRO_GAL_BASE::ResizeScreen ( int  aWidth,
int  aHeight 
)
overridevirtual

Resizes the canvas.

Reimplemented from KIGFX::GAL.

Reimplemented in KIGFX::CAIRO_GAL.

Definition at line 531 of file cairo_gal.cpp.

532 {
533  m_screenSize = VECTOR2I( aWidth, aHeight );
534 }
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
VECTOR2I m_screenSize
Screen size in screen coordinates.

References KIGFX::GAL::m_screenSize.

Referenced by KIGFX::CAIRO_GAL::ResizeScreen().

◆ Restore()

void CAIRO_GAL_BASE::Restore ( )
overridevirtual

Restore the context.

Reimplemented from KIGFX::GAL.

Definition at line 735 of file cairo_gal.cpp.

736 {
737  storePath();
738 
739  if( m_isGrouping )
740  {
741  GROUP_ELEMENT groupElement;
742  groupElement.m_Command = CMD_RESTORE;
743  m_currentGroup->push_back( groupElement );
744  }
745  else
746  {
747  if( !m_xformStack.empty() )
748  {
749  m_currentXform = m_xformStack.back();
750  m_xformStack.pop_back();
752  }
753  }
754 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1062
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:331
std::vector< cairo_matrix_t > m_xformStack
Definition: cairo_gal.h:346
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:105
cairo_matrix_t m_currentXform
Definition: cairo_gal.h:337
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:327
Restore the transformation matrix.
Definition: cairo_gal.h:308

References CMD_RESTORE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Command, m_currentGroup, m_currentXform, m_isGrouping, m_xformStack, storePath(), and updateWorldScreenMatrix().

◆ Rotate()

void CAIRO_GAL_BASE::Rotate ( double  aAngle)
overridevirtual

Rotate the context.

Parameters
aAngleis the rotation angle in radians.

Reimplemented from KIGFX::GAL.

Definition at line 658 of file cairo_gal.cpp.

659 {
660  storePath();
661 
662  if( m_isGrouping )
663  {
664  GROUP_ELEMENT groupElement;
665  groupElement.m_Command = CMD_ROTATE;
666  groupElement.m_Argument.DblArg[0] = aAngle;
667  m_currentGroup->push_back( groupElement );
668  }
669  else
670  {
671  cairo_matrix_rotate( &m_currentXform, aAngle );
673  }
674 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1062
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:331
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:105
cairo_matrix_t m_currentXform
Definition: cairo_gal.h:337
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:327

References CMD_ROTATE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::DblArg, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Argument, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Command, m_currentGroup, m_currentXform, m_isGrouping, storePath(), and updateWorldScreenMatrix().

◆ roundp()

const VECTOR2D CAIRO_GAL_BASE::roundp ( const VECTOR2D v)
protected

Definition at line 187 of file cairo_gal.cpp.

188 {
190  return VECTOR2D( ::roundp( v.x ), ::roundp( v.y ) );
191  else
192  return VECTOR2D( floor( v.x + 0.5 ), floor( v.y + 0.5 ) );
193 }
bool m_isStrokeEnabled
Are the outlines stroked ?
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187

References KIGFX::GAL::m_isStrokeEnabled, m_lineWidthIsOdd, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by DrawArc(), DrawArcSegment(), drawAxes(), DrawCircle(), DrawCurve(), drawGridCross(), drawGridLine(), drawGridPoint(), DrawLine(), drawPoly(), DrawRectangle(), and DrawSegment().

◆ Save()

void CAIRO_GAL_BASE::Save ( )
overridevirtual

Save the context.

Reimplemented from KIGFX::GAL.

Definition at line 717 of file cairo_gal.cpp.

718 {
719  storePath();
720 
721  if( m_isGrouping )
722  {
723  GROUP_ELEMENT groupElement;
724  groupElement.m_Command = CMD_SAVE;
725  m_currentGroup->push_back( groupElement );
726  }
727  else
728  {
729  m_xformStack.push_back( m_currentXform );
731  }
732 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1062
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:331
std::vector< cairo_matrix_t > m_xformStack
Definition: cairo_gal.h:346
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:105
Save the transformation matrix.
Definition: cairo_gal.h:307
cairo_matrix_t m_currentXform
Definition: cairo_gal.h:337
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:327

References CMD_SAVE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Command, m_currentGroup, m_currentXform, m_isGrouping, m_xformStack, storePath(), and updateWorldScreenMatrix().

◆ Scale()

void CAIRO_GAL_BASE::Scale ( const VECTOR2D aScale)
overridevirtual

Scale the context.

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

Reimplemented from KIGFX::GAL.

Definition at line 697 of file cairo_gal.cpp.

698 {
699  storePath();
700 
701  if( m_isGrouping )
702  {
703  GROUP_ELEMENT groupElement;
704  groupElement.m_Command = CMD_SCALE;
705  groupElement.m_Argument.DblArg[0] = aScale.x;
706  groupElement.m_Argument.DblArg[1] = aScale.y;
707  m_currentGroup->push_back( groupElement );
708  }
709  else
710  {
711  cairo_matrix_scale( &m_currentXform, aScale.x, aScale.y );
713  }
714 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1062
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:331
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:105
cairo_matrix_t m_currentXform
Definition: cairo_gal.h:337
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:327

References CMD_SCALE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::DblArg, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Argument, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Command, m_currentGroup, m_currentXform, m_isGrouping, storePath(), updateWorldScreenMatrix(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ SetAxesColor()

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

Set the axes color.

Parameters
aAxesColoris the color to draw the axes if enabled.

Definition at line 907 of file graphics_abstraction_layer.h.

908  {
909  m_axesColor = aAxesColor;
910  }
COLOR4D m_axesColor
Color of the axes.

References KIGFX::GAL::m_axesColor.

Referenced by CAIRO_GAL_BASE(), SYMBOL_VIEWER_FRAME::CommonSettingsChanged(), SYMBOL_EDIT_FRAME::CommonSettingsChanged(), KIGFX::OPENGL_GAL::OPENGL_GAL(), SYMBOL_EDIT_FRAME::SwitchCanvas(), SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME(), and PCB_DRAW_PANEL_GAL::UpdateColors().

◆ SetAxesEnabled()

◆ SetClearColor()

◆ SetCoarseGrid()

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

Draw every tick line wider.

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

Definition at line 925 of file graphics_abstraction_layer.h.

926  {
927  m_gridTick = aInterval;
928  }
int m_gridTick
Every tick line gets the double width.

References KIGFX::GAL::m_gridTick.

Referenced by KIGFX::GAL::GAL().

◆ SetCursorColor()

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

Set the cursor color.

Parameters
aCursorColoris the color of the cursor.

Definition at line 1006 of file graphics_abstraction_layer.h.

1007  {
1008  m_cursorColor = aCursorColor;
1009  }
COLOR4D m_cursorColor
Cursor color.

References KIGFX::GAL::m_cursorColor.

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

◆ SetCursorEnabled()

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

Enable/disable cursor.

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

Definition at line 986 of file graphics_abstraction_layer.h.

987  {
988  m_isCursorEnabled = aCursorEnabled;
989  }
bool m_isCursorEnabled
Is the cursor enabled?

References KIGFX::GAL::m_isCursorEnabled.

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

◆ SetDepthRange()

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

Set the range of the layer depth.

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

Parameters
aDepthRangeis the depth range where component x is the near clipping plane and y is the far clipping plane.

Definition at line 714 of file graphics_abstraction_layer.h.

715  {
716  m_depthRange = aDepthRange;
717  }
VECTOR2D m_depthRange
Range of the depth.

References KIGFX::GAL::m_depthRange.

Referenced by KIGFX::GAL::GAL().

◆ SetFillColor()

void CAIRO_GAL_BASE::SetFillColor ( const COLOR4D aColor)
overridevirtual

Set the fill color.

Parameters
aColoris the color for filling.

Reimplemented from KIGFX::GAL.

Definition at line 599 of file cairo_gal.cpp.

600 {
601  storePath();
602  m_fillColor = aColor;
603 
604  if( m_isGrouping )
605  {
606  GROUP_ELEMENT groupElement;
607  groupElement.m_Command = CMD_SET_FILLCOLOR;
608  groupElement.m_Argument.DblArg[0] = m_fillColor.r;
609  groupElement.m_Argument.DblArg[1] = m_fillColor.g;
610  groupElement.m_Argument.DblArg[2] = m_fillColor.b;
611  groupElement.m_Argument.DblArg[3] = m_fillColor.a;
612  m_currentGroup->push_back( groupElement );
613  }
614 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1062
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:331
double g
Green component.
Definition: color4d.h:364
double b
Blue component.
Definition: color4d.h:365
double a
Alpha component.
Definition: color4d.h:366
COLOR4D m_fillColor
The fill color.
double r
Red component.
Definition: color4d.h:363
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:327

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, CMD_SET_FILLCOLOR, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::DblArg, KIGFX::COLOR4D::g, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Argument, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Command, m_currentGroup, KIGFX::GAL::m_fillColor, m_isGrouping, KIGFX::COLOR4D::r, and storePath().

◆ SetFlip()

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

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 751 of file graphics_abstraction_layer.h.

752  {
753  m_globalFlipX = xAxis;
754  m_globalFlipY = yAxis;
755  }
bool m_globalFlipX
Flag for X axis flipping.
bool m_globalFlipY
Flag for Y axis flipping.

References KIGFX::GAL::m_globalFlipX, and KIGFX::GAL::m_globalFlipY.

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

◆ SetFontBold()

void KIGFX::GAL::SetFontBold ( bool  aBold)
inlineinherited

Set bold property of current font.

Parameters
aBoldtells if the font should be bold or not.

Definition at line 421 of file graphics_abstraction_layer.h.

421 { textProperties.m_bold = aBold; }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties

References KIGFX::GAL::TEXT_PROPERTIES::m_bold, and KIGFX::GAL::textProperties.

Referenced by KIGFX::SCH_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), GraphicTextWidth(), EDA_TEXT::LenSize(), KIGFX::GAL::ResetTextAttributes(), and KIGFX::GAL::SetTextAttributes().

◆ SetFontItalic()

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

Set italic property of current font.

Parameters
aItalictells if the font should be italic or not.

Definition at line 429 of file graphics_abstraction_layer.h.

429 { textProperties.m_italic = aItalic; }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties

References KIGFX::GAL::TEXT_PROPERTIES::m_italic, and KIGFX::GAL::textProperties.

Referenced by KIGFX::SCH_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), GraphicTextWidth(), EDA_TEXT::LenSize(), KIGFX::GAL::ResetTextAttributes(), and KIGFX::GAL::SetTextAttributes().

◆ SetFontUnderlined()

◆ SetGlyphSize()

◆ SetGridColor()

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

Set the grid color.

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

Definition at line 897 of file graphics_abstraction_layer.h.

898  {
899  m_gridColor = aGridColor;
900  }
COLOR4D m_gridColor
Color of the grid.

References KIGFX::GAL::m_gridColor.

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

◆ SetGridOrigin()

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

Set the origin point for the grid.

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

Definition at line 845 of file graphics_abstraction_layer.h.

846  {
847  m_gridOrigin = aGridOrigin;
848 
849  if( m_gridSize.x == 0.0 || m_gridSize.y == 0.0 )
850  {
851  m_gridOffset = VECTOR2D( 0.0, 0.0);
852  }
853  else
854  {
855  m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x,
856  (long) m_gridOrigin.y % (long) m_gridSize.y );
857  }
858  }
VECTOR2D m_gridSize
The grid size.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
VECTOR2D m_gridOffset
The grid offset to compensate cursor position.
VECTOR2D m_gridOrigin
The grid origin.

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

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

◆ SetGridSize()

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

Set the grid size.

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

Definition at line 870 of file graphics_abstraction_layer.h.

871  {
872  m_gridSize = aGridSize;
873 
874  // Avoid stupid grid size values: a grid size should be >= 1 in internal units
875  m_gridSize.x = std::max( 1.0, m_gridSize.x );
876  m_gridSize.y = std::max( 1.0, m_gridSize.y );
877 
878  m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x,
879  (long) m_gridOrigin.y % (long) m_gridSize.y );
880  }
VECTOR2D m_gridSize
The grid size.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
VECTOR2D m_gridOffset
The grid offset to compensate cursor position.
VECTOR2D m_gridOrigin
The grid origin.

References KIGFX::GAL::m_gridOffset, KIGFX::GAL::m_gridOrigin, KIGFX::GAL::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)
inlineinherited

Set the visibility setting of the grid.

Parameters
aVisibilityis the new visibility setting of the grid.

Definition at line 830 of file graphics_abstraction_layer.h.

830 { m_gridVisibility = aVisibility; }
bool m_gridVisibility
Should the grid be shown.

References KIGFX::GAL::m_gridVisibility.

Referenced by KIGFX::GAL::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 EDA_TEXT_HJUSTIFY_T  aHorizontalJustify)
inlineinherited

Set the horizontal justify for text drawing.

Parameters
aHorizontalJustifyis the horizontal justify value.

Definition at line 448 of file graphics_abstraction_layer.h.

449  {
450  textProperties.m_horizontalJustify = aHorizontalJustify;
451  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
EDA_TEXT_HJUSTIFY_T m_horizontalJustify
Horizontal justification.

References KIGFX::GAL::TEXT_PROPERTIES::m_horizontalJustify, and KIGFX::GAL::textProperties.

Referenced by KIGFX::SCH_PAINTER::Draw(), KIGFX::SCH_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), KIGFX::PREVIEW::DrawTextNextToCursor(), drawTicksAlongLine(), KIGFX::GAL::ResetTextAttributes(), and KIGFX::GAL::SetTextAttributes().

◆ SetIsFill()

void CAIRO_GAL_BASE::SetIsFill ( bool  aIsFillEnabled)
overridevirtual

Enable/disable fill.

Parameters
aIsFillEnabledis true, when the graphics objects should be filled, else false.

Reimplemented from KIGFX::GAL.

Definition at line 551 of file cairo_gal.cpp.

552 {
553  storePath();
554  m_isFillEnabled = aIsFillEnabled;
555 
556  if( m_isGrouping )
557  {
558  GROUP_ELEMENT groupElement;
559  groupElement.m_Command = CMD_SET_FILL;
560  groupElement.m_Argument.BoolArg = aIsFillEnabled;
561  m_currentGroup->push_back( groupElement );
562  }
563 }
bool m_isFillEnabled
Is filling of graphic objects enabled ?
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1062
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:331
Enable/disable filling.
Definition: cairo_gal.h:296
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:327

References KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::BoolArg, CMD_SET_FILL, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Argument, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Command, m_currentGroup, KIGFX::GAL::m_isFillEnabled, m_isGrouping, and storePath().

◆ SetIsStroke()

void CAIRO_GAL_BASE::SetIsStroke ( bool  aIsStrokeEnabled)
overridevirtual

Enable/disable stroked outlines.

Parameters
aIsStrokeEnabledis true, if the outline of an object should be stroked.

Reimplemented from KIGFX::GAL.

Definition at line 566 of file cairo_gal.cpp.

567 {
568  storePath();
569  m_isStrokeEnabled = aIsStrokeEnabled;
570 
571  if( m_isGrouping )
572  {
573  GROUP_ELEMENT groupElement;
574  groupElement.m_Command = CMD_SET_STROKE;
575  groupElement.m_Argument.BoolArg = aIsStrokeEnabled;
576  m_currentGroup->push_back( groupElement );
577  }
578 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1062
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:331
bool m_isStrokeEnabled
Are the outlines stroked ?
Enable/disable stroking.
Definition: cairo_gal.h:297
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:327

References KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::BoolArg, CMD_SET_STROKE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Argument, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Command, m_currentGroup, m_isGrouping, KIGFX::GAL::m_isStrokeEnabled, and storePath().

◆ SetLayerDepth()

void CAIRO_GAL_BASE::SetLayerDepth ( double  aLayerDepth)
overridevirtual

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

Parameters
aLayerDepththe layer depth for the objects.

Reimplemented from KIGFX::GAL.

Definition at line 636 of file cairo_gal.cpp.

637 {
638  super::SetLayerDepth( aLayerDepth );
639  storePath();
640 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1062
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)

References KIGFX::GAL::SetLayerDepth(), and storePath().

Referenced by DrawGrid().

◆ SetLineWidth()

void CAIRO_GAL_BASE::SetLineWidth ( float  aLineWidth)
overridevirtual

Set the line width.

Parameters
aLineWidthis the line width.

Reimplemented from KIGFX::GAL.

Definition at line 617 of file cairo_gal.cpp.

618 {
619  storePath();
620  GAL::SetLineWidth( aLineWidth );
621 
622  if( m_isGrouping )
623  {
624  GROUP_ELEMENT groupElement;
625  groupElement.m_Command = CMD_SET_LINE_WIDTH;
626  groupElement.m_Argument.DblArg[0] = aLineWidth;
627  m_currentGroup->push_back( groupElement );
628  }
629  else
630  {
631  m_lineWidth = aLineWidth;
632  }
633 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1062
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:331
virtual void SetLineWidth(float aLineWidth)
Set the line width.
float m_lineWidth
The line width.
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:327

References CMD_SET_LINE_WIDTH, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::DblArg, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Argument, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Command, m_currentGroup, m_isGrouping, KIGFX::GAL::m_lineWidth, KIGFX::GAL::SetLineWidth(), and storePath().

Referenced by DrawGrid(), and DrawSegment().

◆ SetLookAtPoint()

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

Set the Point in world space to look at.

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

Parameters
aPointis the look at point (center of the actual drawing area).

Definition at line 651 of file graphics_abstraction_layer.h.

652  {
653  m_lookAtPoint = aPoint;
654  }
VECTOR2D m_lookAtPoint
Point to be looked at in world space.

References KIGFX::GAL::m_lookAtPoint.

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

◆ SetNativeCursorStyle()

bool GAL::SetNativeCursorStyle ( KICURSOR  aCursor)
virtualinherited

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 }
KICURSOR m_currentNativeCursor
Current cursor.

References KIGFX::GAL::m_currentNativeCursor.

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

◆ SetNegativeDrawMode()

void CAIRO_GAL_BASE::SetNegativeDrawMode ( bool  aSetting)
overridevirtual

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 from KIGFX::GAL.

Definition at line 922 of file cairo_gal.cpp.

923 {
924  cairo_set_operator( m_currentContext, aSetting ? CAIRO_OPERATOR_CLEAR : CAIRO_OPERATOR_OVER );
925 }
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339

References m_currentContext.

◆ SetRotation()

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

Set the rotation angle.

Parameters
aRotationis the new rotation angle (radians).

Definition at line 691 of file graphics_abstraction_layer.h.

692  {
693  m_rotation = aRotation;
694  }
double m_rotation
Rotation transformation (radians)

References KIGFX::GAL::m_rotation.

Referenced by KIGFX::GAL::GAL().

◆ SetScreenDPI()

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

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.

Parameters
aScreenDPIare the screen DPI.

Definition at line 639 of file graphics_abstraction_layer.h.

640  {
641  m_screenDPI = aScreenDPI;
642  }
double m_screenDPI
The dots per inch of the screen.

References KIGFX::GAL::m_screenDPI.

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

◆ SetScreenSize()

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

Definition at line 626 of file graphics_abstraction_layer.h.

627  {
628  m_screenSize = aSize;
629  }
VECTOR2I m_screenSize
Screen size in screen coordinates.

References KIGFX::GAL::m_screenSize.

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

◆ SetStrokeColor()

void CAIRO_GAL_BASE::SetStrokeColor ( const COLOR4D aColor)
overridevirtual

Set the stroke color.

Parameters
aColoris the color for stroking the outline.

Reimplemented from KIGFX::GAL.

Definition at line 581 of file cairo_gal.cpp.

582 {
583  storePath();
584  m_strokeColor = aColor;
585 
586  if( m_isGrouping )
587  {
588  GROUP_ELEMENT groupElement;
589  groupElement.m_Command = CMD_SET_STROKECOLOR;
590  groupElement.m_Argument.DblArg[0] = m_strokeColor.r;
591  groupElement.m_Argument.DblArg[1] = m_strokeColor.g;
592  groupElement.m_Argument.DblArg[2] = m_strokeColor.b;
593  groupElement.m_Argument.DblArg[3] = m_strokeColor.a;
594  m_currentGroup->push_back( groupElement );
595  }
596 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1062
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:331
double g
Green component.
Definition: color4d.h:364
double b
Blue component.
Definition: color4d.h:365
double a
Alpha component.
Definition: color4d.h:366
COLOR4D m_strokeColor
The color of the outlines.
double r
Red component.
Definition: color4d.h:363
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:327

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, CMD_SET_STROKECOLOR, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::DblArg, KIGFX::COLOR4D::g, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Argument, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Command, m_currentGroup, m_isGrouping, KIGFX::GAL::m_strokeColor, KIGFX::COLOR4D::r, and storePath().

◆ SetTarget()

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

Set the target for rendering.

Parameters
aTargetis the new target for rendering.

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

Definition at line 782 of file graphics_abstraction_layer.h.

782 {};

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

◆ SetTextAttributes()

void GAL::SetTextAttributes ( const EDA_TEXT aText)
virtualinherited

Loads attributes of the given text (bold/italic/underline/mirrored and so on).

Parameters
aTextis the text item.

Definition at line 155 of file graphics_abstraction_layer.cpp.

156 {
157  SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
160  SetFontBold( aText->IsBold() );
161  SetFontItalic( aText->IsItalic() );
162  SetFontUnderlined( false );
163  SetTextMirrored( aText->IsMirrored() );
164 }
bool IsBold() const
Definition: eda_text.h:183
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:199
bool IsMirrored() const
Definition: eda_text.h:189
void SetFontBold(bool aBold)
Set bold property of current font.
bool IsItalic() const
Definition: eda_text.h:180
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:198
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
const wxSize & GetTextSize() const
Definition: eda_text.h:238
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
void SetFontItalic(bool aItalic)
Set italic property of current font.
void SetGlyphSize(const VECTOR2D &aSize)
Set the font glyph size.
void SetTextMirrored(bool aMirrored)
Set a mirrored property of text.
void SetFontUnderlined(bool aUnderlined)
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.

References EDA_TEXT::GetHorizJustify(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetVertJustify(), EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), EDA_TEXT::IsMirrored(), KIGFX::GAL::SetFontBold(), KIGFX::GAL::SetFontItalic(), KIGFX::GAL::SetFontUnderlined(), KIGFX::GAL::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetTextMirrored(), and KIGFX::GAL::SetVerticalJustify().

Referenced by KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), and GRText().

◆ SetTextMirrored()

void KIGFX::GAL::SetTextMirrored ( bool  aMirrored)
inlineinherited

◆ SetVerticalJustify()

void KIGFX::GAL::SetVerticalJustify ( const EDA_TEXT_VJUSTIFY_T  aVerticalJustify)
inlineinherited

Set the vertical justify for text drawing.

Parameters
aVerticalJustifyis the vertical justify value.

Definition at line 466 of file graphics_abstraction_layer.h.

467  {
468  textProperties.m_verticalJustify = aVerticalJustify;
469  }
EDA_TEXT_VJUSTIFY_T m_verticalJustify
Vertical justification.
struct KIGFX::GAL::TEXT_PROPERTIES textProperties

References KIGFX::GAL::TEXT_PROPERTIES::m_verticalJustify, and KIGFX::GAL::textProperties.

Referenced by KIGFX::SCH_PAINTER::Draw(), KIGFX::SCH_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), KIGFX::GAL::ResetTextAttributes(), and KIGFX::GAL::SetTextAttributes().

◆ SetWorldScreenMatrix()

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

Set the world <-> screen transformation matrix.

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

Definition at line 602 of file graphics_abstraction_layer.h.

603  {
604  m_worldScreenMatrix = aMatrix;
605  }
MATRIX3x3D m_worldScreenMatrix
World transformation.

References KIGFX::GAL::m_worldScreenMatrix.

◆ SetWorldUnitLength()

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

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.

Parameters
aWorldUnitLengthis the world Unit length.

Definition at line 621 of file graphics_abstraction_layer.h.

622  {
623  m_worldUnitLength = aWorldUnitLength;
624  }
double m_worldUnitLength
The unit length of the world coordinates [inch].

References KIGFX::GAL::m_worldUnitLength.

Referenced by KIGFX::GAL::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(), GERBVIEW_DRAW_PANEL_GAL::SwitchBackend(), PL_DRAW_PANEL_GAL::SwitchBackend(), SCH_DRAW_PANEL::SwitchBackend(), and PCB_DRAW_PANEL_GAL::SwitchBackend().

◆ SetZoomFactor()

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

Set the zoom factor of the scene.

Parameters
aZoomFactoris the zoom factor.

Definition at line 671 of file graphics_abstraction_layer.h.

672  {
673  m_zoomFactor = aZoomFactor;
674  }
double m_zoomFactor
The zoom factor.

References KIGFX::GAL::m_zoomFactor.

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

◆ Show()

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

Show/hide the GAL canvas.

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

Definition at line 204 of file graphics_abstraction_layer.h.

204 { return true; };

◆ storePath()

void CAIRO_GAL_BASE::storePath ( )
protected

Store the actual path.

Definition at line 1062 of file cairo_gal.cpp.

1063 {
1064  if( m_isElementAdded )
1065  {
1066  m_isElementAdded = false;
1067 
1068  if( !m_isGrouping )
1069  {
1070  if( m_isFillEnabled )
1071  {
1072  cairo_set_source_rgba( m_currentContext, m_fillColor.r, m_fillColor.g,
1074  cairo_fill_preserve( m_currentContext );
1075  }
1076 
1077  if( m_isStrokeEnabled )
1078  {
1079  cairo_set_source_rgba( m_currentContext, m_strokeColor.r, m_strokeColor.g,
1081  cairo_stroke_preserve( m_currentContext );
1082  }
1083  }
1084  else
1085  {
1086  // Copy the actual path, append it to the global path list
1087  // then check, if the path needs to be stroked/filled and
1088  // add this command to the group list;
1089  if( m_isStrokeEnabled )
1090  {
1091  GROUP_ELEMENT groupElement;
1092  groupElement.m_CairoPath = cairo_copy_path( m_currentContext );
1093  groupElement.m_Command = CMD_STROKE_PATH;
1094  m_currentGroup->push_back( groupElement );
1095  }
1096 
1097  if( m_isFillEnabled )
1098  {
1099  GROUP_ELEMENT groupElement;
1100  groupElement.m_CairoPath = cairo_copy_path( m_currentContext );
1101  groupElement.m_Command = CMD_FILL_PATH;
1102  m_currentGroup->push_back( groupElement );
1103  }
1104  }
1105 
1106  cairo_new_path( m_currentContext );
1107  }
1108 }
bool m_isFillEnabled
Is filling of graphic objects enabled ?
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:331
double g
Green component.
Definition: color4d.h:364
double b
Blue component.
Definition: color4d.h:365
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:328
double a
Alpha component.
Definition: color4d.h:366
bool m_isStrokeEnabled
Are the outlines stroked ?
COLOR4D m_strokeColor
The color of the outlines.
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
COLOR4D m_fillColor
The fill color.
double r
Red component.
Definition: color4d.h:363
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:327

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, CMD_FILL_PATH, CMD_STROKE_PATH, KIGFX::COLOR4D::g, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_CairoPath, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Command, m_currentContext, m_currentGroup, KIGFX::GAL::m_fillColor, m_isElementAdded, KIGFX::GAL::m_isFillEnabled, m_isGrouping, KIGFX::GAL::m_isStrokeEnabled, KIGFX::GAL::m_strokeColor, and KIGFX::COLOR4D::r.

Referenced by BeginGroup(), ChangeGroupColor(), DeleteGroup(), DrawGroup(), EndGroup(), Flush(), Restore(), Rotate(), Save(), Scale(), SetFillColor(), SetIsFill(), SetIsStroke(), SetLayerDepth(), SetLineWidth(), SetStrokeColor(), KIGFX::CAIRO_GAL::SetTarget(), and Translate().

◆ StrokeText()

virtual void KIGFX::GAL::StrokeText ( const wxString &  aText,
const VECTOR2D aPosition,
double  aRotationAngle 
)
inlinevirtualinherited

Draw a vector type text using preloaded Newstroke font.

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

Definition at line 345 of file graphics_abstraction_layer.h.

347  {
348  m_strokeFont.Draw( aText, aPosition, aRotationAngle );
349  }
STROKE_FONT m_strokeFont
Instance of object that stores information about how to draw texts.
void Draw(const UTF8 &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draw a string.

References KIGFX::STROKE_FONT::Draw(), and KIGFX::GAL::m_strokeFont.

Referenced by KIGFX::GAL::BitmapText(), KIGFX::SCH_PAINTER::Draw(), KIGFX::PCB_PAINTER::draw(), KIGFX::PREVIEW::DrawTextNextToCursor(), drawTicksAlongLine(), GRText(), and KIGFX::SCH_PAINTER::strokeText().

◆ syncLineWidth()

void CAIRO_GAL_BASE::syncLineWidth ( bool  aForceWidth = false,
double  aWidth = 0.0 
)
protected

Definition at line 210 of file cairo_gal.cpp.

211 {
212  double w = floor( xform( aForceWidth ? aWidth : m_lineWidth ) + 0.5 );
213 
214  if( w <= 1.0 )
215  {
216  w = 1.0;
217  cairo_set_line_join( m_currentContext, CAIRO_LINE_JOIN_MITER );
218  cairo_set_line_cap( m_currentContext, CAIRO_LINE_CAP_BUTT );
219  cairo_set_line_width( m_currentContext, 1.0 );
220  m_lineWidthIsOdd = true;
221  }
222  else
223  {
224  cairo_set_line_join( m_currentContext, CAIRO_LINE_JOIN_ROUND );
225  cairo_set_line_cap( m_currentContext, CAIRO_LINE_CAP_ROUND );
226  cairo_set_line_width( m_currentContext, w );
227  m_lineWidthIsOdd = ( (int) w % 2 ) == 1;
228  }
229 
231 }
double m_lineWidthInPixels
Definition: cairo_gal.h:333
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
const double xform(double x)
Definition: cairo_gal.cpp:173
float m_lineWidth
The line width.

References m_currentContext, KIGFX::GAL::m_lineWidth, m_lineWidthInPixels, m_lineWidthIsOdd, and xform().

Referenced by DrawArc(), DrawArcSegment(), drawAxes(), DrawCircle(), DrawCurve(), drawGridCross(), drawGridLine(), DrawLine(), drawPoly(), DrawRectangle(), and DrawSegment().

◆ ToScreen()

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

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 968 of file graphics_abstraction_layer.h.

969  {
970  return VECTOR2D( m_worldScreenMatrix * aPoint );
971  }
MATRIX3x3D m_worldScreenMatrix
World transformation.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622

References KIGFX::GAL::m_worldScreenMatrix.

Referenced by blitCursor().

◆ ToWorld()

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

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 957 of file graphics_abstraction_layer.h.

958  {
959  return VECTOR2D( m_screenWorldMatrix * aPoint );
960  }
MATRIX3x3D m_screenWorldMatrix
Screen transformation.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622

References KIGFX::GAL::m_screenWorldMatrix.

◆ Transform()

void CAIRO_GAL_BASE::Transform ( const MATRIX3x3D aTransformation)
overridevirtual

Transform the context.

Parameters
aTransformationis the transformation matrix.

Reimplemented from KIGFX::GAL.

Definition at line 643 of file cairo_gal.cpp.

644 {
645  cairo_matrix_t cairoTransformation, newXform;
646 
647  cairo_matrix_init( &cairoTransformation, aTransformation.m_data[0][0],
648  aTransformation.m_data[1][0], aTransformation.m_data[0][1],
649  aTransformation.m_data[1][1], aTransformation.m_data[0][2],
650  aTransformation.m_data[1][2] );
651 
652  cairo_matrix_multiply( &newXform, &m_currentXform, &cairoTransformation );
653  m_currentXform = newXform;
655 }
T m_data[3][3]
Definition: matrix3x3.h:64
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:105
cairo_matrix_t m_currentXform
Definition: cairo_gal.h:337

References m_currentXform, MATRIX3x3< T >::m_data, and updateWorldScreenMatrix().

◆ Translate()

void CAIRO_GAL_BASE::Translate ( const VECTOR2D aTranslation)
overridevirtual

Translate the context.

Parameters
aTranslationis the translation vector.

Reimplemented from KIGFX::GAL.

Definition at line 677 of file cairo_gal.cpp.

678 {
679  storePath();
680 
681  if( m_isGrouping )
682  {
683  GROUP_ELEMENT groupElement;
684  groupElement.m_Command = CMD_TRANSLATE;
685  groupElement.m_Argument.DblArg[0] = aTranslation.x;
686  groupElement.m_Argument.DblArg[1] = aTranslation.y;
687  m_currentGroup->push_back( groupElement );
688  }
689  else
690  {
691  cairo_matrix_translate( &m_currentXform, aTranslation.x, aTranslation.y );
693  }
694 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1062
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:331
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:105
cairo_matrix_t m_currentXform
Definition: cairo_gal.h:337
Translate the context.
Definition: cairo_gal.h:305
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:327

References CMD_TRANSLATE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::DblArg, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Argument, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Command, m_currentGroup, m_currentXform, m_isGrouping, storePath(), updateWorldScreenMatrix(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ unlockContext()

virtual void KIGFX::GAL::unlockContext ( int  aClientCookie)
inlineprotectedvirtualinherited

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1059 of file graphics_abstraction_layer.h.

1059 {}

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

◆ updatedGalDisplayOptions()

bool GAL::updatedGalDisplayOptions ( const GAL_DISPLAY_OPTIONS aOptions)
protectedvirtualinherited

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 110 of file graphics_abstraction_layer.cpp.

111 {
112  bool refresh = false;
113 
115  {
117  refresh = true;
118  }
119 
121  {
122  m_gridLineWidth = std::floor( m_options.m_gridLineWidth + 0.5 );
123  refresh = true;
124  }
125 
127  {
129  refresh = true;
130  }
131 
133  {
135  refresh = true;
136  }
137 
139  {
141  refresh = true;
142  }
143 
145  {
147  refresh = true;
148  }
149 
150  // tell the derived class if the base class needs an update or not
151  return refresh;
152 }
bool m_axesEnabled
Should the axes be drawn.
KIGFX::GRID_STYLE m_gridStyle
Snapping options for the grid.
bool m_forceDisplayCursor
The pixel scale factor (>1 for hi-DPI scaled displays)
double m_gridMinSpacing
Whether or not to draw the coordinate system axes.
float m_gridLineWidth
Line width of the grid.
bool m_axesEnabled
Fullscreen crosshair or small cross.
GAL_DISPLAY_OPTIONS & m_options
int m_gridMinSpacing
Minimum screen size of the grid (pixels) below which the grid is not drawn.
GRID_STYLE m_gridStyle
Grid display style.
bool m_forceDisplayCursor
Always show cursor.
double m_gridLineWidth
Minimum pixel distance between displayed grid lines.
bool m_fullscreenCursor
Shape of the cursor (fullscreen or small cross)
bool m_fullscreenCursor
Force cursor display.

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

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

◆ updateWorldScreenMatrix()

void CAIRO_GAL_BASE::updateWorldScreenMatrix ( )
protected

Definition at line 105 of file cairo_gal.cpp.

106 {
107  cairo_matrix_multiply( &m_currentWorld2Screen, &m_currentXform, &m_cairoWorldScreenMatrix );
108 }
cairo_matrix_t m_cairoWorldScreenMatrix
Cairo world to screen transform matrix.
Definition: cairo_gal.h:336
cairo_matrix_t m_currentWorld2Screen
Definition: cairo_gal.h:338
cairo_matrix_t m_currentXform
Definition: cairo_gal.h:337

References m_cairoWorldScreenMatrix, m_currentWorld2Screen, and m_currentXform.

Referenced by resetContext(), Restore(), Rotate(), Save(), Scale(), Transform(), and Translate().

◆ xform() [1/3]

const double CAIRO_GAL_BASE::xform ( double  x)
protected

Definition at line 173 of file cairo_gal.cpp.

174 {
175  double dx = m_currentWorld2Screen.xx * x;
176  double dy = m_currentWorld2Screen.yx * x;
177  return sqrt( dx * dx + dy * dy );
178 }
cairo_matrix_t m_currentWorld2Screen
Definition: cairo_gal.h:338

References m_currentWorld2Screen.

Referenced by DrawArc(), DrawArcSegment(), drawAxes(), DrawCircle(), DrawCurve(), drawGridCross(), drawGridLine(), drawGridPoint(), DrawLine(), drawPoly(), DrawRectangle(), DrawSegment(), syncLineWidth(), and xform().

◆ xform() [2/3]

const VECTOR2D CAIRO_GAL_BASE::xform ( double  x,
double  y 
)
protected

Definition at line 111 of file cairo_gal.cpp.

112 {
113  VECTOR2D rv;
114 
117  return rv;
118 }
cairo_matrix_t m_currentWorld2Screen
Definition: cairo_gal.h:338

References m_currentWorld2Screen, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ xform() [3/3]

const VECTOR2D CAIRO_GAL_BASE::xform ( const VECTOR2D aP)
protected

Definition at line 121 of file cairo_gal.cpp.

122 {
123  return xform( aP.x, aP.y );
124 }
const double xform(double x)
Definition: cairo_gal.cpp:173

References VECTOR2< T >::x, xform(), and VECTOR2< T >::y.

Member Data Documentation

◆ GAL_FORMAT

constexpr cairo_format_t KIGFX::CAIRO_GAL_BASE::GAL_FORMAT = CAIRO_FORMAT_ARGB32
staticprotected

Format used to store pixels.

Definition at line 348 of file cairo_gal.h.

Referenced by KIGFX::CAIRO_GAL::allocateBitmaps(), and KIGFX::CAIRO_GAL::initSurface().

◆ GRID_DEPTH

const int GAL::GRID_DEPTH = MAX_DEPTH - 1
staticprotectedinherited

Depth level on which the grid is drawn.

Definition at line 1094 of file graphics_abstraction_layer.h.

◆ m_axesColor

COLOR4D KIGFX::GAL::m_axesColor
protectedinherited

Color of the axes.

Definition at line 1157 of file graphics_abstraction_layer.h.

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

◆ m_axesEnabled

bool KIGFX::GAL::m_axesEnabled
protectedinherited

◆ m_cairoWorldScreenMatrix

cairo_matrix_t KIGFX::CAIRO_GAL_BASE::m_cairoWorldScreenMatrix
protected

Cairo world to screen transform matrix.

Definition at line 336 of file cairo_gal.h.

Referenced by CAIRO_GAL_BASE(), resetContext(), and updateWorldScreenMatrix().

◆ m_clearColor

◆ m_context

◆ m_currentContext

◆ m_currentGroup

GROUP* KIGFX::CAIRO_GAL_BASE::m_currentGroup
protected

◆ m_currentNativeCursor

KICURSOR KIGFX::GAL::m_currentNativeCursor
protectedinherited

◆ m_currentWorld2Screen

cairo_matrix_t KIGFX::CAIRO_GAL_BASE::m_currentWorld2Screen
protected

Definition at line 338 of file cairo_gal.h.

Referenced by angle_xform(), CAIRO_GAL_BASE(), DrawBitmap(), updateWorldScreenMatrix(), and xform().

◆ m_currentXform

cairo_matrix_t KIGFX::CAIRO_GAL_BASE::m_currentXform
protected

◆ m_cursorColor

COLOR4D KIGFX::GAL::m_cursorColor
protectedinherited

Cursor color.

Definition at line 1167 of file graphics_abstraction_layer.h.

Referenced by KIGFX::GAL::getCursorColor(), and KIGFX::GAL::SetCursorColor().

◆ m_cursorPosition

VECTOR2D KIGFX::GAL::m_cursorPosition
protectedinherited

Current cursor position (world coordinates)

Definition at line 1169 of file graphics_abstraction_layer.h.

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

◆ m_depthRange

VECTOR2D KIGFX::GAL::m_depthRange
protectedinherited

◆ m_depthStack

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

Stored depth values.

Definition at line 1122 of file graphics_abstraction_layer.h.

Referenced by KIGFX::GAL::PopDepth(), and KIGFX::GAL::PushDepth().

◆ m_fillColor

◆ m_forceDisplayCursor

bool KIGFX::GAL::m_forceDisplayCursor
protectedinherited

◆ m_fullscreenCursor

bool KIGFX::GAL::m_fullscreenCursor
protectedinherited

Shape of the cursor (fullscreen or small cross)

Definition at line 1168 of file graphics_abstraction_layer.h.

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