KiCad PCB EDA Suite
KIGFX::CAIRO_GAL Class Reference

#include <cairo_gal.h>

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

Public Member Functions

 CAIRO_GAL (GAL_DISPLAY_OPTIONS &aDisplayOptions, wxWindow *aParent, wxEvtHandler *aMouseListener=NULL, wxEvtHandler *aPaintListener=NULL, const wxString &aName=wxT("CairoCanvas"))
 Constructor CAIRO_GAL_BASE. More...
 
virtual ~CAIRO_GAL ()
 
bool IsVisible () const override
 

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

More...
 
virtual bool IsInitialized () const
 Returns the initalization status for the canvas. More...
 
virtual bool IsOpenGlEngine ()
 Returns true if the GAL engine is a opengl based type. More...
 
const VECTOR2IGetScreenPixelSize () const
 Returns GAL canvas size in pixels. More...
 
void SetClearColor (const COLOR4D &aColor)
 
const COLOR4DGetClearColor () const
 
const COLOR4DGetFillColor () const
 Get the fill color. More...
 
const COLOR4DGetStrokeColor () const
 Get the stroke color. More...
 
float GetLineWidth () const
 Get the line width. More...
 
const STROKE_FONTGetStrokeFont () const
 
virtual void StrokeText (const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
 Draws a vector type text using preloaded Newstroke font. More...
 
virtual void BitmapText (const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
 Draws a text using a bitmap font. More...
 
VECTOR2D GetTextLineSize (const UTF8 &aText) const
 Compute the X and Y size of a given text. More...
 
double GetOverbarVerticalPosition () const
 Compute the vertical position of an overbar, sometimes used in texts. More...
 
virtual void SetTextAttributes (const EDA_TEXT *aText)
 Loads attributes of the given text (bold/italic/underline/mirrored and so on). More...
 
void ResetTextAttributes ()
 Reset text attributes to default styling. More...
 
void SetGlyphSize (const VECTOR2D aGlyphSize)
 Set the font glyph size. More...
 
const VECTOR2DGetGlyphSize () const
 
void SetFontBold (const bool aBold)
 Set bold property of current font. More...
 
bool IsFontBold () const
 Returns true if current font has 'bold' attribute enabled. More...
 
void SetFontItalic (const bool aItalic)
 Set italic property of current font. More...
 
bool IsFontItalic () const
 Returns true if current font has 'italic' attribute enabled. More...
 
void SetTextMirrored (const bool aMirrored)
 Set a mirrored property of text. More...
 
bool IsTextMirrored () const
 Returns true if text should displayed mirrored. More...
 
void SetHorizontalJustify (const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
 Set the horizontal justify for text drawing. More...
 
EDA_TEXT_HJUSTIFY_T GetHorizontalJustify () const
 Returns current text horizontal justification setting. More...
 
void SetVerticalJustify (const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
 Set the vertical justify for text drawing. More...
 
EDA_TEXT_VJUSTIFY_T GetVerticalJustify () const
 Returns current text vertical justification setting. More...
 
virtual void ComputeWorldScreenMatrix ()
 Compute the world <-> screen transformation matrix. More...
 
const MATRIX3x3DGetWorldScreenMatrix () const
 Get the world <-> screen transformation matrix. More...
 
const MATRIX3x3DGetScreenWorldMatrix () const
 Get the screen <-> world transformation matrix. More...
 
void SetWorldScreenMatrix (const MATRIX3x3D &aMatrix)
 Set the world <-> screen transformation matrix. More...
 
void SetWorldUnitLength (double aWorldUnitLength)
 Set the unit length. More...
 
void SetScreenSize (const VECTOR2I &aSize)
 
void SetScreenDPI (double aScreenDPI)
 Set the dots per inch of the screen. More...
 
void SetLookAtPoint (const VECTOR2D &aPoint)
 Set the Point in world space to look at. More...
 
const VECTOR2DGetLookAtPoint () const
 Get the look at point. More...
 
void SetZoomFactor (double aZoomFactor)
 Set the zoom factor of the scene. More...
 
double GetZoomFactor () const
 Get the zoom factor. More...
 
void SetRotation (double aRotation)
 Set the rotation angle. More...
 
double GetRotation () const
 Get the rotation angle. More...
 
void SetDepthRange (const VECTOR2D &aDepthRange)
 Set the range of the layer depth. More...
 
double GetMinDepth () const
 Returns the minimum depth in the currently used range (the top). More...
 
double GetMaxDepth () const
 Returns the maximum depth in the currently used range (the bottom). More...
 
double GetWorldScale () const
 Get the world scale. More...
 
void SetFlip (bool xAxis, bool yAxis)
 Sets flipping of the screen. More...
 
bool IsFlippedX () const
 Return true if flip flag for the X axis is set. More...
 
bool IsFlippedY () const
 Return true if flip flag for the Y axis is set. More...
 
void SetGridVisibility (bool aVisibility)
 Sets the visibility setting of the grid. More...
 
void SetGridOrigin (const VECTOR2D &aGridOrigin)
 Set the origin point for the grid. More...
 
void SetGridSize (const VECTOR2D &aGridSize)
 Set the grid size. More...
 
const VECTOR2DGetGridSize () const
 Returns the grid size. More...
 
void SetGridColor (const COLOR4D &aGridColor)
 Set the grid color. More...
 
void SetAxesColor (const COLOR4D &aAxesColor)
 Set the axes color. More...
 
void SetAxesEnabled (bool aAxesEnabled)
 Enables drawing the axes. More...
 
void SetCoarseGrid (int aInterval)
 Draw every tick line wider. More...
 
float GetGridLineWidth () const
 Get the grid line width. More...
 
VECTOR2D GetGridPoint (const VECTOR2D &aPoint) const
 Function GetGridPoint() For a given point it returns the nearest point belonging to the grid in world coordinates. More...
 
VECTOR2D ToWorld (const VECTOR2D &aPoint) const
 Compute the point position in world coordinates from given screen coordinates. More...
 
VECTOR2D ToScreen (const VECTOR2D &aPoint) const
 Compute the point position in screen coordinates from given world coordinates. More...
 
void SetCursorEnabled (bool aCursorEnabled)
 Enable/disable cursor. More...
 
bool IsCursorEnabled () const
 Returns information about cursor visibility. More...
 
void SetCursorColor (const COLOR4D &aCursorColor)
 Set the cursor color. More...
 
void AdvanceDepth ()
 Changes the current depth to deeper, so it is possible to draw objects right beneath other. More...
 
void PushDepth ()
 Stores current drawing depth on the depth stack. More...
 
void PopDepth ()
 Restores previously stored drawing depth for the depth stack. More...
 

Protected Types

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

Protected Member Functions

virtual void beginDrawing () override
 
virtual void endDrawing () override
 
void initSurface ()
 Prepare Cairo surfaces for drawing. More...
 
void deinitSurface ()
 Destroy Cairo surfaces when are not needed anymore. More...
 
void allocateBitmaps ()
 Allocate the bitmaps for drawing. More...
 
void deleteBitmaps ()
 Allocate the bitmaps for drawing. More...
 
void setCompositor ()
 Prepare the compositor. More...
 
void onPaint (wxPaintEvent &aEvent)
 Paint event handler. More...
 
void skipMouseEvent (wxMouseEvent &aEvent)
 Mouse event handler, forwards the event to the child. More...
 
bool updatedGalDisplayOptions (const GAL_DISPLAY_OPTIONS &aOptions) override
 

Cairo-specific update handlers

More...
 
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)
 
void resetContext ()
 
void drawGridLine (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
 Draw a grid line (usually a simplified line function). More...
 
void drawGridCross (const VECTOR2D &aPoint)
 
void drawGridPoint (const VECTOR2D &aPoint, double aSize)
 
void drawAxes (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
 
void flushPath ()
 
void storePath ()
 Store the actual path. More...
 
virtual void blitCursor (wxMemoryDC &clientDC)
 Blits cursor into the current screen. More...
 
void drawPoly (const std::deque< VECTOR2D > &aPointList)
 Drawing polygons & polylines is the same in cairo, so here is the common code. More...
 
void drawPoly (const VECTOR2D aPointList[], int aListSize)
 
void drawPoly (const SHAPE_LINE_CHAIN &aLineChain)
 
unsigned int getNewGroupNumber ()
 Returns a valid key that can be used as a new group number. More...
 
void syncLineWidth (bool aForceWidth=false, double aWidth=0.0)
 
void updateWorldScreenMatrix ()
 
const VECTOR2D roundp (const VECTOR2D &v)
 
virtual void lockContext (int aClientCookie)
 Private: use GAL_CONTEXT_LOCKER RAII object. More...
 
virtual void unlockContext (int aClientCookie)
 
virtual void beginUpdate ()
 Enables item update mode. More...
 
virtual void endUpdate ()
 Disables item update mode. More...
 
void computeWorldScale ()
 Compute the scaling factor for the world->screen matrix. More...
 
double computeMinGridSpacing () const
 compute minimum grid spacing from the grid settings More...
 
COLOR4D getCursorColor () const
 Gets the actual cursor color to draw. More...
 
void OnGalDisplayOptionsChanged (const GAL_DISPLAY_OPTIONS &aOptions) override
 Handler for observer settings changes. More...
 

Protected Attributes

std::shared_ptr< CAIRO_COMPOSITORcompositor
 Object for layers compositing. More...
 
unsigned int mainBuffer
 Handle to the main buffer. More...
 
unsigned int overlayBuffer
 Handle to the overlay buffer. More...
 
RENDER_TARGET currentTarget
 Current rendering target. More...
 
bool validCompositor
 Compositor initialization flag. More...
 
wxWindow * parentWindow
 Parent window. More...
 
wxEvtHandler * mouseListener
 Mouse listener. More...
 
wxEvtHandler * paintListener
 Paint listener. More...
 
unsigned int bufferSize
 Size of buffers cairoOutput, bitmapBuffers. More...
 
unsigned char * wxOutput
 wxImage comaptible buffer More...
 
unsigned int * bitmapBuffer
 Storage of the cairo image. More...
 
unsigned int * bitmapBufferBackup
 Backup storage of the cairo image. More...
 
int stride
 Stride value for Cairo. More...
 
int wxBufferWidth
 
bool isInitialized
 Are Cairo image & surface ready to use. More...
 
COLOR4D backgroundColor
 Background color. More...
 
bool isGrouping
 Is grouping enabled ? More...
 
bool isElementAdded
 Was an graphic element added ? More...
 
std::map< int, GROUPgroups
 List of graphic groups. More...
 
unsigned int groupCounter
 Counter used for generating keys for groups. More...
 
GROUPcurrentGroup
 Currently used group. More...
 
double lineWidth
 
double linePixelWidth
 
double lineWidthInPixels
 
bool lineWidthIsOdd
 
cairo_matrix_t cairoWorldScreenMatrix
 Cairo world to screen transformation matrix. More...
 
cairo_matrix_t currentXform
 
cairo_matrix_t currentWorld2Screen
 
cairo_t * currentContext
 Currently used Cairo context for drawing. More...
 
cairo_t * context
 Cairo image. More...
 
cairo_surface_t * surface
 Cairo surface. More...
 
std::vector< cairo_matrix_t > xformStack
 
GAL_DISPLAY_OPTIONSoptions
 
UTIL::LINK observerLink
 
std::stack< double > depthStack
 Stored depth values. More...
 
VECTOR2I screenSize
 Screen size in screen coordinates. More...
 
double worldUnitLength
 The unit length of the world coordinates [inch]. More...
 
double screenDPI
 The dots per inch of the screen. More...
 
VECTOR2D lookAtPoint
 Point to be looked at in world space. More...
 
double zoomFactor
 The zoom factor. More...
 
double rotation
 Rotation transformation (radians) More...
 
MATRIX3x3D worldScreenMatrix
 World transformation. More...
 
MATRIX3x3D screenWorldMatrix
 Screen transformation. More...
 
double worldScale
 The scale factor world->screen. More...
 
bool globalFlipX
 Flag for X axis flipping. More...
 
bool globalFlipY
 Flag for Y axis flipping. More...
 
bool isFillEnabled
 Is filling of graphic objects enabled ? More...
 
bool isStrokeEnabled
 Are the outlines stroked ? More...
 
COLOR4D fillColor
 The fill color. More...
 
COLOR4D strokeColor
 The color of the outlines. More...
 
COLOR4D m_clearColor
 
double layerDepth
 The actual layer depth. More...
 
VECTOR2D depthRange
 Range of the depth. More...
 
bool gridVisibility
 Should the grid be shown. More...
 
GRID_STYLE gridStyle
 Grid display style. More...
 
VECTOR2D gridSize
 The grid size. More...
 
VECTOR2D gridOrigin
 The grid origin. More...
 
VECTOR2D gridOffset
 The grid offset to compensate cursor position. More...
 
COLOR4D gridColor
 Color of the grid. More...
 
COLOR4D axesColor
 Color of the axes. More...
 
bool axesEnabled
 Should the axes be drawn. More...
 
int gridTick
 Every tick line gets the double width. More...
 
float gridLineWidth
 Line width of the grid. More...
 
int gridMinSpacing
 Minimum screen size of the grid (pixels) below which the grid is not drawn. More...
 
bool isCursorEnabled
 Is the cursor enabled? More...
 
bool forceDisplayCursor
 Always show cursor. More...
 
COLOR4D cursorColor
 Cursor color. More...
 
bool fullscreenCursor
 Shape of the cursor (fullscreen or small cross) More...
 
VECTOR2D cursorPosition
 Current cursor position (world coordinates) More...
 
STROKE_FONT strokeFont
 Instance of object that stores information about how to draw texts. More...
 

Static Protected Attributes

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

Detailed Description

Definition at line 335 of file cairo_gal.h.

Member Typedef Documentation

◆ GROUP

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

A graphic group type definition.

Definition at line 286 of file cairo_gal.h.

◆ super

typedef GAL KIGFX::CAIRO_GAL_BASE::super
protectedinherited

Super class definition.

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

254  {
255  CMD_SET_FILL,
261  CMD_FILL_PATH,
262  //CMD_TRANSFORM, ///< Transform the actual context
263  CMD_ROTATE,
264  CMD_TRANSLATE,
265  CMD_SCALE,
266  CMD_SAVE,
267  CMD_RESTORE,
269  };
Enable/disable filling.
Definition: cairo_gal.h:255
Save the transformation matrix.
Definition: cairo_gal.h:266
Translate the context.
Definition: cairo_gal.h:264
Enable/disable stroking.
Definition: cairo_gal.h:256
Restore the transformation matrix.
Definition: cairo_gal.h:267

Constructor & Destructor Documentation

◆ CAIRO_GAL()

CAIRO_GAL::CAIRO_GAL ( GAL_DISPLAY_OPTIONS aDisplayOptions,
wxWindow *  aParent,
wxEvtHandler *  aMouseListener = NULL,
wxEvtHandler *  aPaintListener = NULL,
const wxString &  aName = wxT( "CairoCanvas" ) 
)

Constructor CAIRO_GAL_BASE.

Parameters
aParentis the wxWidgets immediate wxWindow parent of this object.
aMouseListeneris the wxEvtHandler that should receive the mouse events, this can be can be any wxWindow, but is often a wxFrame container.
aPaintListeneris the wxEvtHandler that should receive the paint event. This can be any wxWindow, but is often a derived instance of this class or a containing wxFrame. The "paint event" here is a wxCommandEvent holding EVT_GAL_REDRAW, as sent by PostPaint().
aNameis the name of this window for use by wxWindow::FindWindowByName()

Definition at line 1139 of file cairo_gal.cpp.

1141  :
1142  CAIRO_GAL_BASE( aDisplayOptions ),
1143  wxWindow( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxEXPAND, aName )
1144 {
1145  // Initialise compositing state
1146  mainBuffer = 0;
1147  overlayBuffer = 0;
1148  validCompositor = false;
1150 
1151  parentWindow = aParent;
1152  mouseListener = aMouseListener;
1153  paintListener = aPaintListener;
1154 
1155  // Connecting the event handlers
1156  Connect( wxEVT_PAINT, wxPaintEventHandler( CAIRO_GAL::onPaint ) );
1157 
1158  // Mouse events are skipped to the parent
1159  Connect( wxEVT_MOTION, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1160  Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1161  Connect( wxEVT_LEFT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1162  Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1163  Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1164  Connect( wxEVT_MIDDLE_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1165  Connect( wxEVT_MIDDLE_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1166  Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1167  Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1168  Connect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1169  Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1170 #if defined _WIN32 || defined _WIN64
1171  Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1172 #endif
1173 
1174  SetSize( aParent->GetClientSize() );
1175  screenSize = VECTOR2I( aParent->GetClientSize() );
1176 
1177  // Allocate memory for pixel storage
1178  allocateBitmaps();
1179 
1180  isInitialized = false;
1181 }
void onPaint(wxPaintEvent &aEvent)
Paint event handler.
Definition: cairo_gal.cpp:1444
CAIRO_GAL_BASE(GAL_DISPLAY_OPTIONS &aDisplayOptions)
Definition: cairo_gal.cpp:46
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:427
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:411
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:413
Auxiliary rendering target (noncached)
Definition: definitions.h:49
wxEvtHandler * paintListener
Paint listener.
Definition: cairo_gal.h:418
virtual void SetTarget(RENDER_TARGET aTarget) override
Sets the target for rendering.
Definition: cairo_gal.cpp:1312
void skipMouseEvent(wxMouseEvent &aEvent)
Mouse event handler, forwards the event to the child.
Definition: cairo_gal.cpp:1450
VECTOR2I screenSize
Screen size in screen coordinates.
wxEvtHandler * mouseListener
Mouse listener.
Definition: cairo_gal.h:417
void allocateBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1406
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:410
wxWindow * parentWindow
Parent window.
Definition: cairo_gal.h:416

References allocateBitmaps(), isInitialized, mainBuffer, mouseListener, onPaint(), overlayBuffer, paintListener, parentWindow, KIGFX::GAL::screenSize, SetTarget(), skipMouseEvent(), KIGFX::TARGET_NONCACHED, and validCompositor.

◆ ~CAIRO_GAL()

CAIRO_GAL::~CAIRO_GAL ( )
virtual

Definition at line 1184 of file cairo_gal.cpp.

1185 {
1186  deleteBitmaps();
1187 }
void deleteBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1421

References deleteBitmaps().

Member Function Documentation

◆ AdvanceDepth()

void KIGFX::GAL::AdvanceDepth ( )
inlineinherited

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

Definition at line 1022 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::layerDepth.

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

◆ allocateBitmaps()

void CAIRO_GAL::allocateBitmaps ( )
protected

Allocate the bitmaps for drawing.

Definition at line 1406 of file cairo_gal.cpp.

1407 {
1409  while( ( ( wxBufferWidth * 3 ) % 4 ) != 0 ) wxBufferWidth++;
1410 
1411  // Create buffer, use the system independent Cairo context backend
1412  stride = cairo_format_stride_for_width( GAL_FORMAT, wxBufferWidth );
1414 
1415  bitmapBuffer = new unsigned int[bufferSize];
1416  bitmapBufferBackup = new unsigned int[bufferSize];
1417  wxOutput = new unsigned char[wxBufferWidth * 3 * screenSize.y];
1418 }
unsigned char * wxOutput
wxImage comaptible buffer
Definition: cairo_gal.h:420
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:423
int stride
Stride value for Cairo.
Definition: cairo_gal.h:425
unsigned int * bitmapBufferBackup
Backup storage of the cairo image.
Definition: cairo_gal.h:424
VECTOR2I screenSize
Screen size in screen coordinates.
unsigned int bufferSize
Size of buffers cairoOutput, bitmapBuffers.
Definition: cairo_gal.h:419
static constexpr cairo_format_t GAL_FORMAT
Format used to store pixels.
Definition: cairo_gal.h:331

References bitmapBuffer, bitmapBufferBackup, bufferSize, KIGFX::CAIRO_GAL_BASE::GAL_FORMAT, KIGFX::GAL::screenSize, stride, wxBufferWidth, wxOutput, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by CAIRO_GAL(), and ResizeScreen().

◆ angle_xform()

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

Definition at line 118 of file cairo_gal.cpp.

119 {
120  double world_angle = -std::atan2( currentWorld2Screen.xy, currentWorld2Screen.xx );
121 
122  return std::fmod( aAngle + world_angle, 2.0 * M_PI );
123 }
cairo_matrix_t currentWorld2Screen
Definition: cairo_gal.h:298

References KIGFX::CAIRO_GAL_BASE::currentWorld2Screen.

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

◆ beginDrawing()

void CAIRO_GAL::beginDrawing ( )
overrideprotectedvirtual

Reimplemented from KIGFX::CAIRO_GAL_BASE.

Definition at line 1190 of file cairo_gal.cpp.

1191 {
1192  initSurface();
1193 
1195 
1196  if( !validCompositor )
1197  setCompositor();
1198 
1199  compositor->SetMainContext( context );
1200  compositor->SetBuffer( mainBuffer );
1201 }
void initSurface()
Prepare Cairo surfaces for drawing.
Definition: cairo_gal.cpp:1372
void setCompositor()
Prepare the compositor.
Definition: cairo_gal.cpp:1429
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:413
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:409
cairo_t * context
Cairo image.
Definition: cairo_gal.h:300
virtual void beginDrawing() override
Definition: cairo_gal.cpp:84
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:410

References KIGFX::CAIRO_GAL_BASE::beginDrawing(), compositor, KIGFX::CAIRO_GAL_BASE::context, initSurface(), mainBuffer, setCompositor(), and validCompositor.

◆ BeginGroup()

int CAIRO_GAL::BeginGroup ( )
overridevirtual

Begin a group.

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

Returns
the number of the group.

Reimplemented from KIGFX::CAIRO_GAL_BASE.

Definition at line 1298 of file cairo_gal.cpp.

1299 {
1300  initSurface();
1301  return CAIRO_GAL_BASE::BeginGroup();
1302 }
void initSurface()
Prepare Cairo surfaces for drawing.
Definition: cairo_gal.cpp:1372
virtual int BeginGroup() override
Begin a group.
Definition: cairo_gal.cpp:695

References KIGFX::CAIRO_GAL_BASE::BeginGroup(), and initSurface().

◆ beginUpdate()

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

Enables item update mode.

Private: use GAL_UPDATE_CONTEXT RAII object

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1110 of file graphics_abstraction_layer.h.

1110 {}

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

◆ BitmapText()

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

Draws a text using a bitmap font.

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

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

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 353 of file graphics_abstraction_layer.h.

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

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

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

◆ blitCursor()

void CAIRO_GAL_BASE::blitCursor ( wxMemoryDC &  clientDC)
protectedvirtualinherited

Blits cursor into the current screen.

Definition at line 1036 of file cairo_gal.cpp.

1037 {
1038  if( !IsCursorEnabled() )
1039  return;
1040 
1041  auto p = ToScreen( cursorPosition );
1042 
1043  const auto cColor = getCursorColor();
1044  const int cursorSize = fullscreenCursor ? 8000 : 80;
1045 
1046  wxColour color( cColor.r * cColor.a * 255, cColor.g * cColor.a * 255,
1047  cColor.b * cColor.a * 255, 255 );
1048  clientDC.SetPen( wxPen( color ) );
1049  clientDC.DrawLine( p.x - cursorSize / 2, p.y, p.x + cursorSize / 2, p.y );
1050  clientDC.DrawLine( p.x, p.y - cursorSize / 2, p.x, p.y + cursorSize / 2 );
1051 }
VECTOR2D cursorPosition
Current cursor position (world coordinates)
VECTOR2D ToScreen(const VECTOR2D &aPoint) const
Compute the point position in screen coordinates from given world coordinates.
int color
Definition: DXF_plotter.cpp:62
bool fullscreenCursor
Shape of the cursor (fullscreen or small cross)
COLOR4D getCursorColor() const
Gets the actual cursor color to draw.
bool IsCursorEnabled() const
Returns information about cursor visibility.

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

Referenced by endDrawing().

◆ ChangeGroupColor()

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

Changes the color used to draw the group.

Parameters
aGroupNumberis the group number.
aNewColoris the new color.

Reimplemented from KIGFX::GAL.

Definition at line 808 of file cairo_gal.cpp.

809 {
810  storePath();
811 
812  for( GROUP::iterator it = groups[aGroupNumber].begin();
813  it != groups[aGroupNumber].end(); ++it )
814  {
815  if( it->command == CMD_SET_FILLCOLOR || it->command == CMD_SET_STROKECOLOR )
816  {
817  it->argument.dblArg[0] = aNewColor.r;
818  it->argument.dblArg[1] = aNewColor.g;
819  it->argument.dblArg[2] = aNewColor.b;
820  it->argument.dblArg[3] = aNewColor.a;
821  }
822  }
823 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:988
double g
Green component.
Definition: color4d.h:310
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:287
double r
Red component.
Definition: color4d.h:309

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::groups, KIGFX::COLOR4D::r, and KIGFX::CAIRO_GAL_BASE::storePath().

◆ ChangeGroupDepth()

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

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

Parameters
aGroupNumberis the group number.
aDepthis the new depth.

Reimplemented from KIGFX::GAL.

Definition at line 826 of file cairo_gal.cpp.

827 {
828  // Cairo does not have any possibilities to change the depth coordinate of stored items,
829  // it depends only on the order of drawing
830 }

◆ ClearCache()

void CAIRO_GAL_BASE::ClearCache ( )
overridevirtualinherited

Delete all data created during caching of graphic items.

Reimplemented from KIGFX::GAL.

Definition at line 853 of file cairo_gal.cpp.

854 {
855  for( auto it = groups.begin(); it != groups.end(); )
856  DeleteGroup( ( it++ )->first );
857 }
virtual void DeleteGroup(int aGroupNumber) override
Delete the group from the memory.
Definition: cairo_gal.cpp:833
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:287

References KIGFX::CAIRO_GAL_BASE::DeleteGroup(), and KIGFX::CAIRO_GAL_BASE::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 478 of file cairo_gal.cpp.

479 {
480  cairo_set_source_rgb( currentContext, m_clearColor.r, m_clearColor.g, m_clearColor.b );
481  cairo_rectangle( currentContext, 0.0, 0.0, screenSize.x, screenSize.y );
482  cairo_fill( currentContext );
483 }
double g
Green component.
Definition: color4d.h:310
double b
Blue component.
Definition: color4d.h:311
VECTOR2I screenSize
Screen size in screen coordinates.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
double r
Red component.
Definition: color4d.h:309

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

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

◆ ClearTarget()

void CAIRO_GAL::ClearTarget ( RENDER_TARGET  aTarget)
overridevirtual

Clears the target for rendering.

Parameters
aTargetis the target to be cleared.

Reimplemented from KIGFX::GAL.

Definition at line 1346 of file cairo_gal.cpp.

1347 {
1348  // Save the current state
1349  unsigned int currentBuffer = compositor->GetBuffer();
1350 
1351  switch( aTarget )
1352  {
1353  // Cached and noncached items are rendered to the same buffer
1354  default:
1355  case TARGET_CACHED:
1356  case TARGET_NONCACHED:
1357  compositor->SetBuffer( mainBuffer );
1358  break;
1359 
1360  case TARGET_OVERLAY:
1361  compositor->SetBuffer( overlayBuffer );
1362  break;
1363  }
1364 
1365  compositor->ClearBuffer( COLOR4D::BLACK );
1366 
1367  // Restore the previous state
1368  compositor->SetBuffer( currentBuffer );
1369 }
static const COLOR4D BLACK
Definition: color4d.h:319
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:411
Auxiliary rendering target (noncached)
Definition: definitions.h:49
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:409
Items that may change while the view stays the same (noncached)
Definition: definitions.h:50
Main rendering target (cached)
Definition: definitions.h:48
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:410

References KIGFX::COLOR4D::BLACK, compositor, mainBuffer, overlayBuffer, KIGFX::TARGET_CACHED, KIGFX::TARGET_NONCACHED, and KIGFX::TARGET_OVERLAY.

◆ computeMinGridSpacing()

double GAL::computeMinGridSpacing ( ) const
protectedinherited

compute minimum grid spacing from the grid settings

Returns
the minimum spacing to use for drawing the grid

Definition at line 208 of file graphics_abstraction_layer.cpp.

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

References KIGFX::GAL::gridMinSpacing.

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

◆ computeWorldScale()

void KIGFX::GAL::computeWorldScale ( )
inlineprotectedinherited

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

Definition at line 1124 of file graphics_abstraction_layer.h.

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

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

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

◆ ComputeWorldScreenMatrix()

void GAL::ComputeWorldScreenMatrix ( )
virtualinherited

Compute the world <-> screen transformation matrix.

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

Definition at line 179 of file graphics_abstraction_layer.cpp.

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

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

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

◆ deinitSurface()

void CAIRO_GAL::deinitSurface ( )
protected

Destroy Cairo surfaces when are not needed anymore.

Definition at line 1392 of file cairo_gal.cpp.

1393 {
1394  if( !isInitialized )
1395  return;
1396 
1397  cairo_destroy( context );
1398  context = nullptr;
1399  cairo_surface_destroy( surface );
1400  surface = nullptr;
1401 
1402  isInitialized = false;
1403 }
cairo_surface_t * surface
Cairo surface.
Definition: cairo_gal.h:301
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:427
cairo_t * context
Cairo image.
Definition: cairo_gal.h:300

References KIGFX::CAIRO_GAL_BASE::context, isInitialized, and KIGFX::CAIRO_GAL_BASE::surface.

Referenced by endDrawing(), EndGroup(), and updatedGalDisplayOptions().

◆ deleteBitmaps()

void CAIRO_GAL::deleteBitmaps ( )
protected

Allocate the bitmaps for drawing.

Definition at line 1421 of file cairo_gal.cpp.

1422 {
1423  delete[] bitmapBuffer;
1424  delete[] bitmapBufferBackup;
1425  delete[] wxOutput;
1426 }
unsigned char * wxOutput
wxImage comaptible buffer
Definition: cairo_gal.h:420
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:423
unsigned int * bitmapBufferBackup
Backup storage of the cairo image.
Definition: cairo_gal.h:424

References bitmapBuffer, bitmapBufferBackup, and wxOutput.

Referenced by ResizeScreen(), and ~CAIRO_GAL().

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

834 {
835  storePath();
836 
837  // Delete the Cairo paths
838  std::deque<GROUP_ELEMENT>::iterator it, end;
839 
840  for( it = groups[aGroupNumber].begin(), end = groups[aGroupNumber].end(); it != end; ++it )
841  {
842  if( it->command == CMD_FILL_PATH || it->command == CMD_STROKE_PATH )
843  {
844  cairo_path_destroy( it->cairoPath );
845  }
846  }
847 
848  // Delete the group
849  groups.erase( aGroupNumber );
850 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:988
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:287

References KIGFX::CAIRO_GAL_BASE::CMD_FILL_PATH, KIGFX::CAIRO_GAL_BASE::CMD_STROKE_PATH, KIGFX::CAIRO_GAL_BASE::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 256 of file cairo_gal.cpp.

258 {
259  syncLineWidth();
260 
261  SWAP( aStartAngle, >, aEndAngle );
262  auto startAngleS = angle_xform( aStartAngle );
263  auto endAngleS = angle_xform( aEndAngle );
264  auto r = xform( aRadius );
265 
266  // N.B. This is backwards. We set this because we want to adjust the center
267  // point that changes both endpoints. In the worst case, this is twice as far.
268  // We cannot adjust radius or center based on the other because this causes the
269  // whole arc to change position/size
270  lineWidthIsOdd = !( static_cast<int>( aRadius ) % 1 );
271 
272  auto mid = roundp( xform( aCenterPoint ) );
273 
274  cairo_set_line_width( currentContext, lineWidthInPixels );
275  cairo_new_sub_path( currentContext );
276 
277  if( isFillEnabled )
278  cairo_move_to( currentContext, mid.x, mid.y );
279 
280  cairo_arc( currentContext, mid.x, mid.y, r, startAngleS, endAngleS );
281 
282  if( isFillEnabled )
283  cairo_close_path( currentContext );
284 
285  flushPath();
286 
287  isElementAdded = true;
288 }
const double angle_xform(const double aAngle)
Definition: cairo_gal.cpp:118
const double xform(double x)
Definition: cairo_gal.cpp:126
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:140
bool isFillEnabled
Is filling of graphic objects enabled ?
#define SWAP(varA, condition, varB)
Swap the variables if a condition is met.
Definition: definitions.h:31
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:163
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:285

References KIGFX::CAIRO_GAL_BASE::angle_xform(), KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::flushPath(), KIGFX::CAIRO_GAL_BASE::isElementAdded, KIGFX::GAL::isFillEnabled, KIGFX::CAIRO_GAL_BASE::lineWidthInPixels, KIGFX::CAIRO_GAL_BASE::lineWidthIsOdd, KIGFX::CAIRO_GAL_BASE::roundp(), SWAP, 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 
)
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).

Reimplemented from KIGFX::GAL.

Definition at line 291 of file cairo_gal.cpp.

293 {
294  if( isFillEnabled )
295  {
296  lineWidth = aWidth;
297  isStrokeEnabled = true;
298  isFillEnabled = false;
299  DrawArc( aCenterPoint, aRadius, aStartAngle, aEndAngle );
300  isFillEnabled = true;
301  isStrokeEnabled = false;
302  return;
303  }
304 
305  syncLineWidth();
306  SWAP( aStartAngle, >, aEndAngle );
307  auto startAngleS = angle_xform( aStartAngle );
308  auto endAngleS = angle_xform( aEndAngle );
309  auto r = xform( aRadius );
310 
311  // N.B. This is backwards. We set this because we want to adjust the center
312  // point that changes both endpoints. In the worst case, this is twice as far.
313  // We cannot adjust radius or center based on the other because this causes the
314  // whole arc to change position/size
315  lineWidthIsOdd = !( static_cast<int>( aRadius ) % 1 );
316 
317  auto mid = roundp( xform( aCenterPoint ) );
318  auto width = xform( aWidth / 2.0 );
319  auto startPointS = VECTOR2D( r, 0.0 ).Rotate( startAngleS );
320  auto endPointS = VECTOR2D( r, 0.0 ).Rotate( endAngleS );
321 
322  cairo_save( currentContext );
323 
324  cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
325 
326  cairo_translate( currentContext, mid.x, mid.y );
327 
328  cairo_new_sub_path( currentContext );
329  cairo_arc( currentContext, 0, 0, r - width, startAngleS, endAngleS );
330 
331  cairo_new_sub_path( currentContext );
332  cairo_arc( currentContext, 0, 0, r + width, startAngleS, endAngleS );
333 
334  cairo_new_sub_path( currentContext );
335  cairo_arc_negative( currentContext, startPointS.x, startPointS.y, width, startAngleS, startAngleS + M_PI );
336 
337  cairo_new_sub_path( currentContext );
338  cairo_arc( currentContext, endPointS.x, endPointS.y, width, endAngleS, endAngleS + M_PI );
339 
340  cairo_restore( currentContext );
341  flushPath();
342 
343  isElementAdded = true;
344 }
double g
Green component.
Definition: color4d.h:310
const double angle_xform(const double aAngle)
Definition: cairo_gal.cpp:118
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
bool isStrokeEnabled
Are the outlines stroked ?
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
COLOR4D strokeColor
The color of the outlines.
const double xform(double x)
Definition: cairo_gal.cpp:126
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:140
bool isFillEnabled
Is filling of graphic objects enabled ?
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle) override
Draw an arc.
Definition: cairo_gal.cpp:256
VECTOR2< T > Rotate(double aAngle) const
Function Rotate rotates the vector by a given angle.
Definition: vector2d.h:370
#define SWAP(varA, condition, varB)
Swap the variables if a condition is met.
Definition: definitions.h:31
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:163
double r
Red component.
Definition: color4d.h:309
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:285

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

◆ drawAxes()

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

Definition at line 904 of file cairo_gal.cpp.

905 {
906  syncLineWidth();
907  auto p0 = roundp( xform( aStartPoint ) );
908  auto p1 = roundp( xform( aEndPoint ) );
909 
910  cairo_move_to( currentContext, p0.x, 0.0);
911  cairo_line_to( currentContext, p1.x, 0.0 );
912  cairo_move_to( currentContext, 0.0, p0.y );
913  cairo_line_to( currentContext, 0.0, p1.y );
914  cairo_set_source_rgba( currentContext, axesColor.r, axesColor.g, axesColor.b, axesColor.a );
915  cairo_stroke( currentContext );
916 }
double g
Green component.
Definition: color4d.h:310
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
COLOR4D axesColor
Color of the axes.
const double xform(double x)
Definition: cairo_gal.cpp:126
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:140
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:163
double r
Red component.
Definition: color4d.h:309

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

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

402 {
403  cairo_save( currentContext );
404 
405  // We have to calculate the pixel size in users units to draw the image.
406  // worldUnitLength is a factor used for converting IU to inches
407  double scale = 1.0 / ( aBitmap.GetPPI() * worldUnitLength );
408 
409  // The position of the bitmap is the bitmap center.
410  // move the draw origin to the top left bitmap corner:
411  int w = aBitmap.GetSizePixels().x;
412  int h = aBitmap.GetSizePixels().y;
413 
414  cairo_set_matrix( currentContext, &currentWorld2Screen );
415  cairo_scale( currentContext, scale, scale );
416  cairo_translate( currentContext, -w / 2.0, -h / 2.0 );
417 
418  cairo_new_path( currentContext );
419  cairo_surface_t* image = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, w, h );
420  cairo_surface_flush( image );
421 
422  unsigned char* pix_buffer = cairo_image_surface_get_data( image );
423  // The pixel buffer of the initial bitmap:
424  auto bm_pix_buffer = const_cast<BITMAP_BASE&>( aBitmap ).GetImageData();
425  uint32_t mask_color = ( bm_pix_buffer->GetMaskRed() << 16 ) +
426  ( bm_pix_buffer->GetMaskGreen() << 8 ) +
427  ( bm_pix_buffer->GetMaskBlue() );
428 
429  // Copy the source bitmap to the cairo bitmap buffer.
430  // In cairo bitmap buffer, a ARGB32 bitmap is an ARGB pixel packed into a uint_32
431  // 24 low bits only are used for color, top 8 are transparency.
432  for( int row = 0; row < h; row++ )
433  {
434  for( int col = 0; col < w; col++ )
435  {
436  // Build the RGB24 pixel:
437  uint32_t pixel = bm_pix_buffer->GetRed( col, row ) << 16;
438  pixel += bm_pix_buffer->GetGreen( col, row ) << 8;
439  pixel += bm_pix_buffer->GetBlue( col, row );
440 
441  if( bm_pix_buffer->HasAlpha() )
442  pixel += bm_pix_buffer->GetAlpha( col, row ) << 24;
443  else if( bm_pix_buffer->HasMask() && pixel == mask_color )
444  pixel += ( wxALPHA_TRANSPARENT << 24 );
445  else
446  pixel += ( wxALPHA_OPAQUE << 24 );
447 
448  // Write the pixel to the cairo image buffer:
449  uint32_t* pix_ptr = (uint32_t*) pix_buffer;
450  *pix_ptr = pixel;
451  pix_buffer += 4;
452  }
453  }
454 
455  cairo_surface_mark_dirty( image );
456  cairo_set_source_surface( currentContext, image, 0, 0 );
457  cairo_paint( currentContext );
458  cairo_surface_destroy( image );
459 
460  isElementAdded = true;
461 
462  cairo_restore( currentContext );
463 }
double worldUnitLength
The unit length of the world coordinates [inch].
const int scale
wxSize GetSizePixels() const
Function GetSizePixels.
Definition: bitmap_base.h:133
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:285
int GetPPI() const
Definition: bitmap_base.h:145
cairo_matrix_t currentWorld2Screen
Definition: cairo_gal.h:298

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

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

242 {
243  syncLineWidth();
244 
245  auto c = roundp( xform( aCenterPoint ) );
246  auto r = ::roundp( xform( aRadius ) );
247 
248  cairo_new_sub_path( currentContext );
249  cairo_arc( currentContext, c.x, c.y, r, 0.0, 2 * M_PI );
250  cairo_close_path( currentContext );
251  flushPath();
252  isElementAdded = true;
253 }
const double xform(double x)
Definition: cairo_gal.cpp:126
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:140
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:163
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:285

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

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

867 {
868  cursorPosition = aCursorPosition;
869 }
VECTOR2D cursorPosition
Current cursor position (world coordinates)

References KIGFX::GAL::cursorPosition.

◆ DrawCurve()

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

Reimplemented from KIGFX::GAL.

Definition at line 382 of file cairo_gal.cpp.

384 {
385  syncLineWidth();
386 
387  const auto sp = roundp( xform( aStartPoint ) );
388  const auto cpa = roundp( xform( aControlPointA ) );
389  const auto cpb = roundp( xform( aControlPointB ) );
390  const auto ep = roundp( xform( aEndPoint ) );
391 
392  cairo_move_to( currentContext, sp.x, sp.y );
393  cairo_curve_to( currentContext, cpa.x, cpa.y, cpb.x, cpb.y, ep.x, ep.y );
394  cairo_line_to( currentContext, ep.x, ep.y );
395 
396  flushPath();
397  isElementAdded = true;
398 }
const double xform(double x)
Definition: cairo_gal.cpp:126
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:140
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:163
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:285

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

◆ DrawGrid()

void CAIRO_GAL_BASE::DrawGrid ( )
overridevirtualinherited

Draw the grid

Reimplemented from KIGFX::GAL.

Definition at line 1482 of file cairo_gal.cpp.

1483 {
1485 
1486  // Draw the grid
1487  // For the drawing the start points, end points and increments have
1488  // to be calculated in world coordinates
1489  VECTOR2D worldStartPoint = screenWorldMatrix * VECTOR2D( 0.0, 0.0 );
1490  VECTOR2D worldEndPoint = screenWorldMatrix * VECTOR2D( screenSize );
1491 
1492  double gridThreshold = KiROUND( computeMinGridSpacing() / worldScale );
1493 
1495  gridThreshold *= 2.0;
1496 
1497  int gridScreenSizeDense = gridSize.x;
1498  int gridScreenSizeCoarse = KiROUND( gridSize.x * static_cast<double>( gridTick ) );
1499 
1500  // Compute the line marker or point radius of the grid
1501  // Note: generic grids can't handle sub-pixel lines without
1502  // either losing fine/course distinction or having some dots
1503  // fail to render
1504  float marker = std::fmax( 1.0f, gridLineWidth ) / worldScale;
1505  float doubleMarker = 2.0f * marker;
1506 
1507  // Draw axes if desired
1508  if( axesEnabled )
1509  {
1510  SetLineWidth( marker );
1511  drawAxes( worldStartPoint, worldEndPoint );
1512  }
1513 
1514  if( !gridVisibility )
1515  return;
1516 
1517  // If we cannot display the grid density, scale down by a tick size and
1518  // try again. Eventually, we get some representation of the grid
1519  while( std::min( gridScreenSizeDense, gridScreenSizeCoarse ) <= gridThreshold )
1520  {
1521  gridScreenSizeCoarse *= gridTick;
1522  gridScreenSizeDense *= gridTick;
1523  }
1524 
1525  // Compute grid staring and ending indexes to draw grid points on the
1526  // visible screen area
1527  // Note: later any point coordinate will be offsetted by gridOrigin
1528  int gridStartX = KiROUND( ( worldStartPoint.x - gridOrigin.x ) / gridScreenSizeDense );
1529  int gridEndX = KiROUND( ( worldEndPoint.x - gridOrigin.x ) / gridScreenSizeDense );
1530  int gridStartY = KiROUND( ( worldStartPoint.y - gridOrigin.y ) / gridScreenSizeDense );
1531  int gridEndY = KiROUND( ( worldEndPoint.y - gridOrigin.y ) / gridScreenSizeDense );
1532 
1533  // Ensure start coordinate > end coordinate
1534 
1535  SWAP( gridStartX, >, gridStartX );
1536  SWAP( gridStartY, >, gridEndY );
1537 
1538  // Ensure the grid fills the screen
1539  --gridStartX; ++gridEndX;
1540  --gridStartY; ++gridEndY;
1541 
1542  // Draw the grid behind all other layers
1543  SetLayerDepth( depthRange.y * 0.75 );
1544 
1545  if( gridStyle == GRID_STYLE::LINES )
1546  {
1547  // Now draw the grid, every coarse grid line gets the double width
1548 
1549  // Vertical lines
1550  for( int j = gridStartY; j <= gridEndY; j++ )
1551  {
1552  const double y = j * gridScreenSizeDense + gridOrigin.y;
1553 
1554  if( axesEnabled && y == 0 )
1555  continue;
1556 
1557  SetLineWidth( ( j % gridTick ) ? marker : doubleMarker );
1558  drawGridLine( VECTOR2D( gridStartX * gridScreenSizeDense + gridOrigin.x, y ),
1559  VECTOR2D( gridEndX * gridScreenSizeDense + gridOrigin.x, y ) );
1560  }
1561 
1562  // Horizontal lines
1563  for( int i = gridStartX; i <= gridEndX; i++ )
1564  {
1565  const double x = i * gridScreenSizeDense + gridOrigin.x;
1566 
1567  if( axesEnabled && x == 0 )
1568  continue;
1569 
1570  SetLineWidth( ( i % gridTick ) ? marker : doubleMarker );
1571  drawGridLine( VECTOR2D( x, gridStartY * gridScreenSizeDense + gridOrigin.y ),
1572  VECTOR2D( x, gridEndY * gridScreenSizeDense + gridOrigin.y ) );
1573 
1574  }
1575  }
1576  else // Dots or Crosses grid
1577  {
1578  for( int j = gridStartY; j <= gridEndY; j++ )
1579  {
1580  bool tickY = ( j % gridTick == 0 );
1581 
1582  for( int i = gridStartX; i <= gridEndX; i++ )
1583  {
1584  bool tickX = ( i % gridTick == 0 );
1585  SetLineWidth( ( ( tickX && tickY ) ? doubleMarker : marker ) );
1586  auto pos = VECTOR2D( i * gridScreenSizeDense + gridOrigin.x,
1587  j * gridScreenSizeDense + gridOrigin.y );
1588 
1590  drawGridCross( pos );
1591  else if( gridStyle == GRID_STYLE::DOTS )
1592  drawGridPoint( pos, GetLineWidth() );
1593  }
1594  }
1595  }
1596 }
int gridTick
Every tick line gets the double width.
float GetLineWidth() const
Get the line width.
Use lines for the grid.
bool axesEnabled
Should the axes be drawn.
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:121
double computeMinGridSpacing() const
compute minimum grid spacing from the grid settings
GRID_STYLE gridStyle
Grid display style.
VECTOR2D depthRange
Range of the depth.
MATRIX3x3D screenWorldMatrix
Screen transformation.
void drawAxes(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Definition: cairo_gal.cpp:904
virtual void SetLayerDepth(double aLayerDepth) override
Set the depth of the layer (position on the z-axis)
Definition: cairo_gal.cpp:571
Auxiliary rendering target (noncached)
Definition: definitions.h:49
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
float gridLineWidth
Line width of the grid.
VECTOR2D gridOrigin
The grid origin.
void drawGridPoint(const VECTOR2D &aPoint, double aSize)
Definition: cairo_gal.cpp:953
Use dots for the grid.
Use small cross instead of dots for the grid.
bool gridVisibility
Should the grid be shown.
double worldScale
The scale factor world->screen.
VECTOR2D gridSize
The grid size.
size_t i
Definition: json11.cpp:597
VECTOR2I screenSize
Screen size in screen coordinates.
#define SWAP(varA, condition, varB)
Swap the variables if a condition is met.
Definition: definitions.h:31
void drawGridLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a grid line (usually a simplified line function).
Definition: cairo_gal.cpp:919
virtual void SetLineWidth(float aLineWidth) override
Set the line width.
Definition: cairo_gal.cpp:552
virtual void SetTarget(RENDER_TARGET aTarget)
Sets the target for rendering.
void drawGridCross(const VECTOR2D &aPoint)
Definition: cairo_gal.cpp:933
#define min(a, b)
Definition: auxiliary.h:85

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

◆ drawGridCross()

void CAIRO_GAL_BASE::drawGridCross ( const VECTOR2D aPoint)
protectedinherited

Definition at line 933 of file cairo_gal.cpp.

934 {
935  syncLineWidth();
936  VECTOR2D offset( 0, 0 );
937  auto size = 2.0 * lineWidthInPixels;
938 
939  auto p0 = roundp( xform( aPoint ) ) - VECTOR2D( size, 0 ) + offset;
940  auto p1 = roundp( xform( aPoint ) ) + VECTOR2D( size, 0 ) + offset;
941  auto p2 = roundp( xform( aPoint ) ) - VECTOR2D( 0, size ) + offset;
942  auto p3 = roundp( xform( aPoint ) ) + VECTOR2D( 0, size ) + offset;
943 
944  cairo_set_source_rgba( currentContext, gridColor.r, gridColor.g, gridColor.b, gridColor.a );
945  cairo_move_to( currentContext, p0.x, p0.y );
946  cairo_line_to( currentContext, p1.x, p1.y );
947  cairo_move_to( currentContext, p2.x, p2.y );
948  cairo_line_to( currentContext, p3.x, p3.y );
949  cairo_stroke( currentContext );
950 }
double g
Green component.
Definition: color4d.h:310
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
const double xform(double x)
Definition: cairo_gal.cpp:126
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:140
COLOR4D gridColor
Color of the grid.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:163
double r
Red component.
Definition: color4d.h:309

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

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

920 {
921  syncLineWidth();
922  auto p0 = roundp( xform( aStartPoint ) );
923  auto p1 = roundp( xform( aEndPoint ) );
924 
925  printf("Line Width: %f\n", lineWidth);
926  cairo_set_source_rgba( currentContext, gridColor.r, gridColor.g, gridColor.b, gridColor.a );
927  cairo_move_to( currentContext, p0.x, p0.y );
928  cairo_line_to( currentContext, p1.x, p1.y );
929  cairo_stroke( currentContext );
930 }
double g
Green component.
Definition: color4d.h:310
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
const double xform(double x)
Definition: cairo_gal.cpp:126
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:140
COLOR4D gridColor
Color of the grid.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:163
double r
Red component.
Definition: color4d.h:309

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

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

◆ drawGridPoint()

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

Definition at line 953 of file cairo_gal.cpp.

954 {
955  auto p = roundp( xform( aPoint ) );
956  auto s = ::roundp( xform( aSize / 2.0 ) );
957 
958  cairo_set_source_rgba( currentContext, gridColor.r, gridColor.g, gridColor.b, gridColor.a );
959  cairo_move_to( currentContext, p.x, p.y );
960  cairo_arc( currentContext, p.x, p.y, s, 0.0, 2.0 * M_PI );
961  cairo_close_path( currentContext );
962 
963  cairo_fill( currentContext );
964 }
double g
Green component.
Definition: color4d.h:310
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
const double xform(double x)
Definition: cairo_gal.cpp:126
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:140
COLOR4D gridColor
Color of the grid.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
double r
Red component.
Definition: color4d.h:309

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

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

719 {
720  // This method implements a small Virtual Machine - all stored commands
721  // are executed; nested calling is also possible
722 
723  storePath();
724 
725  for( GROUP::iterator it = groups[aGroupNumber].begin();
726  it != groups[aGroupNumber].end(); ++it )
727  {
728  switch( it->command )
729  {
730  case CMD_SET_FILL:
731  isFillEnabled = it->argument.boolArg;
732  break;
733 
734  case CMD_SET_STROKE:
735  isStrokeEnabled = it->argument.boolArg;
736  break;
737 
738  case CMD_SET_FILLCOLOR:
739  fillColor = COLOR4D( it->argument.dblArg[0], it->argument.dblArg[1], it->argument.dblArg[2],
740  it->argument.dblArg[3] );
741  break;
742 
743  case CMD_SET_STROKECOLOR:
744  strokeColor = COLOR4D( it->argument.dblArg[0], it->argument.dblArg[1], it->argument.dblArg[2],
745  it->argument.dblArg[3] );
746  break;
747 
748  case CMD_SET_LINE_WIDTH:
749  {
750  // Make lines appear at least 1 pixel wide, no matter of zoom
751  double x = 1.0, y = 1.0;
752  cairo_device_to_user_distance( currentContext, &x, &y );
753  double minWidth = std::min( fabs( x ), fabs( y ) );
754  cairo_set_line_width( currentContext, std::max( it->argument.dblArg[0], minWidth ) );
755  }
756  break;
757 
758 
759  case CMD_STROKE_PATH:
760  cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
761  cairo_append_path( currentContext, it->cairoPath );
762  cairo_stroke( currentContext );
763  break;
764 
765  case CMD_FILL_PATH:
766  cairo_set_source_rgba( currentContext, fillColor.r, fillColor.g, fillColor.b, strokeColor.a );
767  cairo_append_path( currentContext, it->cairoPath );
768  cairo_fill( currentContext );
769  break;
770 
771  /*
772  case CMD_TRANSFORM:
773  cairo_matrix_t matrix;
774  cairo_matrix_init( &matrix, it->argument.dblArg[0], it->argument.dblArg[1], it->argument.dblArg[2],
775  it->argument.dblArg[3], it->argument.dblArg[4], it->argument.dblArg[5] );
776  cairo_transform( currentContext, &matrix );
777  break;
778  */
779 
780  case CMD_ROTATE:
781  cairo_rotate( currentContext, it->argument.dblArg[0] );
782  break;
783 
784  case CMD_TRANSLATE:
785  cairo_translate( currentContext, it->argument.dblArg[0], it->argument.dblArg[1] );
786  break;
787 
788  case CMD_SCALE:
789  cairo_scale( currentContext, it->argument.dblArg[0], it->argument.dblArg[1] );
790  break;
791 
792  case CMD_SAVE:
793  cairo_save( currentContext );
794  break;
795 
796  case CMD_RESTORE:
797  cairo_restore( currentContext );
798  break;
799 
800  case CMD_CALL_GROUP:
801  DrawGroup( it->argument.intArg );
802  break;
803  }
804  }
805 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:988
double g
Green component.
Definition: color4d.h:310
COLOR4D fillColor
The fill color.
Enable/disable filling.
Definition: cairo_gal.h:255
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
bool isStrokeEnabled
Are the outlines stroked ?
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:287
COLOR4D strokeColor
The color of the outlines.
Save the transformation matrix.
Definition: cairo_gal.h:266
bool isFillEnabled
Is filling of graphic objects enabled ?
#define max(a, b)
Definition: auxiliary.h:86
Translate the context.
Definition: cairo_gal.h:264
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
virtual void DrawGroup(int aGroupNumber) override
Draw the stored group.
Definition: cairo_gal.cpp:718
double r
Red component.
Definition: color4d.h:309
Enable/disable stroking.
Definition: cairo_gal.h:256
Restore the transformation matrix.
Definition: cairo_gal.h:267
#define min(a, b)
Definition: auxiliary.h:85
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

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

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

150 {
151  syncLineWidth();
152 
153  auto p0 = roundp( xform( aStartPoint ) );
154  auto p1 = roundp( xform( aEndPoint ) );
155 
156  cairo_move_to( currentContext, p0.x, p0.y );
157  cairo_line_to( currentContext, p1.x, p1.y );
158  flushPath();
159  isElementAdded = true;
160 }
const double xform(double x)
Definition: cairo_gal.cpp:126
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:140
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:163
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:285

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

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

1055 {
1056  // Iterate over the point list and draw the segments
1057  std::deque<VECTOR2D>::const_iterator it = aPointList.begin();
1058 
1059  syncLineWidth();
1060 
1061  const auto p = roundp( xform( it->x, it->y ) );
1062 
1063  cairo_move_to( currentContext, p.x, p.y );
1064 
1065  for( ++it; it != aPointList.end(); ++it )
1066  {
1067  const auto p2 = roundp( xform( it->x, it->y ) );
1068 
1069  cairo_line_to( currentContext, p2.x, p2.y );
1070  }
1071 
1072  flushPath();
1073  isElementAdded = true;
1074 }
const double xform(double x)
Definition: cairo_gal.cpp:126
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:140
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:163
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:285

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

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

1078 {
1079  // Iterate over the point list and draw the segments
1080  const VECTOR2D* ptr = aPointList;
1081 
1082  syncLineWidth();
1083 
1084  const auto p = roundp( xform( ptr->x, ptr->y ) );
1085  cairo_move_to( currentContext, p.x, p.y );
1086 
1087  for( int i = 0; i < aListSize; ++i )
1088  {
1089  ++ptr;
1090  const auto p2 = roundp( xform( ptr->x, ptr->y ) );
1091  cairo_line_to( currentContext, p2.x, p2.y );
1092  }
1093 
1094  flushPath();
1095  isElementAdded = true;
1096 }
const double xform(double x)
Definition: cairo_gal.cpp:126
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:140
size_t i
Definition: json11.cpp:597
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:163
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:285

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

1100 {
1101  if( aLineChain.PointCount() < 2 )
1102  return;
1103 
1104  syncLineWidth();
1105 
1106  auto numPoints = aLineChain.PointCount();
1107 
1108  if( aLineChain.IsClosed() )
1109  numPoints += 1;
1110 
1111  const VECTOR2I start = aLineChain.CPoint( 0 );
1112  const auto p = roundp( xform( start.x, start.y ) );
1113  cairo_move_to( currentContext, p.x, p.y );
1114 
1115  for( int i = 1; i < numPoints; ++i )
1116  {
1117  const VECTOR2I& pw = aLineChain.CPoint( i );
1118  const auto ps = roundp( xform( pw.x, pw.y ) );
1119  cairo_line_to( currentContext, ps.x, ps.y );
1120  }
1121 
1122  flushPath();
1123  isElementAdded = true;
1124 }
int PointCount() const
Function PointCount()
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
const double xform(double x)
Definition: cairo_gal.cpp:126
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:140
size_t i
Definition: json11.cpp:597
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:163
bool IsClosed() const
Function IsClosed()
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:285

References SHAPE_LINE_CHAIN::CPoint(), KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::flushPath(), i, SHAPE_LINE_CHAIN::IsClosed(), KIGFX::CAIRO_GAL_BASE::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]

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

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

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolygon() [2/4]

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

Reimplemented from KIGFX::GAL.

Definition at line 108 of file cairo_gal.h.

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

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolygon() [3/4]

void CAIRO_GAL_BASE::DrawPolygon ( const SHAPE_POLY_SET aPolySet)
overridevirtualinherited

Reimplemented from KIGFX::GAL.

Definition at line 369 of file cairo_gal.cpp.

370 {
371  for( int i = 0; i < aPolySet.OutlineCount(); ++i )
372  drawPoly( aPolySet.COutline( i ) );
373 }
int OutlineCount() const
Returns the number of outlines in the set
void drawPoly(const std::deque< VECTOR2D > &aPointList)
Drawing polygons & polylines is the same in cairo, so here is the common code.
Definition: cairo_gal.cpp:1054
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
size_t i
Definition: json11.cpp:597

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

377 {
378  drawPoly( aPolygon );
379 }
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:1054

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolyline() [1/3]

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

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

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolyline() [2/3]

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

Reimplemented from KIGFX::GAL.

Definition at line 103 of file cairo_gal.h.

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

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolyline() [3/3]

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

Reimplemented from KIGFX::GAL.

Definition at line 104 of file cairo_gal.h.

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

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

348 {
349  // Calculate the diagonal points
350  syncLineWidth();
351 
352  const auto p0 = roundp( xform( aStartPoint ) );
353  const auto p1 = roundp( xform( VECTOR2D( aEndPoint.x, aStartPoint.y ) ) );
354  const auto p2 = roundp( xform( aEndPoint ) );
355  const auto p3 = roundp( xform( VECTOR2D( aStartPoint.x, aEndPoint.y ) ) );
356 
357  // The path is composed from 4 segments
358  cairo_move_to( currentContext, p0.x, p0.y );
359  cairo_line_to( currentContext, p1.x, p1.y );
360  cairo_line_to( currentContext, p2.x, p2.y );
361  cairo_line_to( currentContext, p3.x, p3.y );
362  cairo_close_path( currentContext );
363  flushPath();
364 
365  isElementAdded = true;
366 }
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
const double xform(double x)
Definition: cairo_gal.cpp:126
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:140
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:163
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:285

References KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::flushPath(), KIGFX::CAIRO_GAL_BASE::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 187 of file cairo_gal.cpp.

189 {
190  if( isFillEnabled )
191  {
192  syncLineWidth( true, aWidth );
193 
194  auto p0 = roundp( xform( aStartPoint ) );
195  auto p1 = roundp( xform( aEndPoint ) );
196 
197  cairo_move_to( currentContext, p0.x, p0.y );
198  cairo_line_to( currentContext, p1.x, p1.y );
199  cairo_set_source_rgba( currentContext, fillColor.r, fillColor.g, fillColor.b, fillColor.a );
200  cairo_stroke( currentContext );
201  }
202  else
203  {
204  aWidth /= 2.0;
205  SetLineWidth( 1.0 );
206  syncLineWidth();
207 
208  // Outline mode for tracks
209  VECTOR2D startEndVector = aEndPoint - aStartPoint;
210  double lineAngle = atan2( startEndVector.y, startEndVector.x );
211 
212  double sa = sin( lineAngle + M_PI / 2.0 );
213  double ca = cos( lineAngle + M_PI / 2.0 );
214 
215  auto pa0 = xform ( aStartPoint + VECTOR2D(aWidth * ca, aWidth * sa ) );
216  auto pa1 = xform ( aStartPoint - VECTOR2D(aWidth * ca, aWidth * sa ) );
217  auto pb0 = xform ( aEndPoint + VECTOR2D(aWidth * ca, aWidth * sa ) );
218  auto pb1 = xform ( aEndPoint - VECTOR2D(aWidth * ca, aWidth * sa ) );
219  auto pa = xform( aStartPoint );
220  auto pb = xform( aEndPoint );
221  auto rb = (pa0 - pa).EuclideanNorm();
222 
223  cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
224 
225  cairo_move_to( currentContext, pa0.x, pa0.y );
226  cairo_line_to( currentContext, pb0.x, pb0.y );
227 
228  cairo_move_to( currentContext, pa1.x, pa1.y );
229  cairo_line_to( currentContext, pb1.x, pb1.y );
230 
231  cairo_arc( currentContext, pb.x, pb.y, rb, lineAngle - M_PI / 2.0, lineAngle + M_PI / 2.0 );
232  cairo_arc( currentContext, pa.x, pa.y, rb, lineAngle + M_PI / 2.0, lineAngle + 3.0 * M_PI / 2.0 );
233 
234  flushPath();
235  }
236 
237  isElementAdded = true;
238 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:112
double g
Green component.
Definition: color4d.h:310
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
COLOR4D strokeColor
The color of the outlines.
const double xform(double x)
Definition: cairo_gal.cpp:126
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:140
bool isFillEnabled
Is filling of graphic objects enabled ?
virtual void SetLineWidth(float aLineWidth) override
Set the line width.
Definition: cairo_gal.cpp:552
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:163
double r
Red component.
Definition: color4d.h:309
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:285

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

873 {
874 }

◆ endDrawing()

void CAIRO_GAL::endDrawing ( )
overrideprotectedvirtual

Reimplemented from KIGFX::CAIRO_GAL_BASE.

Definition at line 1204 of file cairo_gal.cpp.

1205 {
1207 
1208  // Merge buffers on the screen
1209  compositor->DrawBuffer( mainBuffer );
1210  compositor->DrawBuffer( overlayBuffer );
1211 
1212  // Now translate the raw context data from the format stored
1213  // by cairo into a format understood by wxImage.
1214  pixman_image_t* dstImg = pixman_image_create_bits( PIXMAN_r8g8b8,
1215  screenSize.x, screenSize.y, (uint32_t*) wxOutput, wxBufferWidth * 3 );
1216  pixman_image_t* srcImg = pixman_image_create_bits( PIXMAN_a8b8g8r8,
1217  screenSize.x, screenSize.y, (uint32_t*) bitmapBuffer, wxBufferWidth * 4 );
1218 
1219  pixman_image_composite( PIXMAN_OP_SRC, srcImg, NULL, dstImg,
1220  0, 0, 0, 0, 0, 0, screenSize.x, screenSize.y );
1221 
1222  // Free allocated memory
1223  pixman_image_unref( srcImg );
1224  pixman_image_unref( dstImg );
1225 
1226  wxImage img( wxBufferWidth, screenSize.y, (unsigned char*) wxOutput, true );
1227  wxBitmap bmp( img );
1228  wxMemoryDC mdc( bmp );
1229  wxClientDC clientDC( this );
1230 
1231  // Now it is the time to blit the mouse cursor
1232  blitCursor( mdc );
1233  clientDC.Blit( 0, 0, screenSize.x, screenSize.y, &mdc, 0, 0, wxCOPY );
1234 
1235  deinitSurface();
1236 }
void deinitSurface()
Destroy Cairo surfaces when are not needed anymore.
Definition: cairo_gal.cpp:1392
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:411
unsigned char * wxOutput
wxImage comaptible buffer
Definition: cairo_gal.h:420
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:409
virtual void endDrawing() override
Definition: cairo_gal.cpp:90
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:423
VECTOR2I screenSize
Screen size in screen coordinates.
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:410
virtual void blitCursor(wxMemoryDC &clientDC)
Blits cursor into the current screen.
Definition: cairo_gal.cpp:1036

References bitmapBuffer, KIGFX::CAIRO_GAL_BASE::blitCursor(), compositor, deinitSurface(), KIGFX::CAIRO_GAL_BASE::endDrawing(), mainBuffer, overlayBuffer, KIGFX::GAL::screenSize, wxBufferWidth, wxOutput, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ EndGroup()

void CAIRO_GAL::EndGroup ( )
overridevirtual

End the group.

Reimplemented from KIGFX::CAIRO_GAL_BASE.

Definition at line 1305 of file cairo_gal.cpp.

1306 {
1308  deinitSurface();
1309 }
virtual void EndGroup() override
End the group.
Definition: cairo_gal.cpp:711
void deinitSurface()
Destroy Cairo surfaces when are not needed anymore.
Definition: cairo_gal.cpp:1392

References deinitSurface(), and KIGFX::CAIRO_GAL_BASE::EndGroup().

◆ endUpdate()

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

Disables item update mode.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1113 of file graphics_abstraction_layer.h.

1113 {}

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

◆ Flush()

void CAIRO_GAL_BASE::Flush ( )
overridevirtualinherited

Force all remaining objects to be drawn.

Reimplemented from KIGFX::GAL.

Definition at line 472 of file cairo_gal.cpp.

473 {
474  storePath();
475 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:988

References KIGFX::CAIRO_GAL_BASE::storePath().

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

◆ flushPath()

void CAIRO_GAL_BASE::flushPath ( )
protectedinherited

Definition at line 966 of file cairo_gal.cpp.

967 {
968  if( isFillEnabled )
969  {
970  cairo_set_source_rgba( currentContext,
972 
973  if( isStrokeEnabled )
974  cairo_fill_preserve( currentContext );
975  else
976  cairo_fill( currentContext );
977  }
978 
979  if( isStrokeEnabled )
980  {
981  cairo_set_source_rgba( currentContext,
983  cairo_stroke( currentContext );
984  }
985 }
double g
Green component.
Definition: color4d.h:310
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
bool isStrokeEnabled
Are the outlines stroked ?
COLOR4D strokeColor
The color of the outlines.
bool isFillEnabled
Is filling of graphic objects enabled ?
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
double r
Red component.
Definition: color4d.h:309

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

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

216  {
217  return m_clearColor;
218  }

References KIGFX::GAL::m_clearColor.

◆ getCursorColor()

COLOR4D GAL::getCursorColor ( ) const
protectedinherited

Gets the actual cursor color to draw.

Definition at line 238 of file graphics_abstraction_layer.cpp.

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

References color, KIGFX::GAL::cursorColor, and KIGFX::GAL::isCursorEnabled.

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

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

References KIGFX::GAL::fillColor.

◆ GetGlyphSize()

◆ GetGridLineWidth()

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

Get the grid line width.

Returns
the grid line width

Definition at line 943 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::gridLineWidth.

◆ GetGridPoint()

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

Function GetGridPoint() For a given point it returns the nearest point belonging to the grid in world coordinates.

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

Definition at line 216 of file graphics_abstraction_layer.cpp.

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

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

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

◆ GetGridSize()

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

Returns the grid size.

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

Definition at line 895 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::gridSize.

Referenced by SCH_BASE_FRAME::SyncView().

◆ GetHorizontalJustify()

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

Returns current text horizontal justification setting.

Definition at line 487 of file graphics_abstraction_layer.h.

488  {
490  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
EDA_TEXT_HJUSTIFY_T m_horizontalJustify
Horizontal justification.

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

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

◆ GetLineWidth()

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

◆ GetLookAtPoint()

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

Get the look at point.

Returns
the look at point.

Definition at line 687 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::lookAtPoint.

◆ GetMaxDepth()

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

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

Definition at line 756 of file graphics_abstraction_layer.h.

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

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

◆ GetMinDepth()

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

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

Definition at line 748 of file graphics_abstraction_layer.h.

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

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

◆ getNewGroupNumber()

unsigned int CAIRO_GAL_BASE::getNewGroupNumber ( )
protectedinherited

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

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

Definition at line 1127 of file cairo_gal.cpp.

1128 {
1129  wxASSERT_MSG( groups.size() < std::numeric_limits<unsigned int>::max(),
1130  wxT( "There are no free slots to store a group" ) );
1131 
1132  while( groups.find( groupCounter ) != groups.end() )
1133  groupCounter++;
1134 
1135  return groupCounter++;
1136 }
unsigned int groupCounter
Counter used for generating keys for groups.
Definition: cairo_gal.h:288
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:287
#define max(a, b)
Definition: auxiliary.h:86

References KIGFX::CAIRO_GAL_BASE::groupCounter, KIGFX::CAIRO_GAL_BASE::groups, and max.

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

◆ GetOverbarVerticalPosition()

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

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

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

Returns
the relative position of the overbar axis.

Definition at line 382 of file graphics_abstraction_layer.h.

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

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

◆ GetRotation()

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

Get the rotation angle.

Returns
The rotation angle (radians).

Definition at line 727 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::rotation.

◆ GetScreenPixelSize()

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

◆ GetScreenWorldMatrix()

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

Get the screen <-> world transformation matrix.

Returns
the transformation matrix.

Definition at line 623 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::screenWorldMatrix.

Referenced by KIGFX::OPENGL_GAL::getWorldPixelSize(), and KIGFX::VIEW::ToWorld().

◆ GetStrokeColor()

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

Get the stroke color.

Returns
the color for stroking the outline.

Definition at line 285 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::strokeColor.

◆ GetStrokeFont()

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

Definition at line 327 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::strokeFont.

Referenced by EDA_TEXT::GetTextBox().

◆ GetTarget()

RENDER_TARGET CAIRO_GAL::GetTarget ( ) const
overridevirtual

Gets the currently used target for rendering.

Returns
The current rendering target.

Reimplemented from KIGFX::GAL.

Definition at line 1340 of file cairo_gal.cpp.

1341 {
1342  return currentTarget;
1343 }
RENDER_TARGET currentTarget
Current rendering target.
Definition: cairo_gal.h:412

References currentTarget.

◆ GetTextLineSize()

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

Compute the X and Y size of a given text.

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

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

Definition at line 170 of file graphics_abstraction_layer.cpp.

171 {
172  // Compute the X and Y size of a given text.
173  // Because computeTextLineSize expects a one line text,
174  // aText is expected to be only one line text.
175  return strokeFont.computeTextLineSize( aText );
176 }
STROKE_FONT strokeFont
Instance of object that stores information about how to draw texts.
VECTOR2D computeTextLineSize(const UTF8 &aText) const
Compute the X and Y size of a given text.

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

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

◆ GetVerticalJustify()

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

Returns current text vertical justification setting.

Definition at line 505 of file graphics_abstraction_layer.h.

506  {
508  }
EDA_TEXT_VJUSTIFY_T m_verticalJustify
Vertical justification.
struct KIGFX::GAL::TEXT_PROPERTIES textProperties

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

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

◆ GetWorldScale()

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

Get the world scale.

Returns
the actual world scale factor.

Definition at line 766 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::worldScale.

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

◆ GetWorldScreenMatrix()

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

Get the world <-> screen transformation matrix.

Returns
the transformation matrix.

Definition at line 613 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::worldScreenMatrix.

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

◆ GetZoomFactor()

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

Get the zoom factor.

Returns
the zoom factor.

Definition at line 707 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::zoomFactor.

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

◆ initSurface()

void CAIRO_GAL::initSurface ( )
protected

Prepare Cairo surfaces for drawing.

Definition at line 1372 of file cairo_gal.cpp.

1373 {
1374  if( isInitialized )
1375  return;
1376 
1377  surface = cairo_image_surface_create_for_data( (unsigned char*) bitmapBuffer, GAL_FORMAT,
1379 
1380  context = cairo_create( surface );
1381 
1382 #ifdef __WXDEBUG__
1383  cairo_status_t status = cairo_status( context );
1384  wxASSERT_MSG( status == CAIRO_STATUS_SUCCESS, wxT( "Cairo context creation error" ) );
1385 #endif /* __WXDEBUG__ */
1387 
1388  isInitialized = true;
1389 }
cairo_surface_t * surface
Cairo surface.
Definition: cairo_gal.h:301
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:427
cairo_t * context
Cairo image.
Definition: cairo_gal.h:300
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:423
int stride
Stride value for Cairo.
Definition: cairo_gal.h:425
VECTOR2I screenSize
Screen size in screen coordinates.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
static constexpr cairo_format_t GAL_FORMAT
Format used to store pixels.
Definition: cairo_gal.h:331

References bitmapBuffer, KIGFX::CAIRO_GAL_BASE::context, KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::GAL_FORMAT, isInitialized, KIGFX::GAL::screenSize, stride, KIGFX::CAIRO_GAL_BASE::surface, wxBufferWidth, and VECTOR2< T >::y.

Referenced by beginDrawing(), and BeginGroup().

◆ IsCairoEngine()

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

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

Reimplemented from KIGFX::GAL.

Definition at line 75 of file cairo_gal.h.

75 { return true; }

◆ IsCursorEnabled()

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

Returns information about cursor visibility.

Returns
True if cursor is visible.

Definition at line 996 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::forceDisplayCursor, and KIGFX::GAL::isCursorEnabled.

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

◆ IsFlippedX()

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

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

Definition at line 786 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::globalFlipX.

◆ IsFlippedY()

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

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

Definition at line 794 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::globalFlipY.

◆ IsFontBold()

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

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

Definition at line 433 of file graphics_abstraction_layer.h.

434  {
435  return textProperties.m_bold;
436  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties

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

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

◆ IsFontItalic()

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

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

Definition at line 451 of file graphics_abstraction_layer.h.

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

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

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

◆ IsInitialized()

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

Returns the initalization status for the canvas.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 73 of file graphics_abstraction_layer.h.

73 { return true; }

Referenced by EDA_DRAW_PANEL_GAL::onRefreshTimer().

◆ IsOpenGlEngine()

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

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

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 82 of file graphics_abstraction_layer.h.

82 { return false; }

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

◆ IsTextMirrored()

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

Returns true if text should displayed mirrored.

Definition at line 469 of file graphics_abstraction_layer.h.

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

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

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

◆ IsVisible()

bool KIGFX::CAIRO_GAL::IsVisible ( ) const
inlineoverridevirtual

Reimplemented from KIGFX::GAL.

Definition at line 360 of file cairo_gal.h.

361  {
362  return IsShownOnScreen() && !GetClientRect().IsEmpty();
363  }

◆ lockContext()

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

Private: use GAL_CONTEXT_LOCKER RAII object.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1104 of file graphics_abstraction_layer.h.

1104 {}

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

◆ OnGalDisplayOptionsChanged()

void GAL::OnGalDisplayOptionsChanged ( const GAL_DISPLAY_OPTIONS aOptions)
overrideprotectedvirtualinherited

Handler for observer settings changes.

Implements KIGFX::GAL_DISPLAY_OPTIONS_OBSERVER.

Definition at line 90 of file graphics_abstraction_layer.cpp.

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

References KIGFX::GAL::updatedGalDisplayOptions().

◆ onPaint()

void CAIRO_GAL::onPaint ( wxPaintEvent &  aEvent)
protected

Paint event handler.

Parameters
aEventis the paint event.

Definition at line 1444 of file cairo_gal.cpp.

1445 {
1446  PostPaint();
1447 }
void PostPaint()
Function PostPaint posts an event to m_paint_listener.
Definition: cairo_gal.h:388

References PostPaint().

Referenced by CAIRO_GAL().

◆ PopDepth()

void KIGFX::GAL::PopDepth ( )
inlineinherited

Restores previously stored drawing depth for the depth stack.

Definition at line 1038 of file graphics_abstraction_layer.h.

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

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

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

◆ PostPaint()

void KIGFX::CAIRO_GAL::PostPaint ( )
inline

Function PostPaint posts an event to m_paint_listener.

A post is used so that the actual drawing function can use a device context type that is not specific to the wxEVT_PAINT event.

Definition at line 388 of file cairo_gal.h.

389  {
390  if( paintListener )
391  {
392  wxPaintEvent redrawEvent;
393  wxPostEvent( paintListener, redrawEvent );
394  }
395  }
wxEvtHandler * paintListener
Paint listener.
Definition: cairo_gal.h:418

References paintListener.

Referenced by onPaint().

◆ PushDepth()

void KIGFX::GAL::PushDepth ( )
inlineinherited

Stores current drawing depth on the depth stack.

Definition at line 1030 of file graphics_abstraction_layer.h.

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

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

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

◆ resetContext()

void CAIRO_GAL_BASE::resetContext ( )
protectedinherited

Definition at line 877 of file cairo_gal.cpp.

878 {
879  ClearScreen();
880 
881  // Compute the world <-> screen transformations
883 
884  cairo_matrix_init( &cairoWorldScreenMatrix, worldScreenMatrix.m_data[0][0],
887  worldScreenMatrix.m_data[1][2] );
888 
889  // we work in screen-space coordinates and do the transforms outside.
890  cairo_identity_matrix( context );
891 
892  cairo_matrix_init_identity( &currentXform );
893 
894  // Start drawing with a new path
895  cairo_new_path( context );
896  isElementAdded = true;
897 
899 
900  lineWidth = 0;
901 }
virtual void ComputeWorldScreenMatrix()
Compute the world <-> screen transformation matrix.
T m_data[3][3]
Definition: matrix3x3.h:64
virtual void ClearScreen() override
Clear the screen.
Definition: cairo_gal.cpp:478
cairo_t * context
Cairo image.
Definition: cairo_gal.h:300
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:96
MATRIX3x3D worldScreenMatrix
World transformation.
cairo_matrix_t currentXform
Definition: cairo_gal.h:297
cairo_matrix_t cairoWorldScreenMatrix
Cairo world to screen transformation matrix.
Definition: cairo_gal.h:296
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:285

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

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

◆ ResetTextAttributes()

void GAL::ResetTextAttributes ( )
inherited

Reset text attributes to default styling.

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

Definition at line 155 of file graphics_abstraction_layer.cpp.

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

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

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

◆ ResizeScreen()

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

Resizes the canvas.

Reimplemented from KIGFX::CAIRO_GAL_BASE.

Definition at line 1239 of file cairo_gal.cpp.

1240 {
1241  CAIRO_GAL_BASE::ResizeScreen( aWidth, aHeight );
1242 
1243  // Recreate the bitmaps
1244  deleteBitmaps();
1245  allocateBitmaps();
1246 
1247  if( validCompositor )
1248  compositor->Resize( aWidth, aHeight );
1249 
1250  validCompositor = false;
1251 
1252  SetSize( wxSize( aWidth, aHeight ) );
1253 }
virtual void ResizeScreen(int aWidth, int aHeight) override
Resizes the canvas.
Definition: cairo_gal.cpp:466
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:413
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:409
void deleteBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1421
void allocateBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1406

References allocateBitmaps(), compositor, deleteBitmaps(), KIGFX::CAIRO_GAL_BASE::ResizeScreen(), and validCompositor.

◆ Restore()

void CAIRO_GAL_BASE::Restore ( )
overridevirtualinherited

Restore the context.

Reimplemented from KIGFX::GAL.

Definition at line 673 of file cairo_gal.cpp.

674 {
675  storePath();
676 
677  if( isGrouping )
678  {
679  GROUP_ELEMENT groupElement;
680  groupElement.command = CMD_RESTORE;
681  currentGroup->push_back( groupElement );
682  }
683  else
684  {
685  if( !xformStack.empty() )
686  {
687  currentXform = xformStack.back();
688  xformStack.pop_back();
690  }
691  }
692 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:988
std::vector< cairo_matrix_t > xformStack
Definition: cairo_gal.h:303
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:289
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:284
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:96
cairo_matrix_t currentXform
Definition: cairo_gal.h:297
Restore the transformation matrix.
Definition: cairo_gal.h:267

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

◆ RestoreScreen()

void CAIRO_GAL::RestoreScreen ( )
overridevirtual

Restore the screen contents.

Reimplemented from KIGFX::GAL.

Definition at line 1283 of file cairo_gal.cpp.

1284 {
1285  int offset = 0;
1286 
1287  for( int j = 0; j < screenSize.y; j++ )
1288  {
1289  for( int i = 0; i < stride; i++ )
1290  {
1291  bitmapBuffer[offset + i] = bitmapBufferBackup[offset + i];
1292  offset += stride;
1293  }
1294  }
1295 }
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:423
int stride
Stride value for Cairo.
Definition: cairo_gal.h:425
unsigned int * bitmapBufferBackup
Backup storage of the cairo image.
Definition: cairo_gal.h:424
size_t i
Definition: json11.cpp:597
VECTOR2I screenSize
Screen size in screen coordinates.

References bitmapBuffer, bitmapBufferBackup, i, KIGFX::GAL::screenSize, stride, and VECTOR2< T >::y.

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

597 {
598  storePath();
599 
600  if( isGrouping )
601  {
602  GROUP_ELEMENT groupElement;
603  groupElement.command = CMD_ROTATE;
604  groupElement.argument.dblArg[0] = aAngle;
605  currentGroup->push_back( groupElement );
606  }
607  else
608  {
609  cairo_matrix_rotate( &currentXform, aAngle );
611  }
612 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:988
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:289
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:284
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:96
cairo_matrix_t currentXform
Definition: cairo_gal.h:297

References KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::argument, KIGFX::CAIRO_GAL_BASE::CMD_ROTATE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, KIGFX::CAIRO_GAL_BASE::currentGroup, KIGFX::CAIRO_GAL_BASE::currentXform, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::dblArg, KIGFX::CAIRO_GAL_BASE::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 655 of file cairo_gal.cpp.

656 {
657  storePath();
658 
659  if( isGrouping )
660  {
661  GROUP_ELEMENT groupElement;
662  groupElement.command = CMD_SAVE;
663  currentGroup->push_back( groupElement );
664  }
665  else
666  {
667  xformStack.push_back( currentXform );
669  }
670 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:988
std::vector< cairo_matrix_t > xformStack
Definition: cairo_gal.h:303
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:289
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:284
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:96
Save the transformation matrix.
Definition: cairo_gal.h:266
cairo_matrix_t currentXform
Definition: cairo_gal.h:297

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

◆ SaveScreen()

void CAIRO_GAL::SaveScreen ( )
overridevirtual

Save the screen contents.

Reimplemented from KIGFX::GAL.

Definition at line 1267 of file cairo_gal.cpp.

1268 {
1269  // Copy the current bitmap to the backup buffer
1270  int offset = 0;
1271 
1272  for( int j = 0; j < screenSize.y; j++ )
1273  {
1274  for( int i = 0; i < stride; i++ )
1275  {
1276  bitmapBufferBackup[offset + i] = bitmapBuffer[offset + i];
1277  offset += stride;
1278  }
1279  }
1280 }
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:423
int stride
Stride value for Cairo.
Definition: cairo_gal.h:425
unsigned int * bitmapBufferBackup
Backup storage of the cairo image.
Definition: cairo_gal.h:424
size_t i
Definition: json11.cpp:597
VECTOR2I screenSize
Screen size in screen coordinates.

References bitmapBuffer, bitmapBufferBackup, i, KIGFX::GAL::screenSize, stride, and VECTOR2< T >::y.

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

636 {
637  storePath();
638 
639  if( isGrouping )
640  {
641  GROUP_ELEMENT groupElement;
642  groupElement.command = CMD_SCALE;
643  groupElement.argument.dblArg[0] = aScale.x;
644  groupElement.argument.dblArg[1] = aScale.y;
645  currentGroup->push_back( groupElement );
646  }
647  else
648  {
649  cairo_matrix_scale( &currentXform, aScale.x, aScale.y );
651  }
652 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:988
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:289
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:284
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:96
cairo_matrix_t currentXform
Definition: cairo_gal.h:297

References KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::argument, KIGFX::CAIRO_GAL_BASE::CMD_SCALE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, KIGFX::CAIRO_GAL_BASE::currentGroup, KIGFX::CAIRO_GAL_BASE::currentXform, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::dblArg, KIGFX::CAIRO_GAL_BASE::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

Set the axes color.

Parameters
aAxesColoris the color to draw the axes if enabled.

Definition at line 915 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::axesColor.

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

◆ SetAxesEnabled()

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

Enables drawing the axes.

Definition at line 923 of file graphics_abstraction_layer.h.

924  {
925  axesEnabled = aAxesEnabled;
926  }
bool axesEnabled
Should the axes be drawn.

References KIGFX::GAL::axesEnabled.

Referenced by FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME(), KIGFX::GAL::GAL(), and FOOTPRINT_EDIT_FRAME::UseGalCanvas().

◆ SetClearColor()

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

◆ SetCoarseGrid()

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

Draw every tick line wider.

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

Definition at line 933 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::gridTick.

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

◆ setCompositor()

void CAIRO_GAL::setCompositor ( )
protected

Prepare the compositor.

Definition at line 1429 of file cairo_gal.cpp.

1430 {
1431  // Recreate the compositor with the new Cairo context
1432  compositor.reset( new CAIRO_COMPOSITOR( &currentContext ) );
1433  compositor->Resize( screenSize.x, screenSize.y );
1434  compositor->SetAntialiasingMode( options.cairo_antialiasing_mode );
1435 
1436  // Prepare buffers
1437  mainBuffer = compositor->CreateBuffer();
1438  overlayBuffer = compositor->CreateBuffer();
1439 
1440  validCompositor = true;
1441 }
GAL_DISPLAY_OPTIONS & options
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:411
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:413
CAIRO_ANTIALIASING_MODE cairo_antialiasing_mode
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:409
VECTOR2I screenSize
Screen size in screen coordinates.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:410

References KIGFX::GAL_DISPLAY_OPTIONS::cairo_antialiasing_mode, compositor, KIGFX::CAIRO_GAL_BASE::currentContext, mainBuffer, KIGFX::GAL::options, overlayBuffer, KIGFX::GAL::screenSize, validCompositor, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by beginDrawing().

◆ SetCursorColor()

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

Set the cursor color.

Parameters
aCursorColoris the color of the cursor.

Definition at line 1006 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::cursorColor.

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

◆ SetCursorEnabled()

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

Enable/disable cursor.

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

Definition at line 987 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::isCursorEnabled.

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

◆ SetDepthRange()

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

Set the range of the layer depth.

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

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

Definition at line 740 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::depthRange.

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

◆ SetFillColor()

void CAIRO_GAL_BASE::SetFillColor ( const COLOR4D aColor)
overridevirtualinherited

Set the fill color.

Parameters
aColoris the color for filling.

Reimplemented from KIGFX::GAL.

Definition at line 534 of file cairo_gal.cpp.

535 {
536  storePath();
537  fillColor = aColor;
538 
539  if( isGrouping )
540  {
541  GROUP_ELEMENT groupElement;
542  groupElement.command = CMD_SET_FILLCOLOR;
543  groupElement.argument.dblArg[0] = fillColor.r;
544  groupElement.argument.dblArg[1] = fillColor.g;
545  groupElement.argument.dblArg[2] = fillColor.b;
546  groupElement.argument.dblArg[3] = fillColor.a;
547  currentGroup->push_back( groupElement );
548  }
549 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:988
double g
Green component.
Definition: color4d.h:310
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:289
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:284
double r
Red component.
Definition: color4d.h:309

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

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

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

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

◆ SetFontBold()

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

Set bold property of current font.

Parameters
aBoldtells if the font should be bold or not.

Definition at line 425 of file graphics_abstraction_layer.h.

426  {
427  textProperties.m_bold = aBold;
428  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties

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

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

◆ SetFontItalic()

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

Set italic property of current font.

Parameters
aItalictells if the font should be italic or not.

Definition at line 443 of file graphics_abstraction_layer.h.

444  {
445  textProperties.m_italic = aItalic;
446  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties

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

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

◆ SetGlyphSize()

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

Set the font glyph size.

Parameters
aGlyphSizeis the new font glyph size.

Definition at line 407 of file graphics_abstraction_layer.h.

408  {
409  textProperties.m_glyphSize = aGlyphSize;
410  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
VECTOR2D m_glyphSize
Size of the glyphs.

References KIGFX::GAL::TEXT_PROPERTIES::m_glyphSize, 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(), KIGFX::PREVIEW::SetConstantGlyphHeight(), and KIGFX::GAL::SetTextAttributes().

◆ SetGridColor()

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

Set the grid color.

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

Definition at line 905 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::gridColor.

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

◆ SetGridOrigin()

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

Set the origin point for the grid.

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

Definition at line 866 of file graphics_abstraction_layer.h.

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

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

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

◆ SetGridSize()

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

Set the grid size.

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

Definition at line 882 of file graphics_abstraction_layer.h.

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

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

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

◆ SetGridVisibility()

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

Sets the visibility setting of the grid.

Parameters
aVisibilityis the new visibility setting of the grid.

Definition at line 856 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::gridVisibility.

Referenced by KIGFX::GAL::GAL(), PCB_LAYER_WIDGET::OnRenderEnable(), GERBER_LAYER_WIDGET::OnRenderEnable(), EDA_DRAW_FRAME::OnToggleGridState(), 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 479 of file graphics_abstraction_layer.h.

480  {
481  textProperties.m_horizontalJustify = aHorizontalJustify;
482  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
EDA_TEXT_HJUSTIFY_T m_horizontalJustify
Horizontal justification.

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

Referenced by KIGFX::SCH_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), 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 486 of file cairo_gal.cpp.

487 {
488  storePath();
489  isFillEnabled = aIsFillEnabled;
490 
491  if( isGrouping )
492  {
493  GROUP_ELEMENT groupElement;
494  groupElement.command = CMD_SET_FILL;
495  groupElement.argument.boolArg = aIsFillEnabled;
496  currentGroup->push_back( groupElement );
497  }
498 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:988
Enable/disable filling.
Definition: cairo_gal.h:255
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:289
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:284
bool isFillEnabled
Is filling of graphic objects enabled ?

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

502 {
503  storePath();
504  isStrokeEnabled = aIsStrokeEnabled;
505 
506  if( isGrouping )
507  {
508  GROUP_ELEMENT groupElement;
509  groupElement.command = CMD_SET_STROKE;
510  groupElement.argument.boolArg = aIsStrokeEnabled;
511  currentGroup->push_back( groupElement );
512  }
513 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:988
bool isStrokeEnabled
Are the outlines stroked ?
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:289
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:284
Enable/disable stroking.
Definition: cairo_gal.h:256

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

572 {
573  super::SetLayerDepth( aLayerDepth );
574  storePath();
575 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:988
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.

Reimplemented in KIGFX::CAIRO_PRINT_GAL.

Definition at line 552 of file cairo_gal.cpp.

553 {
554  storePath();
555  GAL::SetLineWidth( aLineWidth );
556 
557  if( isGrouping )
558  {
559  GROUP_ELEMENT groupElement;
560  groupElement.command = CMD_SET_LINE_WIDTH;
561  groupElement.argument.dblArg[0] = aLineWidth;
562  currentGroup->push_back( groupElement );
563  }
564  else
565  {
566  lineWidth = aLineWidth;
567  }
568 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:988
virtual void SetLineWidth(float aLineWidth)
Set the line width.
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:289
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:284

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

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

References KIGFX::GAL::lookAtPoint.

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

◆ SetMouseListener()

void KIGFX::CAIRO_GAL::SetMouseListener ( wxEvtHandler *  aMouseListener)
inline

Definition at line 397 of file cairo_gal.h.

398  {
399  mouseListener = aMouseListener;
400  }
wxEvtHandler * mouseListener
Mouse listener.
Definition: cairo_gal.h:417

References mouseListener.

◆ SetNegativeDrawMode()

void CAIRO_GAL_BASE::SetNegativeDrawMode ( bool  aSetting)
overridevirtualinherited

Sets negative draw mode in the renderer.

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

Parameters
aSettingis true if negative mode should be enabled

Reimplemented from KIGFX::GAL.

Definition at line 860 of file cairo_gal.cpp.

861 {
862  cairo_set_operator( currentContext, aSetting ? CAIRO_OPERATOR_CLEAR : CAIRO_OPERATOR_OVER );
863 }
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299

References KIGFX::CAIRO_GAL_BASE::currentContext.

◆ SetPaintListener()

void KIGFX::CAIRO_GAL::SetPaintListener ( wxEvtHandler *  aPaintListener)
inline

Definition at line 402 of file cairo_gal.h.

403  {
404  paintListener = aPaintListener;
405  }
wxEvtHandler * paintListener
Paint listener.
Definition: cairo_gal.h:418

References paintListener.

◆ SetRotation()

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

Set the rotation angle.

Parameters
aRotationis the new rotation angle (radians).

Definition at line 717 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::rotation.

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

◆ SetScreenDPI()

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

Set the dots per inch of the screen.

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

Parameters
aScreenDPIare the screen DPI.

Definition at line 665 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::screenDPI.

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

◆ SetScreenSize()

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

Definition at line 652 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::screenSize.

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

◆ SetStrokeColor()

void CAIRO_GAL_BASE::SetStrokeColor ( const COLOR4D aColor)
overridevirtualinherited

Set the stroke color.

Parameters
aColoris the color for stroking the outline.

Reimplemented from KIGFX::GAL.

Definition at line 516 of file cairo_gal.cpp.

517 {
518  storePath();
519  strokeColor = aColor;
520 
521  if( isGrouping )
522  {
523  GROUP_ELEMENT groupElement;
524  groupElement.command = CMD_SET_STROKECOLOR;
525  groupElement.argument.dblArg[0] = strokeColor.r;
526  groupElement.argument.dblArg[1] = strokeColor.g;
527  groupElement.argument.dblArg[2] = strokeColor.b;
528  groupElement.argument.dblArg[3] = strokeColor.a;
529  currentGroup->push_back( groupElement );
530  }
531 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:988
double g
Green component.
Definition: color4d.h:310
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:289
COLOR4D strokeColor
The color of the outlines.
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:284
double r
Red component.
Definition: color4d.h:309

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

◆ SetTarget()

void CAIRO_GAL::SetTarget ( RENDER_TARGET  aTarget)
overridevirtual

Sets the target for rendering.

Parameters
aTargetis the new target for rendering.

Reimplemented from KIGFX::GAL.

Definition at line 1312 of file cairo_gal.cpp.

1313 {
1314  // If the compositor is not set, that means that there is a recaching process going on
1315  // and we do not need the compositor now
1316  if( !validCompositor )
1317  return;
1318 
1319  // Cairo grouping prevents display of overlapping items on the same layer in the lighter color
1320  if( isInitialized )
1321  storePath();
1322 
1323  switch( aTarget )
1324  {
1325  default:
1326  case TARGET_CACHED:
1327  case TARGET_NONCACHED:
1328  compositor->SetBuffer( mainBuffer );
1329  break;
1330 
1331  case TARGET_OVERLAY:
1332  compositor->SetBuffer( overlayBuffer );
1333  break;
1334  }
1335 
1336  currentTarget = aTarget;
1337 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:988
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:427
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:411
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:413
Auxiliary rendering target (noncached)
Definition: definitions.h:49
RENDER_TARGET currentTarget
Current rendering target.
Definition: cairo_gal.h:412
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:409
Items that may change while the view stays the same (noncached)
Definition: definitions.h:50
Main rendering target (cached)
Definition: definitions.h:48
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:410

References compositor, currentTarget, isInitialized, mainBuffer, overlayBuffer, KIGFX::CAIRO_GAL_BASE::storePath(), KIGFX::TARGET_CACHED, KIGFX::TARGET_NONCACHED, KIGFX::TARGET_OVERLAY, and validCompositor.

Referenced by CAIRO_GAL().

◆ SetTextAttributes()

void GAL::SetTextAttributes ( const EDA_TEXT aText)
virtualinherited

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

Parameters
aTextis the text item.

Definition at line 144 of file graphics_abstraction_layer.cpp.

145 {
146  SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
149  SetFontBold( aText->IsBold() );
150  SetFontItalic( aText->IsItalic() );
151  SetTextMirrored( aText->IsMirrored() );
152 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:186
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:204
bool IsMirrored() const
Definition: eda_text.h:192
bool IsItalic() const
Definition: eda_text.h:183
void SetFontBold(const bool aBold)
Set bold property of current font.
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:203
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
const wxSize & GetTextSize() const
Definition: eda_text.h:228
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.

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

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

◆ SetTextMirrored()

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

Set a mirrored property of text.

Parameters
aMirroredtells if the text should be mirrored or not.

Definition at line 461 of file graphics_abstraction_layer.h.

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

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

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

◆ SetVerticalJustify()

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

Set the vertical justify for text drawing.

Parameters
aVerticalJustifyis the vertical justify value.

Definition at line 497 of file graphics_abstraction_layer.h.

498  {
499  textProperties.m_verticalJustify = aVerticalJustify;
500  }
EDA_TEXT_VJUSTIFY_T m_verticalJustify
Vertical justification.
struct KIGFX::GAL::TEXT_PROPERTIES textProperties

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

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

◆ SetWorldScreenMatrix()

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

Set the world <-> screen transformation matrix.

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

Definition at line 633 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::worldScreenMatrix.

◆ SetWorldUnitLength()

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

Set the unit length.

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

Parameters
aWorldUnitLengthis the world Unit length.

Definition at line 647 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::worldUnitLength.

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

◆ SetZoomFactor()

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

Set the zoom factor of the scene.

Parameters
aZoomFactoris the zoom factor.

Definition at line 697 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::zoomFactor.

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

◆ Show()

bool CAIRO_GAL::Show ( bool  aShow)
overridevirtual

Shows/hides the GAL canvas.

Reimplemented from KIGFX::GAL.

Definition at line 1256 of file cairo_gal.cpp.

1257 {
1258  bool s = wxWindow::Show( aShow );
1259 
1260  if( aShow )
1261  wxWindow::Raise();
1262 
1263  return s;
1264 }

◆ skipMouseEvent()

void CAIRO_GAL::skipMouseEvent ( wxMouseEvent &  aEvent)
protected

Mouse event handler, forwards the event to the child.

Parameters
aEventis the mouse event to be forwarded.

Definition at line 1450 of file cairo_gal.cpp.

1451 {
1452  // Post the mouse event to the event listener registered in constructor, if any
1453  if( mouseListener )
1454  wxPostEvent( mouseListener, aEvent );
1455 }
wxEvtHandler * mouseListener
Mouse listener.
Definition: cairo_gal.h:417

References mouseListener.

Referenced by CAIRO_GAL().

◆ storePath()

void CAIRO_GAL_BASE::storePath ( )
protectedinherited

Store the actual path.

Definition at line 988 of file cairo_gal.cpp.

989 {
990  if( isElementAdded )
991  {
992  isElementAdded = false;
993 
994  if( !isGrouping )
995  {
996  if( isFillEnabled )
997  {
998  cairo_set_source_rgba( currentContext, fillColor.r, fillColor.g, fillColor.b, fillColor.a );
999  cairo_fill_preserve( currentContext );
1000  }
1001 
1002  if( isStrokeEnabled )
1003  {
1004  cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g,
1006  cairo_stroke_preserve( currentContext );
1007  }
1008  }
1009  else
1010  {
1011  // Copy the actual path, append it to the global path list
1012  // then check, if the path needs to be stroked/filled and
1013  // add this command to the group list;
1014  if( isStrokeEnabled )
1015  {
1016  GROUP_ELEMENT groupElement;
1017  groupElement.cairoPath = cairo_copy_path( currentContext );
1018  groupElement.command = CMD_STROKE_PATH;
1019  currentGroup->push_back( groupElement );
1020  }
1021 
1022  if( isFillEnabled )
1023  {
1024  GROUP_ELEMENT groupElement;
1025  groupElement.cairoPath = cairo_copy_path( currentContext );
1026  groupElement.command = CMD_FILL_PATH;
1027  currentGroup->push_back( groupElement );
1028  }
1029  }
1030 
1031  cairo_new_path( currentContext );
1032  }
1033 }
double g
Green component.
Definition: color4d.h:310
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:311
double a
Alpha component.
Definition: color4d.h:312
bool isStrokeEnabled
Are the outlines stroked ?
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:289
COLOR4D strokeColor
The color of the outlines.
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:284
bool isFillEnabled
Is filling of graphic objects enabled ?
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299
double r
Red component.
Definition: color4d.h:309
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:285

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

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_PRINT_GAL::SetLineWidth(), KIGFX::CAIRO_GAL_BASE::SetLineWidth(), KIGFX::CAIRO_GAL_BASE::SetStrokeColor(), SetTarget(), and KIGFX::CAIRO_GAL_BASE::Translate().

◆ StrokeText()

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

Draws a vector type text using preloaded Newstroke font.

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

Definition at line 339 of file graphics_abstraction_layer.h.

341  {
342  strokeFont.Draw( aText, aPosition, aRotationAngle );
343  }
STROKE_FONT strokeFont
Instance of object that stores information about how to draw texts.
void Draw(const UTF8 &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draw a string.

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

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

◆ syncLineWidth()

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

Definition at line 163 of file cairo_gal.cpp.

164 {
165  auto w = floor( xform( aForceWidth ? aWidth : lineWidth ) + 0.5 );
166 
167  if (w <= 1.0)
168  {
169  w = 1.0;
170  cairo_set_line_join( currentContext, CAIRO_LINE_JOIN_MITER );
171  cairo_set_line_cap( currentContext, CAIRO_LINE_CAP_BUTT );
172  cairo_set_line_width( currentContext, 1.0 );
173  lineWidthIsOdd = true;
174  }
175  else
176  {
177  cairo_set_line_join( currentContext, CAIRO_LINE_JOIN_ROUND );
178  cairo_set_line_cap( currentContext, CAIRO_LINE_CAP_ROUND );
179  cairo_set_line_width( currentContext, w );
180  lineWidthIsOdd = ((int)w % 2) == 1;
181  }
182 
183  lineWidthInPixels = w;
184 }
const double xform(double x)
Definition: cairo_gal.cpp:126
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:299

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

Definition at line 977 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::worldScreenMatrix.

Referenced by 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 pointposition in screen coordinates.
Returns
the point position in world coordinates.

Definition at line 966 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::screenWorldMatrix.

◆ Transform()

void CAIRO_GAL_BASE::Transform ( const MATRIX3x3D aTransformation)
overridevirtualinherited

Transform the context.

Parameters
aTransformationis the transformation matrix.

Reimplemented from KIGFX::GAL.

Definition at line 578 of file cairo_gal.cpp.

579 {
580  cairo_matrix_t cairoTransformation, newXform;
581 
582  cairo_matrix_init( &cairoTransformation,
583  aTransformation.m_data[0][0],
584  aTransformation.m_data[1][0],
585  aTransformation.m_data[0][1],
586  aTransformation.m_data[1][1],
587  aTransformation.m_data[0][2],
588  aTransformation.m_data[1][2] );
589 
590  cairo_matrix_multiply( &newXform, &currentXform, &cairoTransformation );
591  currentXform = newXform;
593 }
T m_data[3][3]
Definition: matrix3x3.h:64
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:96
cairo_matrix_t currentXform
Definition: cairo_gal.h:297

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

616 {
617  storePath();
618 
619  if( isGrouping )
620  {
621  GROUP_ELEMENT groupElement;
622  groupElement.command = CMD_TRANSLATE;
623  groupElement.argument.dblArg[0] = aTranslation.x;
624  groupElement.argument.dblArg[1] = aTranslation.y;
625  currentGroup->push_back( groupElement );
626  }
627  else
628  {
629  cairo_matrix_translate ( &currentXform, aTranslation.x, aTranslation.y );
631  }
632 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:988
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:289
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:284
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:96
cairo_matrix_t currentXform
Definition: cairo_gal.h:297
Translate the context.
Definition: cairo_gal.h:264

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

1106 {}

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

◆ updatedGalDisplayOptions()

bool CAIRO_GAL::updatedGalDisplayOptions ( const GAL_DISPLAY_OPTIONS aOptions)
overrideprotectedvirtual

Cairo-specific update handlers

Reimplemented from KIGFX::GAL.

Definition at line 1458 of file cairo_gal.cpp.

1459 {
1460  bool refresh = false;
1461 
1462  if( validCompositor && aOptions.cairo_antialiasing_mode != compositor->GetAntialiasingMode() )
1463  {
1464 
1465  compositor->SetAntialiasingMode( options.cairo_antialiasing_mode );
1466  validCompositor = false;
1467  deinitSurface();
1468 
1469  refresh = true;
1470  }
1471 
1472  if( super::updatedGalDisplayOptions( aOptions ) )
1473  {
1474  Refresh();
1475  refresh = true;
1476  }
1477 
1478  return refresh;
1479 }
void deinitSurface()
Destroy Cairo surfaces when are not needed anymore.
Definition: cairo_gal.cpp:1392
GAL_DISPLAY_OPTIONS & options
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:413
CAIRO_ANTIALIASING_MODE cairo_antialiasing_mode
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:409
virtual bool updatedGalDisplayOptions(const GAL_DISPLAY_OPTIONS &aOptions)
Function updatedGalDisplayOptions.

References KIGFX::GAL_DISPLAY_OPTIONS::cairo_antialiasing_mode, compositor, deinitSurface(), KIGFX::GAL::options, Refresh(), KIGFX::GAL::updatedGalDisplayOptions(), and validCompositor.

◆ updateWorldScreenMatrix()

◆ xform() [1/3]

◆ xform() [2/3]

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

Definition at line 102 of file cairo_gal.cpp.

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

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

◆ xform() [3/3]

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

Definition at line 112 of file cairo_gal.cpp.

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