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...
 
 ~CAIRO_GAL ()
 
bool IsVisible () const override
 

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

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...
 
virtual bool HasTarget (RENDER_TARGET aTarget)
 Returns true if the target exists. More...
 
void SetGridVisibility (bool aVisibility)
 Sets the visibility setting of the grid. More...
 
bool GetGridVisibility () const
 
bool GetGridSnapping () const
 
void SetGridOrigin (const VECTOR2D &aGridOrigin)
 Set the origin point for the grid. More...
 
const VECTOR2DGetGridOrigin () const
 
void SetGridSize (const VECTOR2D &aGridSize)
 Set the grid size. More...
 
const VECTOR2DGetGridSize () const
 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

void beginDrawing () override
 
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)
 Transform according to the rotation from currentWorld2Screen transform matrix: More...
 
void arc_angles_xform_and_normalize (double &aStartAngle, double &aEndAngle)
 Transform according to the rotation from currentWorld2Screen transform matrix for the start angle and the end angle of an arc. More...
 
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...
 
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 char * bitmapBuffer
 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 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_surface_t * > imageSurfaces
 List of surfaces that were created by painting images, to be cleaned up later. 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...
 
float lineWidth
 The line width. 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_ARGB32
 Format used to store pixels. More...
 
static const int MIN_DEPTH = -1024
 Possible depth range. More...
 
static const int MAX_DEPTH = 1023
 
static const int GRID_DEPTH = MAX_DEPTH - 1
 Depth level on which the grid is drawn. More...
 

Detailed Description

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

◆ super

typedef GAL KIGFX::CAIRO_GAL_BASE::super
protectedinherited

Super class definition.

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

258  {
259  CMD_SET_FILL,
265  CMD_FILL_PATH,
266  //CMD_TRANSFORM, ///< Transform the actual context
267  CMD_ROTATE,
268  CMD_TRANSLATE,
269  CMD_SCALE,
270  CMD_SAVE,
271  CMD_RESTORE,
273  };
Enable/disable filling.
Definition: cairo_gal.h:259
Save the transformation matrix.
Definition: cairo_gal.h:270
Translate the context.
Definition: cairo_gal.h:268
Enable/disable stroking.
Definition: cairo_gal.h:260
Restore the transformation matrix.
Definition: cairo_gal.h:271

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

1208  :
1209  CAIRO_GAL_BASE( aDisplayOptions ),
1210  wxWindow( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxEXPAND, aName )
1211 {
1212  // Initialise compositing state
1213  mainBuffer = 0;
1214  overlayBuffer = 0;
1215  validCompositor = false;
1217 
1218  parentWindow = aParent;
1219  mouseListener = aMouseListener;
1220  paintListener = aPaintListener;
1221 
1222  // Connecting the event handlers
1223  Connect( wxEVT_PAINT, wxPaintEventHandler( CAIRO_GAL::onPaint ) );
1224 
1225  // Mouse events are skipped to the parent
1226  Connect( wxEVT_MOTION, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1227  Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1228  Connect( wxEVT_LEFT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1229  Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1230  Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1231  Connect( wxEVT_MIDDLE_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1232  Connect( wxEVT_MIDDLE_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1233  Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1234  Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1235  Connect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1236  Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1237 #if defined _WIN32 || defined _WIN64
1238  Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1239 #endif
1240 
1241  SetSize( aParent->GetClientSize() );
1242  screenSize = VECTOR2I( aParent->GetClientSize() );
1243 
1244  // Allocate memory for pixel storage
1245  allocateBitmaps();
1246 
1247  isInitialized = false;
1248 }
void onPaint(wxPaintEvent &aEvent)
Paint event handler.
Definition: cairo_gal.cpp:1491
CAIRO_GAL_BASE(GAL_DISPLAY_OPTIONS &aDisplayOptions)
Definition: cairo_gal.cpp:47
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:422
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:407
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:409
Auxiliary rendering target (noncached)
Definition: definitions.h:49
wxEvtHandler * paintListener
Paint listener.
Definition: cairo_gal.h:414
void SetTarget(RENDER_TARGET aTarget) override
Sets the target for rendering.
Definition: cairo_gal.cpp:1361
void skipMouseEvent(wxMouseEvent &aEvent)
Mouse event handler, forwards the event to the child.
Definition: cairo_gal.cpp:1497
VECTOR2I screenSize
Screen size in screen coordinates.
wxEvtHandler * mouseListener
Mouse listener.
Definition: cairo_gal.h:413
void allocateBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1455
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:406
wxWindow * parentWindow
Parent window.
Definition: cairo_gal.h:412

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

Definition at line 1251 of file cairo_gal.cpp.

1252 {
1253  deleteBitmaps();
1254 }
void deleteBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1469

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

1040  {
1041  layerDepth -= 0.05;
1042  }
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 1455 of file cairo_gal.cpp.

1456 {
1458  while( ( ( wxBufferWidth * 3 ) % 4 ) != 0 ) wxBufferWidth++;
1459 
1460  // Create buffer, use the system independent Cairo context backend
1461  stride = cairo_format_stride_for_width( GAL_FORMAT, wxBufferWidth );
1463 
1464  bitmapBuffer = new unsigned char[bufferSize * 4];
1465  wxOutput = new unsigned char[wxBufferWidth * 3 * screenSize.y];
1466 }
unsigned char * wxOutput
wxImage comaptible buffer
Definition: cairo_gal.h:416
int stride
Stride value for Cairo.
Definition: cairo_gal.h:420
VECTOR2I screenSize
Screen size in screen coordinates.
unsigned int bufferSize
Size of buffers cairoOutput, bitmapBuffers.
Definition: cairo_gal.h:415
unsigned char * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:419
static constexpr cairo_format_t GAL_FORMAT
Format used to store pixels.
Definition: cairo_gal.h:337

References bitmapBuffer, 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

Transform according to the rotation from currentWorld2Screen transform matrix:

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

Definition at line 126 of file cairo_gal.cpp.

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

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

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

◆ arc_angles_xform_and_normalize()

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

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

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

Definition at line 140 of file cairo_gal.cpp.

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

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

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

◆ beginDrawing()

void CAIRO_GAL::beginDrawing ( )
overrideprotectedvirtual

Reimplemented from KIGFX::CAIRO_GAL_BASE.

Definition at line 1257 of file cairo_gal.cpp.

1258 {
1259  initSurface();
1260 
1262 
1263  if( !validCompositor )
1264  setCompositor();
1265 
1266  compositor->SetMainContext( context );
1267  compositor->SetBuffer( mainBuffer );
1268 }
void initSurface()
Prepare Cairo surfaces for drawing.
Definition: cairo_gal.cpp:1421
void setCompositor()
Prepare the compositor.
Definition: cairo_gal.cpp:1476
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:409
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:405
cairo_t * context
Cairo image.
Definition: cairo_gal.h:303
void beginDrawing() override
Definition: cairo_gal.cpp:92
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:406

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

1348 {
1349  initSurface();
1350  return CAIRO_GAL_BASE::BeginGroup();
1351 }
void initSurface()
Prepare Cairo surfaces for drawing.
Definition: cairo_gal.cpp:1421
int BeginGroup() override
Begin a group.
Definition: cairo_gal.cpp:753

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

1127 {}

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

359  {
360  // Fallback: use stroke font
361 
362  // Handle flipped view
363  if( globalFlipX )
365 
366  StrokeText( aText, aPosition, aRotationAngle );
367 
368  if( globalFlipX )
370  }
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)
protectedinherited

Blits cursor into the current screen.

Definition at line 1100 of file cairo_gal.cpp.

1101 {
1102  if( !IsCursorEnabled() )
1103  return;
1104 
1105  auto p = ToScreen( cursorPosition );
1106 
1107  const auto cColor = getCursorColor();
1108  const int cursorSize = fullscreenCursor ? 8000 : 80;
1109 
1110  wxColour color( cColor.r * cColor.a * 255, cColor.g * cColor.a * 255,
1111  cColor.b * cColor.a * 255, 255 );
1112  clientDC.SetPen( wxPen( color ) );
1113  clientDC.DrawLine( p.x - cursorSize / 2, p.y, p.x + cursorSize / 2, p.y );
1114  clientDC.DrawLine( p.x, p.y - cursorSize / 2, p.x, p.y + cursorSize / 2 );
1115 }
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:61
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 866 of file cairo_gal.cpp.

867 {
868  storePath();
869 
870  for( GROUP::iterator it = groups[aGroupNumber].begin();
871  it != groups[aGroupNumber].end(); ++it )
872  {
873  if( it->command == CMD_SET_FILLCOLOR || it->command == CMD_SET_STROKECOLOR )
874  {
875  it->argument.dblArg[0] = aNewColor.r;
876  it->argument.dblArg[1] = aNewColor.g;
877  it->argument.dblArg[2] = aNewColor.b;
878  it->argument.dblArg[3] = aNewColor.a;
879  }
880  }
881 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1052
double g
Green component.
Definition: color4d.h:367
double b
Blue component.
Definition: color4d.h:368
double a
Alpha component.
Definition: color4d.h:369
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:291
double r
Red component.
Definition: color4d.h:366

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

885 {
886  // Cairo does not have any possibilities to change the depth coordinate of stored items,
887  // it depends only on the order of drawing
888 }

◆ ClearCache()

void CAIRO_GAL_BASE::ClearCache ( )
overridevirtualinherited

Delete all data created during caching of graphic items.

Reimplemented from KIGFX::GAL.

Definition at line 911 of file cairo_gal.cpp.

912 {
913  for( auto it = groups.begin(); it != groups.end(); )
914  DeleteGroup( ( it++ )->first );
915 }
void DeleteGroup(int aGroupNumber) override
Delete the group from the memory.
Definition: cairo_gal.cpp:891
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:291

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

537 {
538  cairo_set_source_rgb( currentContext, m_clearColor.r, m_clearColor.g, m_clearColor.b );
539  cairo_rectangle( currentContext, 0.0, 0.0, screenSize.x, screenSize.y );
540  cairo_fill( currentContext );
541 }
double g
Green component.
Definition: color4d.h:367
double b
Blue component.
Definition: color4d.h:368
VECTOR2I screenSize
Screen size in screen coordinates.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:302
double r
Red component.
Definition: color4d.h:366

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

1396 {
1397  // Save the current state
1398  unsigned int currentBuffer = compositor->GetBuffer();
1399 
1400  switch( aTarget )
1401  {
1402  // Cached and noncached items are rendered to the same buffer
1403  default:
1404  case TARGET_CACHED:
1405  case TARGET_NONCACHED:
1406  compositor->SetBuffer( mainBuffer );
1407  break;
1408 
1409  case TARGET_OVERLAY:
1410  compositor->SetBuffer( overlayBuffer );
1411  break;
1412  }
1413 
1414  compositor->ClearBuffer( COLOR4D::BLACK );
1415 
1416  // Restore the previous state
1417  compositor->SetBuffer( currentBuffer );
1418 }
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:407
Auxiliary rendering target (noncached)
Definition: definitions.h:49
static const COLOR4D BLACK
Definition: color4d.h:376
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:405
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:406

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

211 {
212  // just return the current value. This could be cleverer and take
213  // into account other settings in future
214  return gridMinSpacing;
215 }
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 1141 of file graphics_abstraction_layer.h.

1142  {
1144  }
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 181 of file graphics_abstraction_layer.cpp.

182 {
184 
185  MATRIX3x3D translation;
186  translation.SetIdentity();
187  translation.SetTranslation( 0.5 * VECTOR2D( screenSize ) );
188 
189  MATRIX3x3D rotate;
190  rotate.SetIdentity();
191  rotate.SetRotation( rotation );
192 
194  scale.SetIdentity();
195  scale.SetScale( VECTOR2D( worldScale, worldScale ) );
196 
197  MATRIX3x3D flip;
198  flip.SetIdentity();
199  flip.SetScale( VECTOR2D( globalFlipX ? -1.0 : 1.0, globalFlipY ? -1.0 : 1.0 ) );
200 
201  MATRIX3x3D lookat;
202  lookat.SetIdentity();
203  lookat.SetTranslation( -lookAtPoint );
204 
205  worldScreenMatrix = translation * rotate * flip * scale * lookat;
207 }
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:593
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 1441 of file cairo_gal.cpp.

1442 {
1443  if( !isInitialized )
1444  return;
1445 
1446  cairo_destroy( context );
1447  context = nullptr;
1448  cairo_surface_destroy( surface );
1449  surface = nullptr;
1450 
1451  isInitialized = false;
1452 }
cairo_surface_t * surface
Cairo surface.
Definition: cairo_gal.h:304
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:422
cairo_t * context
Cairo image.
Definition: cairo_gal.h:303

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

1470 {
1471  delete[] bitmapBuffer;
1472  delete[] wxOutput;
1473 }
unsigned char * wxOutput
wxImage comaptible buffer
Definition: cairo_gal.h:416
unsigned char * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:419

References bitmapBuffer, 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 891 of file cairo_gal.cpp.

892 {
893  storePath();
894 
895  // Delete the Cairo paths
896  std::deque<GROUP_ELEMENT>::iterator it, end;
897 
898  for( it = groups[aGroupNumber].begin(), end = groups[aGroupNumber].end(); it != end; ++it )
899  {
900  if( it->command == CMD_FILL_PATH || it->command == CMD_STROKE_PATH )
901  {
902  cairo_path_destroy( it->cairoPath );
903  }
904  }
905 
906  // Delete the group
907  groups.erase( aGroupNumber );
908 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1052
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:291

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

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

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

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

References KIGFX::COLOR4D::a, KIGFX::CAIRO_GAL_BASE::arc_angles_xform_and_normalize(), 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::GAL::lineWidth, KIGFX::CAIRO_GAL_BASE::lineWidthIsOdd, KIGFX::COLOR4D::r, VECTOR2< T >::Rotate(), KIGFX::CAIRO_GAL_BASE::roundp(), KIGFX::GAL::strokeColor, 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 967 of file cairo_gal.cpp.

968 {
969  syncLineWidth();
970 
971  auto p0 = roundp( xform( aStartPoint ) );
972  auto p1 = roundp( xform( aEndPoint ) );
973  auto org = roundp( xform( VECTOR2D( 0.0, 0.0 ) ) ); // Axis origin = 0,0 coord
974 
975  cairo_set_source_rgba( currentContext, axesColor.r, axesColor.g, axesColor.b, axesColor.a );
976  cairo_move_to( currentContext, p0.x, org.y);
977  cairo_line_to( currentContext, p1.x, org.y );
978  cairo_move_to( currentContext, org.x, p0.y );
979  cairo_line_to( currentContext, org.x, p1.y );
980  cairo_stroke( currentContext );
981 }
double g
Green component.
Definition: color4d.h:367
double b
Blue component.
Definition: color4d.h:368
double a
Alpha component.
Definition: color4d.h:369
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
COLOR4D axesColor
Color of the axes.
const double xform(double x)
Definition: cairo_gal.cpp:172
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:186
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:302
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:209
double r
Red component.
Definition: color4d.h:366

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

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

References KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::currentWorld2Screen, BITMAP_BASE::GetImageData(), BITMAP_BASE::GetPPI(), BITMAP_BASE::GetSizePixels(), KIGFX::CAIRO_GAL_BASE::imageSurfaces, 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 287 of file cairo_gal.cpp.

288 {
289  syncLineWidth();
290 
291  auto c = roundp( xform( aCenterPoint ) );
292  auto r = ::roundp( xform( aRadius ) );
293 
294  cairo_set_line_width( currentContext, std::min( 2.0 * r, lineWidthInPixels ) );
295  cairo_new_sub_path( currentContext );
296  cairo_arc( currentContext, c.x, c.y, r, 0.0, 2 * M_PI );
297  cairo_close_path( currentContext );
298  flushPath();
299  isElementAdded = true;
300 }
const double xform(double x)
Definition: cairo_gal.cpp:172
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:186
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:302
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:209
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:289

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

925 {
926  cursorPosition = aCursorPosition;
927 }
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,
double  aFilterValue = 0.0 
)
overridevirtualinherited

Draw a cubic bezier spline.

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

Reimplemented from KIGFX::GAL.

Definition at line 434 of file cairo_gal.cpp.

437 {
438  // Note: aFilterValue is not used because the cubic Bezier curve is
439  // supported by Cairo.
440  syncLineWidth();
441 
442  const auto sp = roundp( xform( aStartPoint ) );
443  const auto cpa = roundp( xform( aControlPointA ) );
444  const auto cpb = roundp( xform( aControlPointB ) );
445  const auto ep = roundp( xform( aEndPoint ) );
446 
447  cairo_move_to( currentContext, sp.x, sp.y );
448  cairo_curve_to( currentContext, cpa.x, cpa.y, cpb.x, cpb.y, ep.x, ep.y );
449  cairo_line_to( currentContext, ep.x, ep.y );
450 
451  flushPath();
452  isElementAdded = true;
453 }
const double xform(double x)
Definition: cairo_gal.cpp:172
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:186
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:302
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:209
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:289

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

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

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, KiROUND(), KIGFX::LINES, 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 997 of file cairo_gal.cpp.

998 {
999  syncLineWidth();
1000  VECTOR2D offset( 0, 0 );
1001  auto size = 2.0 * lineWidthInPixels;
1002 
1003  auto p0 = roundp( xform( aPoint ) ) - VECTOR2D( size, 0 ) + offset;
1004  auto p1 = roundp( xform( aPoint ) ) + VECTOR2D( size, 0 ) + offset;
1005  auto p2 = roundp( xform( aPoint ) ) - VECTOR2D( 0, size ) + offset;
1006  auto p3 = roundp( xform( aPoint ) ) + VECTOR2D( 0, size ) + offset;
1007 
1008  cairo_set_source_rgba( currentContext, gridColor.r, gridColor.g, gridColor.b, gridColor.a );
1009  cairo_move_to( currentContext, p0.x, p0.y );
1010  cairo_line_to( currentContext, p1.x, p1.y );
1011  cairo_move_to( currentContext, p2.x, p2.y );
1012  cairo_line_to( currentContext, p3.x, p3.y );
1013  cairo_stroke( currentContext );
1014 }
double g
Green component.
Definition: color4d.h:367
double b
Blue component.
Definition: color4d.h:368
double a
Alpha component.
Definition: color4d.h:369
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
const double xform(double x)
Definition: cairo_gal.cpp:172
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:186
COLOR4D gridColor
Color of the grid.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:302
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:209
double r
Red component.
Definition: color4d.h:366

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

985 {
986  syncLineWidth();
987  auto p0 = roundp( xform( aStartPoint ) );
988  auto p1 = roundp( xform( aEndPoint ) );
989 
990  cairo_set_source_rgba( currentContext, gridColor.r, gridColor.g, gridColor.b, gridColor.a );
991  cairo_move_to( currentContext, p0.x, p0.y );
992  cairo_line_to( currentContext, p1.x, p1.y );
993  cairo_stroke( currentContext );
994 }
double g
Green component.
Definition: color4d.h:367
double b
Blue component.
Definition: color4d.h:368
double a
Alpha component.
Definition: color4d.h:369
const double xform(double x)
Definition: cairo_gal.cpp:172
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:186
COLOR4D gridColor
Color of the grid.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:302
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:209
double r
Red component.
Definition: color4d.h:366

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

1018 {
1019  auto p = roundp( xform( aPoint ) );
1020  auto s = xform( aSize / 2.0 );
1021 
1022  cairo_set_source_rgba( currentContext, gridColor.r, gridColor.g, gridColor.b, gridColor.a );
1023  cairo_move_to( currentContext, p.x, p.y );
1024  cairo_arc( currentContext, p.x, p.y, s, 0.0, 2.0 * M_PI );
1025  cairo_close_path( currentContext );
1026 
1027  cairo_fill( currentContext );
1028 }
double g
Green component.
Definition: color4d.h:367
double b
Blue component.
Definition: color4d.h:368
double a
Alpha component.
Definition: color4d.h:369
const double xform(double x)
Definition: cairo_gal.cpp:172
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:186
COLOR4D gridColor
Color of the grid.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:302
double r
Red component.
Definition: color4d.h:366

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

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

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

196 {
197  syncLineWidth();
198 
199  auto p0 = roundp( xform( aStartPoint ) );
200  auto p1 = roundp( xform( aEndPoint ) );
201 
202  cairo_move_to( currentContext, p0.x, p0.y );
203  cairo_line_to( currentContext, p1.x, p1.y );
204  flushPath();
205  isElementAdded = true;
206 }
const double xform(double x)
Definition: cairo_gal.cpp:172
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:186
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:302
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:209
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:289

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

1119 {
1120  wxCHECK( aPointList.size() > 1, /* void */ );
1121 
1122  // Iterate over the point list and draw the segments
1123  std::deque<VECTOR2D>::const_iterator it = aPointList.begin();
1124 
1125  syncLineWidth();
1126 
1127  const auto p = roundp( xform( it->x, it->y ) );
1128 
1129  cairo_move_to( currentContext, p.x, p.y );
1130 
1131  for( ++it; it != aPointList.end(); ++it )
1132  {
1133  const auto p2 = roundp( xform( it->x, it->y ) );
1134 
1135  cairo_line_to( currentContext, p2.x, p2.y );
1136  }
1137 
1138  flushPath();
1139  isElementAdded = true;
1140 }
const double xform(double x)
Definition: cairo_gal.cpp:172
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:186
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:302
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:209
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:289

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

1144 {
1145  wxCHECK( aListSize > 1, /* void */ );
1146 
1147  // Iterate over the point list and draw the segments
1148  const VECTOR2D* ptr = aPointList;
1149 
1150  syncLineWidth();
1151 
1152  const auto p = roundp( xform( ptr->x, ptr->y ) );
1153  cairo_move_to( currentContext, p.x, p.y );
1154 
1155  for( int i = 0; i < aListSize; ++i )
1156  {
1157  ++ptr;
1158  const auto p2 = roundp( xform( ptr->x, ptr->y ) );
1159  cairo_line_to( currentContext, p2.x, p2.y );
1160  }
1161 
1162  flushPath();
1163  isElementAdded = true;
1164 }
const double xform(double x)
Definition: cairo_gal.cpp:172
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:186
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:302
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:209
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:289

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.

◆ drawPoly() [3/3]

void CAIRO_GAL_BASE::drawPoly ( const SHAPE_LINE_CHAIN aLineChain)
protectedinherited

Definition at line 1167 of file cairo_gal.cpp.

1168 {
1169  wxCHECK( aLineChain.PointCount() > 1, /* void */ );
1170 
1171  syncLineWidth();
1172 
1173  auto numPoints = aLineChain.PointCount();
1174 
1175  if( aLineChain.IsClosed() )
1176  numPoints += 1;
1177 
1178  const VECTOR2I start = aLineChain.CPoint( 0 );
1179  const auto p = roundp( xform( start.x, start.y ) );
1180  cairo_move_to( currentContext, p.x, p.y );
1181 
1182  for( int i = 1; i < numPoints; ++i )
1183  {
1184  const VECTOR2I& pw = aLineChain.CPoint( i );
1185  const auto ps = roundp( xform( pw.x, pw.y ) );
1186  cairo_line_to( currentContext, ps.x, ps.y );
1187  }
1188 
1189  flushPath();
1190  isElementAdded = true;
1191 }
int PointCount() const
Function PointCount()
const VECTOR2I & CPoint(int aIndex) const
Function Point()
bool IsClosed() const override
Function IsClosed()
const double xform(double x)
Definition: cairo_gal.cpp:172
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:186
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:302
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:209
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:289

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

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

97 { 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:1118

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolygon() [2/4]

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

Reimplemented from KIGFX::GAL.

Definition at line 98 of file cairo_gal.h.

98 { 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:1118

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

422 {
423  for( int i = 0; i < aPolySet.OutlineCount(); ++i )
424  drawPoly( aPolySet.COutline( i ) );
425 }
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:1118
const SHAPE_LINE_CHAIN & COutline(int aIndex) const

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

◆ DrawPolygon() [4/4]

void CAIRO_GAL_BASE::DrawPolygon ( const SHAPE_LINE_CHAIN aPolySet)
overridevirtualinherited

Reimplemented from KIGFX::GAL.

Definition at line 428 of file cairo_gal.cpp.

429 {
430  drawPoly( aPolygon );
431 }
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:1118

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolyline() [1/3]

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

Draw a polyline.

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

Reimplemented from KIGFX::GAL.

Definition at line 92 of file cairo_gal.h.

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

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolyline() [2/3]

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

Reimplemented from KIGFX::GAL.

Definition at line 93 of file cairo_gal.h.

93 { 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:1118

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolyline() [3/3]

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

Reimplemented from KIGFX::GAL.

Definition at line 94 of file cairo_gal.h.

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

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

400 {
401  // Calculate the diagonal points
402  syncLineWidth();
403 
404  const auto p0 = roundp( xform( aStartPoint ) );
405  const auto p1 = roundp( xform( VECTOR2D( aEndPoint.x, aStartPoint.y ) ) );
406  const auto p2 = roundp( xform( aEndPoint ) );
407  const auto p3 = roundp( xform( VECTOR2D( aStartPoint.x, aEndPoint.y ) ) );
408 
409  // The path is composed from 4 segments
410  cairo_move_to( currentContext, p0.x, p0.y );
411  cairo_line_to( currentContext, p1.x, p1.y );
412  cairo_line_to( currentContext, p2.x, p2.y );
413  cairo_line_to( currentContext, p3.x, p3.y );
414  cairo_close_path( currentContext );
415  flushPath();
416 
417  isElementAdded = true;
418 }
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
const double xform(double x)
Definition: cairo_gal.cpp:172
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:186
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:302
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:209
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:289

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

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

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

931 {
932 }

◆ endDrawing()

void CAIRO_GAL::endDrawing ( )
overrideprotectedvirtual

Reimplemented from KIGFX::CAIRO_GAL_BASE.

Definition at line 1271 of file cairo_gal.cpp.

1272 {
1274 
1275  // Merge buffers on the screen
1276  compositor->DrawBuffer( mainBuffer );
1277  compositor->DrawBuffer( overlayBuffer );
1278 
1279  // Now translate the raw context data from the format stored
1280  // by cairo into a format understood by wxImage.
1281 
1282  pixman_image_t* dstImg = pixman_image_create_bits(
1283  wxPlatformInfo::Get().GetEndianness() == wxENDIAN_LITTLE ? PIXMAN_b8g8r8 :
1284  PIXMAN_r8g8b8,
1285  screenSize.x, screenSize.y, (uint32_t*) wxOutput, wxBufferWidth * 3 );
1286  pixman_image_t* srcImg = pixman_image_create_bits( PIXMAN_a8r8g8b8, screenSize.x, screenSize.y,
1287  (uint32_t*) bitmapBuffer, wxBufferWidth * 4 );
1288 
1289  pixman_image_composite( PIXMAN_OP_SRC, srcImg, NULL, dstImg,
1290  0, 0, 0, 0, 0, 0, screenSize.x, screenSize.y );
1291 
1292  // Free allocated memory
1293  pixman_image_unref( srcImg );
1294  pixman_image_unref( dstImg );
1295 
1296  wxImage img( wxBufferWidth, screenSize.y, wxOutput, true );
1297  wxBitmap bmp( img );
1298  wxMemoryDC mdc( bmp );
1299  wxClientDC clientDC( this );
1300 
1301  // Now it is the time to blit the mouse cursor
1302  blitCursor( mdc );
1303  clientDC.Blit( 0, 0, screenSize.x, screenSize.y, &mdc, 0, 0, wxCOPY );
1304 
1305  deinitSurface();
1306 }
void deinitSurface()
Destroy Cairo surfaces when are not needed anymore.
Definition: cairo_gal.cpp:1441
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:407
unsigned char * wxOutput
wxImage comaptible buffer
Definition: cairo_gal.h:416
#define NULL
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:405
void endDrawing() override
Definition: cairo_gal.cpp:98
VECTOR2I screenSize
Screen size in screen coordinates.
unsigned char * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:419
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:406
void blitCursor(wxMemoryDC &clientDC)
Blits cursor into the current screen.
Definition: cairo_gal.cpp:1100

References bitmapBuffer, KIGFX::CAIRO_GAL_BASE::blitCursor(), compositor, deinitSurface(), KIGFX::CAIRO_GAL_BASE::endDrawing(), mainBuffer, NULL, 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 1354 of file cairo_gal.cpp.

1355 {
1357  deinitSurface();
1358 }
void EndGroup() override
End the group.
Definition: cairo_gal.cpp:769
void deinitSurface()
Destroy Cairo surfaces when are not needed anymore.
Definition: cairo_gal.cpp:1441

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

1130 {}

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

531 {
532  storePath();
533 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1052

References KIGFX::CAIRO_GAL_BASE::storePath().

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

◆ flushPath()

void CAIRO_GAL_BASE::flushPath ( )
protectedinherited

Definition at line 1030 of file cairo_gal.cpp.

1031 {
1032  if( isFillEnabled )
1033  {
1034  cairo_set_source_rgba( currentContext,
1036 
1037  if( isStrokeEnabled )
1038  cairo_fill_preserve( currentContext );
1039  else
1040  cairo_fill( currentContext );
1041  }
1042 
1043  if( isStrokeEnabled )
1044  {
1045  cairo_set_source_rgba( currentContext,
1047  cairo_stroke( currentContext );
1048  }
1049 }
double g
Green component.
Definition: color4d.h:367
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:368
double a
Alpha component.
Definition: color4d.h:369
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:302
double r
Red component.
Definition: color4d.h:366

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

220  {
221  return m_clearColor;
222  }

References KIGFX::GAL::m_clearColor.

◆ getCursorColor()

COLOR4D GAL::getCursorColor ( ) const
protectedinherited

Gets the actual cursor color to draw.

Definition at line 240 of file graphics_abstraction_layer.cpp.

241 {
242  auto color = cursorColor;
243 
244  // dim the cursor if it's only on because it was forced
245  // (this helps to provide a hint for active tools)
246  if( !isCursorEnabled )
247  {
248  color.a = color.a * 0.5;
249  }
250 
251  return color;
252 }
bool isCursorEnabled
Is the cursor enabled?
int color
Definition: DXF_plotter.cpp:61
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 269 of file graphics_abstraction_layer.h.

270  {
271  return fillColor;
272  }
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 960 of file graphics_abstraction_layer.h.

961  {
962  return gridLineWidth;
963  }
float gridLineWidth
Line width of the grid.

References KIGFX::GAL::gridLineWidth.

◆ GetGridOrigin()

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

Definition at line 885 of file graphics_abstraction_layer.h.

886  {
887  return gridOrigin;
888  }
VECTOR2D gridOrigin
The grid origin.

References KIGFX::GAL::gridOrigin.

Referenced by EE_GRID_HELPER::GetOrigin(), and GRID_HELPER::GetOrigin().

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

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

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

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

913  {
914  return gridSize;
915  }
VECTOR2D gridSize
The grid size.

References KIGFX::GAL::gridSize.

Referenced by COMMON_TOOLS::CursorControl(), DIALOG_BOARD_REANNOTATE::DIALOG_BOARD_REANNOTATE(), GRID_HELPER::GetGrid(), EE_GRID_HELPER::GetGrid(), EDA_DRAW_FRAME::GetNearestGridPosition(), COMMON_TOOLS::PanControl(), and EDA_DRAW_PANEL_GAL::SwitchBackend().

◆ GetGridSnapping()

◆ GetGridVisibility()

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

Definition at line 862 of file graphics_abstraction_layer.h.

862 { return gridVisibility; }
bool gridVisibility
Should the grid be shown.

References KIGFX::GAL::gridVisibility.

Referenced by EDA_DRAW_PANEL_GAL::SwitchBackend().

◆ GetHorizontalJustify()

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

Returns current text horizontal justification setting.

Definition at line 491 of file graphics_abstraction_layer.h.

492  {
494  }
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 691 of file graphics_abstraction_layer.h.

692  {
693  return lookAtPoint;
694  }
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 760 of file graphics_abstraction_layer.h.

761  {
762  return depthRange.y;
763  }
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 752 of file graphics_abstraction_layer.h.

753  {
754  return depthRange.x;
755  }
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 1194 of file cairo_gal.cpp.

1195 {
1196  wxASSERT_MSG( groups.size() < std::numeric_limits<unsigned int>::max(),
1197  wxT( "There are no free slots to store a group" ) );
1198 
1199  while( groups.find( groupCounter ) != groups.end() )
1200  groupCounter++;
1201 
1202  return groupCounter++;
1203 }
unsigned int groupCounter
Counter used for generating keys for groups.
Definition: cairo_gal.h:292
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:291

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

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

387  {
389  }
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 731 of file graphics_abstraction_layer.h.

732  {
733  return rotation;
734  }
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 627 of file graphics_abstraction_layer.h.

628  {
629  return screenWorldMatrix;
630  }
MATRIX3x3D screenWorldMatrix
Screen transformation.

References KIGFX::GAL::screenWorldMatrix.

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

◆ GetStrokeColor()

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

Get the stroke color.

Returns
the color for stroking the outline.

Definition at line 289 of file graphics_abstraction_layer.h.

290  {
291  return strokeColor;
292  }
COLOR4D strokeColor
The color of the outlines.

References KIGFX::GAL::strokeColor.

◆ GetStrokeFont()

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

Definition at line 331 of file graphics_abstraction_layer.h.

332  {
333  return strokeFont;
334  }
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 1389 of file cairo_gal.cpp.

1390 {
1391  return currentTarget;
1392 }
RENDER_TARGET currentTarget
Current rendering target.
Definition: cairo_gal.h:408

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

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

510  {
512  }
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 770 of file graphics_abstraction_layer.h.

771  {
772  return worldScale;
773  }
double worldScale
The scale factor world->screen.

References KIGFX::GAL::worldScale.

Referenced by GRID_HELPER::BestDragOrigin(), EE_GRID_HELPER::BestDragOrigin(), KIGFX::PCB_PAINTER::draw(), 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 617 of file graphics_abstraction_layer.h.

618  {
619  return worldScreenMatrix;
620  }
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 711 of file graphics_abstraction_layer.h.

712  {
713  return zoomFactor;
714  }
double zoomFactor
The zoom factor.

References KIGFX::GAL::zoomFactor.

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

◆ HasTarget()

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

Returns true if the target exists.

Parameters
aTargetis the target to be checked.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 833 of file graphics_abstraction_layer.h.

834  {
835  return true;
836  };

Referenced by EDA_DRAW_PANEL_GAL::DoRePaint().

◆ initSurface()

void CAIRO_GAL::initSurface ( )
protected

Prepare Cairo surfaces for drawing.

Definition at line 1421 of file cairo_gal.cpp.

1422 {
1423  if( isInitialized )
1424  return;
1425 
1426  surface = cairo_image_surface_create_for_data( bitmapBuffer, GAL_FORMAT,
1428 
1429  context = cairo_create( surface );
1430 
1431 #ifdef DEBUG
1432  cairo_status_t status = cairo_status( context );
1433  wxASSERT_MSG( status == CAIRO_STATUS_SUCCESS, wxT( "Cairo context creation error" ) );
1434 #endif /* DEBUG */
1436 
1437  isInitialized = true;
1438 }
cairo_surface_t * surface
Cairo surface.
Definition: cairo_gal.h:304
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:422
cairo_t * context
Cairo image.
Definition: cairo_gal.h:303
int stride
Stride value for Cairo.
Definition: cairo_gal.h:420
VECTOR2I screenSize
Screen size in screen coordinates.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:302
unsigned char * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:419
static constexpr cairo_format_t GAL_FORMAT
Format used to store pixels.
Definition: cairo_gal.h:337

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

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

65 { return true; }

◆ IsCursorEnabled()

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

Returns information about cursor visibility.

Returns
True if cursor is visible.

Definition at line 1013 of file graphics_abstraction_layer.h.

1014  {
1016  }
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 790 of file graphics_abstraction_layer.h.

791  {
792  return globalFlipX;
793  }
bool globalFlipX
Flag for X axis flipping.

References KIGFX::GAL::globalFlipX.

Referenced by KIGFX::CAIRO_GAL_BASE::angle_xform(), KIGFX::CAIRO_GAL_BASE::arc_angles_xform_and_normalize(), and KIGFX::WS_PROXY_VIEW_ITEM::ViewDraw().

◆ IsFlippedY()

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

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

Definition at line 798 of file graphics_abstraction_layer.h.

799  {
800  return globalFlipY;
801  }
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 437 of file graphics_abstraction_layer.h.

438  {
439  return textProperties.m_bold;
440  }
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 455 of file graphics_abstraction_layer.h.

456  {
457  return textProperties.m_italic;
458  }
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 SCH_DRAW_PANEL::onPaint(), and 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 473 of file graphics_abstraction_layer.h.

474  {
475  return textProperties.m_mirrored;
476  }
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 366 of file cairo_gal.h.

367  {
368  return IsShownOnScreen() && !GetClientRect().IsEmpty();
369  }

◆ lockContext()

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

Private: use GAL_CONTEXT_LOCKER RAII object.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1121 of file graphics_abstraction_layer.h.

1121 {}

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

93 {
94  // defer to the child class first
95  updatedGalDisplayOptions( aOptions );
96 
97  // there is no refresh to do at this level
98 }
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 1491 of file cairo_gal.cpp.

1492 {
1493  PostPaint( aEvent );
1494 }
void PostPaint(wxPaintEvent &aEvent)
Function PostPaint posts an event to m_paint_listener.
Definition: cairo_gal.cpp:1309

References PostPaint().

Referenced by CAIRO_GAL().

◆ PopDepth()

void KIGFX::GAL::PopDepth ( )
inlineinherited

Restores previously stored drawing depth for the depth stack.

Definition at line 1055 of file graphics_abstraction_layer.h.

1056  {
1057  layerDepth = depthStack.top();
1058  depthStack.pop();
1059  }
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 CAIRO_GAL::PostPaint ( wxPaintEvent &  aEvent)

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, just by changing the PostPaint code.

Definition at line 1309 of file cairo_gal.cpp.

1310 {
1311  // posts an event to m_paint_listener to ask for redraw the canvas.
1312  if( paintListener )
1313  {
1314  wxPostEvent( paintListener, aEvent );
1315  }
1316 }
wxEvtHandler * paintListener
Paint listener.
Definition: cairo_gal.h:414

References paintListener.

Referenced by onPaint().

◆ PushDepth()

void KIGFX::GAL::PushDepth ( )
inlineinherited

Stores current drawing depth on the depth stack.

Definition at line 1047 of file graphics_abstraction_layer.h.

1048  {
1049  depthStack.push( layerDepth );
1050  }
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 935 of file cairo_gal.cpp.

936 {
937  for( auto imageSurface : imageSurfaces )
938  cairo_surface_destroy( imageSurface );
939 
940  imageSurfaces.clear();
941 
942  ClearScreen();
943 
944  // Compute the world <-> screen transformations
946 
947  cairo_matrix_init( &cairoWorldScreenMatrix, worldScreenMatrix.m_data[0][0],
950  worldScreenMatrix.m_data[1][2] );
951 
952  // we work in screen-space coordinates and do the transforms outside.
953  cairo_identity_matrix( context );
954 
955  cairo_matrix_init_identity( &currentXform );
956 
957  // Start drawing with a new path
958  cairo_new_path( context );
959  isElementAdded = true;
960 
962 
963  lineWidth = 0;
964 }
virtual void ComputeWorldScreenMatrix()
Compute the world <-> screen transformation matrix.
T m_data[3][3]
Definition: matrix3x3.h:64
void ClearScreen() override
Clear the screen.
Definition: cairo_gal.cpp:536
std::vector< cairo_surface_t * > imageSurfaces
List of surfaces that were created by painting images, to be cleaned up later.
Definition: cairo_gal.h:307
cairo_t * context
Cairo image.
Definition: cairo_gal.h:303
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:104
MATRIX3x3D worldScreenMatrix
World transformation.
float lineWidth
The line width.
cairo_matrix_t currentXform
Definition: cairo_gal.h:300
cairo_matrix_t cairoWorldScreenMatrix
Cairo world to screen transformation matrix.
Definition: cairo_gal.h:299
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:289

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::imageSurfaces, KIGFX::CAIRO_GAL_BASE::isElementAdded, KIGFX::GAL::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 157 of file graphics_abstraction_layer.cpp.

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

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

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

◆ ResizeScreen()

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

Resizes the canvas.

Reimplemented from KIGFX::CAIRO_GAL_BASE.

Definition at line 1319 of file cairo_gal.cpp.

1320 {
1321  CAIRO_GAL_BASE::ResizeScreen( aWidth, aHeight );
1322 
1323  // Recreate the bitmaps
1324  deleteBitmaps();
1325  allocateBitmaps();
1326 
1327  if( validCompositor )
1328  compositor->Resize( aWidth, aHeight );
1329 
1330  validCompositor = false;
1331 
1332  SetSize( wxSize( aWidth, aHeight ) );
1333 }
void ResizeScreen(int aWidth, int aHeight) override
Resizes the canvas.
Definition: cairo_gal.cpp:524
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:409
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:405
void deleteBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1469
void allocateBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1455

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

732 {
733  storePath();
734 
735  if( isGrouping )
736  {
737  GROUP_ELEMENT groupElement;
738  groupElement.command = CMD_RESTORE;
739  currentGroup->push_back( groupElement );
740  }
741  else
742  {
743  if( !xformStack.empty() )
744  {
745  currentXform = xformStack.back();
746  xformStack.pop_back();
748  }
749  }
750 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1052
std::vector< cairo_matrix_t > xformStack
Definition: cairo_gal.h:309
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:293
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:288
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:104
cairo_matrix_t currentXform
Definition: cairo_gal.h:300
Restore the transformation matrix.
Definition: cairo_gal.h:271

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.

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

655 {
656  storePath();
657 
658  if( isGrouping )
659  {
660  GROUP_ELEMENT groupElement;
661  groupElement.command = CMD_ROTATE;
662  groupElement.argument.dblArg[0] = aAngle;
663  currentGroup->push_back( groupElement );
664  }
665  else
666  {
667  cairo_matrix_rotate( &currentXform, aAngle );
669  }
670 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1052
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:293
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:288
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:104
cairo_matrix_t currentXform
Definition: cairo_gal.h:300

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

714 {
715  storePath();
716 
717  if( isGrouping )
718  {
719  GROUP_ELEMENT groupElement;
720  groupElement.command = CMD_SAVE;
721  currentGroup->push_back( groupElement );
722  }
723  else
724  {
725  xformStack.push_back( currentXform );
727  }
728 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1052
std::vector< cairo_matrix_t > xformStack
Definition: cairo_gal.h:309
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:293
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:288
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:104
Save the transformation matrix.
Definition: cairo_gal.h:270
cairo_matrix_t currentXform
Definition: cairo_gal.h:300

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.

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

694 {
695  storePath();
696 
697  if( isGrouping )
698  {
699  GROUP_ELEMENT groupElement;
700  groupElement.command = CMD_SCALE;
701  groupElement.argument.dblArg[0] = aScale.x;
702  groupElement.argument.dblArg[1] = aScale.y;
703  currentGroup->push_back( groupElement );
704  }
705  else
706  {
707  cairo_matrix_scale( &currentXform, aScale.x, aScale.y );
709  }
710 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1052
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:293
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:288
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:104
cairo_matrix_t currentXform
Definition: cairo_gal.h:300

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

933  {
934  axesColor = aAxesColor;
935  }
COLOR4D axesColor
Color of the axes.

References KIGFX::GAL::axesColor.

Referenced by KIGFX::CAIRO_GAL_BASE::CAIRO_GAL_BASE(), LIB_EDIT_FRAME::CommonSettingsChanged(), KIGFX::OPENGL_GAL::OPENGL_GAL(), and LIB_EDIT_FRAME::SwitchCanvas().

◆ SetAxesEnabled()

◆ SetClearColor()

◆ SetCoarseGrid()

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

Draw every tick line wider.

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

Definition at line 950 of file graphics_abstraction_layer.h.

951  {
952  gridTick = aInterval;
953  }
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 1476 of file cairo_gal.cpp.

1477 {
1478  // Recreate the compositor with the new Cairo context
1479  compositor.reset( new CAIRO_COMPOSITOR( &currentContext ) );
1480  compositor->Resize( screenSize.x, screenSize.y );
1481  compositor->SetAntialiasingMode( options.cairo_antialiasing_mode );
1482 
1483  // Prepare buffers
1484  mainBuffer = compositor->CreateBuffer();
1485  overlayBuffer = compositor->CreateBuffer();
1486 
1487  validCompositor = true;
1488 }
GAL_DISPLAY_OPTIONS & options
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:407
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:409
CAIRO_ANTIALIASING_MODE cairo_antialiasing_mode
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:405
VECTOR2I screenSize
Screen size in screen coordinates.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:302
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:406

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

1024  {
1025  cursorColor = aCursorColor;
1026  }
COLOR4D cursorColor
Cursor color.

References KIGFX::GAL::cursorColor.

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

◆ SetCursorEnabled()

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

Enable/disable cursor.

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

Definition at line 1004 of file graphics_abstraction_layer.h.

1005  {
1006  isCursorEnabled = aCursorEnabled;
1007  }
bool isCursorEnabled
Is the cursor enabled?

References KIGFX::GAL::isCursorEnabled.

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

◆ SetDepthRange()

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

Set the range of the layer depth.

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

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

Definition at line 744 of file graphics_abstraction_layer.h.

745  {
746  depthRange = aDepthRange;
747  }
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 592 of file cairo_gal.cpp.

593 {
594  storePath();
595  fillColor = aColor;
596 
597  if( isGrouping )
598  {
599  GROUP_ELEMENT groupElement;
600  groupElement.command = CMD_SET_FILLCOLOR;
601  groupElement.argument.dblArg[0] = fillColor.r;
602  groupElement.argument.dblArg[1] = fillColor.g;
603  groupElement.argument.dblArg[2] = fillColor.b;
604  groupElement.argument.dblArg[3] = fillColor.a;
605  currentGroup->push_back( groupElement );
606  }
607 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1052
double g
Green component.
Definition: color4d.h:367
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:368
double a
Alpha component.
Definition: color4d.h:369
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:293
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:288
double r
Red component.
Definition: color4d.h:366

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

782  {
783  globalFlipX = xAxis;
784  globalFlipY = yAxis;
785  }
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 429 of file graphics_abstraction_layer.h.

430  {
431  textProperties.m_bold = aBold;
432  }
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 447 of file graphics_abstraction_layer.h.

448  {
449  textProperties.m_italic = aItalic;
450  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties

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

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

◆ SetGlyphSize()

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

◆ SetGridColor()

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

Set the grid color.

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

Definition at line 922 of file graphics_abstraction_layer.h.

923  {
924  gridColor = aGridColor;
925  }
COLOR4D gridColor
Color of the grid.

References KIGFX::GAL::gridColor.

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

◆ SetGridOrigin()

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

Set the origin point for the grid.

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

Definition at line 874 of file graphics_abstraction_layer.h.

875  {
876  gridOrigin = aGridOrigin;
877 
878  if( gridSize.x == 0.0 || gridSize.y == 0.0 )
879  gridOffset = VECTOR2D(0.0, 0.0);
880  else
881  gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
882  (long) gridOrigin.y % (long) gridSize.y );
883  }
VECTOR2D gridOffset
The grid offset to compensate cursor position.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
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 895 of file graphics_abstraction_layer.h.

896  {
897  gridSize = aGridSize;
898 
899  // Avoid stupid grid size values: a grid size should be >= 1 in internal units
900  gridSize.x = std::max( 1.0, gridSize.x );
901  gridSize.y = std::max( 1.0, gridSize.y );
902 
903  gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
904  (long) gridOrigin.y % (long) gridSize.y );
905  }
VECTOR2D gridOffset
The grid offset to compensate cursor position.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
VECTOR2D gridOrigin
The grid origin.
VECTOR2D gridSize
The grid size.

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

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

◆ SetGridVisibility()

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

Sets the visibility setting of the grid.

Parameters
aVisibilityis the new visibility setting of the grid.

Definition at line 860 of file graphics_abstraction_layer.h.

860 { gridVisibility = aVisibility; }
bool gridVisibility
Should the grid be shown.

References KIGFX::GAL::gridVisibility.

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

◆ SetHorizontalJustify()

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

Set the horizontal justify for text drawing.

Parameters
aHorizontalJustifyis the horizontal justify value.

Definition at line 483 of file graphics_abstraction_layer.h.

484  {
485  textProperties.m_horizontalJustify = aHorizontalJustify;
486  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
EDA_TEXT_HJUSTIFY_T m_horizontalJustify
Horizontal justification.

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

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

◆ SetIsFill()

void CAIRO_GAL_BASE::SetIsFill ( bool  aIsFillEnabled)
overridevirtualinherited

Enable/disable fill.

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

Reimplemented from KIGFX::GAL.

Definition at line 544 of file cairo_gal.cpp.

545 {
546  storePath();
547  isFillEnabled = aIsFillEnabled;
548 
549  if( isGrouping )
550  {
551  GROUP_ELEMENT groupElement;
552  groupElement.command = CMD_SET_FILL;
553  groupElement.argument.boolArg = aIsFillEnabled;
554  currentGroup->push_back( groupElement );
555  }
556 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1052
Enable/disable filling.
Definition: cairo_gal.h:259
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:293
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:288
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 559 of file cairo_gal.cpp.

560 {
561  storePath();
562  isStrokeEnabled = aIsStrokeEnabled;
563 
564  if( isGrouping )
565  {
566  GROUP_ELEMENT groupElement;
567  groupElement.command = CMD_SET_STROKE;
568  groupElement.argument.boolArg = aIsStrokeEnabled;
569  currentGroup->push_back( groupElement );
570  }
571 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1052
bool isStrokeEnabled
Are the outlines stroked ?
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:293
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:288
Enable/disable stroking.
Definition: cairo_gal.h:260

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

630 {
631  super::SetLayerDepth( aLayerDepth );
632  storePath();
633 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1052
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)

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

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

◆ SetLineWidth()

void CAIRO_GAL_BASE::SetLineWidth ( float  aLineWidth)
overridevirtualinherited

Set the line width.

Parameters
aLineWidthis the line width.

Reimplemented from KIGFX::GAL.

Definition at line 610 of file cairo_gal.cpp.

611 {
612  storePath();
613  GAL::SetLineWidth( aLineWidth );
614 
615  if( isGrouping )
616  {
617  GROUP_ELEMENT groupElement;
618  groupElement.command = CMD_SET_LINE_WIDTH;
619  groupElement.argument.dblArg[0] = aLineWidth;
620  currentGroup->push_back( groupElement );
621  }
622  else
623  {
624  lineWidth = aLineWidth;
625  }
626 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1052
virtual void SetLineWidth(float aLineWidth)
Set the line width.
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:293
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:288
float lineWidth
The line width.

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::GAL::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 681 of file graphics_abstraction_layer.h.

682  {
683  lookAtPoint = aPoint;
684  }
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 393 of file cairo_gal.h.

394  {
395  mouseListener = aMouseListener;
396  }
wxEvtHandler * mouseListener
Mouse listener.
Definition: cairo_gal.h:413

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

919 {
920  cairo_set_operator( currentContext, aSetting ? CAIRO_OPERATOR_CLEAR : CAIRO_OPERATOR_OVER );
921 }
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:302

References KIGFX::CAIRO_GAL_BASE::currentContext.

◆ SetPaintListener()

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

Definition at line 398 of file cairo_gal.h.

399  {
400  paintListener = aPaintListener;
401  }
wxEvtHandler * paintListener
Paint listener.
Definition: cairo_gal.h:414

References paintListener.

◆ SetRotation()

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

Set the rotation angle.

Parameters
aRotationis the new rotation angle (radians).

Definition at line 721 of file graphics_abstraction_layer.h.

722  {
723  rotation = aRotation;
724  }
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 669 of file graphics_abstraction_layer.h.

670  {
671  screenDPI = aScreenDPI;
672  }
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 656 of file graphics_abstraction_layer.h.

657  {
658  screenSize = aSize;
659  }
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 574 of file cairo_gal.cpp.

575 {
576  storePath();
577  strokeColor = aColor;
578 
579  if( isGrouping )
580  {
581  GROUP_ELEMENT groupElement;
582  groupElement.command = CMD_SET_STROKECOLOR;
583  groupElement.argument.dblArg[0] = strokeColor.r;
584  groupElement.argument.dblArg[1] = strokeColor.g;
585  groupElement.argument.dblArg[2] = strokeColor.b;
586  groupElement.argument.dblArg[3] = strokeColor.a;
587  currentGroup->push_back( groupElement );
588  }
589 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1052
double g
Green component.
Definition: color4d.h:367
double b
Blue component.
Definition: color4d.h:368
double a
Alpha component.
Definition: color4d.h:369
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:293
COLOR4D strokeColor
The color of the outlines.
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:288
double r
Red component.
Definition: color4d.h:366

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

1362 {
1363  // If the compositor is not set, that means that there is a recaching process going on
1364  // and we do not need the compositor now
1365  if( !validCompositor )
1366  return;
1367 
1368  // Cairo grouping prevents display of overlapping items on the same layer in the lighter color
1369  if( isInitialized )
1370  storePath();
1371 
1372  switch( aTarget )
1373  {
1374  default:
1375  case TARGET_CACHED:
1376  case TARGET_NONCACHED:
1377  compositor->SetBuffer( mainBuffer );
1378  break;
1379 
1380  case TARGET_OVERLAY:
1381  compositor->SetBuffer( overlayBuffer );
1382  break;
1383  }
1384 
1385  currentTarget = aTarget;
1386 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1052
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:422
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:407
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:409
Auxiliary rendering target (noncached)
Definition: definitions.h:49
RENDER_TARGET currentTarget
Current rendering target.
Definition: cairo_gal.h:408
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:405
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:406

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

147 {
148  SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
151  SetFontBold( aText->IsBold() );
152  SetFontItalic( aText->IsItalic() );
153  SetTextMirrored( aText->IsMirrored() );
154 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsBold() const
Definition: eda_text.h:183
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:200
bool IsMirrored() const
Definition: eda_text.h:189
bool IsItalic() const
Definition: eda_text.h:180
void SetFontBold(const bool aBold)
Set bold property of current font.
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:199
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
const wxSize & GetTextSize() const
Definition: eda_text.h:239
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::PCB_PAINTER::draw(), and GRText().

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

466  {
467  textProperties.m_mirrored = aMirrored;
468  }
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 501 of file graphics_abstraction_layer.h.

502  {
503  textProperties.m_verticalJustify = aVerticalJustify;
504  }
EDA_TEXT_VJUSTIFY_T m_verticalJustify
Vertical justification.
struct KIGFX::GAL::TEXT_PROPERTIES textProperties

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

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

◆ SetWorldScreenMatrix()

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

Set the world <-> screen transformation matrix.

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

Definition at line 637 of file graphics_abstraction_layer.h.

638  {
639  worldScreenMatrix = aMatrix;
640  }
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 651 of file graphics_abstraction_layer.h.

652  {
653  worldUnitLength = aWorldUnitLength;
654  }
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(), PL_DRAW_PANEL_GAL::PL_DRAW_PANEL_GAL(), SCH_DRAW_PANEL::SCH_DRAW_PANEL(), SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL(), GERBVIEW_PRINTOUT::setupGal(), PCBNEW_PRINTOUT::setupGal(), PL_DRAW_PANEL_GAL::SwitchBackend(), GERBVIEW_DRAW_PANEL_GAL::SwitchBackend(), SCH_DRAW_PANEL::SwitchBackend(), and PCB_DRAW_PANEL_GAL::SwitchBackend().

◆ SetZoomFactor()

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

Set the zoom factor of the scene.

Parameters
aZoomFactoris the zoom factor.

Definition at line 701 of file graphics_abstraction_layer.h.

702  {
703  zoomFactor = aZoomFactor;
704  }
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 1336 of file cairo_gal.cpp.

1337 {
1338  bool s = wxWindow::Show( aShow );
1339 
1340  if( aShow )
1341  wxWindow::Raise();
1342 
1343  return s;
1344 }

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

1498 {
1499  // Post the mouse event to the event listener registered in constructor, if any
1500  if( mouseListener )
1501  wxPostEvent( mouseListener, aEvent );
1502 }
wxEvtHandler * mouseListener
Mouse listener.
Definition: cairo_gal.h:413

References mouseListener.

Referenced by CAIRO_GAL().

◆ storePath()

void CAIRO_GAL_BASE::storePath ( )
protectedinherited

Store the actual path.

Definition at line 1052 of file cairo_gal.cpp.

1053 {
1054  if( isElementAdded )
1055  {
1056  isElementAdded = false;
1057 
1058  if( !isGrouping )
1059  {
1060  if( isFillEnabled )
1061  {
1062  cairo_set_source_rgba( currentContext, fillColor.r, fillColor.g, fillColor.b, fillColor.a );
1063  cairo_fill_preserve( currentContext );
1064  }
1065 
1066  if( isStrokeEnabled )
1067  {
1068  cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g,
1070  cairo_stroke_preserve( currentContext );
1071  }
1072  }
1073  else
1074  {
1075  // Copy the actual path, append it to the global path list
1076  // then check, if the path needs to be stroked/filled and
1077  // add this command to the group list;
1078  if( isStrokeEnabled )
1079  {
1080  GROUP_ELEMENT groupElement;
1081  groupElement.cairoPath = cairo_copy_path( currentContext );
1082  groupElement.command = CMD_STROKE_PATH;
1083  currentGroup->push_back( groupElement );
1084  }
1085 
1086  if( isFillEnabled )
1087  {
1088  GROUP_ELEMENT groupElement;
1089  groupElement.cairoPath = cairo_copy_path( currentContext );
1090  groupElement.command = CMD_FILL_PATH;
1091  currentGroup->push_back( groupElement );
1092  }
1093  }
1094 
1095  cairo_new_path( currentContext );
1096  }
1097 }
double g
Green component.
Definition: color4d.h:367
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:368
double a
Alpha component.
Definition: color4d.h:369
bool isStrokeEnabled
Are the outlines stroked ?
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:293
COLOR4D strokeColor
The color of the outlines.
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:288
bool isFillEnabled
Is filling of graphic objects enabled ?
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:302
double r
Red component.
Definition: color4d.h:366
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:289

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

345  {
346  strokeFont.Draw( aText, aPosition, aRotationAngle );
347  }
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::PCB_PAINTER::draw(), GRText(), and KIGFX::SCH_PAINTER::strokeText().

◆ syncLineWidth()

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

Definition at line 209 of file cairo_gal.cpp.

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

References KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::GAL::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 994 of file graphics_abstraction_layer.h.

995  {
996  return VECTOR2D( worldScreenMatrix * aPoint );
997  }
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
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 983 of file graphics_abstraction_layer.h.

984  {
985  return VECTOR2D( screenWorldMatrix * aPoint );
986  }
MATRIX3x3D screenWorldMatrix
Screen transformation.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593

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

637 {
638  cairo_matrix_t cairoTransformation, newXform;
639 
640  cairo_matrix_init( &cairoTransformation,
641  aTransformation.m_data[0][0],
642  aTransformation.m_data[1][0],
643  aTransformation.m_data[0][1],
644  aTransformation.m_data[1][1],
645  aTransformation.m_data[0][2],
646  aTransformation.m_data[1][2] );
647 
648  cairo_matrix_multiply( &newXform, &currentXform, &cairoTransformation );
649  currentXform = newXform;
651 }
T m_data[3][3]
Definition: matrix3x3.h:64
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:104
cairo_matrix_t currentXform
Definition: cairo_gal.h:300

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

674 {
675  storePath();
676 
677  if( isGrouping )
678  {
679  GROUP_ELEMENT groupElement;
680  groupElement.command = CMD_TRANSLATE;
681  groupElement.argument.dblArg[0] = aTranslation.x;
682  groupElement.argument.dblArg[1] = aTranslation.y;
683  currentGroup->push_back( groupElement );
684  }
685  else
686  {
687  cairo_matrix_translate ( &currentXform, aTranslation.x, aTranslation.y );
689  }
690 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1052
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:293
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:288
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:104
cairo_matrix_t currentXform
Definition: cairo_gal.h:300
Translate the context.
Definition: cairo_gal.h:268

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

1123 {}

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

1506 {
1507  bool refresh = false;
1508 
1509  if( validCompositor && aOptions.cairo_antialiasing_mode != compositor->GetAntialiasingMode() )
1510  {
1511 
1512  compositor->SetAntialiasingMode( options.cairo_antialiasing_mode );
1513  validCompositor = false;
1514  deinitSurface();
1515 
1516  refresh = true;
1517  }
1518 
1519  if( super::updatedGalDisplayOptions( aOptions ) )
1520  {
1521  Refresh();
1522  refresh = true;
1523  }
1524 
1525  return refresh;
1526 }
void deinitSurface()
Destroy Cairo surfaces when are not needed anymore.
Definition: cairo_gal.cpp:1441
GAL_DISPLAY_OPTIONS & options
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:409
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:405
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()

void CAIRO_GAL_BASE::updateWorldScreenMatrix ( )
protectedinherited

Definition at line 104 of file cairo_gal.cpp.

105 {
106  cairo_matrix_multiply( &currentWorld2Screen, &currentXform, &cairoWorldScreenMatrix );
107 }
cairo_matrix_t currentXform
Definition: cairo_gal.h:300
cairo_matrix_t cairoWorldScreenMatrix
Cairo world to screen transformation matrix.
Definition: cairo_gal.h:299