KiCad PCB EDA Suite
KIGFX::CAIRO_PRINT_GAL Class Reference

#include <cairo_print.h>

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

Public Member Functions

 CAIRO_PRINT_GAL (GAL_DISPLAY_OPTIONS &aDisplayOptions, std::unique_ptr< CAIRO_PRINT_CTX > aContext)
 
void ComputeWorldScreenMatrix () override
 Compute the world <-> screen transformation matrix. More...
 
GALGetGAL () override
 
PRINT_CONTEXTGetPrintCtx () const override
 
void SetNativePaperSize (const VECTOR2D &aSize, bool aRotateIfLandscape) override
 
void SetSheetSize (const VECTOR2D &aSize) override
 
bool IsCairoEngine () override
 Return true if the GAL engine is a Cairo based type. More...
 
void DrawLine (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint) override
 Draw a line. More...
 
void DrawSegment (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth) override
 Draw a rounded segment. More...
 
void DrawCircle (const VECTOR2D &aCenterPoint, double aRadius) override
 Draw a circle using world coordinates. More...
 
void DrawArc (const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle) override
 Draw an arc. More...
 
void DrawArcSegment (const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth, double aMaxError) override
 Draw an arc segment. More...
 
void DrawRectangle (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint) override
 Draw a rectangle. More...
 
void DrawPolyline (const std::deque< VECTOR2D > &aPointList) override
 Draw a polyline. More...
 
void DrawPolyline (const VECTOR2D aPointList[], int aListSize) override
 
void DrawPolyline (const SHAPE_LINE_CHAIN &aLineChain) override
 
void DrawPolygon (const std::deque< VECTOR2D > &aPointList) override
 Draw a polygon. More...
 
void DrawPolygon (const VECTOR2D aPointList[], int aListSize) override
 
void DrawPolygon (const SHAPE_POLY_SET &aPolySet, bool aStrokeTriangulation=false) override
 
void DrawPolygon (const SHAPE_LINE_CHAIN &aPolySet) override
 
void DrawCurve (const VECTOR2D &startPoint, const VECTOR2D &controlPointA, const VECTOR2D &controlPointB, const VECTOR2D &endPoint, double aFilterValue=0.0) override
 Draw a cubic bezier spline. More...
 
void DrawBitmap (const BITMAP_BASE &aBitmap) override
 Draw a bitmap image. More...
 
void ResizeScreen (int aWidth, int aHeight) override
 Resizes the canvas. More...
 
void Flush () override
 Force all remaining objects to be drawn. More...
 
void ClearScreen () override
 Clear the screen. More...
 
void SetIsFill (bool aIsFillEnabled) override
 Enable/disable fill. More...
 
void SetIsStroke (bool aIsStrokeEnabled) override
 Enable/disable stroked outlines. More...
 
void SetStrokeColor (const COLOR4D &aColor) override
 Set the stroke color. More...
 
void SetFillColor (const COLOR4D &aColor) override
 Set the fill color. More...
 
void SetLineWidth (float aLineWidth) override
 Set the line width. More...
 
void SetLayerDepth (double aLayerDepth) override
 Set the depth of the layer (position on the z-axis) More...
 
void Transform (const MATRIX3x3D &aTransformation) override
 Transform the context. More...
 
void Rotate (double aAngle) override
 Rotate the context. More...
 
void Translate (const VECTOR2D &aTranslation) override
 Translate the context. More...
 
void Scale (const VECTOR2D &aScale) override
 Scale the context. More...
 
void Save () override
 Save the context. More...
 
void Restore () override
 Restore the context. More...
 
int BeginGroup () override
 Begin a group. More...
 
void EndGroup () override
 End the group. More...
 
void DrawGroup (int aGroupNumber) override
 Draw the stored group. More...
 
void ChangeGroupColor (int aGroupNumber, const COLOR4D &aNewColor) override
 Change the color used to draw the group. More...
 
void ChangeGroupDepth (int aGroupNumber, int aDepth) override
 Change the depth (Z-axis position) of the group. More...
 
void DeleteGroup (int aGroupNumber) override
 Delete the group from the memory. More...
 
void ClearCache () override
 Delete all data created during caching of graphic items. More...
 
void SetNegativeDrawMode (bool aSetting) override
 Set negative draw mode in the renderer. More...
 
void DrawCursor (const VECTOR2D &aCursorPosition) override
 Draw the cursor. More...
 
void EnableDepthTest (bool aEnabled=false) override
 
void DrawGrid () override
 
virtual bool IsInitialized () const
 Return the initialization status for the canvas. More...
 
virtual bool IsVisible () const
 Return true if the GAL canvas is visible on the screen. More...
 
virtual bool IsOpenGlEngine ()
 Return true if the GAL engine is a OpenGL based type. More...
 
virtual bool Show (bool aShow)
 Show/hide the GAL canvas. More...
 
const VECTOR2IGetScreenPixelSize () const
 Return GAL canvas size in pixels. More...
 
void SetClearColor (const COLOR4D &aColor)
 
const COLOR4DGetClearColor () const
 
const COLOR4DGetFillColor () const
 Get the fill color. More...
 
const COLOR4DGetStrokeColor () const
 Get the stroke color. More...
 
float GetLineWidth () const
 Get the line width. More...
 
const STROKE_FONTGetStrokeFont () const
 
virtual void StrokeText (const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
 Draw a vector type text using preloaded Newstroke font. More...
 
virtual void BitmapText (const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
 Draw a text using a bitmap font. More...
 
VECTOR2D GetTextLineSize (const UTF8 &aText) const
 Compute the X and Y size of a given text. More...
 
virtual void SetTextAttributes (const EDA_TEXT *aText)
 Loads attributes of the given text (bold/italic/underline/mirrored and so on). More...
 
void ResetTextAttributes ()
 Reset text attributes to default styling. More...
 
void SetGlyphSize (const VECTOR2D &aSize)
 Set the font glyph size. More...
 
const VECTOR2DGetGlyphSize () const
 
void SetFontBold (bool aBold)
 Set bold property of current font. More...
 
bool IsFontBold () const
 
void SetFontItalic (bool aItalic)
 Set italic property of current font. More...
 
bool IsFontItalic () const
 
void SetFontUnderlined (bool aUnderlined)
 
bool IsFontUnderlined () const
 
void SetTextMirrored (bool aMirrored)
 Set a mirrored property of text. More...
 
bool IsTextMirrored () const
 
void SetHorizontalJustify (const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
 Set the horizontal justify for text drawing. More...
 
EDA_TEXT_HJUSTIFY_T GetHorizontalJustify () const
 Return current text horizontal justification setting. More...
 
void SetVerticalJustify (const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
 Set the vertical justify for text drawing. More...
 
EDA_TEXT_VJUSTIFY_T GetVerticalJustify () const
 Returns current text vertical justification setting. More...
 
const MATRIX3x3DGetWorldScreenMatrix () const
 Get the world <-> screen transformation matrix. More...
 
const MATRIX3x3DGetScreenWorldMatrix () const
 Get the screen <-> world transformation matrix. More...
 
void SetWorldScreenMatrix (const MATRIX3x3D &aMatrix)
 Set the world <-> screen transformation matrix. More...
 
BOX2D GetVisibleWorldExtents () const
 
void SetWorldUnitLength (double aWorldUnitLength)
 Set the unit length. More...
 
void SetScreenSize (const VECTOR2I &aSize)
 
void SetScreenDPI (double aScreenDPI)
 Set the dots per inch of the screen. More...
 
void SetLookAtPoint (const VECTOR2D &aPoint)
 Set the Point in world space to look at. More...
 
const VECTOR2DGetLookAtPoint () const
 Get the look at point. More...
 
void SetZoomFactor (double aZoomFactor)
 Set the zoom factor of the scene. More...
 
double GetZoomFactor () const
 Get the zoom factor. More...
 
void SetRotation (double aRotation)
 Set the rotation angle. More...
 
double GetRotation () const
 Get the rotation angle. More...
 
void SetDepthRange (const VECTOR2D &aDepthRange)
 Set the range of the layer depth. More...
 
double GetMinDepth () const
 Return the minimum depth in the currently used range (the top). More...
 
double GetMaxDepth () const
 Return the maximum depth in the currently used range (the bottom). More...
 
double GetWorldScale () const
 Get the world scale. More...
 
void SetFlip (bool xAxis, bool yAxis)
 Sets flipping of the screen. More...
 
bool IsFlippedX () const
 Return true if flip flag for the X axis is set. More...
 
bool IsFlippedY () const
 Return true if flip flag for the Y axis is set. More...
 
virtual void SetTarget (RENDER_TARGET aTarget)
 Set the target for rendering. More...
 
virtual RENDER_TARGET GetTarget () const
 Get the currently used target for rendering. More...
 
virtual void ClearTarget (RENDER_TARGET aTarget)
 Clear the target for rendering. More...
 
virtual bool HasTarget (RENDER_TARGET aTarget)
 Return true if the target exists. More...
 
virtual void StartDiffLayer ()
 Begins rendering of a differential layer. More...
 
virtual void EndDiffLayer ()
 Ends rendering of a differential layer. More...
 
virtual void StartNegativesLayer ()
 Begins rendering in a new layer that will be copied to the main layer in EndNegativesLayer(). More...
 
virtual void EndNegativesLayer ()
 Ends rendering of a negatives layer and draws it to the main layer. More...
 
void SetGridVisibility (bool aVisibility)
 Set the visibility setting of the grid. More...
 
bool GetGridVisibility () const
 
bool GetGridSnapping () const
 
void SetGridOrigin (const VECTOR2D &aGridOrigin)
 Set the origin point for the grid. More...
 
const VECTOR2DGetGridOrigin () const
 
void SetGridSize (const VECTOR2D &aGridSize)
 Set the grid size. More...
 
const VECTOR2DGetGridSize () const
 Return the grid size. More...
 
void SetGridColor (const COLOR4D &aGridColor)
 Set the grid color. More...
 
void SetAxesColor (const COLOR4D &aAxesColor)
 Set the axes color. More...
 
void SetAxesEnabled (bool aAxesEnabled)
 Enable drawing the axes. More...
 
void SetCoarseGrid (int aInterval)
 Draw every tick line wider. More...
 
float GetGridLineWidth () const
 Get the grid line width. More...
 
VECTOR2D GetGridPoint (const VECTOR2D &aPoint) const
 For a given point it returns the nearest point belonging to the grid in world coordinates. More...
 
VECTOR2D ToWorld (const VECTOR2D &aPoint) const
 Compute the point position in world coordinates from given screen coordinates. More...
 
VECTOR2D ToScreen (const VECTOR2D &aPoint) const
 Compute the point position in screen coordinates from given world coordinates. More...
 
virtual bool SetNativeCursorStyle (KICURSOR aCursor)
 Set the cursor in the native panel. More...
 
void SetCursorEnabled (bool aCursorEnabled)
 Enable/disable cursor. More...
 
bool IsCursorEnabled () const
 Return information about cursor visibility. More...
 
void SetCursorColor (const COLOR4D &aCursorColor)
 Set the cursor color. More...
 
void AdvanceDepth ()
 Change the current depth to deeper, so it is possible to draw objects right beneath other. More...
 
void PushDepth ()
 Store current drawing depth on the depth stack. More...
 
void PopDepth ()
 Restore previously stored drawing depth for the depth stack. More...
 
virtual bool IsContextLocked ()
 Checks the state of the context lock. More...
 

Protected Types

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

Protected Member Functions

const double xform (double x)
 
const VECTOR2D xform (double x, double y)
 
const VECTOR2D xform (const VECTOR2D &aP)
 
const double angle_xform (const double aAngle)
 Transform according to the rotation from m_currentWorld2Screen transform matrix. More...
 
void arc_angles_xform_and_normalize (double &aStartAngle, double &aEndAngle)
 Transform according to the rotation from m_currentWorld2Screen transform matrix for the start angle and the end angle of an arc. More...
 
void beginDrawing () override
 
void endDrawing () override
 
void resetContext ()
 
void drawGridLine (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
 Draw a grid line (usually a simplified line function). More...
 
void drawGridCross (const VECTOR2D &aPoint)
 
void drawGridPoint (const VECTOR2D &aPoint, double aWidth, double aHeight)
 
void drawAxes (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
 
void flushPath ()
 
void storePath ()
 Store the actual path. More...
 
void blitCursor (wxMemoryDC &clientDC)
 Blit cursor into the current screen. More...
 
void drawPoly (const std::deque< VECTOR2D > &aPointList)
 Drawing polygons & polylines is the same in Cairo, so here is the common code. More...
 
void drawPoly (const VECTOR2D aPointList[], int aListSize)
 
void drawPoly (const SHAPE_LINE_CHAIN &aLineChain)
 
unsigned int getNewGroupNumber ()
 Return a valid key that can be used as a new group number. More...
 
void syncLineWidth (bool aForceWidth=false, double aWidth=0.0)
 
void updateWorldScreenMatrix ()
 
const VECTOR2D roundp (const VECTOR2D &v)
 
virtual void lockContext (int aClientCookie)
 Use GAL_CONTEXT_LOCKER RAII object. More...
 
virtual void unlockContext (int aClientCookie)
 
virtual void beginUpdate ()
 Enable item update mode. More...
 
virtual void endUpdate ()
 Disable item update mode. More...
 
void computeWorldScale ()
 Compute the scaling factor for the world->screen matrix. More...
 
double computeMinGridSpacing () const
 compute minimum grid spacing from the grid settings More...
 
COLOR4D getCursorColor () const
 Get the actual cursor color to draw. More...
 
void OnGalDisplayOptionsChanged (const GAL_DISPLAY_OPTIONS &aOptions) override
 Handler for observer settings changes. More...
 
virtual bool updatedGalDisplayOptions (const GAL_DISPLAY_OPTIONS &aOptions)
 Handle updating display options. More...
 

Protected Attributes

bool m_isGrouping
 Is grouping enabled ? More...
 
bool m_isElementAdded
 Was an graphic element added ? More...
 
std::map< int, GROUPm_groups
 List of graphic groups. More...
 
unsigned int m_groupCounter
 Counter used for generating group keys. More...
 
GROUPm_currentGroup
 Currently used group. More...
 
double m_lineWidthInPixels
 
bool m_lineWidthIsOdd
 
cairo_matrix_t m_cairoWorldScreenMatrix
 Cairo world to screen transform matrix. More...
 
cairo_matrix_t m_currentXform
 
cairo_matrix_t m_currentWorld2Screen
 
cairo_t * m_currentContext
 Currently used Cairo context for drawing. More...
 
cairo_t * m_context
 Cairo image. More...
 
cairo_surface_t * m_surface
 Cairo surface. More...
 
std::vector< cairo_surface_t * > m_imageSurfaces
 List of surfaces that were created by painting images, to be cleaned up later. More...
 
std::vector< cairo_matrix_t > m_xformStack
 
GAL_DISPLAY_OPTIONSm_options
 
UTIL::LINK m_observerLink
 
std::stack< double > m_depthStack
 Stored depth values. More...
 
VECTOR2I m_screenSize
 Screen size in screen coordinates. More...
 
double m_worldUnitLength
 The unit length of the world coordinates [inch]. More...
 
double m_screenDPI
 The dots per inch of the screen. More...
 
VECTOR2D m_lookAtPoint
 Point to be looked at in world space. More...
 
double m_zoomFactor
 The zoom factor. More...
 
double m_rotation
 Rotation transformation (radians) More...
 
MATRIX3x3D m_worldScreenMatrix
 World transformation. More...
 
MATRIX3x3D m_screenWorldMatrix
 Screen transformation. More...
 
double m_worldScale
 The scale factor world->screen. More...
 
bool m_globalFlipX
 Flag for X axis flipping. More...
 
bool m_globalFlipY
 Flag for Y axis flipping. More...
 
float m_lineWidth
 The line width. More...
 
bool m_isFillEnabled
 Is filling of graphic objects enabled ? More...
 
bool m_isStrokeEnabled
 Are the outlines stroked ? More...
 
COLOR4D m_fillColor
 The fill color. More...
 
COLOR4D m_strokeColor
 The color of the outlines. More...
 
COLOR4D m_clearColor
 
double m_layerDepth
 The actual layer depth. More...
 
VECTOR2D m_depthRange
 Range of the depth. More...
 
bool m_gridVisibility
 Should the grid be shown. More...
 
GRID_STYLE m_gridStyle
 Grid display style. More...
 
VECTOR2D m_gridSize
 The grid size. More...
 
VECTOR2D m_gridOrigin
 The grid origin. More...
 
VECTOR2D m_gridOffset
 The grid offset to compensate cursor position. More...
 
COLOR4D m_gridColor
 Color of the grid. More...
 
COLOR4D m_axesColor
 Color of the axes. More...
 
bool m_axesEnabled
 Should the axes be drawn. More...
 
int m_gridTick
 Every tick line gets the double width. More...
 
float m_gridLineWidth
 Line width of the grid. More...
 
int m_gridMinSpacing
 Minimum screen size of the grid (pixels) below which the grid is not drawn. More...
 
bool m_isCursorEnabled
 Is the cursor enabled? More...
 
bool m_forceDisplayCursor
 Always show cursor. More...
 
COLOR4D m_cursorColor
 Cursor color. More...
 
bool m_fullscreenCursor
 Shape of the cursor (fullscreen or small cross) More...
 
VECTOR2D m_cursorPosition
 Current cursor position (world coordinates) More...
 
STROKE_FONT m_strokeFont
 Instance of object that stores information about how to draw texts. More...
 
KICURSOR m_currentNativeCursor
 Current cursor. More...
 

Static Protected Attributes

static const int MAX_CAIRO_ARGUMENTS = 4
 Maximum number of arguments for one command. More...
 
static constexpr cairo_format_t GAL_FORMAT = CAIRO_FORMAT_ARGB32
 Format used to store pixels. More...
 
static const int MIN_DEPTH = -1024
 Possible depth range. More...
 
static const int MAX_DEPTH = 1023
 
static const int GRID_DEPTH = MAX_DEPTH - 1
 Depth level on which the grid is drawn. More...
 

Private Member Functions

bool isLandscape () const
 < Returns true if page orientation is landscape More...
 

Private Attributes

VECTOR2D m_nativePaperSize
 Flag indicating whether the platform rotates page automatically or GAL needs to handle it in the transformation matrix. More...
 
bool m_hasNativeLandscapeRotation
 
std::unique_ptr< CAIRO_PRINT_CTXm_printCtx
 

Detailed Description

Definition at line 82 of file cairo_print.h.

Member Typedef Documentation

◆ GROUP

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

A graphic group type definition.

Definition at line 326 of file cairo_gal.h.

◆ super

typedef GAL KIGFX::CAIRO_GAL_BASE::super
protectedinherited

Super class definition.

Definition at line 290 of file cairo_gal.h.

Member Enumeration Documentation

◆ GRAPHICS_COMMAND

enum KIGFX::CAIRO_GAL_BASE::GRAPHICS_COMMAND
protectedinherited

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

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

Constructor & Destructor Documentation

◆ CAIRO_PRINT_GAL()

CAIRO_PRINT_GAL::CAIRO_PRINT_GAL ( GAL_DISPLAY_OPTIONS aDisplayOptions,
std::unique_ptr< CAIRO_PRINT_CTX aContext 
)

Definition at line 134 of file cairo_print.cpp.

135  :
136  CAIRO_GAL_BASE( aDisplayOptions )
137 {
138  m_printCtx = std::move( aContext );
139  m_context = m_currentContext = m_printCtx->GetContext();
140  m_surface = m_printCtx->GetSurface();
141  cairo_reference( m_context );
142  cairo_surface_reference( m_surface );
143  m_clearColor = COLOR4D( 1.0, 1.0, 1.0, 1.0 );
145  resetContext();
146 
147  SetScreenDPI( m_printCtx->GetNativeDPI() );
148 }
CAIRO_GAL_BASE(GAL_DISPLAY_OPTIONS &aDisplayOptions)
Definition: cairo_gal.cpp:49
void SetScreenDPI(double aScreenDPI)
Set the dots per inch of the screen.
std::unique_ptr< CAIRO_PRINT_CTX > m_printCtx
Definition: cairo_print.h:126
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
cairo_t * m_context
Cairo image.
Definition: cairo_gal.h:342
cairo_surface_t * m_surface
Cairo surface.
Definition: cairo_gal.h:343
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References KIGFX::GAL::m_clearColor, KIGFX::CAIRO_GAL_BASE::m_context, KIGFX::CAIRO_GAL_BASE::m_currentContext, m_hasNativeLandscapeRotation, m_printCtx, KIGFX::CAIRO_GAL_BASE::m_surface, KIGFX::CAIRO_GAL_BASE::resetContext(), and KIGFX::GAL::SetScreenDPI().

Member Function Documentation

◆ AdvanceDepth()

void KIGFX::GAL::AdvanceDepth ( )
inlineinherited

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

Definition at line 1056 of file graphics_abstraction_layer.h.

1057  {
1058  m_layerDepth -= 0.05;
1059  }
double m_layerDepth
The actual layer depth.

References KIGFX::GAL::m_layerDepth.

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

◆ angle_xform()

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

Transform according to the rotation from m_currentWorld2Screen transform matrix.

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

Definition at line 127 of file cairo_gal.cpp.

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

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

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

◆ arc_angles_xform_and_normalize()

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

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

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

Definition at line 141 of file cairo_gal.cpp.

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

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

Referenced by KIGFX::CAIRO_GAL_BASE::DrawArc(), and KIGFX::CAIRO_GAL_BASE::DrawArcSegment().

◆ beginDrawing()

void CAIRO_GAL_BASE::beginDrawing ( )
overrideprotectedvirtualinherited

Reimplemented from KIGFX::GAL.

Reimplemented in KIGFX::CAIRO_GAL.

Definition at line 92 of file cairo_gal.cpp.

93 {
94  resetContext();
95 }

References KIGFX::CAIRO_GAL_BASE::resetContext().

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

◆ BeginGroup()

int CAIRO_GAL_BASE::BeginGroup ( )
overridevirtualinherited

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

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

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

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

◆ beginUpdate()

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

Enable item update mode.

Private: use GAL_UPDATE_CONTEXT RAII object

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1097 of file graphics_abstraction_layer.h.

1097 {}

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

◆ BitmapText()

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

Draw a text using a bitmap font.

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

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

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 361 of file graphics_abstraction_layer.h.

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

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

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

◆ blitCursor()

void CAIRO_GAL_BASE::blitCursor ( wxMemoryDC &  clientDC)
protectedinherited

Blit cursor into the current screen.

Definition at line 1139 of file cairo_gal.cpp.

1140 {
1141  if( !IsCursorEnabled() )
1142  return;
1143 
1145  const COLOR4D cColor = getCursorColor();
1146  const int cursorSize = m_fullscreenCursor ? 8000 : 80;
1147 
1148  wxColour color( cColor.r * cColor.a * 255, cColor.g * cColor.a * 255, cColor.b * cColor.a * 255,
1149  255 );
1150  clientDC.SetPen( wxPen( color ) );
1151  clientDC.DrawLine( p.x - cursorSize / 2, p.y, p.x + cursorSize / 2, p.y );
1152  clientDC.DrawLine( p.x, p.y - cursorSize / 2, p.x, p.y + cursorSize / 2 );
1153 }
VECTOR2D ToScreen(const VECTOR2D &aPoint) const
Compute the point position in screen coordinates from given world coordinates.
int color
Definition: DXF_plotter.cpp:57
double g
Green component.
Definition: color4d.h:372
double b
Blue component.
Definition: color4d.h:373
VECTOR2D m_cursorPosition
Current cursor position (world coordinates)
double a
Alpha component.
Definition: color4d.h:374
COLOR4D getCursorColor() const
Get the actual cursor color to draw.
bool m_fullscreenCursor
Shape of the cursor (fullscreen or small cross)
double r
Red component.
Definition: color4d.h:371
bool IsCursorEnabled() const
Return information about cursor visibility.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

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

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

◆ ChangeGroupColor()

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

Change the color used to draw the group.

Parameters
aGroupNumberis the group number.
aNewColoris the new color.

Reimplemented from KIGFX::GAL.

Definition at line 875 of file cairo_gal.cpp.

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

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

◆ ChangeGroupDepth()

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

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

Parameters
aGroupNumberis the group number.
aDepthis the new depth.

Reimplemented from KIGFX::GAL.

Definition at line 892 of file cairo_gal.cpp.

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

◆ ClearCache()

void CAIRO_GAL_BASE::ClearCache ( )
overridevirtualinherited

Delete all data created during caching of graphic items.

Reimplemented from KIGFX::GAL.

Definition at line 917 of file cairo_gal.cpp.

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

References KIGFX::CAIRO_GAL_BASE::DeleteGroup(), and KIGFX::CAIRO_GAL_BASE::m_groups.

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

◆ ClearScreen()

void CAIRO_GAL_BASE::ClearScreen ( )
overridevirtualinherited

Clear the screen.

Parameters
aColoris the color used for clearing.

Reimplemented from KIGFX::GAL.

Definition at line 545 of file cairo_gal.cpp.

546 {
547  cairo_set_source_rgb( m_currentContext, m_clearColor.r, m_clearColor.g, m_clearColor.b );
548  cairo_rectangle( m_currentContext, 0.0, 0.0, m_screenSize.x, m_screenSize.y );
549  cairo_fill( m_currentContext );
550 }
double g
Green component.
Definition: color4d.h:372
double b
Blue component.
Definition: color4d.h:373
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
double r
Red component.
Definition: color4d.h:371
VECTOR2I m_screenSize
Screen size in screen coordinates.

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

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

◆ ClearTarget()

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

Clear the target for rendering.

Parameters
aTargetis the target to be cleared.

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

Definition at line 798 of file graphics_abstraction_layer.h.

798 {};

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

◆ computeMinGridSpacing()

double GAL::computeMinGridSpacing ( ) const
protectedinherited

compute minimum grid spacing from the grid settings

Returns
the minimum spacing to use for drawing the grid

Definition at line 237 of file graphics_abstraction_layer.cpp.

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

References KIGFX::GAL::m_gridMinSpacing.

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

◆ computeWorldScale()

void KIGFX::GAL::computeWorldScale ( )
inlineprotectedinherited

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

Definition at line 1111 of file graphics_abstraction_layer.h.

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

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

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

◆ ComputeWorldScreenMatrix()

void CAIRO_PRINT_GAL::ComputeWorldScreenMatrix ( )
overridevirtual

Compute the world <-> screen transformation matrix.

Reimplemented from KIGFX::GAL.

Definition at line 151 of file cairo_print.cpp.

152 {
154  const VECTOR2D paperSizeIU = VECTOR2D( m_nativePaperSize.y, m_nativePaperSize.x ) /* inches */
155  / m_worldUnitLength; /* 1" in IU */
156  const VECTOR2D paperSizeIUTransposed( paperSizeIU.y, paperSizeIU.x );
157 
158  MATRIX3x3D scale, translation, flip, rotate, lookat;
159 
160  scale.SetIdentity();
161  translation.SetIdentity();
162  flip.SetIdentity();
163  rotate.SetIdentity();
164  lookat.SetIdentity();
165 
167  {
168  translation.SetTranslation( 0.5 / m_zoomFactor * paperSizeIUTransposed );
169  }
170  else
171  {
172  if( isLandscape() )
173  {
174  translation.SetTranslation( 0.5 / m_zoomFactor * paperSizeIU );
175  rotate.SetRotation( 90.0 * M_PI / 180.0 );
176  }
177  else
178  {
179  translation.SetTranslation( 0.5 / m_zoomFactor * paperSizeIUTransposed );
180  }
181  }
182 
183  scale.SetScale( VECTOR2D( m_worldScale, m_worldScale ) );
184  flip.SetScale( VECTOR2D( m_globalFlipX ? -1.0 : 1.0, m_globalFlipY ? -1.0 : 1.0 ) );
185  lookat.SetTranslation( -m_lookAtPoint );
186 
187  m_worldScreenMatrix = scale * translation * flip * rotate * lookat;
189 }
double m_zoomFactor
The zoom factor.
void SetRotation(T aAngle)
Set the rotation components of the matrix.
Definition: matrix3x3.h:245
MATRIX3x3D m_screenWorldMatrix
Screen transformation.
MATRIX3x3 Inverse() const
Determine the inverse of the matrix.
Definition: matrix3x3.h:339
VECTOR2D m_lookAtPoint
Point to be looked at in world space.
void SetIdentity()
Set the matrix to the identity matrix.
Definition: matrix3x3.h:210
MATRIX3x3D m_worldScreenMatrix
World transformation.
double m_worldScale
The scale factor world->screen.
double m_screenDPI
The dots per inch of the screen.
bool m_globalFlipX
Flag for X axis flipping.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
bool isLandscape() const
< Returns true if page orientation is landscape
Definition: cairo_print.h:114
const int scale
void SetScale(VECTOR2< T > aScale)
Set the scale components of the matrix.
Definition: matrix3x3.h:257
bool m_globalFlipY
Flag for Y axis flipping.
void SetTranslation(VECTOR2< T > aTranslation)
Set the translation components of the matrix.
Definition: matrix3x3.h:226
VECTOR2D m_nativePaperSize
Flag indicating whether the platform rotates page automatically or GAL needs to handle it in the tran...
Definition: cairo_print.h:120
double m_worldUnitLength
The unit length of the world coordinates [inch].

References MATRIX3x3< T >::Inverse(), isLandscape(), KIGFX::GAL::m_globalFlipX, KIGFX::GAL::m_globalFlipY, m_hasNativeLandscapeRotation, KIGFX::GAL::m_lookAtPoint, m_nativePaperSize, KIGFX::GAL::m_screenDPI, KIGFX::GAL::m_screenWorldMatrix, KIGFX::GAL::m_worldScale, KIGFX::GAL::m_worldScreenMatrix, KIGFX::GAL::m_worldUnitLength, KIGFX::GAL::m_zoomFactor, scale, MATRIX3x3< T >::SetIdentity(), MATRIX3x3< T >::SetRotation(), MATRIX3x3< T >::SetScale(), MATRIX3x3< T >::SetTranslation(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ DeleteGroup()

void CAIRO_GAL_BASE::DeleteGroup ( int  aGroupNumber)
overridevirtualinherited

Delete the group from the memory.

Parameters
aGroupNumberis the group number.

Reimplemented from KIGFX::GAL.

Definition at line 899 of file cairo_gal.cpp.

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

References KIGFX::CAIRO_GAL_BASE::CMD_FILL_PATH, KIGFX::CAIRO_GAL_BASE::CMD_STROKE_PATH, KIGFX::CAIRO_GAL_BASE::m_groups, and KIGFX::CAIRO_GAL_BASE::storePath().

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

◆ DrawArc()

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

Draw an arc.

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

Reimplemented from KIGFX::GAL.

Definition at line 308 of file cairo_gal.cpp.

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

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

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

◆ DrawArcSegment()

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

Draw an arc segment.

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

TODO: Unify Arc routines

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

Reimplemented from KIGFX::GAL.

Definition at line 344 of file cairo_gal.cpp.

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

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

◆ drawAxes()

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

Definition at line 999 of file cairo_gal.cpp.

1000 {
1001  syncLineWidth();
1002 
1003  VECTOR2D p0 = roundp( xform( aStartPoint ) );
1004  VECTOR2D p1 = roundp( xform( aEndPoint ) );
1005  VECTOR2D org = roundp( xform( VECTOR2D( 0.0, 0.0 ) ) ); // Axis origin = 0,0 coord
1006 
1007  cairo_set_source_rgba( m_currentContext, m_axesColor.r, m_axesColor.g, m_axesColor.b,
1008  m_axesColor.a );
1009  cairo_move_to( m_currentContext, p0.x, org.y );
1010  cairo_line_to( m_currentContext, p1.x, org.y );
1011  cairo_move_to( m_currentContext, org.x, p0.y );
1012  cairo_line_to( m_currentContext, org.x, p1.y );
1013  cairo_stroke( m_currentContext );
1014 }
double g
Green component.
Definition: color4d.h:372
double b
Blue component.
Definition: color4d.h:373
double a
Alpha component.
Definition: color4d.h:374
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
COLOR4D m_axesColor
Color of the axes.
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:210
double r
Red component.
Definition: color4d.h:371

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

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

◆ DrawBitmap()

void CAIRO_GAL_BASE::DrawBitmap ( const BITMAP_BASE aBitmap)
overridevirtualinherited

Draw a bitmap image.

Reimplemented from KIGFX::GAL.

Definition at line 465 of file cairo_gal.cpp.

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

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

◆ DrawCircle()

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

Draw a circle using world coordinates.

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

Reimplemented from KIGFX::GAL.

Definition at line 292 of file cairo_gal.cpp.

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

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

◆ DrawCursor()

void CAIRO_GAL_BASE::DrawCursor ( const VECTOR2D aCursorPosition)
overridevirtualinherited

Draw the cursor.

Parameters
aCursorPositionis the cursor position in screen coordinates.

Reimplemented from KIGFX::GAL.

Definition at line 956 of file cairo_gal.cpp.

957 {
958  m_cursorPosition = aCursorPosition;
959 }
VECTOR2D m_cursorPosition
Current cursor position (world coordinates)

References KIGFX::GAL::m_cursorPosition.

◆ DrawCurve()

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

Draw a cubic bezier spline.

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

Reimplemented from KIGFX::GAL.

Definition at line 443 of file cairo_gal.cpp.

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

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

◆ DrawGrid()

void CAIRO_GAL_BASE::DrawGrid ( )
overridevirtualinherited

Reimplemented from KIGFX::GAL.

Definition at line 1597 of file cairo_gal.cpp.

1598 {
1600 
1601  // Draw the grid
1602  // For the drawing the start points, end points and increments have
1603  // to be calculated in world coordinates
1604  VECTOR2D worldStartPoint = m_screenWorldMatrix * VECTOR2D( 0.0, 0.0 );
1605  VECTOR2D worldEndPoint = m_screenWorldMatrix * VECTOR2D( m_screenSize );
1606 
1607  // Compute the line marker or point radius of the grid
1608  // Note: generic grids can't handle sub-pixel lines without
1609  // either losing fine/course distinction or having some dots
1610  // fail to render
1611  float marker = std::fmax( 1.0f, m_gridLineWidth ) / m_worldScale;
1612  float doubleMarker = 2.0f * marker;
1613 
1614  // Draw axes if desired
1615  if( m_axesEnabled )
1616  {
1617  SetLineWidth( marker );
1618  drawAxes( worldStartPoint, worldEndPoint );
1619  }
1620 
1621  if( !m_gridVisibility || m_gridSize.x == 0 || m_gridSize.y == 0 )
1622  return;
1623 
1624  VECTOR2D gridScreenSize( m_gridSize );
1625 
1626  double gridThreshold = KiROUND( computeMinGridSpacing() / m_worldScale );
1627 
1629  gridThreshold *= 2.0;
1630 
1631  // If we cannot display the grid density, scale down by a tick size and
1632  // try again. Eventually, we get some representation of the grid
1633  while( std::min( gridScreenSize.x, gridScreenSize.y ) <= gridThreshold )
1634  {
1635  gridScreenSize = gridScreenSize * static_cast<double>( m_gridTick );
1636  }
1637 
1638  // Compute grid starting and ending indexes to draw grid points on the
1639  // visible screen area
1640  // Note: later any point coordinate will be offsetted by m_gridOrigin
1641  int gridStartX = KiROUND( ( worldStartPoint.x - m_gridOrigin.x ) / gridScreenSize.x );
1642  int gridEndX = KiROUND( ( worldEndPoint.x - m_gridOrigin.x ) / gridScreenSize.x );
1643  int gridStartY = KiROUND( ( worldStartPoint.y - m_gridOrigin.y ) / gridScreenSize.y );
1644  int gridEndY = KiROUND( ( worldEndPoint.y - m_gridOrigin.y ) / gridScreenSize.y );
1645 
1646  // Ensure start coordinate > end coordinate
1647  SWAP( gridStartX, >, gridEndX );
1648  SWAP( gridStartY, >, gridEndY );
1649 
1650  // Ensure the grid fills the screen
1651  --gridStartX;
1652  ++gridEndX;
1653  --gridStartY;
1654  ++gridEndY;
1655 
1656  // Draw the grid behind all other layers
1657  SetLayerDepth( m_depthRange.y * 0.75 );
1658 
1660  {
1661  // Now draw the grid, every coarse grid line gets the double width
1662 
1663  // Vertical lines
1664  for( int j = gridStartY; j <= gridEndY; j++ )
1665  {
1666  const double y = j * gridScreenSize.y + m_gridOrigin.y;
1667 
1668  if( m_axesEnabled && y == 0.0 )
1669  continue;
1670 
1671  SetLineWidth( ( j % m_gridTick ) ? marker : doubleMarker );
1672  drawGridLine( VECTOR2D( gridStartX * gridScreenSize.x + m_gridOrigin.x, y ),
1673  VECTOR2D( gridEndX * gridScreenSize.x + m_gridOrigin.x, y ) );
1674  }
1675 
1676  // Horizontal lines
1677  for( int i = gridStartX; i <= gridEndX; i++ )
1678  {
1679  const double x = i * gridScreenSize.x + m_gridOrigin.x;
1680 
1681  if( m_axesEnabled && x == 0.0 )
1682  continue;
1683 
1684  SetLineWidth( ( i % m_gridTick ) ? marker : doubleMarker );
1685  drawGridLine( VECTOR2D( x, gridStartY * gridScreenSize.y + m_gridOrigin.y ),
1686  VECTOR2D( x, gridEndY * gridScreenSize.y + m_gridOrigin.y ) );
1687  }
1688  }
1689  else // Dots or Crosses grid
1690  {
1691  m_lineWidthIsOdd = true;
1692  m_isStrokeEnabled = true;
1693 
1694  for( int j = gridStartY; j <= gridEndY; j++ )
1695  {
1696  bool tickY = ( j % m_gridTick == 0 );
1697 
1698  for( int i = gridStartX; i <= gridEndX; i++ )
1699  {
1700  bool tickX = ( i % m_gridTick == 0 );
1701  VECTOR2D pos{ i * gridScreenSize.x + m_gridOrigin.x,
1702  j * gridScreenSize.y + m_gridOrigin.y };
1703 
1705  {
1706  SetLineWidth( ( tickX && tickY ) ? doubleMarker : marker );
1707  drawGridCross( pos );
1708  }
1709  else if( m_gridStyle == GRID_STYLE::DOTS )
1710  {
1711  double doubleGridLineWidth = m_gridLineWidth * 2.0f;
1712  drawGridPoint( pos, ( tickX ) ? doubleGridLineWidth : m_gridLineWidth,
1713  ( tickY ) ? doubleGridLineWidth : m_gridLineWidth );
1714  }
1715  }
1716  }
1717  }
1718 }
Use lines for the grid.
bool m_axesEnabled
Should the axes be drawn.
double computeMinGridSpacing() const
compute minimum grid spacing from the grid settings
MATRIX3x3D m_screenWorldMatrix
Screen transformation.
VECTOR2D m_gridSize
The grid size.
void drawAxes(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Definition: cairo_gal.cpp:999
void SetLayerDepth(double aLayerDepth) override
Set the depth of the layer (position on the z-axis)
Definition: cairo_gal.cpp:638
int m_gridTick
Every tick line gets the double width.
float m_gridLineWidth
Line width of the grid.
Auxiliary rendering target (noncached)
Definition: definitions.h:49
double m_worldScale
The scale factor world->screen.
void drawGridPoint(const VECTOR2D &aPoint, double aWidth, double aHeight)
Definition: cairo_gal.cpp:1052
bool m_isStrokeEnabled
Are the outlines stroked ?
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
bool m_gridVisibility
Should the grid be shown.
Use dots for the grid.
Use small cross instead of dots for the grid.
GRID_STYLE m_gridStyle
Grid display style.
VECTOR2D m_depthRange
Range of the depth.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
#define SWAP(varA, condition, varB)
Swap the variables if a condition is met.
Definition: definitions.h:31
void drawGridLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a grid line (usually a simplified line function).
Definition: cairo_gal.cpp:1017
void SetLineWidth(float aLineWidth) override
Set the line width.
Definition: cairo_gal.cpp:619
VECTOR2D m_gridOrigin
The grid origin.
VECTOR2I m_screenSize
Screen size in screen coordinates.
virtual void SetTarget(RENDER_TARGET aTarget)
Set the target for rendering.
void drawGridCross(const VECTOR2D &aPoint)
Definition: cairo_gal.cpp:1031

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

◆ drawGridCross()

void CAIRO_GAL_BASE::drawGridCross ( const VECTOR2D aPoint)
protectedinherited

Definition at line 1031 of file cairo_gal.cpp.

1032 {
1033  syncLineWidth();
1034  VECTOR2D offset( 0, 0 );
1035  double size = 2.0 * m_lineWidthInPixels + 0.5;
1036 
1037  VECTOR2D p0 = roundp( xform( aPoint ) ) - VECTOR2D( size, 0 ) + offset;
1038  VECTOR2D p1 = roundp( xform( aPoint ) ) + VECTOR2D( size, 0 ) + offset;
1039  VECTOR2D p2 = roundp( xform( aPoint ) ) - VECTOR2D( 0, size ) + offset;
1040  VECTOR2D p3 = roundp( xform( aPoint ) ) + VECTOR2D( 0, size ) + offset;
1041 
1042  cairo_set_source_rgba( m_currentContext, m_gridColor.r, m_gridColor.g, m_gridColor.b,
1043  m_gridColor.a );
1044  cairo_move_to( m_currentContext, p0.x, p0.y );
1045  cairo_line_to( m_currentContext, p1.x, p1.y );
1046  cairo_move_to( m_currentContext, p2.x, p2.y );
1047  cairo_line_to( m_currentContext, p3.x, p3.y );
1048  cairo_stroke( m_currentContext );
1049 }
double m_lineWidthInPixels
Definition: cairo_gal.h:335
double g
Green component.
Definition: color4d.h:372
double b
Blue component.
Definition: color4d.h:373
COLOR4D m_gridColor
Color of the grid.
double a
Alpha component.
Definition: color4d.h:374
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:210
double r
Red component.
Definition: color4d.h:371

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

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

◆ drawGridLine()

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

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

1018 {
1019  syncLineWidth();
1020  VECTOR2D p0 = roundp( xform( aStartPoint ) );
1021  VECTOR2D p1 = roundp( xform( aEndPoint ) );
1022 
1023  cairo_set_source_rgba( m_currentContext, m_gridColor.r, m_gridColor.g, m_gridColor.b,
1024  m_gridColor.a );
1025  cairo_move_to( m_currentContext, p0.x, p0.y );
1026  cairo_line_to( m_currentContext, p1.x, p1.y );
1027  cairo_stroke( m_currentContext );
1028 }
double g
Green component.
Definition: color4d.h:372
double b
Blue component.
Definition: color4d.h:373
COLOR4D m_gridColor
Color of the grid.
double a
Alpha component.
Definition: color4d.h:374
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:210
double r
Red component.
Definition: color4d.h:371

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

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

◆ drawGridPoint()

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

Definition at line 1052 of file cairo_gal.cpp.

1053 {
1054  VECTOR2D p = roundp( xform( aPoint ) );
1055 
1056  double sw = std::max( 1.0, aWidth );
1057  double sh = std::max( 1.0, aHeight );
1058 
1059  cairo_set_source_rgba( m_currentContext, m_gridColor.r, m_gridColor.g, m_gridColor.b,
1060  m_gridColor.a );
1061  cairo_rectangle( m_currentContext, p.x - std::floor( sw / 2 ) - 0.5,
1062  p.y - std::floor( sh / 2 ) - 0.5, sw, sh );
1063 
1064  cairo_fill( m_currentContext );
1065 }
double g
Green component.
Definition: color4d.h:372
double b
Blue component.
Definition: color4d.h:373
COLOR4D m_gridColor
Color of the grid.
double a
Alpha component.
Definition: color4d.h:374
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
double r
Red component.
Definition: color4d.h:371

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

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

◆ DrawGroup()

void CAIRO_GAL_BASE::DrawGroup ( int  aGroupNumber)
overridevirtualinherited

Draw the stored group.

Parameters
aGroupNumberis the group number.

Reimplemented from KIGFX::GAL.

Definition at line 782 of file cairo_gal.cpp.

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

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

◆ DrawLine()

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

Draw a line.

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

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

Reimplemented from KIGFX::GAL.

Definition at line 196 of file cairo_gal.cpp.

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

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

◆ drawPoly() [1/3]

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

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

Definition at line 1156 of file cairo_gal.cpp.

1157 {
1158  wxCHECK( aPointList.size() > 1, /* void */ );
1159 
1160  // Iterate over the point list and draw the segments
1161  std::deque<VECTOR2D>::const_iterator it = aPointList.begin();
1162 
1163  syncLineWidth();
1164 
1165  const VECTOR2D p = roundp( xform( it->x, it->y ) );
1166 
1167  cairo_move_to( m_currentContext, p.x, p.y );
1168 
1169  for( ++it; it != aPointList.end(); ++it )
1170  {
1171  const VECTOR2D p2 = roundp( xform( it->x, it->y ) );
1172 
1173  cairo_line_to( m_currentContext, p2.x, p2.y );
1174  }
1175 
1176  flushPath();
1177  m_isElementAdded = true;
1178 }
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:330
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:210

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

Referenced by KIGFX::CAIRO_GAL_BASE::DrawPolygon(), and KIGFX::CAIRO_GAL_BASE::DrawPolyline().

◆ drawPoly() [2/3]

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

Definition at line 1181 of file cairo_gal.cpp.

1182 {
1183  wxCHECK( aListSize > 1, /* void */ );
1184 
1185  // Iterate over the point list and draw the segments
1186  const VECTOR2D* ptr = aPointList;
1187 
1188  syncLineWidth();
1189 
1190  const VECTOR2D p = roundp( xform( ptr->x, ptr->y ) );
1191  cairo_move_to( m_currentContext, p.x, p.y );
1192 
1193  for( int i = 1; i < aListSize; ++i )
1194  {
1195  ++ptr;
1196  const VECTOR2D p2 = roundp( xform( ptr->x, ptr->y ) );
1197  cairo_line_to( m_currentContext, p2.x, p2.y );
1198  }
1199 
1200  flushPath();
1201  m_isElementAdded = true;
1202 }
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:330
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:210

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

◆ drawPoly() [3/3]

void CAIRO_GAL_BASE::drawPoly ( const SHAPE_LINE_CHAIN aLineChain)
protectedinherited

Definition at line 1205 of file cairo_gal.cpp.

1206 {
1207  wxCHECK( aLineChain.PointCount() > 1, /* void */ );
1208 
1209  syncLineWidth();
1210 
1211  auto numPoints = aLineChain.PointCount();
1212 
1213  if( aLineChain.IsClosed() )
1214  numPoints += 1;
1215 
1216  const VECTOR2I start = aLineChain.CPoint( 0 );
1217  const VECTOR2D p = roundp( xform( start.x, start.y ) );
1218  cairo_move_to( m_currentContext, p.x, p.y );
1219 
1220  for( int i = 1; i < numPoints; ++i )
1221  {
1222  const VECTOR2I& pw = aLineChain.CPoint( i );
1223  const VECTOR2D ps = roundp( xform( pw.x, pw.y ) );
1224  cairo_line_to( m_currentContext, ps.x, ps.y );
1225  }
1226 
1227  flushPath();
1228  m_isElementAdded = true;
1229 }
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:330
bool IsClosed() const override
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp:173
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:187
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:210

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

◆ DrawPolygon() [1/4]

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

Draw a polygon.

Parameters
aPointListis the list of the polygon points.

Reimplemented from KIGFX::GAL.

Definition at line 103 of file cairo_gal.h.

103 { 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:1156

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolygon() [2/4]

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

Reimplemented from KIGFX::GAL.

Definition at line 104 of file cairo_gal.h.

105  {
106  drawPoly( aPointList, aListSize );
107  }
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:1156

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolygon() [3/4]

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

Reimplemented from KIGFX::GAL.

Definition at line 430 of file cairo_gal.cpp.

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

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

◆ DrawPolygon() [4/4]

void CAIRO_GAL_BASE::DrawPolygon ( const SHAPE_LINE_CHAIN aPolySet)
overridevirtualinherited

Reimplemented from KIGFX::GAL.

Definition at line 437 of file cairo_gal.cpp.

438 {
439  drawPoly( aPolygon );
440 }
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:1156

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolyline() [1/3]

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

Draw a polyline.

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

Reimplemented from KIGFX::GAL.

Definition at line 94 of file cairo_gal.h.

94 { 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:1156

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolyline() [2/3]

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

Reimplemented from KIGFX::GAL.

Definition at line 95 of file cairo_gal.h.

96  {
97  drawPoly( aPointList, aListSize );
98  }
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:1156

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolyline() [3/3]

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

Reimplemented from KIGFX::GAL.

Definition at line 100 of file cairo_gal.h.

100 { 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:1156

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawRectangle()

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

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

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

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

◆ DrawSegment()

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

Draw a rounded segment.

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

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

Reimplemented from KIGFX::GAL.

Definition at line 234 of file cairo_gal.cpp.

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

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

◆ EnableDepthTest()

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

Reimplemented from KIGFX::GAL.

Definition at line 962 of file cairo_gal.cpp.

963 {
964 }

◆ EndDiffLayer()

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

Ends rendering of a differential layer.

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

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

Definition at line 837 of file graphics_abstraction_layer.h.

837 {};

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

◆ endDrawing()

void CAIRO_GAL_BASE::endDrawing ( )
overrideprotectedvirtualinherited

Reimplemented from KIGFX::GAL.

Reimplemented in KIGFX::CAIRO_GAL.

Definition at line 98 of file cairo_gal.cpp.

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

References KIGFX::CAIRO_GAL_BASE::Flush().

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

◆ EndGroup()

void CAIRO_GAL_BASE::EndGroup ( )
overridevirtualinherited

End the group.

Reimplemented from KIGFX::GAL.

Reimplemented in KIGFX::CAIRO_GAL.

Definition at line 775 of file cairo_gal.cpp.

776 {
777  storePath();
778  m_isGrouping = false;
779 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1090
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:329

References KIGFX::CAIRO_GAL_BASE::m_isGrouping, and KIGFX::CAIRO_GAL_BASE::storePath().

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

◆ EndNegativesLayer()

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

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

No-op in OpenGL.

Reimplemented in KIGFX::CAIRO_GAL.

Definition at line 853 of file graphics_abstraction_layer.h.

853 {};

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

◆ endUpdate()

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

Disable item update mode.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1100 of file graphics_abstraction_layer.h.

1100 {}

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

◆ Flush()

void CAIRO_GAL_BASE::Flush ( )
overridevirtualinherited

Force all remaining objects to be drawn.

Reimplemented from KIGFX::GAL.

Definition at line 539 of file cairo_gal.cpp.

540 {
541  storePath();
542 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1090

References KIGFX::CAIRO_GAL_BASE::storePath().

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

◆ flushPath()

void CAIRO_GAL_BASE::flushPath ( )
protectedinherited

Definition at line 1068 of file cairo_gal.cpp.

1069 {
1070  if( m_isFillEnabled )
1071  {
1072  cairo_set_source_rgba( m_currentContext, m_fillColor.r, m_fillColor.g, m_fillColor.b,
1073  m_fillColor.a );
1074 
1075  if( m_isStrokeEnabled )
1076  cairo_fill_preserve( m_currentContext );
1077  else
1078  cairo_fill( m_currentContext );
1079  }
1080 
1081  if( m_isStrokeEnabled )
1082  {
1083  cairo_set_source_rgba( m_currentContext, m_strokeColor.r, m_strokeColor.g, m_strokeColor.b,
1084  m_strokeColor.a );
1085  cairo_stroke( m_currentContext );
1086  }
1087 }
bool m_isFillEnabled
Is filling of graphic objects enabled ?
double g
Green component.
Definition: color4d.h:372
double b
Blue component.
Definition: color4d.h:373
double a
Alpha component.
Definition: color4d.h:374
bool m_isStrokeEnabled
Are the outlines stroked ?
COLOR4D m_strokeColor
The color of the outlines.
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
COLOR4D m_fillColor
The fill color.
double r
Red component.
Definition: color4d.h:371

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

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

◆ GetClearColor()

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

Definition at line 222 of file graphics_abstraction_layer.h.

223  {
224  return m_clearColor;
225  }

References KIGFX::GAL::m_clearColor.

Referenced by EDIT_POINTS::ViewDraw().

◆ getCursorColor()

COLOR4D GAL::getCursorColor ( ) const
protectedinherited

Get the actual cursor color to draw.

Definition at line 267 of file graphics_abstraction_layer.cpp.

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

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

Referenced by KIGFX::CAIRO_GAL_BASE::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 273 of file graphics_abstraction_layer.h.

274  {
275  return m_fillColor;
276  }
COLOR4D m_fillColor
The fill color.

References KIGFX::GAL::m_fillColor.

◆ GetGAL()

GAL* KIGFX::CAIRO_PRINT_GAL::GetGAL ( )
inlineoverridevirtual

Implements KIGFX::GAL_PRINT.

Definition at line 90 of file cairo_print.h.

91  {
92  return this;
93  }

◆ GetGlyphSize()

◆ GetGridLineWidth()

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

Get the grid line width.

Returns
the grid line widthDraw the grid

Definition at line 969 of file graphics_abstraction_layer.h.

References KIGFX::GAL::m_gridLineWidth.

◆ GetGridOrigin()

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

Definition at line 894 of file graphics_abstraction_layer.h.

895  {
896  return m_gridOrigin;
897  }
VECTOR2D m_gridOrigin
The grid origin.

References KIGFX::GAL::m_gridOrigin.

Referenced by GRID_HELPER::GetOrigin().

◆ GetGridPoint()

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

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

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

Definition at line 245 of file graphics_abstraction_layer.cpp.

246 {
247 #if 0
248  // This old code expects a non zero grid size, which can be wrong here.
249  return VECTOR2D( KiROUND( ( aPoint.x - m_gridOffset.x ) / m_gridSize.x ) * m_gridSize.x + m_gridOffset.x,
250  KiROUND( ( aPoint.y - m_gridOffset.y ) / m_gridSize.y ) * m_gridSize.y + m_gridOffset.y );
251 #else
252  // if grid size == 0.0 there is no grid, so use aPoint as grid reference position
253  double cx = m_gridSize.x > 0.0 ? KiROUND( ( aPoint.x - m_gridOffset.x ) / m_gridSize.x ) * m_gridSize.x + m_gridOffset.x
254  : aPoint.x;
255  double cy = m_gridSize.y > 0.0 ? KiROUND( ( aPoint.y - m_gridOffset.y ) / m_gridSize.y ) * m_gridSize.y + m_gridOffset.y
256  : aPoint.y;
257 
258  return VECTOR2D( cx, cy );
259 #endif
260 }
VECTOR2D m_gridSize
The grid size.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
VECTOR2D m_gridOffset
The grid offset to compensate cursor position.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73

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

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

◆ GetGridSize()

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

◆ GetGridSnapping()

◆ GetGridVisibility()

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

Definition at line 866 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_gridVisibility.

Referenced by EDA_DRAW_PANEL_GAL::SwitchBackend().

◆ GetHorizontalJustify()

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

Return current text horizontal justification setting.

Definition at line 458 of file graphics_abstraction_layer.h.

459  {
461  }
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(), KIGFX::SCH_PAINTER::boxText(), 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 663 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_lookAtPoint.

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

◆ GetMaxDepth()

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

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

Definition at line 732 of file graphics_abstraction_layer.h.

733  {
734  return m_depthRange.y;
735  }
VECTOR2D m_depthRange
Range of the depth.

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

◆ GetMinDepth()

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

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

Definition at line 724 of file graphics_abstraction_layer.h.

725  {
726  return m_depthRange.x;
727  }
VECTOR2D m_depthRange
Range of the depth.

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

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

◆ getNewGroupNumber()

unsigned int CAIRO_GAL_BASE::getNewGroupNumber ( )
protectedinherited

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

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

Definition at line 1232 of file cairo_gal.cpp.

1233 {
1234  wxASSERT_MSG( m_groups.size() < std::numeric_limits<unsigned int>::max(),
1235  wxT( "There are no free slots to store a group" ) );
1236 
1237  while( m_groups.find( m_groupCounter ) != m_groups.end() )
1238  m_groupCounter++;
1239 
1240  return m_groupCounter++;
1241 }
std::map< int, GROUP > m_groups
List of graphic groups.
Definition: cairo_gal.h:331
unsigned int m_groupCounter
Counter used for generating group keys.
Definition: cairo_gal.h:332

References KIGFX::CAIRO_GAL_BASE::m_groupCounter, and KIGFX::CAIRO_GAL_BASE::m_groups.

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

◆ GetPrintCtx()

PRINT_CONTEXT* KIGFX::CAIRO_PRINT_GAL::GetPrintCtx ( ) const
inlineoverridevirtual

Implements KIGFX::GAL_PRINT.

Definition at line 95 of file cairo_print.h.

96  {
97  return m_printCtx.get();
98  }
std::unique_ptr< CAIRO_PRINT_CTX > m_printCtx
Definition: cairo_print.h:126

References m_printCtx.

◆ GetRotation()

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

Get the rotation angle.

Returns
The rotation angle (radians).

Definition at line 703 of file graphics_abstraction_layer.h.

704  {
705  return m_rotation;
706  }
double m_rotation
Rotation transformation (radians)

References KIGFX::GAL::m_rotation.

◆ GetScreenPixelSize()

◆ GetScreenWorldMatrix()

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

Get the screen <-> world transformation matrix.

Returns
the transformation matrix.

Definition at line 594 of file graphics_abstraction_layer.h.

595  {
596  return m_screenWorldMatrix;
597  }
MATRIX3x3D m_screenWorldMatrix
Screen transformation.

References KIGFX::GAL::m_screenWorldMatrix.

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

◆ GetStrokeColor()

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

Get the stroke color.

Returns
the color for stroking the outline.

Definition at line 293 of file graphics_abstraction_layer.h.

294  {
295  return m_strokeColor;
296  }
COLOR4D m_strokeColor
The color of the outlines.

References KIGFX::GAL::m_strokeColor.

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

◆ GetStrokeFont()

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

Definition at line 335 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_strokeFont.

Referenced by KIGFX::SCH_PAINTER::boxText(), and EDA_TEXT::GetTextBox().

◆ GetTarget()

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

Get the currently used target for rendering.

Returns
The current rendering target.

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

Definition at line 791 of file graphics_abstraction_layer.h.

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

References KIGFX::TARGET_CACHED.

◆ GetTextLineSize()

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

Compute the X and Y size of a given text.

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

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

Definition at line 183 of file graphics_abstraction_layer.cpp.

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

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

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

◆ GetVerticalJustify()

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

Returns current text vertical justification setting.

Definition at line 476 of file graphics_abstraction_layer.h.

477  {
479  }
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(), KIGFX::SCH_PAINTER::boxText(), and KIGFX::STROKE_FONT::Draw().

◆ GetVisibleWorldExtents()

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

Definition at line 222 of file graphics_abstraction_layer.cpp.

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

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

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

◆ GetWorldScale()

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

◆ GetWorldScreenMatrix()

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

Get the world <-> screen transformation matrix.

Returns
the transformation matrix.

Definition at line 584 of file graphics_abstraction_layer.h.

585  {
586  return m_worldScreenMatrix;
587  }
MATRIX3x3D m_worldScreenMatrix
World transformation.

References KIGFX::GAL::m_worldScreenMatrix.

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

◆ GetZoomFactor()

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

Get the zoom factor.

Returns
the zoom factor.

Definition at line 683 of file graphics_abstraction_layer.h.

684  {
685  return m_zoomFactor;
686  }
double m_zoomFactor
The zoom factor.

References KIGFX::GAL::m_zoomFactor.

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

◆ HasTarget()

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

Return true if the target exists.

Parameters
aTargetis the target to be checked.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 805 of file graphics_abstraction_layer.h.

806  {
807  return true;
808  };

Referenced by EDA_DRAW_PANEL_GAL::DoRePaint().

◆ IsCairoEngine()

bool KIGFX::CAIRO_GAL_BASE::IsCairoEngine ( )
inlineoverridevirtualinherited

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

Reimplemented from KIGFX::GAL.

Definition at line 64 of file cairo_gal.h.

64 { return true; }

◆ IsContextLocked()

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

Checks the state of the context lock.

Returns
True if the context is currently locked

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1084 of file graphics_abstraction_layer.h.

1085  {
1086  return false;
1087  }

Referenced by EDA_DRAW_PANEL_GAL::onSize().

◆ IsCursorEnabled()

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

Return information about cursor visibility.

Returns
True if cursor is visible.

Definition at line 1030 of file graphics_abstraction_layer.h.

1031  {
1033  }
bool m_isCursorEnabled
Is the cursor enabled?
bool m_forceDisplayCursor
Always show cursor.

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

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

◆ IsFlippedX()

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

◆ IsFlippedY()

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

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

Definition at line 770 of file graphics_abstraction_layer.h.

771  {
772  return m_globalFlipY;
773  }
bool m_globalFlipY
Flag for Y axis flipping.

References KIGFX::GAL::m_globalFlipY.

◆ IsFontBold()

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

Definition at line 424 of file graphics_abstraction_layer.h.

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

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

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

◆ IsFontItalic()

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

◆ IsFontUnderlined()

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

◆ IsInitialized()

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

Return the initialization status for the canvas.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 74 of file graphics_abstraction_layer.h.

74 { return true; }

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

◆ isLandscape()

bool KIGFX::CAIRO_PRINT_GAL::isLandscape ( ) const
inlineprivate

< Returns true if page orientation is landscape

Printout size

Definition at line 114 of file cairo_print.h.

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

Referenced by ComputeWorldScreenMatrix().

◆ IsOpenGlEngine()

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

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

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 83 of file graphics_abstraction_layer.h.

83 { return false; }

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

◆ IsTextMirrored()

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

◆ IsVisible()

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

◆ lockContext()

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

Use GAL_CONTEXT_LOCKER RAII object.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1091 of file graphics_abstraction_layer.h.

1091 {}

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

◆ OnGalDisplayOptionsChanged()

void GAL::OnGalDisplayOptionsChanged ( const GAL_DISPLAY_OPTIONS aOptions)
overrideprotectedvirtualinherited

Handler for observer settings changes.

Implements KIGFX::GAL_DISPLAY_OPTIONS_OBSERVER.

Definition at line 101 of file graphics_abstraction_layer.cpp.

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

References KIGFX::GAL::updatedGalDisplayOptions().

◆ PopDepth()

void KIGFX::GAL::PopDepth ( )
inlineinherited

Restore previously stored drawing depth for the depth stack.

Definition at line 1072 of file graphics_abstraction_layer.h.

1073  {
1074  m_layerDepth = m_depthStack.top();
1075  m_depthStack.pop();
1076  }
double m_layerDepth
The actual layer depth.
std::stack< double > m_depthStack
Stored depth values.

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

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

◆ PushDepth()

void KIGFX::GAL::PushDepth ( )
inlineinherited

Store current drawing depth on the depth stack.

Definition at line 1064 of file graphics_abstraction_layer.h.

1065  {
1066  m_depthStack.push( m_layerDepth );
1067  }
double m_layerDepth
The actual layer depth.
std::stack< double > m_depthStack
Stored depth values.

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

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

◆ resetContext()

void CAIRO_GAL_BASE::resetContext ( )
protectedinherited

Definition at line 967 of file cairo_gal.cpp.

968 {
969  for( _cairo_surface* imageSurface : m_imageSurfaces )
970  cairo_surface_destroy( imageSurface );
971 
972  m_imageSurfaces.clear();
973 
974  ClearScreen();
975 
976  // Compute the world <-> screen transformations
978 
979  cairo_matrix_init( &m_cairoWorldScreenMatrix, m_worldScreenMatrix.m_data[0][0],
982  m_worldScreenMatrix.m_data[1][2] );
983 
984  // we work in screen-space coordinates and do the transforms outside.
985  cairo_identity_matrix( m_context );
986 
987  cairo_matrix_init_identity( &m_currentXform );
988 
989  // Start drawing with a new path
990  cairo_new_path( m_context );
991  m_isElementAdded = true;
992 
994 
995  m_lineWidth = 0;
996 }
cairo_matrix_t m_cairoWorldScreenMatrix
Cairo world to screen transform matrix.
Definition: cairo_gal.h:338
virtual void ComputeWorldScreenMatrix()
Compute the world <-> screen transformation matrix.
MATRIX3x3D m_worldScreenMatrix
World transformation.
T m_data[3][3]
Definition: matrix3x3.h:64
void ClearScreen() override
Clear the screen.
Definition: cairo_gal.cpp:545
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:330
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:105
cairo_t * m_context
Cairo image.
Definition: cairo_gal.h:342
cairo_matrix_t m_currentXform
Definition: cairo_gal.h:339
float m_lineWidth
The line width.
std::vector< cairo_surface_t * > m_imageSurfaces
List of surfaces that were created by painting images, to be cleaned up later.
Definition: cairo_gal.h:346

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

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

◆ ResetTextAttributes()

void GAL::ResetTextAttributes ( )
inherited

Reset text attributes to default styling.

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

Definition at line 167 of file graphics_abstraction_layer.cpp.

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

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

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

◆ ResizeScreen()

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

Resizes the canvas.

Reimplemented from KIGFX::GAL.

Reimplemented in KIGFX::CAIRO_GAL.

Definition at line 533 of file cairo_gal.cpp.

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

References KIGFX::GAL::m_screenSize.

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

◆ Restore()

void CAIRO_GAL_BASE::Restore ( )
overridevirtualinherited

Restore the context.

Reimplemented from KIGFX::GAL.

Definition at line 737 of file cairo_gal.cpp.

738 {
739  storePath();
740 
741  if( m_isGrouping )
742  {
743  GROUP_ELEMENT groupElement;
744  groupElement.m_Command = CMD_RESTORE;
745  m_currentGroup->push_back( groupElement );
746  }
747  else
748  {
749  if( !m_xformStack.empty() )
750  {
751  m_currentXform = m_xformStack.back();
752  m_xformStack.pop_back();
754  }
755  }
756 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1090
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:333
std::vector< cairo_matrix_t > m_xformStack
Definition: cairo_gal.h:348
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:105
cairo_matrix_t m_currentXform
Definition: cairo_gal.h:339
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:329
Restore the transformation matrix.
Definition: cairo_gal.h:310

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

◆ Rotate()

void CAIRO_GAL_BASE::Rotate ( double  aAngle)
overridevirtualinherited

Rotate the context.

Parameters
aAngleis the rotation angle in radians.

Reimplemented from KIGFX::GAL.

Definition at line 660 of file cairo_gal.cpp.

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

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

◆ roundp()

◆ Save()

void CAIRO_GAL_BASE::Save ( )
overridevirtualinherited

Save the context.

Reimplemented from KIGFX::GAL.

Definition at line 719 of file cairo_gal.cpp.

720 {
721  storePath();
722 
723  if( m_isGrouping )
724  {
725  GROUP_ELEMENT groupElement;
726  groupElement.m_Command = CMD_SAVE;
727  m_currentGroup->push_back( groupElement );
728  }
729  else
730  {
731  m_xformStack.push_back( m_currentXform );
733  }
734 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1090
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:333
std::vector< cairo_matrix_t > m_xformStack
Definition: cairo_gal.h:348
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:105
Save the transformation matrix.
Definition: cairo_gal.h:309
cairo_matrix_t m_currentXform
Definition: cairo_gal.h:339
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:329

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

◆ Scale()

void CAIRO_GAL_BASE::Scale ( const VECTOR2D aScale)
overridevirtualinherited

Scale the context.

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

Reimplemented from KIGFX::GAL.

Definition at line 699 of file cairo_gal.cpp.

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

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

◆ SetAxesColor()

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

◆ SetAxesEnabled()

◆ SetClearColor()

◆ SetCoarseGrid()

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

Draw every tick line wider.

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

Definition at line 959 of file graphics_abstraction_layer.h.

960  {
961  m_gridTick = aInterval;
962  }
int m_gridTick
Every tick line gets the double width.

References KIGFX::GAL::m_gridTick.

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

◆ SetCursorColor()

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

Set the cursor color.

Parameters
aCursorColoris the color of the cursor.

Definition at line 1040 of file graphics_abstraction_layer.h.

1041  {
1042  m_cursorColor = aCursorColor;
1043  }
COLOR4D m_cursorColor
Cursor color.

References KIGFX::GAL::m_cursorColor.

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

◆ SetCursorEnabled()

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

Enable/disable cursor.

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

Definition at line 1020 of file graphics_abstraction_layer.h.

1021  {
1022  m_isCursorEnabled = aCursorEnabled;
1023  }
bool m_isCursorEnabled
Is the cursor enabled?

References KIGFX::GAL::m_isCursorEnabled.

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

◆ SetDepthRange()

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

Set the range of the layer depth.

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

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

Definition at line 716 of file graphics_abstraction_layer.h.

717  {
718  m_depthRange = aDepthRange;
719  }
VECTOR2D m_depthRange
Range of the depth.

References KIGFX::GAL::m_depthRange.

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

◆ SetFillColor()

void CAIRO_GAL_BASE::SetFillColor ( const COLOR4D aColor)
overridevirtualinherited

Set the fill color.

Parameters
aColoris the color for filling.

Reimplemented from KIGFX::GAL.

Definition at line 601 of file cairo_gal.cpp.

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

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, KIGFX::CAIRO_GAL_BASE::CMD_SET_FILLCOLOR, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::DblArg, KIGFX::COLOR4D::g, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Argument, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Command, KIGFX::CAIRO_GAL_BASE::m_currentGroup, KIGFX::GAL::m_fillColor, KIGFX::CAIRO_GAL_BASE::m_isGrouping, KIGFX::COLOR4D::r, and KIGFX::CAIRO_GAL_BASE::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 753 of file graphics_abstraction_layer.h.

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

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

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

◆ SetFontBold()

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

Set bold property of current font.

Parameters
aBoldtells if the font should be bold or not.

Definition at line 423 of file graphics_abstraction_layer.h.

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

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

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

◆ SetFontItalic()

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

Set italic property of current font.

Parameters
aItalictells if the font should be italic or not.

Definition at line 431 of file graphics_abstraction_layer.h.

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

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

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

◆ SetFontUnderlined()

◆ SetGlyphSize()

◆ SetGridColor()

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

Set the grid color.

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

Definition at line 931 of file graphics_abstraction_layer.h.

932  {
933  m_gridColor = aGridColor;
934  }
COLOR4D m_gridColor
Color of the grid.

References KIGFX::GAL::m_gridColor.

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

◆ SetGridOrigin()

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

Set the origin point for the grid.

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

Definition at line 879 of file graphics_abstraction_layer.h.

880  {
881  m_gridOrigin = aGridOrigin;
882 
883  if( m_gridSize.x == 0.0 || m_gridSize.y == 0.0 )
884  {
885  m_gridOffset = VECTOR2D( 0.0, 0.0);
886  }
887  else
888  {
889  m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x,
890  (long) m_gridOrigin.y % (long) m_gridSize.y );
891  }
892  }
VECTOR2D m_gridSize
The grid size.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
VECTOR2D m_gridOffset
The grid offset to compensate cursor position.
VECTOR2D m_gridOrigin
The grid origin.

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

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

◆ SetGridSize()

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

Set the grid size.

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

Definition at line 904 of file graphics_abstraction_layer.h.

905  {
906  m_gridSize = aGridSize;
907 
908  // Avoid stupid grid size values: a grid size should be >= 1 in internal units
909  m_gridSize.x = std::max( 1.0, m_gridSize.x );
910  m_gridSize.y = std::max( 1.0, m_gridSize.y );
911 
912  m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x,
913  (long) m_gridOrigin.y % (long) m_gridSize.y );
914  }
VECTOR2D m_gridSize
The grid size.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
VECTOR2D m_gridOffset
The grid offset to compensate cursor position.
VECTOR2D m_gridOrigin
The grid origin.

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

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

◆ SetGridVisibility()

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

Set the visibility setting of the grid.

Parameters
aVisibilityis the new visibility setting of the grid.

Definition at line 864 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_gridVisibility.

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

◆ SetHorizontalJustify()

void KIGFX::GAL::SetHorizontalJustify ( const EDA_TEXT_HJUSTIFY_T  aHorizontalJustify)
inlineinherited

Set the horizontal justify for text drawing.

Parameters
aHorizontalJustifyis the horizontal justify value.

Definition at line 450 of file graphics_abstraction_layer.h.

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

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

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

◆ SetIsFill()

void CAIRO_GAL_BASE::SetIsFill ( bool  aIsFillEnabled)
overridevirtualinherited

Enable/disable fill.

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

Reimplemented from KIGFX::GAL.

Definition at line 553 of file cairo_gal.cpp.

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

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

◆ SetIsStroke()

void CAIRO_GAL_BASE::SetIsStroke ( bool  aIsStrokeEnabled)
overridevirtualinherited

Enable/disable stroked outlines.

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

Reimplemented from KIGFX::GAL.

Definition at line 568 of file cairo_gal.cpp.

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

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

◆ SetLayerDepth()

void CAIRO_GAL_BASE::SetLayerDepth ( double  aLayerDepth)
overridevirtualinherited

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

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

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

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

◆ SetLineWidth()

void CAIRO_GAL_BASE::SetLineWidth ( float  aLineWidth)
overridevirtualinherited

Set the line width.

Parameters
aLineWidthis the line width.

Reimplemented from KIGFX::GAL.

Definition at line 619 of file cairo_gal.cpp.

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

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

Referenced by KIGFX::CAIRO_GAL_BASE::DrawGrid(), and KIGFX::CAIRO_GAL_BASE::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 653 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_lookAtPoint.

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

◆ SetNativeCursorStyle()

bool GAL::SetNativeCursorStyle ( KICURSOR  aCursor)
virtualinherited

Set the cursor in the native panel.

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

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

Definition at line 280 of file graphics_abstraction_layer.cpp.

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

References KIGFX::GAL::m_currentNativeCursor.

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

◆ SetNativePaperSize()

void CAIRO_PRINT_GAL::SetNativePaperSize ( const VECTOR2D aSize,
bool  aRotateIfLandscape 
)
overridevirtual
Parameters
aSizeis the printing sheet size expressed in inches.
aRotateIfLandscapetrue if the platform requires 90 degrees rotation in order to print in landscape format.

Implements KIGFX::GAL_PRINT.

Definition at line 192 of file cairo_print.cpp.

193 {
194  m_nativePaperSize = aSize;
195  m_hasNativeLandscapeRotation = aHasNativeLandscapeRotation;
196 }
VECTOR2D m_nativePaperSize
Flag indicating whether the platform rotates page automatically or GAL needs to handle it in the tran...
Definition: cairo_print.h:120

References m_hasNativeLandscapeRotation, and m_nativePaperSize.

◆ SetNegativeDrawMode()

void CAIRO_GAL_BASE::SetNegativeDrawMode ( bool  aSetting)
overridevirtualinherited

Set negative draw mode in the renderer.

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

Parameters
aSettingis true if negative mode should be enabled

Reimplemented from KIGFX::GAL.

Definition at line 924 of file cairo_gal.cpp.

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

References KIGFX::CAIRO_GAL_BASE::m_currentContext.

◆ SetRotation()

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

Set the rotation angle.

Parameters
aRotationis the new rotation angle (radians).

Definition at line 693 of file graphics_abstraction_layer.h.

694  {
695  m_rotation = aRotation;
696  }
double m_rotation
Rotation transformation (radians)

References KIGFX::GAL::m_rotation.

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

◆ SetScreenDPI()

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

Set the dots per inch of the screen.

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

Parameters
aScreenDPIare the screen DPI.

Definition at line 641 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_screenDPI.

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

◆ SetScreenSize()

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

Definition at line 628 of file graphics_abstraction_layer.h.

629  {
630  m_screenSize = aSize;
631  }
VECTOR2I m_screenSize
Screen size in screen coordinates.

References KIGFX::GAL::m_screenSize.

Referenced by SetSheetSize().

◆ SetSheetSize()

void CAIRO_PRINT_GAL::SetSheetSize ( const VECTOR2D aSize)
overridevirtual
Parameters
aSizeis the schematics sheet size expressed in inches.

Implements KIGFX::GAL_PRINT.

Definition at line 199 of file cairo_print.cpp.

200 {
201  // Convert aSize (inches) to pixels
202  SetScreenSize( VECTOR2I( std::ceil( aSize.x * m_screenDPI ) * 2,
203  std::ceil( aSize.y * m_screenDPI ) * 2 ) );
204 }
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
double m_screenDPI
The dots per inch of the screen.
void SetScreenSize(const VECTOR2I &aSize)

References KIGFX::GAL::m_screenDPI, KIGFX::GAL::SetScreenSize(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ SetStrokeColor()

void CAIRO_GAL_BASE::SetStrokeColor ( const COLOR4D aColor)
overridevirtualinherited

Set the stroke color.

Parameters
aColoris the color for stroking the outline.

Reimplemented from KIGFX::GAL.

Definition at line 583 of file cairo_gal.cpp.

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

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

◆ SetTarget()

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

Set the target for rendering.

Parameters
aTargetis the new target for rendering.

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

Definition at line 784 of file graphics_abstraction_layer.h.

784 {};

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

◆ SetTextAttributes()

void GAL::SetTextAttributes ( const EDA_TEXT aText)
virtualinherited

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

Parameters
aTextis the text item.

Definition at line 155 of file graphics_abstraction_layer.cpp.

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

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

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

◆ SetTextMirrored()

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

◆ SetVerticalJustify()

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

Set the vertical justify for text drawing.

Parameters
aVerticalJustifyis the vertical justify value.

Definition at line 468 of file graphics_abstraction_layer.h.

469  {
470  textProperties.m_verticalJustify = aVerticalJustify;
471  }
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 604 of file graphics_abstraction_layer.h.

605  {
606  m_worldScreenMatrix = aMatrix;
607  }
MATRIX3x3D m_worldScreenMatrix
World transformation.

References KIGFX::GAL::m_worldScreenMatrix.

◆ SetWorldUnitLength()

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

Set the unit length.

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

Parameters
aWorldUnitLengthis the world Unit length.

Definition at line 623 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_worldUnitLength.

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

◆ SetZoomFactor()

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

Set the zoom factor of the scene.

Parameters
aZoomFactoris the zoom factor.

Definition at line 673 of file graphics_abstraction_layer.h.

674  {
675  m_zoomFactor = aZoomFactor;
676  }
double m_zoomFactor
The zoom factor.

References KIGFX::GAL::m_zoomFactor.

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

◆ Show()

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

Show/hide the GAL canvas.

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

Definition at line 206 of file graphics_abstraction_layer.h.

206 { return true; };

◆ StartDiffLayer()

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

Begins rendering of a differential layer.

Used by gerbview's differential mode.

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

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

Definition at line 830 of file graphics_abstraction_layer.h.

830 {};

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

◆ StartNegativesLayer()

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

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

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

Reimplemented in KIGFX::CAIRO_GAL.

Definition at line 847 of file graphics_abstraction_layer.h.

847 {};

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

◆ storePath()

void CAIRO_GAL_BASE::storePath ( )
protectedinherited

Store the actual path.

Definition at line 1090 of file cairo_gal.cpp.

1091 {
1092  if( m_isElementAdded )
1093  {
1094  m_isElementAdded = false;
1095 
1096  if( !m_isGrouping )
1097  {
1098  if( m_isFillEnabled )
1099  {
1100  cairo_set_source_rgba( m_currentContext, m_fillColor.r, m_fillColor.g,
1102  cairo_fill_preserve( m_currentContext );
1103  }
1104 
1105  if( m_isStrokeEnabled )
1106  {
1107  cairo_set_source_rgba( m_currentContext, m_strokeColor.r, m_strokeColor.g,
1109  cairo_stroke_preserve( m_currentContext );
1110  }
1111  }
1112  else
1113  {
1114  // Copy the actual path, append it to the global path list
1115  // then check, if the path needs to be stroked/filled and
1116  // add this command to the group list;
1117  if( m_isStrokeEnabled )
1118  {
1119  GROUP_ELEMENT groupElement;
1120  groupElement.m_CairoPath = cairo_copy_path( m_currentContext );
1121  groupElement.m_Command = CMD_STROKE_PATH;
1122  m_currentGroup->push_back( groupElement );
1123  }
1124 
1125  if( m_isFillEnabled )
1126  {
1127  GROUP_ELEMENT groupElement;
1128  groupElement.m_CairoPath = cairo_copy_path( m_currentContext );
1129  groupElement.m_Command = CMD_FILL_PATH;
1130  m_currentGroup->push_back( groupElement );
1131  }
1132  }
1133 
1134  cairo_new_path( m_currentContext );
1135  }
1136 }
bool m_isFillEnabled
Is filling of graphic objects enabled ?
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:333
double g
Green component.
Definition: color4d.h:372
double b
Blue component.
Definition: color4d.h:373
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:330
double a
Alpha component.
Definition: color4d.h:374
bool m_isStrokeEnabled
Are the outlines stroked ?
COLOR4D m_strokeColor
The color of the outlines.
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
COLOR4D m_fillColor
The fill color.
double r
Red component.
Definition: color4d.h:371
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:329

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

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

◆ StrokeText()

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

Draw a vector type text using preloaded Newstroke font.

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

Definition at line 347 of file graphics_abstraction_layer.h.

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

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

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

◆ syncLineWidth()

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

Definition at line 210 of file cairo_gal.cpp.

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

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

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

◆ ToScreen()

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

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

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

Definition at line 1002 of file graphics_abstraction_layer.h.

1003  {
1004  return VECTOR2D( m_worldScreenMatrix * aPoint );
1005  }
MATRIX3x3D m_worldScreenMatrix
World transformation.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622

References KIGFX::GAL::m_worldScreenMatrix.

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

◆ ToWorld()

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

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

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

Definition at line 991 of file graphics_abstraction_layer.h.

992  {
993  return VECTOR2D( m_screenWorldMatrix * aPoint );
994  }
MATRIX3x3D m_screenWorldMatrix
Screen transformation.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622

References KIGFX::GAL::m_screenWorldMatrix.

◆ Transform()

void CAIRO_GAL_BASE::Transform ( const MATRIX3x3D aTransformation)
overridevirtualinherited

Transform the context.

Parameters
aTransformationis the transformation matrix.

Reimplemented from KIGFX::GAL.

Definition at line 645 of file cairo_gal.cpp.

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

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

◆ Translate()

void CAIRO_GAL_BASE::Translate ( const VECTOR2D aTranslation)
overridevirtualinherited

Translate the context.

Parameters
aTranslationis the translation vector.

Reimplemented from KIGFX::GAL.

Definition at line 679 of file cairo_gal.cpp.

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

References KIGFX::CAIRO_GAL_BASE::CMD_TRANSLATE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::DblArg, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Argument, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::m_Command, KIGFX::CAIRO_GAL_BASE::m_currentGroup, KIGFX::CAIRO_GAL_BASE::m_currentXform, KIGFX::CAIRO_GAL_BASE::m_isGrouping, KIGFX::CAIRO_GAL_BASE::storePath(), KIGFX::CAIRO_GAL_BASE::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 1093 of file graphics_abstraction_layer.h.

1093 {}

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

◆ updatedGalDisplayOptions()

bool GAL::updatedGalDisplayOptions ( const GAL_DISPLAY_OPTIONS aOptions)
protectedvirtualinherited

Handle updating display options.

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

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

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

Definition at line 110 of file graphics_abstraction_layer.cpp.

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

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

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

◆ updateWorldScreenMatrix()

◆ xform() [1/3]

◆ xform() [2/3]

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

Definition at line 111 of file cairo_gal.cpp.

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