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)
 
virtual ~CAIRO_GAL_BASE ()
 
virtual bool IsCairoEngine () override
 Returns true if the GAL engine is a cairo based type. More...
 
virtual void DrawLine (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint) override
 Draw a line. More...
 
virtual void DrawSegment (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth) override
 Draw a rounded segment. More...
 
virtual void DrawCircle (const VECTOR2D &aCenterPoint, double aRadius) override
 Draw a circle using world coordinates. More...
 
virtual void DrawArc (const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle) override
 Draw an arc. More...
 
virtual void DrawArcSegment (const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth) override
 Draw an arc segment. More...
 
virtual void DrawRectangle (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint) override
 Draw a rectangle. More...
 
virtual void DrawPolyline (const std::deque< VECTOR2D > &aPointList) override
 Draw a polyline. More...
 
virtual void DrawPolyline (const VECTOR2D aPointList[], int aListSize) override
 
virtual void DrawPolyline (const SHAPE_LINE_CHAIN &aLineChain) override
 
virtual void DrawPolygon (const std::deque< VECTOR2D > &aPointList) override
 Draw a polygon. More...
 
virtual void DrawPolygon (const VECTOR2D aPointList[], int aListSize) override
 
virtual void DrawPolygon (const SHAPE_POLY_SET &aPolySet) override
 
virtual void DrawPolygon (const SHAPE_LINE_CHAIN &aPolySet) override
 
virtual void DrawCurve (const VECTOR2D &startPoint, const VECTOR2D &controlPointA, const VECTOR2D &controlPointB, const VECTOR2D &endPoint) override
 Draw a cubic bezier spline. More...
 
virtual void DrawBitmap (const BITMAP_BASE &aBitmap) override
 Draw a bitmap image. More...
 
virtual void ResizeScreen (int aWidth, int aHeight) override
 Resizes the canvas. More...
 
virtual void Flush () override
 Force all remaining objects to be drawn. More...
 
virtual void ClearScreen () override
 Clear the screen. More...
 
virtual void SetIsFill (bool aIsFillEnabled) override
 Enable/disable fill. More...
 
virtual void SetIsStroke (bool aIsStrokeEnabled) override
 Enable/disable stroked outlines. More...
 
virtual void SetStrokeColor (const COLOR4D &aColor) override
 Set the stroke color. More...
 
virtual void SetFillColor (const COLOR4D &aColor) override
 Set the fill color. More...
 
virtual void SetLineWidth (float aLineWidth) override
 Set the line width. More...
 
virtual void SetLayerDepth (double aLayerDepth) override
 Set the depth of the layer (position on the z-axis) More...
 
virtual void Transform (const MATRIX3x3D &aTransformation) override
 Transform the context. More...
 
virtual void Rotate (double aAngle) override
 Rotate the context. More...
 
virtual void Translate (const VECTOR2D &aTranslation) override
 Translate the context. More...
 
virtual void Scale (const VECTOR2D &aScale) override
 Scale the context. More...
 
virtual void Save () override
 Save the context. More...
 
virtual void Restore () override
 Restore the context. More...
 
virtual int BeginGroup () override
 Begin a group. More...
 
virtual void EndGroup () override
 End the group. More...
 
virtual void DrawGroup (int aGroupNumber) override
 Draw the stored group. More...
 
virtual void ChangeGroupColor (int aGroupNumber, const COLOR4D &aNewColor) override
 Changes the color used to draw the group. More...
 
virtual void ChangeGroupDepth (int aGroupNumber, int aDepth) override
 Changes the depth (Z-axis position) of the group. More...
 
virtual void DeleteGroup (int aGroupNumber) override
 Delete the group from the memory. More...
 
virtual void ClearCache () override
 Delete all data created during caching of graphic items. More...
 
virtual void SetNegativeDrawMode (bool aSetting) override
 Sets negative draw mode in the renderer. More...
 
virtual void DrawCursor (const VECTOR2D &aCursorPosition) override
 Draw the cursor. More...
 
virtual void EnableDepthTest (bool aEnabled=false) override
 
virtual void DrawGrid () override
 

More...
 
virtual bool IsInitialized () const
 Returns the initalization status for the canvas. More...
 
virtual bool IsVisible () const
 Returns true if the GAL canvas is visible on the screen. More...
 
virtual bool IsOpenGlEngine ()
 Returns true if the GAL engine is a opengl based type. More...
 
virtual bool Show (bool aShow)
 Shows/hides the GAL canvas. More...
 
const VECTOR2IGetScreenPixelSize () const
 Returns 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)
 Draws a vector type text using preloaded Newstroke font. More...
 
virtual void BitmapText (const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
 Draws a text using a bitmap font. More...
 
VECTOR2D GetTextLineSize (const UTF8 &aText) const
 Compute the X and Y size of a given text. More...
 
double GetOverbarVerticalPosition () const
 Compute the vertical position of an overbar, sometimes used in texts. 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 aGlyphSize)
 Set the font glyph size. More...
 
const VECTOR2DGetGlyphSize () const
 
void SetFontBold (const bool aBold)
 Set bold property of current font. More...
 
bool IsFontBold () const
 Returns true if current font has 'bold' attribute enabled. More...
 
void SetFontItalic (const bool aItalic)
 Set italic property of current font. More...
 
bool IsFontItalic () const
 Returns true if current font has 'italic' attribute enabled. More...
 
void SetTextMirrored (const bool aMirrored)
 Set a mirrored property of text. More...
 
bool IsTextMirrored () const
 Returns true if text should displayed mirrored. More...
 
void SetHorizontalJustify (const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
 Set the horizontal justify for text drawing. More...
 
EDA_TEXT_HJUSTIFY_T GetHorizontalJustify () const
 Returns 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...
 
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
 Returns the minimum depth in the currently used range (the top). More...
 
double GetMaxDepth () const
 Returns 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 SaveScreen ()
 Save the screen contents. More...
 
virtual void RestoreScreen ()
 Restore the screen contents. More...
 
virtual void SetTarget (RENDER_TARGET aTarget)
 Sets the target for rendering. More...
 
virtual RENDER_TARGET GetTarget () const
 Gets the currently used target for rendering. More...
 
virtual void ClearTarget (RENDER_TARGET aTarget)
 Clears the target for rendering. More...
 
void SetGridVisibility (bool aVisibility)
 Sets the visibility setting of the grid. More...
 
void SetGridOrigin (const VECTOR2D &aGridOrigin)
 Set the origin point for the grid. More...
 
void SetGridSize (const VECTOR2D &aGridSize)
 Set the grid size. More...
 
const VECTOR2DGetGridSize () const
 Returns 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)
 Enables 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
 Function GetGridPoint() 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...
 
void SetCursorEnabled (bool aCursorEnabled)
 Enable/disable cursor. More...
 
bool IsCursorEnabled () const
 Returns information about cursor visibility. More...
 
void SetCursorColor (const COLOR4D &aCursorColor)
 Set the cursor color. More...
 
void AdvanceDepth ()
 Changes the current depth to deeper, so it is possible to draw objects right beneath other. More...
 
void PushDepth ()
 Stores current drawing depth on the depth stack. More...
 
void PopDepth ()
 Restores previously stored drawing depth for the depth stack. 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 currentWorld2Screen transform matrix: More...
 
void arc_angles_xform_and_normalize (double &aStartAngle, double &aEndAngle)
 Transform according to the rotation from currentWorld2Screen transform matrix for the start angle and the end angle of an arc. More...
 
virtual void beginDrawing () override
 
virtual 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 aSize)
 
void drawAxes (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
 
void flushPath ()
 
void storePath ()
 Store the actual path. More...
 
virtual void blitCursor (wxMemoryDC &clientDC)
 Blits 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 ()
 Returns 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)
 Private: use GAL_CONTEXT_LOCKER RAII object. More...
 
virtual void unlockContext (int aClientCookie)
 
virtual void beginUpdate ()
 Enables item update mode. More...
 
virtual void endUpdate ()
 Disables 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
 Gets 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)
 Function updatedGalDisplayOptions. More...
 

Protected Attributes

bool isGrouping
 Is grouping enabled ? More...
 
bool isElementAdded
 Was an graphic element added ? More...
 
std::map< int, GROUPgroups
 List of graphic groups. More...
 
unsigned int groupCounter
 Counter used for generating keys for groups. More...
 
GROUPcurrentGroup
 Currently used group. More...
 
double lineWidth
 
double linePixelWidth
 
double lineWidthInPixels
 
bool lineWidthIsOdd
 
cairo_matrix_t cairoWorldScreenMatrix
 Cairo world to screen transformation matrix. More...
 
cairo_matrix_t currentXform
 
cairo_matrix_t currentWorld2Screen
 
cairo_t * currentContext
 Currently used Cairo context for drawing. More...
 
cairo_t * context
 Cairo image. More...
 
cairo_surface_t * surface
 Cairo surface. More...
 
std::vector< cairo_matrix_t > xformStack
 
GAL_DISPLAY_OPTIONSoptions
 
UTIL::LINK observerLink
 
std::stack< double > depthStack
 Stored depth values. More...
 
VECTOR2I screenSize
 Screen size in screen coordinates. More...
 
double worldUnitLength
 The unit length of the world coordinates [inch]. More...
 
double screenDPI
 The dots per inch of the screen. More...
 
VECTOR2D lookAtPoint
 Point to be looked at in world space. More...
 
double zoomFactor
 The zoom factor. More...
 
double rotation
 Rotation transformation (radians) More...
 
MATRIX3x3D worldScreenMatrix
 World transformation. More...
 
MATRIX3x3D screenWorldMatrix
 Screen transformation. More...
 
double worldScale
 The scale factor world->screen. More...
 
bool globalFlipX
 Flag for X axis flipping. More...
 
bool globalFlipY
 Flag for Y axis flipping. More...
 
bool isFillEnabled
 Is filling of graphic objects enabled ? More...
 
bool isStrokeEnabled
 Are the outlines stroked ? More...
 
COLOR4D fillColor
 The fill color. More...
 
COLOR4D strokeColor
 The color of the outlines. More...
 
COLOR4D m_clearColor
 
double layerDepth
 The actual layer depth. More...
 
VECTOR2D depthRange
 Range of the depth. More...
 
bool gridVisibility
 Should the grid be shown. More...
 
GRID_STYLE gridStyle
 Grid display style. More...
 
VECTOR2D gridSize
 The grid size. More...
 
VECTOR2D gridOrigin
 The grid origin. More...
 
VECTOR2D gridOffset
 The grid offset to compensate cursor position. More...
 
COLOR4D gridColor
 Color of the grid. More...
 
COLOR4D axesColor
 Color of the axes. More...
 
bool axesEnabled
 Should the axes be drawn. More...
 
int gridTick
 Every tick line gets the double width. More...
 
float gridLineWidth
 Line width of the grid. More...
 
int gridMinSpacing
 Minimum screen size of the grid (pixels) below which the grid is not drawn. More...
 
bool isCursorEnabled
 Is the cursor enabled? More...
 
bool forceDisplayCursor
 Always show cursor. More...
 
COLOR4D cursorColor
 Cursor color. More...
 
bool fullscreenCursor
 Shape of the cursor (fullscreen or small cross) More...
 
VECTOR2D cursorPosition
 Current cursor position (world coordinates) More...
 
STROKE_FONT strokeFont
 Instance of object that stores information about how to draw texts. 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_RGB24
 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 68 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 299 of file cairo_gal.h.

◆ super

typedef GAL KIGFX::CAIRO_GAL_BASE::super
protected

Super class definition.

Definition at line 260 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 266 of file cairo_gal.h.

267  {
268  CMD_SET_FILL,
274  CMD_FILL_PATH,
275  //CMD_TRANSFORM, ///< Transform the actual context
276  CMD_ROTATE,
277  CMD_TRANSLATE,
278  CMD_SCALE,
279  CMD_SAVE,
280  CMD_RESTORE,
282  };
Enable/disable filling.
Definition: cairo_gal.h:268
Save the transformation matrix.
Definition: cairo_gal.h:279
Translate the context.
Definition: cairo_gal.h:277
Enable/disable stroking.
Definition: cairo_gal.h:269
Restore the transformation matrix.
Definition: cairo_gal.h:280

Constructor & Destructor Documentation

◆ CAIRO_GAL_BASE()

CAIRO_GAL_BASE::CAIRO_GAL_BASE ( GAL_DISPLAY_OPTIONS aDisplayOptions)

Definition at line 46 of file cairo_gal.cpp.

46  :
47  GAL( aDisplayOptions )
48 {
49  // Initialise grouping
50  isGrouping = false;
51  isElementAdded = false;
52  groupCounter = 0;
53  currentGroup = nullptr;
54 
55  lineWidth = 1.0;
56  linePixelWidth = 1.0;
57  lineWidthInPixels = 1.0;
58  lineWidthIsOdd = true;
59 
60  // Initialise Cairo state
61  cairo_matrix_init_identity( &cairoWorldScreenMatrix );
62  currentContext = nullptr;
63  context = nullptr;
64  surface = nullptr;
65 
66  // Grid color settings are different in Cairo and OpenGL
67  SetGridColor( COLOR4D( 0.1, 0.1, 0.1, 0.8 ) );
69 }
Definition: colors.h:57
unsigned int groupCounter
Counter used for generating keys for groups.
Definition: cairo_gal.h:301
cairo_surface_t * surface
Cairo surface.
Definition: cairo_gal.h:314
GAL(GAL_DISPLAY_OPTIONS &aOptions)
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:302
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
cairo_t * context
Cairo image.
Definition: cairo_gal.h:313
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:297
cairo_matrix_t cairoWorldScreenMatrix
Cairo world to screen transformation matrix.
Definition: cairo_gal.h:309
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:298
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References BLUE, cairoWorldScreenMatrix, context, currentContext, currentGroup, groupCounter, isElementAdded, isGrouping, linePixelWidth, lineWidth, lineWidthInPixels, lineWidthIsOdd, KIGFX::GAL::SetAxesColor(), KIGFX::GAL::SetGridColor(), and surface.

◆ ~CAIRO_GAL_BASE()

CAIRO_GAL_BASE::~CAIRO_GAL_BASE ( )
virtual

Definition at line 72 of file cairo_gal.cpp.

73 {
74  ClearCache();
75 
76  if( surface )
77  cairo_surface_destroy( surface );
78 
79  if( context )
80  cairo_destroy( context );
81 }
cairo_surface_t * surface
Cairo surface.
Definition: cairo_gal.h:314
virtual void ClearCache() override
Delete all data created during caching of graphic items.
Definition: cairo_gal.cpp:888
cairo_t * context
Cairo image.
Definition: cairo_gal.h:313

References ClearCache(), context, and surface.

Member Function Documentation

◆ AdvanceDepth()

void KIGFX::GAL::AdvanceDepth ( )
inlineinherited

Changes 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  layerDepth -= 0.05;
1025  }
double layerDepth
The actual layer depth.

References KIGFX::GAL::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 currentWorld2Screen transform matrix:

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

Definition at line 118 of file cairo_gal.cpp.

119 {
120  // calculate rotation angle due to the rotation transform
121  // and if flipped on X axis.
122  double world_rotation = -std::atan2( currentWorld2Screen.xy, currentWorld2Screen.xx );
123 
124  // When flipped on X axis, the rotation angle is M_PI - initial angle:
125  if( IsFlippedX() )
126  world_rotation = M_PI - world_rotation;
127 
128  return std::fmod( aAngle + world_rotation, 2.0 * M_PI );
129 }
bool IsFlippedX() const
Return true if flip flag for the X axis is set.
cairo_matrix_t currentWorld2Screen
Definition: cairo_gal.h:311

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

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 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 132 of file cairo_gal.cpp.

133 {
134  double startAngle = aStartAngle;
135  double endAngle = aEndAngle;
136 
137  // When the view is flipped, the coordinates are flipped by the matrix transform
138  // However, arc angles need to be "flipped": the flipped angle is M_PI - initial angle.
139  if( IsFlippedX() )
140  {
141  startAngle = M_PI - startAngle;
142  endAngle = M_PI - endAngle;
143  }
144 
145  // Normalize arc angles
146  SWAP( startAngle, >, endAngle );
147 
148  // now rotate arc according to the rotation transform matrix
149  aStartAngle = angle_xform( startAngle );
150  aEndAngle = angle_xform( endAngle );
151 }
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 currentWorld2Screen transform matrix:
Definition: cairo_gal.cpp:118
#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 84 of file cairo_gal.cpp.

85 {
86  resetContext();
87 }

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 730 of file cairo_gal.cpp.

731 {
732  // If the grouping is started: the actual path is stored in the group, when
733  // a attribute was changed or when grouping stops with the end group method.
734  storePath();
735 
736  GROUP group;
737  int groupNumber = getNewGroupNumber();
738  groups.insert( std::make_pair( groupNumber, group ) );
739  currentGroup = &groups[groupNumber];
740  isGrouping = true;
741 
742  return groupNumber;
743 }
std::deque< GROUP_ELEMENT > GROUP
A graphic group type definition.
Definition: cairo_gal.h:299
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1024
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:302
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:300
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:297
unsigned int getNewGroupNumber()
Returns a valid key that can be used as a new group number.
Definition: cairo_gal.cpp:1163

References currentGroup, getNewGroupNumber(), groups, isGrouping, and storePath().

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

◆ beginUpdate()

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

Enables item update mode.

Private: use GAL_UPDATE_CONTEXT RAII object

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1110 of file graphics_abstraction_layer.h.

1110 {}

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

◆ BitmapText()

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

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

355  {
356  // Fallback: use stroke font
357 
358  // Handle flipped view
359  if( globalFlipX )
361 
362  StrokeText( aText, aPosition, aRotationAngle );
363 
364  if( globalFlipX )
366  }
bool globalFlipX
Flag for X axis flipping.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
struct KIGFX::GAL::TEXT_PROPERTIES textProperties

References KIGFX::GAL::globalFlipX, KIGFX::GAL::TEXT_PROPERTIES::m_mirrored, KIGFX::GAL::StrokeText(), and KIGFX::GAL::textProperties.

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

◆ blitCursor()

void CAIRO_GAL_BASE::blitCursor ( wxMemoryDC &  clientDC)
protectedvirtual

Blits cursor into the current screen.

Definition at line 1072 of file cairo_gal.cpp.

1073 {
1074  if( !IsCursorEnabled() )
1075  return;
1076 
1077  auto p = ToScreen( cursorPosition );
1078 
1079  const auto cColor = getCursorColor();
1080  const int cursorSize = fullscreenCursor ? 8000 : 80;
1081 
1082  wxColour color( cColor.r * cColor.a * 255, cColor.g * cColor.a * 255,
1083  cColor.b * cColor.a * 255, 255 );
1084  clientDC.SetPen( wxPen( color ) );
1085  clientDC.DrawLine( p.x - cursorSize / 2, p.y, p.x + cursorSize / 2, p.y );
1086  clientDC.DrawLine( p.x, p.y - cursorSize / 2, p.x, p.y + cursorSize / 2 );
1087 }
VECTOR2D cursorPosition
Current cursor position (world coordinates)
VECTOR2D ToScreen(const VECTOR2D &aPoint) const
Compute the point position in screen coordinates from given world coordinates.
int color
Definition: DXF_plotter.cpp:62
bool fullscreenCursor
Shape of the cursor (fullscreen or small cross)
COLOR4D getCursorColor() const
Gets the actual cursor color to draw.
bool IsCursorEnabled() const
Returns information about cursor visibility.

References color, KIGFX::GAL::cursorPosition, KIGFX::GAL::fullscreenCursor, KIGFX::GAL::getCursorColor(), KIGFX::GAL::IsCursorEnabled(), and KIGFX::GAL::ToScreen().

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

◆ ChangeGroupColor()

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

Changes the color used to draw the group.

Parameters
aGroupNumberis the group number.
aNewColoris the new color.

Reimplemented from KIGFX::GAL.

Definition at line 843 of file cairo_gal.cpp.

844 {
845  storePath();
846 
847  for( GROUP::iterator it = groups[aGroupNumber].begin();
848  it != groups[aGroupNumber].end(); ++it )
849  {
850  if( it->command == CMD_SET_FILLCOLOR || it->command == CMD_SET_STROKECOLOR )
851  {
852  it->argument.dblArg[0] = aNewColor.r;
853  it->argument.dblArg[1] = aNewColor.g;
854  it->argument.dblArg[2] = aNewColor.b;
855  it->argument.dblArg[3] = aNewColor.a;
856  }
857  }
858 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1024
double g
Green component.
Definition: color4d.h:310
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:300
double r
Red component.
Definition: color4d.h:309

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

◆ ChangeGroupDepth()

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

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

Parameters
aGroupNumberis the group number.
aDepthis the new depth.

Reimplemented from KIGFX::GAL.

Definition at line 861 of file cairo_gal.cpp.

862 {
863  // Cairo does not have any possibilities to change the depth coordinate of stored items,
864  // it depends only on the order of drawing
865 }

◆ ClearCache()

void CAIRO_GAL_BASE::ClearCache ( )
overridevirtual

Delete all data created during caching of graphic items.

Reimplemented from KIGFX::GAL.

Definition at line 888 of file cairo_gal.cpp.

889 {
890  for( auto it = groups.begin(); it != groups.end(); )
891  DeleteGroup( ( it++ )->first );
892 }
virtual void DeleteGroup(int aGroupNumber) override
Delete the group from the memory.
Definition: cairo_gal.cpp:868
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:300

References DeleteGroup(), and 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 513 of file cairo_gal.cpp.

514 {
515  cairo_set_source_rgb( currentContext, m_clearColor.r, m_clearColor.g, m_clearColor.b );
516  cairo_rectangle( currentContext, 0.0, 0.0, screenSize.x, screenSize.y );
517  cairo_fill( currentContext );
518 }
double g
Green component.
Definition: color4d.h:310
double b
Blue component.
Definition: color4d.h:311
VECTOR2I screenSize
Screen size in screen coordinates.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312
double r
Red component.
Definition: color4d.h:309

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

Referenced by resetContext().

◆ ClearTarget()

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

Clears the target for rendering.

Parameters
aTargetis the target to be cleared.

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

Definition at line 832 of file graphics_abstraction_layer.h.

832 {};

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

209 {
210  // just return the current value. This could be cleverer and take
211  // into account other settings in future
212  return gridMinSpacing;
213 }
int gridMinSpacing
Minimum screen size of the grid (pixels) below which the grid is not drawn.

References KIGFX::GAL::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 1124 of file graphics_abstraction_layer.h.

1125  {
1127  }
double zoomFactor
The zoom factor.
double worldUnitLength
The unit length of the world coordinates [inch].
double worldScale
The scale factor world->screen.
double screenDPI
The dots per inch of the screen.

References KIGFX::GAL::screenDPI, KIGFX::GAL::worldScale, KIGFX::GAL::worldUnitLength, and KIGFX::GAL::zoomFactor.

Referenced by 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 179 of file graphics_abstraction_layer.cpp.

180 {
182 
183  MATRIX3x3D translation;
184  translation.SetIdentity();
185  translation.SetTranslation( 0.5 * VECTOR2D( screenSize ) );
186 
187  MATRIX3x3D rotate;
188  rotate.SetIdentity();
189  rotate.SetRotation( rotation );
190 
192  scale.SetIdentity();
193  scale.SetScale( VECTOR2D( worldScale, worldScale ) );
194 
195  MATRIX3x3D flip;
196  flip.SetIdentity();
197  flip.SetScale( VECTOR2D( globalFlipX ? -1.0 : 1.0, globalFlipY ? -1.0 : 1.0 ) );
198 
199  MATRIX3x3D lookat;
200  lookat.SetIdentity();
201  lookat.SetTranslation( -lookAtPoint );
202 
203  worldScreenMatrix = translation * rotate * flip * scale * lookat;
205 }
void SetRotation(T aAngle)
Set the rotation components of the matrix.
Definition: matrix3x3.h:249
MATRIX3x3 Inverse() const
Determine the inverse of the matrix.
Definition: matrix3x3.h:343
double rotation
Rotation transformation (radians)
MATRIX3x3D screenWorldMatrix
Screen transformation.
bool globalFlipX
Flag for X axis flipping.
void SetIdentity()
Set the matrix to the identity matrix.
Definition: matrix3x3.h:214
VECTOR2D lookAtPoint
Point to be looked at in world space.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
MATRIX3x3D worldScreenMatrix
World transformation.
void computeWorldScale()
Compute the scaling factor for the world->screen matrix.
const int scale
void SetScale(VECTOR2< T > aScale)
Set the scale components of the matrix.
Definition: matrix3x3.h:261
bool globalFlipY
Flag for Y axis flipping.
double worldScale
The scale factor world->screen.
VECTOR2I screenSize
Screen size in screen coordinates.
void SetTranslation(VECTOR2< T > aTranslation)
Set the translation components of the matrix.
Definition: matrix3x3.h:230

References KIGFX::GAL::computeWorldScale(), KIGFX::GAL::globalFlipX, KIGFX::GAL::globalFlipY, MATRIX3x3< T >::Inverse(), KIGFX::GAL::lookAtPoint, KIGFX::GAL::rotation, scale, KIGFX::GAL::screenSize, KIGFX::GAL::screenWorldMatrix, MATRIX3x3< T >::SetIdentity(), MATRIX3x3< T >::SetRotation(), MATRIX3x3< T >::SetScale(), MATRIX3x3< T >::SetTranslation(), KIGFX::GAL::worldScale, and KIGFX::GAL::worldScreenMatrix.

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 868 of file cairo_gal.cpp.

869 {
870  storePath();
871 
872  // Delete the Cairo paths
873  std::deque<GROUP_ELEMENT>::iterator it, end;
874 
875  for( it = groups[aGroupNumber].begin(), end = groups[aGroupNumber].end(); it != end; ++it )
876  {
877  if( it->command == CMD_FILL_PATH || it->command == CMD_STROKE_PATH )
878  {
879  cairo_path_destroy( it->cairoPath );
880  }
881  }
882 
883  // Delete the group
884  groups.erase( aGroupNumber );
885 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1024
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:300

References CMD_FILL_PATH, CMD_STROKE_PATH, 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 285 of file cairo_gal.cpp.

287 {
288  syncLineWidth();
289 
290  // calculate start and end arc angles according to the rotation transform matrix
291  // and normalize:
292  arc_angles_xform_and_normalize( aStartAngle, aEndAngle );
293 
294  double r = xform( aRadius );
295 
296  // N.B. This is backwards. We set this because we want to adjust the center
297  // point that changes both endpoints. In the worst case, this is twice as far.
298  // We cannot adjust radius or center based on the other because this causes the
299  // whole arc to change position/size
300  lineWidthIsOdd = !( static_cast<int>( aRadius ) % 1 );
301 
302  auto mid = roundp( xform( aCenterPoint ) );
303 
304  cairo_set_line_width( currentContext, lineWidthInPixels );
305  cairo_new_sub_path( currentContext );
306 
307  if( isFillEnabled )
308  cairo_move_to( currentContext, mid.x, mid.y );
309 
310  cairo_arc( currentContext, mid.x, mid.y, r, aStartAngle, aEndAngle );
311 
312  if( isFillEnabled )
313  cairo_close_path( currentContext );
314 
315  flushPath();
316 
317  isElementAdded = true;
318 }
const double xform(double x)
Definition: cairo_gal.cpp:154
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:168
bool isFillEnabled
Is filling of graphic objects enabled ?
void arc_angles_xform_and_normalize(double &aStartAngle, double &aEndAngle)
Transform according to the rotation from currentWorld2Screen transform matrix for the start angle and...
Definition: cairo_gal.cpp:132
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:191
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:298

References arc_angles_xform_and_normalize(), currentContext, flushPath(), isElementAdded, KIGFX::GAL::isFillEnabled, lineWidthInPixels, 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 321 of file cairo_gal.cpp.

323 {
324  if( isFillEnabled )
325  {
326  lineWidth = aWidth;
327  isStrokeEnabled = true;
328  isFillEnabled = false;
329  DrawArc( aCenterPoint, aRadius, aStartAngle, aEndAngle );
330  isFillEnabled = true;
331  isStrokeEnabled = false;
332  return;
333  }
334 
335  syncLineWidth();
336 
337  // calculate start and end arc angles according to the rotation transform matrix
338  // and normalize:
339  double startAngleS = aStartAngle;
340  double endAngleS = aEndAngle;
341  arc_angles_xform_and_normalize( startAngleS, endAngleS );
342 
343  double r = xform( aRadius );
344 
345  // N.B. This is backwards. We set this because we want to adjust the center
346  // point that changes both endpoints. In the worst case, this is twice as far.
347  // We cannot adjust radius or center based on the other because this causes the
348  // whole arc to change position/size
349  lineWidthIsOdd = !( static_cast<int>( aRadius ) % 1 );
350 
351  auto mid = roundp( xform( aCenterPoint ) );
352  double width = xform( aWidth / 2.0 );
353  auto startPointS = VECTOR2D( r, 0.0 ).Rotate( startAngleS );
354  auto endPointS = VECTOR2D( r, 0.0 ).Rotate( endAngleS );
355 
356  cairo_save( currentContext );
357 
358  cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
359 
360  cairo_translate( currentContext, mid.x, mid.y );
361 
362  cairo_new_sub_path( currentContext );
363  cairo_arc( currentContext, 0, 0, r - width, startAngleS, endAngleS );
364 
365  cairo_new_sub_path( currentContext );
366  cairo_arc( currentContext, 0, 0, r + width, startAngleS, endAngleS );
367 
368  cairo_new_sub_path( currentContext );
369  cairo_arc_negative( currentContext, startPointS.x, startPointS.y, width, startAngleS, startAngleS + M_PI );
370 
371  cairo_new_sub_path( currentContext );
372  cairo_arc( currentContext, endPointS.x, endPointS.y, width, endAngleS, endAngleS + M_PI );
373 
374  cairo_restore( currentContext );
375  flushPath();
376 
377  isElementAdded = true;
378 }
double g
Green component.
Definition: color4d.h:310
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
bool isStrokeEnabled
Are the outlines stroked ?
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
COLOR4D strokeColor
The color of the outlines.
const double xform(double x)
Definition: cairo_gal.cpp:154
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:168
bool isFillEnabled
Is filling of graphic objects enabled ?
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle) override
Draw an arc.
Definition: cairo_gal.cpp:285
VECTOR2< T > Rotate(double aAngle) const
Function Rotate rotates the vector by a given angle.
Definition: vector2d.h:370
void arc_angles_xform_and_normalize(double &aStartAngle, double &aEndAngle)
Transform according to the rotation from currentWorld2Screen transform matrix for the start angle and...
Definition: cairo_gal.cpp:132
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:191
double r
Red component.
Definition: color4d.h:309
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:298

References KIGFX::COLOR4D::a, arc_angles_xform_and_normalize(), KIGFX::COLOR4D::b, currentContext, DrawArc(), flushPath(), KIGFX::COLOR4D::g, isElementAdded, KIGFX::GAL::isFillEnabled, KIGFX::GAL::isStrokeEnabled, lineWidth, lineWidthIsOdd, KIGFX::COLOR4D::r, VECTOR2< T >::Rotate(), roundp(), KIGFX::GAL::strokeColor, syncLineWidth(), and xform().

◆ drawAxes()

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

Definition at line 939 of file cairo_gal.cpp.

940 {
941  syncLineWidth();
942 
943  auto p0 = roundp( xform( aStartPoint ) );
944  auto p1 = roundp( xform( aEndPoint ) );
945  auto org = roundp( xform( VECTOR2D( 0.0, 0.0 ) ) ); // Axis origin = 0,0 coord
946 
947  cairo_set_source_rgba( currentContext, axesColor.r, axesColor.g, axesColor.b, axesColor.a );
948  cairo_move_to( currentContext, p0.x, org.y);
949  cairo_line_to( currentContext, p1.x, org.y );
950  cairo_move_to( currentContext, org.x, p0.y );
951  cairo_line_to( currentContext, org.x, p1.y );
952  cairo_stroke( currentContext );
953 }
double g
Green component.
Definition: color4d.h:310
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
COLOR4D axesColor
Color of the axes.
const double xform(double x)
Definition: cairo_gal.cpp:154
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:168
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:191
double r
Red component.
Definition: color4d.h:309

References KIGFX::COLOR4D::a, KIGFX::GAL::axesColor, KIGFX::COLOR4D::b, currentContext, KIGFX::COLOR4D::g, KIGFX::COLOR4D::r, roundp(), syncLineWidth(), and xform().

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 435 of file cairo_gal.cpp.

436 {
437  cairo_save( currentContext );
438 
439  // We have to calculate the pixel size in users units to draw the image.
440  // worldUnitLength is a factor used for converting IU to inches
441  double scale = 1.0 / ( aBitmap.GetPPI() * worldUnitLength );
442 
443  // The position of the bitmap is the bitmap center.
444  // move the draw origin to the top left bitmap corner:
445  int w = aBitmap.GetSizePixels().x;
446  int h = aBitmap.GetSizePixels().y;
447 
448  cairo_set_matrix( currentContext, &currentWorld2Screen );
449  cairo_scale( currentContext, scale, scale );
450  cairo_translate( currentContext, -w / 2.0, -h / 2.0 );
451 
452  cairo_new_path( currentContext );
453  cairo_surface_t* image = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, w, h );
454  cairo_surface_flush( image );
455 
456  unsigned char* pix_buffer = cairo_image_surface_get_data( image );
457  // The pixel buffer of the initial bitmap:
458  const wxImage& bm_pix_buffer = *aBitmap.GetImageData();
459 
460  uint32_t mask_color = ( bm_pix_buffer.GetMaskRed() << 16 ) +
461  ( bm_pix_buffer.GetMaskGreen() << 8 ) +
462  ( bm_pix_buffer.GetMaskBlue() );
463 
464  // Copy the source bitmap to the cairo bitmap buffer.
465  // In cairo bitmap buffer, a ARGB32 bitmap is an ARGB pixel packed into a uint_32
466  // 24 low bits only are used for color, top 8 are transparency.
467  for( int row = 0; row < h; row++ )
468  {
469  for( int col = 0; col < w; col++ )
470  {
471  // Build the RGB24 pixel:
472  uint32_t pixel = bm_pix_buffer.GetRed( col, row ) << 16;
473  pixel += bm_pix_buffer.GetGreen( col, row ) << 8;
474  pixel += bm_pix_buffer.GetBlue( col, row );
475 
476  if( bm_pix_buffer.HasAlpha() )
477  pixel += bm_pix_buffer.GetAlpha( col, row ) << 24;
478  else if( bm_pix_buffer.HasMask() && pixel == mask_color )
479  pixel += ( wxALPHA_TRANSPARENT << 24 );
480  else
481  pixel += ( wxALPHA_OPAQUE << 24 );
482 
483  // Write the pixel to the cairo image buffer:
484  uint32_t* pix_ptr = (uint32_t*) pix_buffer;
485  *pix_ptr = pixel;
486  pix_buffer += 4;
487  }
488  }
489 
490  cairo_surface_mark_dirty( image );
491  cairo_set_source_surface( currentContext, image, 0, 0 );
492  cairo_paint( currentContext );
493  cairo_surface_destroy( image );
494 
495  isElementAdded = true;
496 
497  cairo_restore( currentContext );
498 }
wxImage * GetImageData()
Definition: bitmap_base.h:78
double worldUnitLength
The unit length of the world coordinates [inch].
const int scale
wxSize GetSizePixels() const
Function GetSizePixels.
Definition: bitmap_base.h:136
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:298
int GetPPI() const
Definition: bitmap_base.h:148
cairo_matrix_t currentWorld2Screen
Definition: cairo_gal.h:311

References currentContext, currentWorld2Screen, BITMAP_BASE::GetImageData(), BITMAP_BASE::GetPPI(), BITMAP_BASE::GetSizePixels(), isElementAdded, scale, and KIGFX::GAL::worldUnitLength.

◆ 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 269 of file cairo_gal.cpp.

270 {
271  syncLineWidth();
272 
273  auto c = roundp( xform( aCenterPoint ) );
274  auto r = ::roundp( xform( aRadius ) );
275 
276  cairo_set_line_width( currentContext, std::min( 2.0 * r, lineWidthInPixels ) );
277  cairo_new_sub_path( currentContext );
278  cairo_arc( currentContext, c.x, c.y, r, 0.0, 2 * M_PI );
279  cairo_close_path( currentContext );
280  flushPath();
281  isElementAdded = true;
282 }
const double xform(double x)
Definition: cairo_gal.cpp:154
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:168
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:191
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:298
#define min(a, b)
Definition: auxiliary.h:85

References currentContext, flushPath(), isElementAdded, lineWidthInPixels, min, roundp(), syncLineWidth(), and xform().

◆ 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 901 of file cairo_gal.cpp.

902 {
903  cursorPosition = aCursorPosition;
904 }
VECTOR2D cursorPosition
Current cursor position (world coordinates)

References KIGFX::GAL::cursorPosition.

◆ DrawCurve()

void CAIRO_GAL_BASE::DrawCurve ( const VECTOR2D startPoint,
const VECTOR2D controlPointA,
const VECTOR2D controlPointB,
const VECTOR2D endPoint 
)
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.

Reimplemented from KIGFX::GAL.

Definition at line 416 of file cairo_gal.cpp.

418 {
419  syncLineWidth();
420 
421  const auto sp = roundp( xform( aStartPoint ) );
422  const auto cpa = roundp( xform( aControlPointA ) );
423  const auto cpb = roundp( xform( aControlPointB ) );
424  const auto ep = roundp( xform( aEndPoint ) );
425 
426  cairo_move_to( currentContext, sp.x, sp.y );
427  cairo_curve_to( currentContext, cpa.x, cpa.y, cpb.x, cpb.y, ep.x, ep.y );
428  cairo_line_to( currentContext, ep.x, ep.y );
429 
430  flushPath();
431  isElementAdded = true;
432 }
const double xform(double x)
Definition: cairo_gal.cpp:154
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:168
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:191
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:298

References currentContext, flushPath(), isElementAdded, roundp(), syncLineWidth(), and xform().

◆ DrawGrid()

void CAIRO_GAL_BASE::DrawGrid ( )
overridevirtual

Draw the grid

Reimplemented from KIGFX::GAL.

Definition at line 1518 of file cairo_gal.cpp.

1519 {
1521 
1522  // Draw the grid
1523  // For the drawing the start points, end points and increments have
1524  // to be calculated in world coordinates
1525  VECTOR2D worldStartPoint = screenWorldMatrix * VECTOR2D( 0.0, 0.0 );
1526  VECTOR2D worldEndPoint = screenWorldMatrix * VECTOR2D( screenSize );
1527 
1528  double gridThreshold = KiROUND( computeMinGridSpacing() / worldScale );
1529 
1531  gridThreshold *= 2.0;
1532 
1533  int gridScreenSizeDense = gridSize.x;
1534  int gridScreenSizeCoarse = KiROUND( gridSize.x * static_cast<double>( gridTick ) );
1535 
1536  // Compute the line marker or point radius of the grid
1537  // Note: generic grids can't handle sub-pixel lines without
1538  // either losing fine/course distinction or having some dots
1539  // fail to render
1540  float marker = std::fmax( 1.0f, gridLineWidth ) / worldScale;
1541  float doubleMarker = 2.0f * marker;
1542 
1543  // Draw axes if desired
1544  if( axesEnabled )
1545  {
1546  SetLineWidth( marker );
1547  drawAxes( worldStartPoint, worldEndPoint );
1548  }
1549 
1550  if( !gridVisibility )
1551  return;
1552 
1553  // If we cannot display the grid density, scale down by a tick size and
1554  // try again. Eventually, we get some representation of the grid
1555  while( std::min( gridScreenSizeDense, gridScreenSizeCoarse ) <= gridThreshold )
1556  {
1557  gridScreenSizeCoarse *= gridTick;
1558  gridScreenSizeDense *= gridTick;
1559  }
1560 
1561  // Compute grid starting and ending indexes to draw grid points on the
1562  // visible screen area
1563  // Note: later any point coordinate will be offsetted by gridOrigin
1564  int gridStartX = KiROUND( ( worldStartPoint.x - gridOrigin.x ) / gridScreenSizeDense );
1565  int gridEndX = KiROUND( ( worldEndPoint.x - gridOrigin.x ) / gridScreenSizeDense );
1566  int gridStartY = KiROUND( ( worldStartPoint.y - gridOrigin.y ) / gridScreenSizeDense );
1567  int gridEndY = KiROUND( ( worldEndPoint.y - gridOrigin.y ) / gridScreenSizeDense );
1568 
1569  // Ensure start coordinate > end coordinate
1570 
1571  SWAP( gridStartX, >, gridEndX );
1572  SWAP( gridStartY, >, gridEndY );
1573 
1574  // Ensure the grid fills the screen
1575  --gridStartX; ++gridEndX;
1576  --gridStartY; ++gridEndY;
1577 
1578  // Draw the grid behind all other layers
1579  SetLayerDepth( depthRange.y * 0.75 );
1580 
1581  if( gridStyle == GRID_STYLE::LINES )
1582  {
1583  // Now draw the grid, every coarse grid line gets the double width
1584 
1585  // Vertical lines
1586  for( int j = gridStartY; j <= gridEndY; j++ )
1587  {
1588  const double y = j * gridScreenSizeDense + gridOrigin.y;
1589 
1590  if( axesEnabled && y == 0 )
1591  continue;
1592 
1593  SetLineWidth( ( j % gridTick ) ? marker : doubleMarker );
1594  drawGridLine( VECTOR2D( gridStartX * gridScreenSizeDense + gridOrigin.x, y ),
1595  VECTOR2D( gridEndX * gridScreenSizeDense + gridOrigin.x, y ) );
1596  }
1597 
1598  // Horizontal lines
1599  for( int i = gridStartX; i <= gridEndX; i++ )
1600  {
1601  const double x = i * gridScreenSizeDense + gridOrigin.x;
1602 
1603  if( axesEnabled && x == 0 )
1604  continue;
1605 
1606  SetLineWidth( ( i % gridTick ) ? marker : doubleMarker );
1607  drawGridLine( VECTOR2D( x, gridStartY * gridScreenSizeDense + gridOrigin.y ),
1608  VECTOR2D( x, gridEndY * gridScreenSizeDense + gridOrigin.y ) );
1609 
1610  }
1611  }
1612  else // Dots or Crosses grid
1613  {
1614  for( int j = gridStartY; j <= gridEndY; j++ )
1615  {
1616  bool tickY = ( j % gridTick == 0 );
1617 
1618  for( int i = gridStartX; i <= gridEndX; i++ )
1619  {
1620  bool tickX = ( i % gridTick == 0 );
1621  SetLineWidth( ( ( tickX && tickY ) ? doubleMarker : marker ) );
1622  auto pos = VECTOR2D( i * gridScreenSizeDense + gridOrigin.x,
1623  j * gridScreenSizeDense + gridOrigin.y );
1624 
1626  drawGridCross( pos );
1627  else if( gridStyle == GRID_STYLE::DOTS )
1628  drawGridPoint( pos, GetLineWidth() );
1629  }
1630  }
1631  }
1632 }
int gridTick
Every tick line gets the double width.
float GetLineWidth() const
Get the line width.
Use lines for the grid.
bool axesEnabled
Should the axes be drawn.
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:118
double computeMinGridSpacing() const
compute minimum grid spacing from the grid settings
GRID_STYLE gridStyle
Grid display style.
VECTOR2D depthRange
Range of the depth.
MATRIX3x3D screenWorldMatrix
Screen transformation.
void drawAxes(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Definition: cairo_gal.cpp:939
virtual void SetLayerDepth(double aLayerDepth) override
Set the depth of the layer (position on the z-axis)
Definition: cairo_gal.cpp:606
Auxiliary rendering target (noncached)
Definition: definitions.h:49
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
float gridLineWidth
Line width of the grid.
VECTOR2D gridOrigin
The grid origin.
void drawGridPoint(const VECTOR2D &aPoint, double aSize)
Definition: cairo_gal.cpp:989
Use dots for the grid.
Use small cross instead of dots for the grid.
bool gridVisibility
Should the grid be shown.
double worldScale
The scale factor world->screen.
VECTOR2D gridSize
The grid size.
size_t i
Definition: json11.cpp:597
VECTOR2I screenSize
Screen size in screen coordinates.
#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:956
virtual void SetLineWidth(float aLineWidth) override
Set the line width.
Definition: cairo_gal.cpp:587
virtual void SetTarget(RENDER_TARGET aTarget)
Sets the target for rendering.
void drawGridCross(const VECTOR2D &aPoint)
Definition: cairo_gal.cpp:969
#define min(a, b)
Definition: auxiliary.h:85

References KIGFX::GAL::axesEnabled, KIGFX::GAL::computeMinGridSpacing(), KIGFX::GAL::depthRange, KIGFX::DOTS, drawAxes(), drawGridCross(), drawGridLine(), drawGridPoint(), KIGFX::GAL::GetLineWidth(), KIGFX::GAL::gridLineWidth, KIGFX::GAL::gridOrigin, KIGFX::GAL::gridSize, KIGFX::GAL::gridStyle, KIGFX::GAL::gridTick, KIGFX::GAL::gridVisibility, i, KiROUND(), KIGFX::LINES, min, KIGFX::GAL::screenSize, KIGFX::GAL::screenWorldMatrix, SetLayerDepth(), SetLineWidth(), KIGFX::GAL::SetTarget(), KIGFX::SMALL_CROSS, SWAP, KIGFX::TARGET_NONCACHED, KIGFX::GAL::worldScale, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ drawGridCross()

void CAIRO_GAL_BASE::drawGridCross ( const VECTOR2D aPoint)
protected

Definition at line 969 of file cairo_gal.cpp.

970 {
971  syncLineWidth();
972  VECTOR2D offset( 0, 0 );
973  auto size = 2.0 * lineWidthInPixels;
974 
975  auto p0 = roundp( xform( aPoint ) ) - VECTOR2D( size, 0 ) + offset;
976  auto p1 = roundp( xform( aPoint ) ) + VECTOR2D( size, 0 ) + offset;
977  auto p2 = roundp( xform( aPoint ) ) - VECTOR2D( 0, size ) + offset;
978  auto p3 = roundp( xform( aPoint ) ) + VECTOR2D( 0, size ) + offset;
979 
980  cairo_set_source_rgba( currentContext, gridColor.r, gridColor.g, gridColor.b, gridColor.a );
981  cairo_move_to( currentContext, p0.x, p0.y );
982  cairo_line_to( currentContext, p1.x, p1.y );
983  cairo_move_to( currentContext, p2.x, p2.y );
984  cairo_line_to( currentContext, p3.x, p3.y );
985  cairo_stroke( currentContext );
986 }
double g
Green component.
Definition: color4d.h:310
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
const double xform(double x)
Definition: cairo_gal.cpp:154
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:168
COLOR4D gridColor
Color of the grid.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:191
double r
Red component.
Definition: color4d.h:309

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, currentContext, KIGFX::COLOR4D::g, KIGFX::GAL::gridColor, lineWidthInPixels, KIGFX::COLOR4D::r, roundp(), syncLineWidth(), and xform().

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 956 of file cairo_gal.cpp.

957 {
958  syncLineWidth();
959  auto p0 = roundp( xform( aStartPoint ) );
960  auto p1 = roundp( xform( aEndPoint ) );
961 
962  cairo_set_source_rgba( currentContext, gridColor.r, gridColor.g, gridColor.b, gridColor.a );
963  cairo_move_to( currentContext, p0.x, p0.y );
964  cairo_line_to( currentContext, p1.x, p1.y );
965  cairo_stroke( currentContext );
966 }
double g
Green component.
Definition: color4d.h:310
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
const double xform(double x)
Definition: cairo_gal.cpp:154
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:168
COLOR4D gridColor
Color of the grid.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:191
double r
Red component.
Definition: color4d.h:309

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, currentContext, KIGFX::COLOR4D::g, KIGFX::GAL::gridColor, KIGFX::COLOR4D::r, roundp(), syncLineWidth(), and xform().

Referenced by DrawGrid().

◆ drawGridPoint()

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

Definition at line 989 of file cairo_gal.cpp.

990 {
991  auto p = roundp( xform( aPoint ) );
992  auto s = xform( aSize / 2.0 );
993 
994  cairo_set_source_rgba( currentContext, gridColor.r, gridColor.g, gridColor.b, gridColor.a );
995  cairo_move_to( currentContext, p.x, p.y );
996  cairo_arc( currentContext, p.x, p.y, s, 0.0, 2.0 * M_PI );
997  cairo_close_path( currentContext );
998 
999  cairo_fill( currentContext );
1000 }
double g
Green component.
Definition: color4d.h:310
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
const double xform(double x)
Definition: cairo_gal.cpp:154
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:168
COLOR4D gridColor
Color of the grid.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312
double r
Red component.
Definition: color4d.h:309

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, currentContext, KIGFX::COLOR4D::g, KIGFX::GAL::gridColor, KIGFX::COLOR4D::r, roundp(), and xform().

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 753 of file cairo_gal.cpp.

754 {
755  // This method implements a small Virtual Machine - all stored commands
756  // are executed; nested calling is also possible
757 
758  storePath();
759 
760  for( GROUP::iterator it = groups[aGroupNumber].begin();
761  it != groups[aGroupNumber].end(); ++it )
762  {
763  switch( it->command )
764  {
765  case CMD_SET_FILL:
766  isFillEnabled = it->argument.boolArg;
767  break;
768 
769  case CMD_SET_STROKE:
770  isStrokeEnabled = it->argument.boolArg;
771  break;
772 
773  case CMD_SET_FILLCOLOR:
774  fillColor = COLOR4D( it->argument.dblArg[0], it->argument.dblArg[1], it->argument.dblArg[2],
775  it->argument.dblArg[3] );
776  break;
777 
778  case CMD_SET_STROKECOLOR:
779  strokeColor = COLOR4D( it->argument.dblArg[0], it->argument.dblArg[1], it->argument.dblArg[2],
780  it->argument.dblArg[3] );
781  break;
782 
783  case CMD_SET_LINE_WIDTH:
784  {
785  // Make lines appear at least 1 pixel wide, no matter of zoom
786  double x = 1.0, y = 1.0;
787  cairo_device_to_user_distance( currentContext, &x, &y );
788  double minWidth = std::min( fabs( x ), fabs( y ) );
789  cairo_set_line_width( currentContext, std::max( it->argument.dblArg[0], minWidth ) );
790  }
791  break;
792 
793 
794  case CMD_STROKE_PATH:
795  cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
796  cairo_append_path( currentContext, it->cairoPath );
797  cairo_stroke( currentContext );
798  break;
799 
800  case CMD_FILL_PATH:
801  cairo_set_source_rgba( currentContext, fillColor.r, fillColor.g, fillColor.b, strokeColor.a );
802  cairo_append_path( currentContext, it->cairoPath );
803  cairo_fill( currentContext );
804  break;
805 
806  /*
807  case CMD_TRANSFORM:
808  cairo_matrix_t matrix;
809  cairo_matrix_init( &matrix, it->argument.dblArg[0], it->argument.dblArg[1], it->argument.dblArg[2],
810  it->argument.dblArg[3], it->argument.dblArg[4], it->argument.dblArg[5] );
811  cairo_transform( currentContext, &matrix );
812  break;
813  */
814 
815  case CMD_ROTATE:
816  cairo_rotate( currentContext, it->argument.dblArg[0] );
817  break;
818 
819  case CMD_TRANSLATE:
820  cairo_translate( currentContext, it->argument.dblArg[0], it->argument.dblArg[1] );
821  break;
822 
823  case CMD_SCALE:
824  cairo_scale( currentContext, it->argument.dblArg[0], it->argument.dblArg[1] );
825  break;
826 
827  case CMD_SAVE:
828  cairo_save( currentContext );
829  break;
830 
831  case CMD_RESTORE:
832  cairo_restore( currentContext );
833  break;
834 
835  case CMD_CALL_GROUP:
836  DrawGroup( it->argument.intArg );
837  break;
838  }
839  }
840 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1024
double g
Green component.
Definition: color4d.h:310
COLOR4D fillColor
The fill color.
Enable/disable filling.
Definition: cairo_gal.h:268
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
bool isStrokeEnabled
Are the outlines stroked ?
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:300
COLOR4D strokeColor
The color of the outlines.
Save the transformation matrix.
Definition: cairo_gal.h:279
bool isFillEnabled
Is filling of graphic objects enabled ?
#define max(a, b)
Definition: auxiliary.h:86
Translate the context.
Definition: cairo_gal.h:277
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312
virtual void DrawGroup(int aGroupNumber) override
Draw the stored group.
Definition: cairo_gal.cpp:753
double r
Red component.
Definition: color4d.h:309
Enable/disable stroking.
Definition: cairo_gal.h:269
Restore the transformation matrix.
Definition: cairo_gal.h:280
#define min(a, b)
Definition: auxiliary.h:85
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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, currentContext, KIGFX::GAL::fillColor, KIGFX::COLOR4D::g, groups, KIGFX::GAL::isFillEnabled, KIGFX::GAL::isStrokeEnabled, max, min, KIGFX::COLOR4D::r, storePath(), and KIGFX::GAL::strokeColor.

◆ 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 177 of file cairo_gal.cpp.

178 {
179  syncLineWidth();
180 
181  auto p0 = roundp( xform( aStartPoint ) );
182  auto p1 = roundp( xform( aEndPoint ) );
183 
184  cairo_move_to( currentContext, p0.x, p0.y );
185  cairo_line_to( currentContext, p1.x, p1.y );
186  flushPath();
187  isElementAdded = true;
188 }
const double xform(double x)
Definition: cairo_gal.cpp:154
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:168
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:191
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:298

References currentContext, flushPath(), isElementAdded, roundp(), syncLineWidth(), and xform().

◆ 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 1090 of file cairo_gal.cpp.

1091 {
1092  // Iterate over the point list and draw the segments
1093  std::deque<VECTOR2D>::const_iterator it = aPointList.begin();
1094 
1095  syncLineWidth();
1096 
1097  const auto p = roundp( xform( it->x, it->y ) );
1098 
1099  cairo_move_to( currentContext, p.x, p.y );
1100 
1101  for( ++it; it != aPointList.end(); ++it )
1102  {
1103  const auto p2 = roundp( xform( it->x, it->y ) );
1104 
1105  cairo_line_to( currentContext, p2.x, p2.y );
1106  }
1107 
1108  flushPath();
1109  isElementAdded = true;
1110 }
const double xform(double x)
Definition: cairo_gal.cpp:154
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:168
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:191
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:298

References currentContext, flushPath(), isElementAdded, roundp(), syncLineWidth(), and xform().

Referenced by DrawPolygon(), and DrawPolyline().

◆ drawPoly() [2/3]

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

Definition at line 1113 of file cairo_gal.cpp.

1114 {
1115  // Iterate over the point list and draw the segments
1116  const VECTOR2D* ptr = aPointList;
1117 
1118  syncLineWidth();
1119 
1120  const auto p = roundp( xform( ptr->x, ptr->y ) );
1121  cairo_move_to( currentContext, p.x, p.y );
1122 
1123  for( int i = 0; i < aListSize; ++i )
1124  {
1125  ++ptr;
1126  const auto p2 = roundp( xform( ptr->x, ptr->y ) );
1127  cairo_line_to( currentContext, p2.x, p2.y );
1128  }
1129 
1130  flushPath();
1131  isElementAdded = true;
1132 }
const double xform(double x)
Definition: cairo_gal.cpp:154
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:168
size_t i
Definition: json11.cpp:597
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:191
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:298

References currentContext, flushPath(), i, 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 1135 of file cairo_gal.cpp.

1136 {
1137  if( aLineChain.PointCount() < 2 )
1138  return;
1139 
1140  syncLineWidth();
1141 
1142  auto numPoints = aLineChain.PointCount();
1143 
1144  if( aLineChain.IsClosed() )
1145  numPoints += 1;
1146 
1147  const VECTOR2I start = aLineChain.CPoint( 0 );
1148  const auto p = roundp( xform( start.x, start.y ) );
1149  cairo_move_to( currentContext, p.x, p.y );
1150 
1151  for( int i = 1; i < numPoints; ++i )
1152  {
1153  const VECTOR2I& pw = aLineChain.CPoint( i );
1154  const auto ps = roundp( xform( pw.x, pw.y ) );
1155  cairo_line_to( currentContext, ps.x, ps.y );
1156  }
1157 
1158  flushPath();
1159  isElementAdded = true;
1160 }
int PointCount() const
Function PointCount()
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
const double xform(double x)
Definition: cairo_gal.cpp:154
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:168
size_t i
Definition: json11.cpp:597
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:191
bool IsClosed() const
Function IsClosed()
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:298

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

◆ DrawPolygon() [1/4]

virtual 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 107 of file cairo_gal.h.

107 { 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:1090

References drawPoly().

◆ DrawPolygon() [2/4]

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

Reimplemented from KIGFX::GAL.

Definition at line 108 of file cairo_gal.h.

108 { drawPoly( aPointList, aListSize ); }
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:1090

References drawPoly().

◆ DrawPolygon() [3/4]

void CAIRO_GAL_BASE::DrawPolygon ( const SHAPE_POLY_SET aPolySet)
overridevirtual

Reimplemented from KIGFX::GAL.

Definition at line 403 of file cairo_gal.cpp.

404 {
405  for( int i = 0; i < aPolySet.OutlineCount(); ++i )
406  drawPoly( aPolySet.COutline( i ) );
407 }
int OutlineCount() const
Returns the number of outlines in the set
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:1090
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
size_t i
Definition: json11.cpp:597

References SHAPE_POLY_SET::COutline(), drawPoly(), i, 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 410 of file cairo_gal.cpp.

411 {
412  drawPoly( aPolygon );
413 }
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:1090

References drawPoly().

◆ DrawPolyline() [1/3]

virtual 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 102 of file cairo_gal.h.

102 { 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:1090

References drawPoly().

◆ DrawPolyline() [2/3]

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

Reimplemented from KIGFX::GAL.

Definition at line 103 of file cairo_gal.h.

103 { drawPoly( aPointList, aListSize ); }
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:1090

References drawPoly().

◆ DrawPolyline() [3/3]

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

Reimplemented from KIGFX::GAL.

Definition at line 104 of file cairo_gal.h.

104 { 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:1090

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 381 of file cairo_gal.cpp.

382 {
383  // Calculate the diagonal points
384  syncLineWidth();
385 
386  const auto p0 = roundp( xform( aStartPoint ) );
387  const auto p1 = roundp( xform( VECTOR2D( aEndPoint.x, aStartPoint.y ) ) );
388  const auto p2 = roundp( xform( aEndPoint ) );
389  const auto p3 = roundp( xform( VECTOR2D( aStartPoint.x, aEndPoint.y ) ) );
390 
391  // The path is composed from 4 segments
392  cairo_move_to( currentContext, p0.x, p0.y );
393  cairo_line_to( currentContext, p1.x, p1.y );
394  cairo_line_to( currentContext, p2.x, p2.y );
395  cairo_line_to( currentContext, p3.x, p3.y );
396  cairo_close_path( currentContext );
397  flushPath();
398 
399  isElementAdded = true;
400 }
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
const double xform(double x)
Definition: cairo_gal.cpp:154
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:168
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:191
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:298

References currentContext, flushPath(), 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 215 of file cairo_gal.cpp.

217 {
218  if( isFillEnabled )
219  {
220  syncLineWidth( true, aWidth );
221 
222  auto p0 = roundp( xform( aStartPoint ) );
223  auto p1 = roundp( xform( aEndPoint ) );
224 
225  cairo_move_to( currentContext, p0.x, p0.y );
226  cairo_line_to( currentContext, p1.x, p1.y );
227  cairo_set_source_rgba( currentContext, fillColor.r, fillColor.g, fillColor.b, fillColor.a );
228  cairo_stroke( currentContext );
229  }
230  else
231  {
232  aWidth /= 2.0;
233  SetLineWidth( 1.0 );
234  syncLineWidth();
235 
236  // Outline mode for tracks
237  VECTOR2D startEndVector = aEndPoint - aStartPoint;
238  double lineAngle = atan2( startEndVector.y, startEndVector.x );
239 
240  double sa = sin( lineAngle + M_PI / 2.0 );
241  double ca = cos( lineAngle + M_PI / 2.0 );
242 
243  auto pa0 = xform ( aStartPoint + VECTOR2D(aWidth * ca, aWidth * sa ) );
244  auto pa1 = xform ( aStartPoint - VECTOR2D(aWidth * ca, aWidth * sa ) );
245  auto pb0 = xform ( aEndPoint + VECTOR2D(aWidth * ca, aWidth * sa ) );
246  auto pb1 = xform ( aEndPoint - VECTOR2D(aWidth * ca, aWidth * sa ) );
247  auto pa = xform( aStartPoint );
248  auto pb = xform( aEndPoint );
249  auto rb = (pa0 - pa).EuclideanNorm();
250 
251  cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
252 
253  cairo_move_to( currentContext, pa0.x, pa0.y );
254  cairo_line_to( currentContext, pb0.x, pb0.y );
255 
256  cairo_move_to( currentContext, pa1.x, pa1.y );
257  cairo_line_to( currentContext, pb1.x, pb1.y );
258 
259  cairo_arc( currentContext, pb.x, pb.y, rb, lineAngle - M_PI / 2.0, lineAngle + M_PI / 2.0 );
260  cairo_arc( currentContext, pa.x, pa.y, rb, lineAngle + M_PI / 2.0, lineAngle + 3.0 * M_PI / 2.0 );
261 
262  flushPath();
263  }
264 
265  isElementAdded = true;
266 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:121
double g
Green component.
Definition: color4d.h:310
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
COLOR4D strokeColor
The color of the outlines.
const double xform(double x)
Definition: cairo_gal.cpp:154
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:168
bool isFillEnabled
Is filling of graphic objects enabled ?
virtual void SetLineWidth(float aLineWidth) override
Set the line width.
Definition: cairo_gal.cpp:587
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:191
double r
Red component.
Definition: color4d.h:309
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:298

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, currentContext, EuclideanNorm(), KIGFX::GAL::fillColor, flushPath(), KIGFX::COLOR4D::g, isElementAdded, KIGFX::GAL::isFillEnabled, KIGFX::COLOR4D::r, roundp(), SetLineWidth(), KIGFX::GAL::strokeColor, 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 907 of file cairo_gal.cpp.

908 {
909 }

◆ endDrawing()

void CAIRO_GAL_BASE::endDrawing ( )
overrideprotectedvirtual

Reimplemented from KIGFX::GAL.

Reimplemented in KIGFX::CAIRO_GAL.

Definition at line 90 of file cairo_gal.cpp.

91 {
92  // Force remaining objects to be drawn
93  Flush();
94 }
virtual void Flush() override
Force all remaining objects to be drawn.
Definition: cairo_gal.cpp:507

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 746 of file cairo_gal.cpp.

747 {
748  storePath();
749  isGrouping = false;
750 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1024
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:297

References isGrouping, and storePath().

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

◆ endUpdate()

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

Disables item update mode.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1113 of file graphics_abstraction_layer.h.

1113 {}

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 507 of file cairo_gal.cpp.

508 {
509  storePath();
510 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1024

References storePath().

Referenced by endDrawing().

◆ flushPath()

void CAIRO_GAL_BASE::flushPath ( )
protected

Definition at line 1002 of file cairo_gal.cpp.

1003 {
1004  if( isFillEnabled )
1005  {
1006  cairo_set_source_rgba( currentContext,
1008 
1009  if( isStrokeEnabled )
1010  cairo_fill_preserve( currentContext );
1011  else
1012  cairo_fill( currentContext );
1013  }
1014 
1015  if( isStrokeEnabled )
1016  {
1017  cairo_set_source_rgba( currentContext,
1019  cairo_stroke( currentContext );
1020  }
1021 }
double g
Green component.
Definition: color4d.h:310
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
bool isStrokeEnabled
Are the outlines stroked ?
COLOR4D strokeColor
The color of the outlines.
bool isFillEnabled
Is filling of graphic objects enabled ?
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312
double r
Red component.
Definition: color4d.h:309

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, currentContext, KIGFX::GAL::fillColor, KIGFX::COLOR4D::g, KIGFX::GAL::isFillEnabled, KIGFX::GAL::isStrokeEnabled, KIGFX::COLOR4D::r, and KIGFX::GAL::strokeColor.

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

◆ GetClearColor()

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

Definition at line 215 of file graphics_abstraction_layer.h.

216  {
217  return m_clearColor;
218  }

References KIGFX::GAL::m_clearColor.

Referenced by EDIT_POINTS::ViewDraw().

◆ getCursorColor()

COLOR4D GAL::getCursorColor ( ) const
protectedinherited

Gets the actual cursor color to draw.

Definition at line 238 of file graphics_abstraction_layer.cpp.

239 {
240  auto color = cursorColor;
241 
242  // dim the cursor if it's only on because it was forced
243  // (this helps to provide a hint for active tools)
244  if( !isCursorEnabled )
245  {
246  color.a = color.a * 0.5;
247  }
248 
249  return color;
250 }
bool isCursorEnabled
Is the cursor enabled?
int color
Definition: DXF_plotter.cpp:62
COLOR4D cursorColor
Cursor color.

References color, KIGFX::GAL::cursorColor, and KIGFX::GAL::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 265 of file graphics_abstraction_layer.h.

266  {
267  return fillColor;
268  }
COLOR4D fillColor
The fill color.

References KIGFX::GAL::fillColor.

◆ GetGlyphSize()

◆ GetGridLineWidth()

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

Get the grid line width.

Returns
the grid line width

Definition at line 943 of file graphics_abstraction_layer.h.

944  {
945  return gridLineWidth;
946  }
float gridLineWidth
Line width of the grid.

References KIGFX::GAL::gridLineWidth.

◆ GetGridPoint()

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

Function GetGridPoint() 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 216 of file graphics_abstraction_layer.cpp.

217 {
218 #if 0
219  // This old code expects a non zero grid size, which can be wrong here.
220  return VECTOR2D( KiROUND( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x,
221  KiROUND( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y );
222 #else
223  // if grid size == 0.0 there is no grid, so use aPoint as grid reference position
224  double cx = gridSize.x > 0.0 ? KiROUND( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x
225  : aPoint.x;
226  double cy = gridSize.y > 0.0 ? KiROUND( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y
227  : aPoint.y;
228 
229  return VECTOR2D( cx, cy );
230 #endif
231 }
VECTOR2D gridOffset
The grid offset to compensate cursor position.
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:118
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
VECTOR2D gridSize
The grid size.

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

Referenced by EDIT_POINTS_FACTORY::buildForPolyOutline(), and KIGFX::WX_VIEW_CONTROLS::GetRawCursorPosition().

◆ GetGridSize()

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

Returns the grid size.

Returns
A vector containing the grid size in x and y direction.

Definition at line 895 of file graphics_abstraction_layer.h.

896  {
897  return gridSize;
898  }
VECTOR2D gridSize
The grid size.

References KIGFX::GAL::gridSize.

Referenced by SCH_BASE_FRAME::SyncView().

◆ GetHorizontalJustify()

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

Returns current text horizontal justification setting.

Definition at line 487 of file graphics_abstraction_layer.h.

488  {
490  }
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 687 of file graphics_abstraction_layer.h.

688  {
689  return lookAtPoint;
690  }
VECTOR2D lookAtPoint
Point to be looked at in world space.

References KIGFX::GAL::lookAtPoint.

◆ GetMaxDepth()

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

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

Definition at line 756 of file graphics_abstraction_layer.h.

757  {
758  return depthRange.y;
759  }
VECTOR2D depthRange
Range of the depth.

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

◆ GetMinDepth()

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

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

Definition at line 748 of file graphics_abstraction_layer.h.

749  {
750  return depthRange.x;
751  }
VECTOR2D depthRange
Range of the depth.

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

◆ getNewGroupNumber()

unsigned int CAIRO_GAL_BASE::getNewGroupNumber ( )
protected

Returns 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 1163 of file cairo_gal.cpp.

1164 {
1165  wxASSERT_MSG( groups.size() < std::numeric_limits<unsigned int>::max(),
1166  wxT( "There are no free slots to store a group" ) );
1167 
1168  while( groups.find( groupCounter ) != groups.end() )
1169  groupCounter++;
1170 
1171  return groupCounter++;
1172 }
unsigned int groupCounter
Counter used for generating keys for groups.
Definition: cairo_gal.h:301
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:300
#define max(a, b)
Definition: auxiliary.h:86

References groupCounter, groups, and max.

Referenced by BeginGroup().

◆ GetOverbarVerticalPosition()

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

Compute the vertical position of an overbar, sometimes used in texts.

This is the distance between the text base line and the overbar.

Returns
the relative position of the overbar axis.

Definition at line 382 of file graphics_abstraction_layer.h.

383  {
385  }
STROKE_FONT strokeFont
Instance of object that stores information about how to draw texts.
double computeOverbarVerticalPosition() const
Compute the vertical position of an overbar, sometimes used in texts.

References KIGFX::STROKE_FONT::computeOverbarVerticalPosition(), and KIGFX::GAL::strokeFont.

◆ GetRotation()

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

Get the rotation angle.

Returns
The rotation angle (radians).

Definition at line 727 of file graphics_abstraction_layer.h.

728  {
729  return rotation;
730  }
double rotation
Rotation transformation (radians)

References KIGFX::GAL::rotation.

◆ GetScreenPixelSize()

const VECTOR2I& KIGFX::GAL::GetScreenPixelSize ( ) const
inlineinherited

◆ GetScreenWorldMatrix()

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

Get the screen <-> world transformation matrix.

Returns
the transformation matrix.

Definition at line 623 of file graphics_abstraction_layer.h.

624  {
625  return screenWorldMatrix;
626  }
MATRIX3x3D screenWorldMatrix
Screen transformation.

References KIGFX::GAL::screenWorldMatrix.

Referenced by KIGFX::OPENGL_GAL::getWorldPixelSize(), 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 285 of file graphics_abstraction_layer.h.

286  {
287  return strokeColor;
288  }
COLOR4D strokeColor
The color of the outlines.

References KIGFX::GAL::strokeColor.

◆ GetStrokeFont()

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

Definition at line 327 of file graphics_abstraction_layer.h.

328  {
329  return strokeFont;
330  }
STROKE_FONT strokeFont
Instance of object that stores information about how to draw texts.

References KIGFX::GAL::strokeFont.

Referenced by EDA_TEXT::GetTextBox().

◆ GetTarget()

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

Gets the currently used target for rendering.

Returns
The current rendering target.

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

Definition at line 825 of file graphics_abstraction_layer.h.

825 { 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 170 of file graphics_abstraction_layer.cpp.

171 {
172  // Compute the X and Y size of a given text.
173  // Because computeTextLineSize expects a one line text,
174  // aText is expected to be only one line text.
175  return strokeFont.computeTextLineSize( aText );
176 }
STROKE_FONT 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::strokeFont.

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

◆ GetVerticalJustify()

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

Returns current text vertical justification setting.

Definition at line 505 of file graphics_abstraction_layer.h.

506  {
508  }
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().

◆ GetWorldScale()

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

Get the world scale.

Returns
the actual world scale factor.

Definition at line 766 of file graphics_abstraction_layer.h.

767  {
768  return worldScale;
769  }
double worldScale
The scale factor world->screen.

References KIGFX::GAL::worldScale.

Referenced by GRID_HELPER::BestDragOrigin(), GRID_HELPER::BestSnapAnchor(), KIGFX::PCB_PAINTER::draw(), SCH_BASE_FRAME::RedrawScreen(), SCH_BASE_FRAME::RedrawScreen2(), and KIGFX::PREVIEW::SetConstantGlyphHeight().

◆ GetWorldScreenMatrix()

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

Get the world <-> screen transformation matrix.

Returns
the transformation matrix.

Definition at line 613 of file graphics_abstraction_layer.h.

614  {
615  return worldScreenMatrix;
616  }
MATRIX3x3D worldScreenMatrix
World transformation.

References KIGFX::GAL::worldScreenMatrix.

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

◆ GetZoomFactor()

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

Get the zoom factor.

Returns
the zoom factor.

Definition at line 707 of file graphics_abstraction_layer.h.

708  {
709  return zoomFactor;
710  }
double zoomFactor
The zoom factor.

References KIGFX::GAL::zoomFactor.

Referenced by EDA_DRAW_PANEL_GAL::GetLegacyZoom(), EDA_DRAW_FRAME::GetZoomLevelIndicator(), SCH_BASE_FRAME::RedrawScreen(), and SCH_BASE_FRAME::RedrawScreen2().

◆ IsCairoEngine()

virtual bool KIGFX::CAIRO_GAL_BASE::IsCairoEngine ( )
inlineoverridevirtual

Returns true if the GAL engine is a cairo based type.

Reimplemented from KIGFX::GAL.

Definition at line 75 of file cairo_gal.h.

75 { return true; }

◆ IsCursorEnabled()

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

Returns information about cursor visibility.

Returns
True if cursor is visible.

Definition at line 996 of file graphics_abstraction_layer.h.

997  {
999  }
bool isCursorEnabled
Is the cursor enabled?
bool forceDisplayCursor
Always show cursor.

References KIGFX::GAL::forceDisplayCursor, and KIGFX::GAL::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 786 of file graphics_abstraction_layer.h.

787  {
788  return globalFlipX;
789  }
bool globalFlipX
Flag for X axis flipping.

References KIGFX::GAL::globalFlipX.

Referenced by angle_xform(), and arc_angles_xform_and_normalize().

◆ IsFlippedY()

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

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

Definition at line 794 of file graphics_abstraction_layer.h.

795  {
796  return globalFlipY;
797  }
bool globalFlipY
Flag for Y axis flipping.

References KIGFX::GAL::globalFlipY.

◆ IsFontBold()

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

Returns true if current font has 'bold' attribute enabled.

Definition at line 433 of file graphics_abstraction_layer.h.

434  {
435  return textProperties.m_bold;
436  }
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

Returns true if current font has 'italic' attribute enabled.

Definition at line 451 of file graphics_abstraction_layer.h.

452  {
453  return textProperties.m_italic;
454  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties

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

Referenced by KIGFX::STROKE_FONT::ComputeStringBoundaryLimits(), and KIGFX::STROKE_FONT::drawSingleLineText().

◆ IsInitialized()

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

Returns the initalization status for the canvas.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 73 of file graphics_abstraction_layer.h.

73 { return true; }

Referenced by EDA_DRAW_PANEL_GAL::onRefreshTimer().

◆ IsOpenGlEngine()

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

Returns true if the GAL engine is a opengl based type.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 82 of file graphics_abstraction_layer.h.

82 { return false; }

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

◆ IsTextMirrored()

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

Returns true if text should displayed mirrored.

Definition at line 469 of file graphics_abstraction_layer.h.

470  {
471  return textProperties.m_mirrored;
472  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties

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

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

◆ IsVisible()

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

◆ lockContext()

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

Private: use GAL_CONTEXT_LOCKER RAII object.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1104 of file graphics_abstraction_layer.h.

1104 {}

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

91 {
92  // defer to the child class first
93  updatedGalDisplayOptions( aOptions );
94 
95  // there is no refresh to do at this level
96 }
virtual bool updatedGalDisplayOptions(const GAL_DISPLAY_OPTIONS &aOptions)
Function updatedGalDisplayOptions.

References KIGFX::GAL::updatedGalDisplayOptions().

◆ PopDepth()

void KIGFX::GAL::PopDepth ( )
inlineinherited

Restores previously stored drawing depth for the depth stack.

Definition at line 1038 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::depthStack, and KIGFX::GAL::layerDepth.

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

◆ PushDepth()

void KIGFX::GAL::PushDepth ( )
inlineinherited

Stores current drawing depth on the depth stack.

Definition at line 1030 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::depthStack, and KIGFX::GAL::layerDepth.

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

◆ resetContext()

void CAIRO_GAL_BASE::resetContext ( )
protected

Definition at line 912 of file cairo_gal.cpp.

913 {
914  ClearScreen();
915 
916  // Compute the world <-> screen transformations
918 
919  cairo_matrix_init( &cairoWorldScreenMatrix, worldScreenMatrix.m_data[0][0],
922  worldScreenMatrix.m_data[1][2] );
923 
924  // we work in screen-space coordinates and do the transforms outside.
925  cairo_identity_matrix( context );
926 
927  cairo_matrix_init_identity( &currentXform );
928 
929  // Start drawing with a new path
930  cairo_new_path( context );
931  isElementAdded = true;
932 
934 
935  lineWidth = 0;
936 }
virtual void ComputeWorldScreenMatrix()
Compute the world <-> screen transformation matrix.
T m_data[3][3]
Definition: matrix3x3.h:64
virtual void ClearScreen() override
Clear the screen.
Definition: cairo_gal.cpp:513
cairo_t * context
Cairo image.
Definition: cairo_gal.h:313
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:96
MATRIX3x3D worldScreenMatrix
World transformation.
cairo_matrix_t currentXform
Definition: cairo_gal.h:310
cairo_matrix_t cairoWorldScreenMatrix
Cairo world to screen transformation matrix.
Definition: cairo_gal.h:309
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:298

References cairoWorldScreenMatrix, ClearScreen(), KIGFX::GAL::ComputeWorldScreenMatrix(), context, currentXform, isElementAdded, lineWidth, MATRIX3x3< T >::m_data, updateWorldScreenMatrix(), and KIGFX::GAL::worldScreenMatrix.

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

156 {
157  // Tiny but non-zero - this will always need setting
158  // there is no built-in default
159  SetGlyphSize( { 1.0, 1.0 } );
160 
163 
164  SetFontBold( false );
165  SetFontItalic( false );
166  SetTextMirrored( false );
167 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
void SetFontBold(const bool aBold)
Set bold property of current font.
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
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::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetTextMirrored(), and KIGFX::GAL::SetVerticalJustify().

Referenced by KIGFX::PCB_PAINTER::draw(), KIGFX::GAL::GAL(), and KIGFX::PREVIEW::ARC_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 501 of file cairo_gal.cpp.

502 {
503  screenSize = VECTOR2I( aWidth, aHeight );
504 }
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
VECTOR2I screenSize
Screen size in screen coordinates.

References KIGFX::GAL::screenSize.

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

◆ Restore()

void CAIRO_GAL_BASE::Restore ( )
overridevirtual

Restore the context.

Reimplemented from KIGFX::GAL.

Definition at line 708 of file cairo_gal.cpp.

709 {
710  storePath();
711 
712  if( isGrouping )
713  {
714  GROUP_ELEMENT groupElement;
715  groupElement.command = CMD_RESTORE;
716  currentGroup->push_back( groupElement );
717  }
718  else
719  {
720  if( !xformStack.empty() )
721  {
722  currentXform = xformStack.back();
723  xformStack.pop_back();
725  }
726  }
727 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1024
std::vector< cairo_matrix_t > xformStack
Definition: cairo_gal.h:316
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:302
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:297
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:96
cairo_matrix_t currentXform
Definition: cairo_gal.h:310
Restore the transformation matrix.
Definition: cairo_gal.h:280

References CMD_RESTORE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, currentGroup, currentXform, isGrouping, storePath(), updateWorldScreenMatrix(), and xformStack.

◆ RestoreScreen()

virtual void KIGFX::GAL::RestoreScreen ( )
inlinevirtualinherited

Restore the screen contents.

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

Definition at line 811 of file graphics_abstraction_layer.h.

811 {};

◆ 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 631 of file cairo_gal.cpp.

632 {
633  storePath();
634 
635  if( isGrouping )
636  {
637  GROUP_ELEMENT groupElement;
638  groupElement.command = CMD_ROTATE;
639  groupElement.argument.dblArg[0] = aAngle;
640  currentGroup->push_back( groupElement );
641  }
642  else
643  {
644  cairo_matrix_rotate( &currentXform, aAngle );
646  }
647 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1024
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:302
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:297
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:96
cairo_matrix_t currentXform
Definition: cairo_gal.h:310

References KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::argument, CMD_ROTATE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, currentGroup, currentXform, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::dblArg, isGrouping, storePath(), and updateWorldScreenMatrix().

◆ roundp()

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

Definition at line 168 of file cairo_gal.cpp.

169 {
171  return VECTOR2D( ::roundp( v.x ), ::roundp( v.y ) );
172  else
173  return VECTOR2D( floor( v.x + 0.5 ), floor( v.y + 0.5 ) );
174 }
bool isStrokeEnabled
Are the outlines stroked ?
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:168

References KIGFX::GAL::isStrokeEnabled, 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 690 of file cairo_gal.cpp.

691 {
692  storePath();
693 
694  if( isGrouping )
695  {
696  GROUP_ELEMENT groupElement;
697  groupElement.command = CMD_SAVE;
698  currentGroup->push_back( groupElement );
699  }
700  else
701  {
702  xformStack.push_back( currentXform );
704  }
705 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1024
std::vector< cairo_matrix_t > xformStack
Definition: cairo_gal.h:316
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:302
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:297
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:96
Save the transformation matrix.
Definition: cairo_gal.h:279
cairo_matrix_t currentXform
Definition: cairo_gal.h:310

References CMD_SAVE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, currentGroup, currentXform, isGrouping, storePath(), updateWorldScreenMatrix(), and xformStack.

◆ SaveScreen()

virtual void KIGFX::GAL::SaveScreen ( )
inlinevirtualinherited

Save the screen contents.

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

Definition at line 806 of file graphics_abstraction_layer.h.

806 {};

◆ 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 670 of file cairo_gal.cpp.

671 {
672  storePath();
673 
674  if( isGrouping )
675  {
676  GROUP_ELEMENT groupElement;
677  groupElement.command = CMD_SCALE;
678  groupElement.argument.dblArg[0] = aScale.x;
679  groupElement.argument.dblArg[1] = aScale.y;
680  currentGroup->push_back( groupElement );
681  }
682  else
683  {
684  cairo_matrix_scale( &currentXform, aScale.x, aScale.y );
686  }
687 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1024
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:302
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:297
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:96
cairo_matrix_t currentXform
Definition: cairo_gal.h:310

References KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::argument, CMD_SCALE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, currentGroup, currentXform, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::dblArg, 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 915 of file graphics_abstraction_layer.h.

916  {
917  axesColor = aAxesColor;
918  }
COLOR4D axesColor
Color of the axes.

References KIGFX::GAL::axesColor.

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

◆ SetAxesEnabled()

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

◆ SetClearColor()

void KIGFX::GAL::SetClearColor ( const COLOR4D aColor)
inlineinherited

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

934  {
935  gridTick = aInterval;
936  }
int gridTick
Every tick line gets the double width.

References KIGFX::GAL::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  cursorColor = aCursorColor;
1009  }
COLOR4D cursorColor
Cursor color.

References KIGFX::GAL::cursorColor.

Referenced by KIGFX::GAL::GAL(), EDA_DRAW_PANEL_GAL::onPaint(), SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL(), and PCB_DRAW_PANEL_GAL::UseColorScheme().

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

988  {
989  isCursorEnabled = aCursorEnabled;
990  }
bool isCursorEnabled
Is the cursor enabled?

References KIGFX::GAL::isCursorEnabled.

Referenced by KIGFX::GAL::GAL(), 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 740 of file graphics_abstraction_layer.h.

741  {
742  depthRange = aDepthRange;
743  }
VECTOR2D depthRange
Range of the depth.

References KIGFX::GAL::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 569 of file cairo_gal.cpp.

570 {
571  storePath();
572  fillColor = aColor;
573 
574  if( isGrouping )
575  {
576  GROUP_ELEMENT groupElement;
577  groupElement.command = CMD_SET_FILLCOLOR;
578  groupElement.argument.dblArg[0] = fillColor.r;
579  groupElement.argument.dblArg[1] = fillColor.g;
580  groupElement.argument.dblArg[2] = fillColor.b;
581  groupElement.argument.dblArg[3] = fillColor.a;
582  currentGroup->push_back( groupElement );
583  }
584 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1024
double g
Green component.
Definition: color4d.h:310
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:302
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:297
double r
Red component.
Definition: color4d.h:309

References KIGFX::COLOR4D::a, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::argument, KIGFX::COLOR4D::b, CMD_SET_FILLCOLOR, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, currentGroup, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::dblArg, KIGFX::GAL::fillColor, KIGFX::COLOR4D::g, 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 777 of file graphics_abstraction_layer.h.

778  {
779  globalFlipX = xAxis;
780  globalFlipY = yAxis;
781  }
bool globalFlipX
Flag for X axis flipping.
bool globalFlipY
Flag for Y axis flipping.

References KIGFX::GAL::globalFlipX, and KIGFX::GAL::globalFlipY.

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

◆ SetFontBold()

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

Set bold property of current font.

Parameters
aBoldtells if the font should be bold or not.

Definition at line 425 of file graphics_abstraction_layer.h.

426  {
427  textProperties.m_bold = aBold;
428  }
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 ( const bool  aItalic)
inlineinherited

Set italic property of current font.

Parameters
aItalictells if the font should be italic or not.

Definition at line 443 of file graphics_abstraction_layer.h.

444  {
445  textProperties.m_italic = aItalic;
446  }
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().

◆ SetGlyphSize()

void KIGFX::GAL::SetGlyphSize ( const VECTOR2D  aGlyphSize)
inlineinherited

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

906  {
907  gridColor = aGridColor;
908  }
COLOR4D gridColor
Color of the grid.

References KIGFX::GAL::gridColor.

Referenced by CAIRO_GAL_BASE(), EDA_DRAW_PANEL_GAL::onPaint(), PCB_LAYER_WIDGET::OnRenderColorChange(), KIGFX::OPENGL_GAL::OPENGL_GAL(), SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL(), GERBVIEW_FRAME::SetGridColor(), PCB_DRAW_PANEL_GAL::UseColorScheme(), and GERBVIEW_FRAME::UseGalCanvas().

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

867  {
868  gridOrigin = aGridOrigin;
869 
870  if( gridSize.x == 0.0 || gridSize.y == 0.0 )
871  gridOffset = VECTOR2D(0.0, 0.0);
872  else
873  gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
874  (long) gridOrigin.y % (long) gridSize.y );
875  }
VECTOR2D gridOffset
The grid offset to compensate cursor position.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
VECTOR2D gridOrigin
The grid origin.
VECTOR2D gridSize
The grid size.

References KIGFX::GAL::gridOffset, KIGFX::GAL::gridOrigin, KIGFX::GAL::gridSize, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PCBNEW_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 882 of file graphics_abstraction_layer.h.

883  {
884  gridSize = aGridSize;
885 
886  gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
887  (long) gridOrigin.y % (long) gridSize.y );
888  }
VECTOR2D gridOffset
The grid offset to compensate cursor position.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
VECTOR2D gridOrigin
The grid origin.
VECTOR2D gridSize
The grid size.

References KIGFX::GAL::gridOffset, KIGFX::GAL::gridOrigin, KIGFX::GAL::gridSize, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by COMMON_TOOLS::doGridPreset(), DIALOG_PAD_PROPERTIES::prepareCanvas(), SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL(), and PCBNEW_CONTROL::updateGrid().

◆ SetGridVisibility()

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

Sets the visibility setting of the grid.

Parameters
aVisibilityis the new visibility setting of the grid.

Definition at line 856 of file graphics_abstraction_layer.h.

857  {
858  gridVisibility = aVisibility;
859  }
bool gridVisibility
Should the grid be shown.

References KIGFX::GAL::gridVisibility.

Referenced by KIGFX::GAL::GAL(), PCB_LAYER_WIDGET::OnRenderEnable(), GERBER_LAYER_WIDGET::OnRenderEnable(), DIALOG_PAD_PROPERTIES::prepareCanvas(), SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET(), and COMMON_TOOLS::ToggleGrid().

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

480  {
481  textProperties.m_horizontalJustify = aHorizontalJustify;
482  }
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::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 521 of file cairo_gal.cpp.

522 {
523  storePath();
524  isFillEnabled = aIsFillEnabled;
525 
526  if( isGrouping )
527  {
528  GROUP_ELEMENT groupElement;
529  groupElement.command = CMD_SET_FILL;
530  groupElement.argument.boolArg = aIsFillEnabled;
531  currentGroup->push_back( groupElement );
532  }
533 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1024
Enable/disable filling.
Definition: cairo_gal.h:268
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:302
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:297
bool isFillEnabled
Is filling of graphic objects enabled ?

References KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::argument, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::boolArg, CMD_SET_FILL, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, currentGroup, KIGFX::GAL::isFillEnabled, 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 536 of file cairo_gal.cpp.

537 {
538  storePath();
539  isStrokeEnabled = aIsStrokeEnabled;
540 
541  if( isGrouping )
542  {
543  GROUP_ELEMENT groupElement;
544  groupElement.command = CMD_SET_STROKE;
545  groupElement.argument.boolArg = aIsStrokeEnabled;
546  currentGroup->push_back( groupElement );
547  }
548 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1024
bool isStrokeEnabled
Are the outlines stroked ?
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:302
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:297
Enable/disable stroking.
Definition: cairo_gal.h:269

References KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::argument, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::boolArg, CMD_SET_STROKE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, currentGroup, isGrouping, KIGFX::GAL::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 606 of file cairo_gal.cpp.

607 {
608  super::SetLayerDepth( aLayerDepth );
609  storePath();
610 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1024
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.

Reimplemented in KIGFX::CAIRO_PRINT_GAL.

Definition at line 587 of file cairo_gal.cpp.

588 {
589  storePath();
590  GAL::SetLineWidth( aLineWidth );
591 
592  if( isGrouping )
593  {
594  GROUP_ELEMENT groupElement;
595  groupElement.command = CMD_SET_LINE_WIDTH;
596  groupElement.argument.dblArg[0] = aLineWidth;
597  currentGroup->push_back( groupElement );
598  }
599  else
600  {
601  lineWidth = aLineWidth;
602  }
603 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1024
virtual void SetLineWidth(float aLineWidth)
Set the line width.
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:302
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:297

References KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::argument, CMD_SET_LINE_WIDTH, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, currentGroup, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::dblArg, isGrouping, 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 677 of file graphics_abstraction_layer.h.

678  {
679  lookAtPoint = aPoint;
680  }
VECTOR2D lookAtPoint
Point to be looked at in world space.

References KIGFX::GAL::lookAtPoint.

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

◆ SetNegativeDrawMode()

void CAIRO_GAL_BASE::SetNegativeDrawMode ( bool  aSetting)
overridevirtual

Sets 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 895 of file cairo_gal.cpp.

896 {
897  cairo_set_operator( currentContext, aSetting ? CAIRO_OPERATOR_CLEAR : CAIRO_OPERATOR_OVER );
898 }
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312

References currentContext.

◆ SetRotation()

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

Set the rotation angle.

Parameters
aRotationis the new rotation angle (radians).

Definition at line 717 of file graphics_abstraction_layer.h.

718  {
719  rotation = aRotation;
720  }
double rotation
Rotation transformation (radians)

References KIGFX::GAL::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 665 of file graphics_abstraction_layer.h.

666  {
667  screenDPI = aScreenDPI;
668  }
double screenDPI
The dots per inch of the screen.

References KIGFX::GAL::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 652 of file graphics_abstraction_layer.h.

653  {
654  screenSize = aSize;
655  }
VECTOR2I screenSize
Screen size in screen coordinates.

References KIGFX::GAL::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 551 of file cairo_gal.cpp.

552 {
553  storePath();
554  strokeColor = aColor;
555 
556  if( isGrouping )
557  {
558  GROUP_ELEMENT groupElement;
559  groupElement.command = CMD_SET_STROKECOLOR;
560  groupElement.argument.dblArg[0] = strokeColor.r;
561  groupElement.argument.dblArg[1] = strokeColor.g;
562  groupElement.argument.dblArg[2] = strokeColor.b;
563  groupElement.argument.dblArg[3] = strokeColor.a;
564  currentGroup->push_back( groupElement );
565  }
566 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1024
double g
Green component.
Definition: color4d.h:310
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:302
COLOR4D strokeColor
The color of the outlines.
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:297
double r
Red component.
Definition: color4d.h:309

References KIGFX::COLOR4D::a, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::argument, KIGFX::COLOR4D::b, CMD_SET_STROKECOLOR, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, currentGroup, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::dblArg, KIGFX::COLOR4D::g, isGrouping, KIGFX::COLOR4D::r, storePath(), and KIGFX::GAL::strokeColor.

◆ SetTarget()

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

Sets the target for rendering.

Parameters
aTargetis the new target for rendering.

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

Definition at line 818 of file graphics_abstraction_layer.h.

818 {};

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

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

145 {
146  SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
149  SetFontBold( aText->IsBold() );
150  SetFontItalic( aText->IsItalic() );
151  SetTextMirrored( aText->IsMirrored() );
152 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:190
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:208
bool IsMirrored() const
Definition: eda_text.h:196
bool IsItalic() const
Definition: eda_text.h:187
void SetFontBold(const bool aBold)
Set bold property of current font.
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:207
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
const wxSize & GetTextSize() const
Definition: eda_text.h:232
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
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::SetGlyphSize(), KIGFX::GAL::SetHorizontalJustify(), KIGFX::GAL::SetTextMirrored(), and KIGFX::GAL::SetVerticalJustify().

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

◆ SetTextMirrored()

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

Set a mirrored property of text.

Parameters
aMirroredtells if the text should be mirrored or not.

Definition at line 461 of file graphics_abstraction_layer.h.

462  {
463  textProperties.m_mirrored = aMirrored;
464  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties

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

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

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

498  {
499  textProperties.m_verticalJustify = aVerticalJustify;
500  }
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 633 of file graphics_abstraction_layer.h.

634  {
635  worldScreenMatrix = aMatrix;
636  }
MATRIX3x3D worldScreenMatrix
World transformation.

References KIGFX::GAL::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 647 of file graphics_abstraction_layer.h.

648  {
649  worldUnitLength = aWorldUnitLength;
650  }
double worldUnitLength
The unit length of the world coordinates [inch].

References KIGFX::GAL::worldUnitLength.

Referenced by KIGFX::GAL::GAL(), GERBVIEW_DRAW_PANEL_GAL::GERBVIEW_DRAW_PANEL_GAL(), SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL(), GERBVIEW_PRINTOUT::setupGal(), PCBNEW_PRINTOUT::setupGal(), GERBVIEW_DRAW_PANEL_GAL::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 697 of file graphics_abstraction_layer.h.

698  {
699  zoomFactor = aZoomFactor;
700  }
double zoomFactor
The zoom factor.

References KIGFX::GAL::zoomFactor.

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

◆ Show()

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

Shows/hides the GAL canvas.

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

Definition at line 199 of file graphics_abstraction_layer.h.

199 { return true; };

◆ storePath()

void CAIRO_GAL_BASE::storePath ( )
protected

Store the actual path.

Definition at line 1024 of file cairo_gal.cpp.

1025 {
1026  if( isElementAdded )
1027  {
1028  isElementAdded = false;
1029 
1030  if( !isGrouping )
1031  {
1032  if( isFillEnabled )
1033  {
1034  cairo_set_source_rgba( currentContext, fillColor.r, fillColor.g, fillColor.b, fillColor.a );
1035  cairo_fill_preserve( currentContext );
1036  }
1037 
1038  if( isStrokeEnabled )
1039  {
1040  cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g,
1042  cairo_stroke_preserve( currentContext );
1043  }
1044  }
1045  else
1046  {
1047  // Copy the actual path, append it to the global path list
1048  // then check, if the path needs to be stroked/filled and
1049  // add this command to the group list;
1050  if( isStrokeEnabled )
1051  {
1052  GROUP_ELEMENT groupElement;
1053  groupElement.cairoPath = cairo_copy_path( currentContext );
1054  groupElement.command = CMD_STROKE_PATH;
1055  currentGroup->push_back( groupElement );
1056  }
1057 
1058  if( isFillEnabled )
1059  {
1060  GROUP_ELEMENT groupElement;
1061  groupElement.cairoPath = cairo_copy_path( currentContext );
1062  groupElement.command = CMD_FILL_PATH;
1063  currentGroup->push_back( groupElement );
1064  }
1065  }
1066 
1067  cairo_new_path( currentContext );
1068  }
1069 }
double g
Green component.
Definition: color4d.h:310
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
bool isStrokeEnabled
Are the outlines stroked ?
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:302
COLOR4D strokeColor
The color of the outlines.
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:297
bool isFillEnabled
Is filling of graphic objects enabled ?
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312
double r
Red component.
Definition: color4d.h:309
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:298

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::cairoPath, CMD_FILL_PATH, CMD_STROKE_PATH, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, currentContext, currentGroup, KIGFX::GAL::fillColor, KIGFX::COLOR4D::g, isElementAdded, KIGFX::GAL::isFillEnabled, isGrouping, KIGFX::GAL::isStrokeEnabled, KIGFX::COLOR4D::r, and KIGFX::GAL::strokeColor.

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

◆ StrokeText()

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

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

341  {
342  strokeFont.Draw( aText, aPosition, aRotationAngle );
343  }
STROKE_FONT 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::strokeFont.

Referenced by KIGFX::GAL::BitmapText(), KIGFX::SCH_PAINTER::Draw(), KIGFX::SCH_PAINTER::draw(), KIGFX::WORKSHEET_VIEWITEM::draw(), KIGFX::PCB_PAINTER::draw(), and DrawGraphicText().

◆ syncLineWidth()

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

Definition at line 191 of file cairo_gal.cpp.

192 {
193  auto w = floor( xform( aForceWidth ? aWidth : lineWidth ) + 0.5 );
194 
195  if (w <= 1.0)
196  {
197  w = 1.0;
198  cairo_set_line_join( currentContext, CAIRO_LINE_JOIN_MITER );
199  cairo_set_line_cap( currentContext, CAIRO_LINE_CAP_BUTT );
200  cairo_set_line_width( currentContext, 1.0 );
201  lineWidthIsOdd = true;
202  }
203  else
204  {
205  cairo_set_line_join( currentContext, CAIRO_LINE_JOIN_ROUND );
206  cairo_set_line_cap( currentContext, CAIRO_LINE_CAP_ROUND );
207  cairo_set_line_width( currentContext, w );
208  lineWidthIsOdd = ((int)w % 2) == 1;
209  }
210 
211  lineWidthInPixels = w;
212 }
const double xform(double x)
Definition: cairo_gal.cpp:154
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:312

References currentContext, lineWidth, lineWidthInPixels, 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 pointposition in world coordinates.
Returns
the point position in screen coordinates.

Definition at line 977 of file graphics_abstraction_layer.h.

978  {
979  return VECTOR2D( worldScreenMatrix * aPoint );
980  }
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
MATRIX3x3D worldScreenMatrix
World transformation.

References KIGFX::GAL::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 pointposition in screen coordinates.
Returns
the point position in world coordinates.

Definition at line 966 of file graphics_abstraction_layer.h.

967  {
968  return VECTOR2D( screenWorldMatrix * aPoint );
969  }
MATRIX3x3D screenWorldMatrix
Screen transformation.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586

References KIGFX::GAL::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 613 of file cairo_gal.cpp.

614 {
615  cairo_matrix_t cairoTransformation, newXform;
616 
617  cairo_matrix_init( &cairoTransformation,
618  aTransformation.m_data[0][0],
619  aTransformation.m_data[1][0],
620  aTransformation.m_data[0][1],
621  aTransformation.m_data[1][1],
622  aTransformation.m_data[0][2],
623  aTransformation.m_data[1][2] );
624 
625  cairo_matrix_multiply( &newXform, &currentXform, &cairoTransformation );
626  currentXform = newXform;
628 }
T m_data[3][3]
Definition: matrix3x3.h:64
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:96
cairo_matrix_t currentXform
Definition: cairo_gal.h:310

References 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 650 of file cairo_gal.cpp.

651 {
652  storePath();
653 
654  if( isGrouping )
655  {
656  GROUP_ELEMENT groupElement;
657  groupElement.command = CMD_TRANSLATE;
658  groupElement.argument.dblArg[0] = aTranslation.x;
659  groupElement.argument.dblArg[1] = aTranslation.y;
660  currentGroup->push_back( groupElement );
661  }
662  else
663  {
664  cairo_matrix_translate ( &currentXform, aTranslation.x, aTranslation.y );
666  }
667 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1024
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:302
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:297
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:96
cairo_matrix_t currentXform
Definition: cairo_gal.h:310
Translate the context.
Definition: cairo_gal.h:277

References KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::argument, CMD_TRANSLATE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, currentGroup, currentXform, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::dblArg, 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 1106 of file graphics_abstraction_layer.h.

1106 {}

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

◆ updatedGalDisplayOptions()

bool GAL::updatedGalDisplayOptions ( const GAL_DISPLAY_OPTIONS aOptions)
protectedvirtualinherited

Function updatedGalDisplayOptions.

handler for updated 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 99 of file graphics_abstraction_layer.cpp.

100 {
101  bool refresh = false;
102 
103  if( options.m_gridStyle != gridStyle )
104  {
106  refresh = true;
107  }
108 
110  {
111  gridLineWidth = std::floor( options.m_gridLineWidth + 0.5 );
112  refresh = true;
113  }
114 
116  {
118  refresh = true;
119  }
120 
122  {
124  refresh = true;
125  }
126 
128  {
130  refresh = true;
131  }
132 
134  {
136  refresh = true;
137  }
138 
139  // tell the derived class if the base class needs an update or not
140  return refresh;
141 }
bool axesEnabled
Should the axes be drawn.
KIGFX::GRID_STYLE m_gridStyle
The grid style to draw the grid in
int gridMinSpacing
Minimum screen size of the grid (pixels) below which the grid is not drawn.
GRID_STYLE gridStyle
Grid display style.
GAL_DISPLAY_OPTIONS & options
bool m_forceDisplayCursor
Force cursor display
double m_gridMinSpacing
Minimum pixel distance between displayed grid lines
bool m_axesEnabled
Whether or not to draw the coordinate system axes
bool fullscreenCursor
Shape of the cursor (fullscreen or small cross)
float gridLineWidth
Line width of the grid.
double m_gridLineWidth
Thickness to render grid lines/dots
bool m_fullscreenCursor
Fullscreen crosshair or small cross
bool forceDisplayCursor
Always show cursor.

References KIGFX::GAL::axesEnabled, KIGFX::GAL::forceDisplayCursor, KIGFX::GAL::fullscreenCursor, KIGFX::GAL::gridLineWidth, KIGFX::GAL::gridMinSpacing, KIGFX::GAL::gridStyle, KIGFX::GAL_DISPLAY_OPTIONS::m_axesEnabled, KIGFX::GAL_DISPLAY_OPTIONS::m_forceDisplayCursor, KIGFX::GAL_DISPLAY_OPTIONS::m_fullscreenCursor, KIGFX::GAL_DISPLAY_OPTIONS::m_gridLineWidth, KIGFX::GAL_DISPLAY_OPTIONS::m_gridMinSpacing, KIGFX::GAL_DISPLAY_OPTIONS::m_gridStyle, and KIGFX::GAL::options.

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

◆ updateWorldScreenMatrix()

void CAIRO_GAL_BASE::updateWorldScreenMatrix ( )
protected

Definition at line 96 of file cairo_gal.cpp.

97 {
98  cairo_matrix_multiply( &currentWorld2Screen, &currentXform, &cairoWorldScreenMatrix );
99 }
cairo_matrix_t currentXform
Definition: cairo_gal.h:310
cairo_matrix_t cairoWorldScreenMatrix
Cairo world to screen transformation matrix.
Definition: cairo_gal.h:309
cairo_matrix_t currentWorld2Screen
Definition: cairo_gal.h:311

References cairoWorldScreenMatrix, currentWorld2Screen, and 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 154 of file cairo_gal.cpp.

155 {
156  double dx = currentWorld2Screen.xx * x;
157  double dy = currentWorld2Screen.yx * x;
158  return sqrt( dx * dx + dy * dy );
159 }
cairo_matrix_t currentWorld2Screen
Definition: cairo_gal.h:311

References 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 102 of file cairo_gal.cpp.

103 {
104  VECTOR2D rv;
105 
108  return rv;
109 }
cairo_matrix_t currentWorld2Screen
Definition: cairo_gal.h:311

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

◆ xform() [3/3]

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

Definition at line 112 of file cairo_gal.cpp.

113 {
114  return xform( aP.x, aP.y );
115 }
const double xform(double x)
Definition: cairo_gal.cpp:154

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

Member Data Documentation

◆ axesColor

COLOR4D KIGFX::GAL::axesColor
protectedinherited

Color of the axes.

Definition at line 1086 of file graphics_abstraction_layer.h.

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

◆ axesEnabled

bool KIGFX::GAL::axesEnabled
protectedinherited

◆ cairoWorldScreenMatrix

cairo_matrix_t KIGFX::CAIRO_GAL_BASE::cairoWorldScreenMatrix
protected

Cairo world to screen transformation matrix.

Definition at line 309 of file cairo_gal.h.

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

◆ context

◆ currentContext

◆ currentGroup

GROUP* KIGFX::CAIRO_GAL_BASE::currentGroup
protected

◆ currentWorld2Screen

cairo_matrix_t KIGFX::CAIRO_GAL_BASE::currentWorld2Screen
protected

Definition at line 311 of file cairo_gal.h.

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

◆ currentXform

cairo_matrix_t KIGFX::CAIRO_GAL_BASE::currentXform
protected

◆ cursorColor

COLOR4D KIGFX::GAL::cursorColor
protectedinherited

Cursor color.

Definition at line 1096 of file graphics_abstraction_layer.h.

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

◆ cursorPosition

VECTOR2D KIGFX::GAL::cursorPosition
protectedinherited

Current cursor position (world coordinates)

Definition at line 1098 of file graphics_abstraction_layer.h.

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

◆ depthRange

◆ depthStack

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

Stored depth values.

Definition at line 1051 of file graphics_abstraction_layer.h.

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

◆ fillColor

◆ forceDisplayCursor

bool KIGFX::GAL::forceDisplayCursor
protectedinherited

◆ fullscreenCursor

bool KIGFX::GAL::fullscreenCursor
protectedinherited

Shape of the cursor (fullscreen or small cross)

Definition at line 1097 of file graphics_abstraction_layer.h.

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

◆ GAL_FORMAT

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

Format used to store pixels.

Definition at line 344 of file cairo_gal.h.

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

◆ globalFlipX

◆ globalFlipY

bool KIGFX::GAL::globalFlipY
protectedinherited

◆ GRID_DEPTH

const int GAL::GRID_DEPTH = MAX_DEPTH - 1
staticprotectedinherited

Depth level on which the grid is drawn.

Definition at line 1141 of file graphics_abstraction_layer.h.

◆ gridColor

COLOR4D KIGFX::GAL::gridColor
protectedinherited

◆ gridLineWidth

float KIGFX::GAL::gridLineWidth
protectedinherited

◆ gridMinSpacing

int KIGFX::GAL::gridMinSpacing
protectedinherited

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

Definition at line 1090 of file graphics_abstraction_layer.h.

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

◆ gridOffset

VECTOR2D KIGFX::GAL::gridOffset
protectedinherited

The grid offset to compensate cursor position.

Definition at line 1084 of file graphics_abstraction_layer.h.

Referenced by KIGFX::GAL::GetGridPoint(), KIGFX::GAL::SetGridOrigin(), and KIGFX::GAL::SetGridSize().

◆ gridOrigin

VECTOR2D KIGFX::GAL::gridOrigin
protectedinherited

◆ gridSize

◆ gridStyle

GRID_STYLE KIGFX::GAL::gridStyle
protectedinherited

◆ gridTick

int KIGFX::GAL::gridTick
protectedinherited

Every tick line gets the double width.

Definition at line 1088 of file graphics_abstraction_layer.h.

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

◆ gridVisibility

bool KIGFX::GAL::gridVisibility
protectedinherited

Should the grid be shown.

Definition at line 1080 of file graphics_abstraction_layer.h.

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

◆ groupCounter

unsigned int KIGFX::CAIRO_GAL_BASE::groupCounter
protected

Counter used for generating keys for groups.

Definition at line 301 of file cairo_gal.h.

Referenced by CAIRO_GAL_BASE(), and getNewGroupNumber().

◆ groups

std::map<int, GROUP> KIGFX::CAIRO_GAL_BASE::groups
protected

List of graphic groups.

Definition at line 300 of file cairo_gal.h.

Referenced by BeginGroup(), ChangeGroupColor(), ClearCache(), DeleteGroup(), DrawGroup(), and getNewGroupNumber().

◆ isCursorEnabled

bool KIGFX::GAL::isCursorEnabled
protectedinherited

◆ isElementAdded

bool KIGFX::CAIRO_GAL_BASE::isElementAdded
protected

◆ isFillEnabled

◆ isGrouping

bool KIGFX::CAIRO_GAL_BASE::isGrouping
protected

◆ isStrokeEnabled

◆ layerDepth

◆ linePixelWidth

double KIGFX::CAIRO_GAL_BASE::linePixelWidth
protected

Definition at line 305 of file cairo_gal.h.

Referenced by CAIRO_GAL_BASE().

◆ lineWidth

double KIGFX::CAIRO_GAL_BASE::lineWidth
protected

◆ lineWidthInPixels

double KIGFX::CAIRO_GAL_BASE::lineWidthInPixels
protected

Definition at line 306 of file cairo_gal.h.

Referenced by CAIRO_GAL_BASE(), DrawArc(), DrawCircle(), drawGridCross(), and syncLineWidth().

◆ lineWidthIsOdd

bool KIGFX::CAIRO_GAL_BASE::lineWidthIsOdd
protected

Definition at line 307 of file cairo_gal.h.

Referenced by CAIRO_GAL_BASE(), DrawArc(), DrawArcSegment(), roundp(), and syncLineWidth().

◆ lookAtPoint

◆ m_clearColor

◆ MAX_CAIRO_ARGUMENTS

const int KIGFX::CAIRO_GAL_BASE::MAX_CAIRO_ARGUMENTS = 4
staticprotected

Maximum number of arguments for one command.

Definition at line 263 of file cairo_gal.h.

◆ MAX_DEPTH

const int GAL::MAX_DEPTH = 1023
staticprotectedinherited

Definition at line 1138 of file graphics_abstraction_layer.h.

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

◆ MIN_DEPTH

const int GAL::MIN_DEPTH = -1024
staticprotectedinherited

Possible depth range.

Definition at line 1137 of file graphics_abstraction_layer.h.

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

◆ observerLink

UTIL::LINK KIGFX::GAL::observerLink
protectedinherited

Definition at line 1049 of file graphics_abstraction_layer.h.

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

◆ options

◆ rotation

double KIGFX::GAL::rotation
protectedinherited

Rotation transformation (radians)

Definition at line 1059 of file graphics_abstraction_layer.h.

Referenced by KIGFX::GAL::ComputeWorldScreenMatrix(), KIGFX::GAL::GetRotation(), and KIGFX::GAL::SetRotation().

◆ screenDPI

double KIGFX::GAL::screenDPI
protectedinherited

◆ screenSize

◆ screenWorldMatrix

◆ strokeColor

◆ strokeFont

STROKE_FONT KIGFX::GAL::strokeFont
protectedinherited

Instance of object that stores information about how to draw texts.

Definition at line 1101 of file graphics_abstraction_layer.h.

Referenced by KIGFX::GAL::GAL(), KIGFX::GAL::GetOverbarVerticalPosition(), KIGFX::GAL::GetStrokeFont(), KIGFX::GAL::GetTextLineSize(), and KIGFX::GAL::StrokeText().

◆ surface

cairo_surface_t* KIGFX::CAIRO_GAL_BASE::surface
protected

◆ worldScale

◆ worldScreenMatrix

◆ worldUnitLength

double KIGFX::GAL::worldUnitLength
protectedinherited

◆ xformStack

std::vector<cairo_matrix_t> KIGFX::CAIRO_GAL_BASE::xformStack
protected

Definition at line 316 of file cairo_gal.h.

Referenced by Restore(), and Save().

◆ zoomFactor

double KIGFX::GAL::zoomFactor
protectedinherited

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