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=nullptr, wxEvtHandler *aPaintListener=nullptr, const wxString &aName=wxT("CairoCanvas"))
 
 ~CAIRO_GAL ()
 Return true if the GAL canvas is visible on the screen. More...
 
bool IsVisible () const override
 Return true if the GAL canvas is visible on the screen. More...
 
void ResizeScreen (int aWidth, int aHeight) override
 Resizes the canvas. More...
 
bool Show (bool aShow) override
 Show/hide the GAL canvas. More...
 
int BeginGroup () override
 Begin a group. More...
 
void EndGroup () override
 End the group. More...
 
void SetTarget (RENDER_TARGET aTarget) override
 Set the target for rendering. More...
 
RENDER_TARGET GetTarget () const override
 Get the currently used target for rendering. More...
 
void ClearTarget (RENDER_TARGET aTarget) override
 Clear the target for rendering. More...
 
void StartDiffLayer () override
 Begins rendering of a differential layer. More...
 
void EndDiffLayer () override
 Ends rendering of a differential layer. More...
 
void StartNegativesLayer () override
 Begins rendering in a new layer that will be copied to the main layer in EndNegativesLayer(). More...
 
void EndNegativesLayer () override
 Ends rendering of a negatives layer and draws it to the main layer. More...
 
void PostPaint (wxPaintEvent &aEvent)
 Post an event to m_paint_listener. More...
 
void SetMouseListener (wxEvtHandler *aMouseListener)
 
void SetPaintListener (wxEvtHandler *aPaintListener)
 
bool SetNativeCursorStyle (KICURSOR aCursor) override
 Set the cursor in the native panel. More...
 
void BeginDrawing () override
 Start/end drawing functions, draw calls can be only made in between the calls to BeginDrawing()/EndDrawing(). More...
 
void EndDrawing () override
 End the drawing, needs to be called for every new frame. More...
 
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...
 
void onSetNativeCursor (wxSetCursorEvent &aEvent)
 Give the correct cursor image when the native widget asks for it. More...
 
bool updatedGalDisplayOptions (const GAL_DISPLAY_OPTIONS &aOptions) override
 Handle updating display options. More...
 
bool IsCairoEngine () override
 Return true if the GAL engine is a Cairo based type. More...
 
void DrawLine (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint) override
 Draw a line. More...
 
void DrawSegment (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth) override
 Draw a rounded segment. More...
 
void DrawCircle (const VECTOR2D &aCenterPoint, double aRadius) override
 Draw a circle using world coordinates. More...
 
void DrawArc (const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle) override
 Draw an arc. More...
 
void DrawArcSegment (const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth, double aMaxError) override
 Draw an arc segment. More...
 
void DrawRectangle (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint) override
 Draw a rectangle. More...
 
void DrawPolyline (const std::deque< VECTOR2D > &aPointList) override
 Draw a polyline. More...
 
void DrawPolyline (const VECTOR2D aPointList[], int aListSize) override
 
void DrawPolyline (const SHAPE_LINE_CHAIN &aLineChain) override
 
void DrawPolygon (const std::deque< VECTOR2D > &aPointList) override
 Draw a polygon. More...
 
void DrawPolygon (const VECTOR2D aPointList[], int aListSize) override
 
void DrawPolygon (const SHAPE_POLY_SET &aPolySet, bool aStrokeTriangulation=false) override
 
void DrawPolygon (const SHAPE_LINE_CHAIN &aPolySet) override
 
void DrawCurve (const VECTOR2D &startPoint, const VECTOR2D &controlPointA, const VECTOR2D &controlPointB, const VECTOR2D &endPoint, double aFilterValue=0.0) override
 Draw a cubic bezier spline. More...
 
void DrawBitmap (const BITMAP_BASE &aBitmap) override
 Draw a bitmap image. More...
 
void 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
 Change the color used to draw the group. More...
 
void ChangeGroupDepth (int aGroupNumber, int aDepth) override
 Change the depth (Z-axis position) of the group. More...
 
void DeleteGroup (int aGroupNumber) override
 Delete the group from the memory. More...
 
void ClearCache () override
 Delete all data created during caching of graphic items. More...
 
void SetNegativeDrawMode (bool aSetting) override
 Set negative draw mode in the renderer. More...
 
void DrawCursor (const VECTOR2D &aCursorPosition) override
 Draw the cursor. More...
 
void EnableDepthTest (bool aEnabled=false) override
 
void DrawGrid () override
 
virtual bool IsInitialized () const
 Return the initialization status for the canvas. More...
 
virtual bool IsOpenGlEngine ()
 Return true if the GAL engine is a OpenGL based type. More...
 
const VECTOR2IGetScreenPixelSize () const
 Return GAL canvas size in pixels. More...
 
void SetClearColor (const COLOR4D &aColor)
 
const COLOR4DGetClearColor () const
 
const COLOR4DGetFillColor () const
 Get the fill color. More...
 
const COLOR4DGetStrokeColor () const
 Get the stroke color. More...
 
float GetLineWidth () const
 Get the line width. More...
 
const STROKE_FONTGetStrokeFont () const
 
virtual void StrokeText (const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
 Draw a vector type text using preloaded Newstroke font. More...
 
virtual void BitmapText (const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
 Draw a text using a bitmap font. More...
 
VECTOR2D GetTextLineSize (const UTF8 &aText) const
 Compute the X and Y size of a given text. More...
 
virtual void SetTextAttributes (const EDA_TEXT *aText)
 Loads attributes of the given text (bold/italic/underline/mirrored and so on). More...
 
void ResetTextAttributes ()
 Reset text attributes to default styling. More...
 
void SetGlyphSize (const VECTOR2D &aSize)
 Set the font glyph size. More...
 
const VECTOR2DGetGlyphSize () const
 
void SetFontBold (bool aBold)
 Set bold property of current font. More...
 
bool IsFontBold () const
 
void SetFontItalic (bool aItalic)
 Set italic property of current font. More...
 
bool IsFontItalic () const
 
void SetFontUnderlined (bool aUnderlined)
 
bool IsFontUnderlined () const
 
void SetTextMirrored (bool aMirrored)
 Set a mirrored property of text. More...
 
bool IsTextMirrored () const
 
void SetHorizontalJustify (const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
 Set the horizontal justify for text drawing. More...
 
EDA_TEXT_HJUSTIFY_T GetHorizontalJustify () const
 Return current text horizontal justification setting. More...
 
void SetVerticalJustify (const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
 Set the vertical justify for text drawing. More...
 
EDA_TEXT_VJUSTIFY_T GetVerticalJustify () const
 Returns current text vertical justification setting. More...
 
virtual void ComputeWorldScreenMatrix ()
 Compute the world <-> screen transformation matrix. More...
 
const MATRIX3x3DGetWorldScreenMatrix () const
 Get the world <-> screen transformation matrix. More...
 
const MATRIX3x3DGetScreenWorldMatrix () const
 Get the screen <-> world transformation matrix. More...
 
void SetWorldScreenMatrix (const MATRIX3x3D &aMatrix)
 Set the world <-> screen transformation matrix. More...
 
BOX2D GetVisibleWorldExtents () const
 
void SetWorldUnitLength (double aWorldUnitLength)
 Set the unit length. More...
 
void SetScreenSize (const VECTOR2I &aSize)
 
void SetScreenDPI (double aScreenDPI)
 Set the dots per inch of the screen. More...
 
void SetLookAtPoint (const VECTOR2D &aPoint)
 Set the Point in world space to look at. More...
 
const VECTOR2DGetLookAtPoint () const
 Get the look at point. More...
 
void SetZoomFactor (double aZoomFactor)
 Set the zoom factor of the scene. More...
 
double GetZoomFactor () const
 Get the zoom factor. More...
 
void SetRotation (double aRotation)
 Set the rotation angle. More...
 
double GetRotation () const
 Get the rotation angle. More...
 
void SetDepthRange (const VECTOR2D &aDepthRange)
 Set the range of the layer depth. More...
 
double GetMinDepth () const
 Return the minimum depth in the currently used range (the top). More...
 
double GetMaxDepth () const
 Return the maximum depth in the currently used range (the bottom). More...
 
double GetWorldScale () const
 Get the world scale. More...
 
void SetFlip (bool xAxis, bool yAxis)
 Sets flipping of the screen. More...
 
bool IsFlippedX () const
 Return true if flip flag for the X axis is set. More...
 
bool IsFlippedY () const
 Return true if flip flag for the Y axis is set. More...
 
virtual bool HasTarget (RENDER_TARGET aTarget)
 Return true if the target exists. More...
 
void SetGridVisibility (bool aVisibility)
 Set the visibility setting of the grid. More...
 
bool GetGridVisibility () const
 
bool GetGridSnapping () const
 
void SetGridOrigin (const VECTOR2D &aGridOrigin)
 Set the origin point for the grid. More...
 
const VECTOR2DGetGridOrigin () const
 
void SetGridSize (const VECTOR2D &aGridSize)
 Set the grid size. More...
 
const VECTOR2DGetGridSize () const
 Return the grid size. More...
 
void SetGridColor (const COLOR4D &aGridColor)
 Set the grid color. More...
 
void SetAxesColor (const COLOR4D &aAxesColor)
 Set the axes color. More...
 
void SetAxesEnabled (bool aAxesEnabled)
 Enable drawing the axes. More...
 
void SetCoarseGrid (int aInterval)
 Draw every tick line wider. More...
 
float GetGridLineWidth () const
 Get the grid line width. More...
 
VECTOR2D GetGridPoint (const VECTOR2D &aPoint) const
 For a given point it returns the nearest point belonging to the grid in world coordinates. More...
 
VECTOR2D ToWorld (const VECTOR2D &aPoint) const
 Compute the point position in world coordinates from given screen coordinates. More...
 
VECTOR2D ToScreen (const VECTOR2D &aPoint) const
 Compute the point position in screen coordinates from given world coordinates. More...
 
void SetCursorEnabled (bool aCursorEnabled)
 Enable/disable cursor. More...
 
bool IsCursorEnabled () const
 Return information about cursor visibility. More...
 
void SetCursorColor (const COLOR4D &aCursorColor)
 Set the cursor color. More...
 
void AdvanceDepth ()
 Change the current depth to deeper, so it is possible to draw objects right beneath other. More...
 
void PushDepth ()
 Store current drawing depth on the depth stack. More...
 
void PopDepth ()
 Restore previously stored drawing depth for the depth stack. More...
 
virtual bool IsContextLocked ()
 Checks the state of the context lock. More...
 
virtual void LockContext (int aClientCookie)
 Use GAL_CONTEXT_LOCKER RAII object unless you know what you're doing. More...
 
virtual void UnlockContext (int aClientCookie)
 

Protected Types

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

Protected Member Functions

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

Protected Attributes

std::shared_ptr< CAIRO_COMPOSITORm_compositor
 Object for layers compositing. More...
 
unsigned int m_mainBuffer
 Handle to the main buffer. More...
 
unsigned int m_overlayBuffer
 Handle to the overlay buffer. More...
 
unsigned int m_tempBuffer
 Handle to the temp buffer. More...
 
unsigned int m_savedBuffer
 Handle to buffer to restore after rendering to temp buffer. More...
 
RENDER_TARGET m_currentTarget
 Current rendering target. More...
 
bool m_validCompositor
 Compositor initialization flag. More...
 
wxWindow * m_parentWindow
 Parent window. More...
 
wxEvtHandler * m_mouseListener
 Mouse listener. More...
 
wxEvtHandler * m_paintListener
 Paint listener. More...
 
unsigned int m_bufferSize
 Size of buffers cairoOutput, bitmapBuffers. More...
 
unsigned char * m_wxOutput
 wxImage compatible buffer More...
 
unsigned char * m_bitmapBuffer
 Storage of the Cairo image. More...
 
int m_stride
 Stride value for Cairo. More...
 
int m_wxBufferWidth
 
bool m_isInitialized
 Are Cairo image & surface ready to use. More...
 
COLOR4D m_backgroundColor
 Background color. More...
 
wxCursor m_currentwxCursor
 wxCursor showing the current native cursor More...
 
bool m_isGrouping
 Is grouping enabled ? More...
 
bool m_isElementAdded
 Was an graphic element added ? More...
 
std::map< int, GROUPm_groups
 List of graphic groups. More...
 
unsigned int m_groupCounter
 Counter used for generating group keys. More...
 
GROUPm_currentGroup
 Currently used group. More...
 
double m_lineWidthInPixels
 
bool m_lineWidthIsOdd
 
cairo_matrix_t m_cairoWorldScreenMatrix
 Cairo world to screen transform matrix. More...
 
cairo_matrix_t m_currentXform
 
cairo_matrix_t m_currentWorld2Screen
 
cairo_t * m_currentContext
 Currently used Cairo context for drawing. More...
 
cairo_t * m_context
 Cairo image. More...
 
cairo_surface_t * m_surface
 Cairo surface. More...
 
std::vector< cairo_surface_t * > m_imageSurfaces
 List of surfaces that were created by painting images, to be cleaned up later. More...
 
std::vector< cairo_matrix_t > m_xformStack
 
GAL_DISPLAY_OPTIONSm_options
 
UTIL::LINK m_observerLink
 
std::stack< double > m_depthStack
 Stored depth values. More...
 
VECTOR2I m_screenSize
 Screen size in screen coordinates. More...
 
double m_worldUnitLength
 The unit length of the world coordinates [inch]. More...
 
double m_screenDPI
 The dots per inch of the screen. More...
 
VECTOR2D m_lookAtPoint
 Point to be looked at in world space. More...
 
double m_zoomFactor
 The zoom factor. More...
 
double m_rotation
 Rotation transformation (radians) More...
 
MATRIX3x3D m_worldScreenMatrix
 World transformation. More...
 
MATRIX3x3D m_screenWorldMatrix
 Screen transformation. More...
 
double m_worldScale
 The scale factor world->screen. More...
 
bool m_globalFlipX
 Flag for X axis flipping. More...
 
bool m_globalFlipY
 Flag for Y axis flipping. More...
 
float m_lineWidth
 The line width. More...
 
bool m_isFillEnabled
 Is filling of graphic objects enabled ? More...
 
bool m_isStrokeEnabled
 Are the outlines stroked ? More...
 
COLOR4D m_fillColor
 The fill color. More...
 
COLOR4D m_strokeColor
 The color of the outlines. More...
 
COLOR4D m_clearColor
 
double m_layerDepth
 The actual layer depth. More...
 
VECTOR2D m_depthRange
 Range of the depth. More...
 
bool m_gridVisibility
 Should the grid be shown. More...
 
GRID_STYLE m_gridStyle
 Grid display style. More...
 
VECTOR2D m_gridSize
 The grid size. More...
 
VECTOR2D m_gridOrigin
 The grid origin. More...
 
VECTOR2D m_gridOffset
 The grid offset to compensate cursor position. More...
 
COLOR4D m_gridColor
 Color of the grid. More...
 
COLOR4D m_axesColor
 Color of the axes. More...
 
bool m_axesEnabled
 Should the axes be drawn. More...
 
int m_gridTick
 Every tick line gets the double width. More...
 
float m_gridLineWidth
 Line width of the grid. More...
 
int m_gridMinSpacing
 Minimum screen size of the grid (pixels) below which the grid is not drawn. More...
 
bool m_isCursorEnabled
 Is the cursor enabled? More...
 
bool m_forceDisplayCursor
 Always show cursor. More...
 
COLOR4D m_cursorColor
 Cursor color. More...
 
bool m_fullscreenCursor
 Shape of the cursor (fullscreen or small cross) More...
 
VECTOR2D m_cursorPosition
 Current cursor position (world coordinates) More...
 
STROKE_FONT m_strokeFont
 Instance of object that stores information about how to draw texts. More...
 
KICURSOR m_currentNativeCursor
 Current cursor. More...
 

Static Protected Attributes

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

Detailed Description

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

◆ super

typedef GAL KIGFX::CAIRO_GAL_BASE::super
protectedinherited

Super class definition.

Definition at line 290 of file cairo_gal.h.

Member Enumeration Documentation

◆ GRAPHICS_COMMAND

enum KIGFX::CAIRO_GAL_BASE::GRAPHICS_COMMAND
protectedinherited

Definitions for the command recorder.

Enumerator
CMD_SET_FILL 

Enable/disable filling.

CMD_SET_STROKE 

Enable/disable stroking.

CMD_SET_FILLCOLOR 

Set the fill color.

CMD_SET_STROKECOLOR 

Set the stroke color.

CMD_SET_LINE_WIDTH 

Set the line width.

CMD_STROKE_PATH 

Set the stroke path.

CMD_FILL_PATH 

Set the fill path.

CMD_ROTATE 

Rotate the context.

CMD_TRANSLATE 

Translate the context.

CMD_SCALE 

Scale the context.

CMD_SAVE 

Save the transformation matrix.

CMD_RESTORE 

Restore the transformation matrix.

CMD_CALL_GROUP 

Call a group.

Definition at line 296 of file cairo_gal.h.

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

Constructor & Destructor Documentation

◆ CAIRO_GAL()

CAIRO_GAL::CAIRO_GAL ( GAL_DISPLAY_OPTIONS aDisplayOptions,
wxWindow *  aParent,
wxEvtHandler *  aMouseListener = nullptr,
wxEvtHandler *  aPaintListener = nullptr,
const wxString &  aName = wxT( "CairoCanvas" ) 
)
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 1260 of file cairo_gal.cpp.

1262  :
1263  CAIRO_GAL_BASE( aDisplayOptions ),
1264  wxWindow( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxEXPAND, aName )
1265 {
1266  // Initialise compositing state
1267  m_mainBuffer = 0;
1268  m_overlayBuffer = 0;
1269  m_tempBuffer = 0;
1270  m_savedBuffer = 0;
1271  m_validCompositor = false;
1273 
1274  m_bitmapBuffer = nullptr;
1275  m_wxOutput = nullptr;
1276 
1277  m_parentWindow = aParent;
1278  m_mouseListener = aMouseListener;
1279  m_paintListener = aPaintListener;
1280 
1281  // Connect the native cursor handler
1282  Connect( wxEVT_SET_CURSOR, wxSetCursorEventHandler( CAIRO_GAL::onSetNativeCursor ), nullptr,
1283  this );
1284 
1285  // Connecting the event handlers
1286  Connect( wxEVT_PAINT, wxPaintEventHandler( CAIRO_GAL::onPaint ) );
1287 
1288  // Mouse events are skipped to the parent
1289  Connect( wxEVT_MOTION, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1290  Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1291  Connect( wxEVT_LEFT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1292  Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1293  Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1294  Connect( wxEVT_MIDDLE_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1295  Connect( wxEVT_MIDDLE_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1296  Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1297  Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1298  Connect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1299  Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1300 #if defined _WIN32 || defined _WIN64
1301  Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1302 #endif
1303 
1304  SetSize( aParent->GetClientSize() );
1305  m_screenSize = VECTOR2I( aParent->GetClientSize() );
1306 
1307  // Allocate memory for pixel storage
1308  allocateBitmaps();
1309 
1310  m_isInitialized = false;
1311 }
wxWindow * m_parentWindow
Parent window.
Definition: cairo_gal.h:484
unsigned char * m_wxOutput
wxImage compatible buffer
Definition: cairo_gal.h:488
bool m_isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:494
void onPaint(wxPaintEvent &aEvent)
Paint event handler.
Definition: cairo_gal.cpp:1554
CAIRO_GAL_BASE(GAL_DISPLAY_OPTIONS &aDisplayOptions)
Definition: cairo_gal.cpp:49
unsigned int m_savedBuffer
Handle to buffer to restore after rendering to temp buffer.
Definition: cairo_gal.h:479
unsigned int m_tempBuffer
Handle to the temp buffer.
Definition: cairo_gal.h:478
unsigned char * m_bitmapBuffer
Storage of the Cairo image.
Definition: cairo_gal.h:491
VECTOR2< int > VECTOR2I
Definition: vector2d.h:622
Auxiliary rendering target (noncached)
Definition: definitions.h:49
void onSetNativeCursor(wxSetCursorEvent &aEvent)
Give the correct cursor image when the native widget asks for it.
Definition: cairo_gal.cpp:1607
void SetTarget(RENDER_TARGET aTarget) override
Set the target for rendering.
Definition: cairo_gal.cpp:1422
void skipMouseEvent(wxMouseEvent &aEvent)
Mouse event handler, forwards the event to the child.
Definition: cairo_gal.cpp:1560
bool m_validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:481
wxEvtHandler * m_mouseListener
Mouse listener.
Definition: cairo_gal.h:485
unsigned int m_mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:476
void allocateBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1509
unsigned int m_overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:477
VECTOR2I m_screenSize
Screen size in screen coordinates.
wxEvtHandler * m_paintListener
Paint listener.
Definition: cairo_gal.h:486

References allocateBitmaps(), m_bitmapBuffer, m_isInitialized, m_mainBuffer, m_mouseListener, m_overlayBuffer, m_paintListener, m_parentWindow, m_savedBuffer, KIGFX::GAL::m_screenSize, m_tempBuffer, m_validCompositor, m_wxOutput, onPaint(), onSetNativeCursor(), SetTarget(), skipMouseEvent(), and KIGFX::TARGET_NONCACHED.

◆ ~CAIRO_GAL()

CAIRO_GAL::~CAIRO_GAL ( )

Return true if the GAL canvas is visible on the screen.

Definition at line 1314 of file cairo_gal.cpp.

1315 {
1316  deleteBitmaps();
1317 }
void deleteBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1528

References deleteBitmaps().

Member Function Documentation

◆ AdvanceDepth()

void KIGFX::GAL::AdvanceDepth ( )
inlineinherited

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

Definition at line 1056 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_layerDepth.

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

◆ allocateBitmaps()

void CAIRO_GAL::allocateBitmaps ( )

Allocate the bitmaps for drawing.

Definition at line 1509 of file cairo_gal.cpp.

1510 {
1512 
1513  while( ( ( m_wxBufferWidth * 3 ) % 4 ) != 0 )
1514  m_wxBufferWidth++;
1515 
1516  // Create buffer, use the system independent Cairo context backend
1517  m_stride = cairo_format_stride_for_width( GAL_FORMAT, m_wxBufferWidth );
1519 
1520  wxASSERT( m_bitmapBuffer == nullptr );
1521  m_bitmapBuffer = new unsigned char[m_bufferSize * 4];
1522 
1523  wxASSERT( m_wxOutput == nullptr );
1524  m_wxOutput = new unsigned char[m_wxBufferWidth * 3 * m_screenSize.y];
1525 }
unsigned char * m_wxOutput
wxImage compatible buffer
Definition: cairo_gal.h:488
unsigned char * m_bitmapBuffer
Storage of the Cairo image.
Definition: cairo_gal.h:491
unsigned int m_bufferSize
Size of buffers cairoOutput, bitmapBuffers.
Definition: cairo_gal.h:487
int m_stride
Stride value for Cairo.
Definition: cairo_gal.h:492
VECTOR2I m_screenSize
Screen size in screen coordinates.
static constexpr cairo_format_t GAL_FORMAT
Format used to store pixels.
Definition: cairo_gal.h:350

References KIGFX::CAIRO_GAL_BASE::GAL_FORMAT, m_bitmapBuffer, m_bufferSize, KIGFX::GAL::m_screenSize, m_stride, m_wxBufferWidth, m_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 m_currentWorld2Screen transform matrix.

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

Definition at line 127 of file cairo_gal.cpp.

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

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

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

◆ arc_angles_xform_and_normalize()

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

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

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

Definition at line 141 of file cairo_gal.cpp.

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

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

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

◆ BeginDrawing()

void CAIRO_GAL::BeginDrawing ( )
overridevirtual

Start/end drawing functions, draw calls can be only made in between the calls to BeginDrawing()/EndDrawing().

Normally you should create a GAL_DRAWING_CONTEXT RAII object, but I'm leaving these functions public for more precise (i.e. timing/profiling) control of the drawing process - Tom Begin the drawing, needs to be called for every new frame. Use GAL_DRAWING_CONTEXT RAII object unless you know what you're doing.

Reimplemented from KIGFX::CAIRO_GAL_BASE.

Definition at line 1320 of file cairo_gal.cpp.

1321 {
1322  initSurface();
1323 
1325 
1326  if( !m_validCompositor )
1327  setCompositor();
1328 
1329  m_compositor->SetMainContext( m_context );
1330  m_compositor->SetBuffer( m_mainBuffer );
1331 }
void initSurface()
Prepare Cairo surfaces for drawing.
Definition: cairo_gal.cpp:1474
void setCompositor()
Prepare the compositor.
Definition: cairo_gal.cpp:1538
cairo_t * m_context
Cairo image.
Definition: cairo_gal.h:342
bool m_validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:481
unsigned int m_mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:476
std::shared_ptr< CAIRO_COMPOSITOR > m_compositor
Object for layers compositing.
Definition: cairo_gal.h:475
void BeginDrawing() override
Start/end drawing functions, draw calls can be only made in between the calls to BeginDrawing()/EndDr...
Definition: cairo_gal.cpp:92

References KIGFX::CAIRO_GAL_BASE::BeginDrawing(), initSurface(), m_compositor, KIGFX::CAIRO_GAL_BASE::m_context, m_mainBuffer, m_validCompositor, and setCompositor().

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

1409 {
1410  initSurface();
1411  return CAIRO_GAL_BASE::BeginGroup();
1412 }
void initSurface()
Prepare Cairo surfaces for drawing.
Definition: cairo_gal.cpp:1474
int BeginGroup() override
Begin a group.
Definition: cairo_gal.cpp:769

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

◆ beginUpdate()

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

Enable item update mode.

Private: use GAL_UPDATE_CONTEXT RAII object

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1111 of file graphics_abstraction_layer.h.

1111 {}

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

◆ BitmapText()

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

Draw a text using a bitmap font.

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

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

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 361 of file graphics_abstraction_layer.h.

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

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

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

◆ blitCursor()

void CAIRO_GAL_BASE::blitCursor ( wxMemoryDC &  clientDC)
protectedinherited

Blit cursor into the current screen.

Definition at line 1155 of file cairo_gal.cpp.

1156 {
1157  if( !IsCursorEnabled() )
1158  return;
1159 
1161  const COLOR4D cColor = getCursorColor();
1162  const int cursorSize = m_fullscreenCursor ? 8000 : 80;
1163 
1164  wxColour color( cColor.r * cColor.a * 255, cColor.g * cColor.a * 255, cColor.b * cColor.a * 255,
1165  255 );
1166  clientDC.SetPen( wxPen( color ) );
1167  clientDC.DrawLine( p.x - cursorSize / 2, p.y, p.x + cursorSize / 2, p.y );
1168  clientDC.DrawLine( p.x, p.y - cursorSize / 2, p.x, p.y + cursorSize / 2 );
1169 }
VECTOR2D ToScreen(const VECTOR2D &aPoint) const
Compute the point position in screen coordinates from given world coordinates.
int color
Definition: DXF_plotter.cpp:57
double g
Green component.
Definition: color4d.h:385
double b
Blue component.
Definition: color4d.h:386
VECTOR2D m_cursorPosition
Current cursor position (world coordinates)
double a
Alpha component.
Definition: color4d.h:387
COLOR4D getCursorColor() const
Get the actual cursor color to draw.
bool m_fullscreenCursor
Shape of the cursor (fullscreen or small cross)
double r
Red component.
Definition: color4d.h:384
bool IsCursorEnabled() const
Return information about cursor visibility.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

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

Referenced by EndDrawing().

◆ ChangeGroupColor()

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

Change the color used to draw the group.

Parameters
aGroupNumberis the group number.
aNewColoris the new color.

Reimplemented from KIGFX::GAL.

Definition at line 885 of file cairo_gal.cpp.

886 {
887  storePath();
888 
889  for( auto it = m_groups[aGroupNumber].begin(); it != m_groups[aGroupNumber].end(); ++it )
890  {
891  if( it->m_Command == CMD_SET_FILLCOLOR || it->m_Command == CMD_SET_STROKECOLOR )
892  {
893  it->m_Argument.DblArg[0] = aNewColor.r;
894  it->m_Argument.DblArg[1] = aNewColor.g;
895  it->m_Argument.DblArg[2] = aNewColor.b;
896  it->m_Argument.DblArg[3] = aNewColor.a;
897  }
898  }
899 }
std::map< int, GROUP > m_groups
List of graphic groups.
Definition: cairo_gal.h:331
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1106
double g
Green component.
Definition: color4d.h:385
double b
Blue component.
Definition: color4d.h:386
double a
Alpha component.
Definition: color4d.h:387
double r
Red component.
Definition: color4d.h:384

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

◆ ChangeGroupDepth()

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

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

Parameters
aGroupNumberis the group number.
aDepthis the new depth.

Reimplemented from KIGFX::GAL.

Definition at line 902 of file cairo_gal.cpp.

903 {
904  // Cairo does not have any possibilities to change the depth coordinate of stored items,
905  // it depends only on the order of drawing
906 }

◆ ClearCache()

void CAIRO_GAL_BASE::ClearCache ( )
overridevirtualinherited

Delete all data created during caching of graphic items.

Reimplemented from KIGFX::GAL.

Definition at line 927 of file cairo_gal.cpp.

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

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

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

◆ ClearScreen()

void CAIRO_GAL_BASE::ClearScreen ( )
overridevirtualinherited

Clear the screen.

Parameters
aColoris the color used for clearing.

Reimplemented from KIGFX::GAL.

Definition at line 555 of file cairo_gal.cpp.

556 {
557  cairo_set_source_rgb( m_currentContext, m_clearColor.r, m_clearColor.g, m_clearColor.b );
558  cairo_rectangle( m_currentContext, 0.0, 0.0, m_screenSize.x, m_screenSize.y );
559  cairo_fill( m_currentContext );
560 }
double g
Green component.
Definition: color4d.h:385
double b
Blue component.
Definition: color4d.h:386
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
double r
Red component.
Definition: color4d.h:384
VECTOR2I m_screenSize
Screen size in screen coordinates.

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

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

◆ ClearTarget()

void CAIRO_GAL::ClearTarget ( RENDER_TARGET  aTarget)
overridevirtual

Clear the target for rendering.

Parameters
aTargetis the target to be cleared.

Reimplemented from KIGFX::GAL.

Definition at line 1452 of file cairo_gal.cpp.

1453 {
1454  // Save the current state
1455  unsigned int currentBuffer = m_compositor->GetBuffer();
1456 
1457  switch( aTarget )
1458  {
1459  // Cached and noncached items are rendered to the same buffer
1460  default:
1461  case TARGET_CACHED:
1462  case TARGET_NONCACHED: m_compositor->SetBuffer( m_mainBuffer ); break;
1463  case TARGET_OVERLAY: m_compositor->SetBuffer( m_overlayBuffer ); break;
1464  case TARGET_TEMP: m_compositor->SetBuffer( m_tempBuffer ); break;
1465  }
1466 
1467  m_compositor->ClearBuffer( COLOR4D::BLACK );
1468 
1469  // Restore the previous state
1470  m_compositor->SetBuffer( currentBuffer );
1471 }
static const COLOR4D BLACK
Definition: color4d.h:394
unsigned int m_tempBuffer
Handle to the temp buffer.
Definition: cairo_gal.h:478
Auxiliary rendering target (noncached)
Definition: definitions.h:49
Items that may change while the view stays the same (noncached)
Definition: definitions.h:50
Main rendering target (cached)
Definition: definitions.h:48
Temporary target for drawing in separate layer.
Definition: definitions.h:51
unsigned int m_mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:476
std::shared_ptr< CAIRO_COMPOSITOR > m_compositor
Object for layers compositing.
Definition: cairo_gal.h:475
unsigned int m_overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:477

References KIGFX::COLOR4D::BLACK, m_compositor, m_mainBuffer, m_overlayBuffer, m_tempBuffer, KIGFX::TARGET_CACHED, KIGFX::TARGET_NONCACHED, KIGFX::TARGET_OVERLAY, and KIGFX::TARGET_TEMP.

Referenced by StartDiffLayer(), and StartNegativesLayer().

◆ computeMinGridSpacing()

double GAL::computeMinGridSpacing ( ) const
protectedinherited

compute minimum grid spacing from the grid settings

Returns
the minimum spacing to use for drawing the grid

Definition at line 237 of file graphics_abstraction_layer.cpp.

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

References KIGFX::GAL::m_gridMinSpacing.

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

◆ computeWorldScale()

void KIGFX::GAL::computeWorldScale ( )
inlineprotectedinherited

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

Definition at line 1119 of file graphics_abstraction_layer.h.

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

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

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

◆ ComputeWorldScreenMatrix()

void GAL::ComputeWorldScreenMatrix ( )
virtualinherited

Compute the world <-> screen transformation matrix.

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

Definition at line 192 of file graphics_abstraction_layer.cpp.

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

References KIGFX::GAL::computeWorldScale(), MATRIX3x3< T >::Inverse(), KIGFX::GAL::m_globalFlipX, KIGFX::GAL::m_globalFlipY, KIGFX::GAL::m_lookAtPoint, KIGFX::GAL::m_rotation, KIGFX::GAL::m_screenSize, KIGFX::GAL::m_screenWorldMatrix, KIGFX::GAL::m_worldScale, KIGFX::GAL::m_worldScreenMatrix, scale, MATRIX3x3< T >::SetIdentity(), MATRIX3x3< T >::SetRotation(), MATRIX3x3< T >::SetScale(), MATRIX3x3< T >::SetTranslation(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

◆ deinitSurface()

void CAIRO_GAL::deinitSurface ( )

Destroy Cairo surfaces when are not needed anymore.

Definition at line 1495 of file cairo_gal.cpp.

1496 {
1497  if( !m_isInitialized )
1498  return;
1499 
1500  cairo_destroy( m_context );
1501  m_context = nullptr;
1502  cairo_surface_destroy( m_surface );
1503  m_surface = nullptr;
1504 
1505  m_isInitialized = false;
1506 }
bool m_isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:494
cairo_t * m_context
Cairo image.
Definition: cairo_gal.h:342
cairo_surface_t * m_surface
Cairo surface.
Definition: cairo_gal.h:343

References KIGFX::CAIRO_GAL_BASE::m_context, m_isInitialized, and KIGFX::CAIRO_GAL_BASE::m_surface.

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

◆ deleteBitmaps()

void CAIRO_GAL::deleteBitmaps ( )

Allocate the bitmaps for drawing.

Definition at line 1528 of file cairo_gal.cpp.

1529 {
1530  delete[] m_bitmapBuffer;
1531  m_bitmapBuffer = nullptr;
1532 
1533  delete[] m_wxOutput;
1534  m_wxOutput = nullptr;
1535 }
unsigned char * m_wxOutput
wxImage compatible buffer
Definition: cairo_gal.h:488
unsigned char * m_bitmapBuffer
Storage of the Cairo image.
Definition: cairo_gal.h:491

References m_bitmapBuffer, and m_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 909 of file cairo_gal.cpp.

910 {
911  storePath();
912 
913  // Delete the Cairo paths
914  std::deque<GROUP_ELEMENT>::iterator it, end;
915 
916  for( it = m_groups[aGroupNumber].begin(), end = m_groups[aGroupNumber].end(); it != end; ++it )
917  {
918  if( it->m_Command == CMD_FILL_PATH || it->m_Command == CMD_STROKE_PATH )
919  cairo_path_destroy( it->m_CairoPath );
920  }
921 
922  // Delete the group
923  m_groups.erase( aGroupNumber );
924 }
std::map< int, GROUP > m_groups
List of graphic groups.
Definition: cairo_gal.h:331
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1106

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

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

◆ DrawArc()

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

Draw an arc.

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

Reimplemented from KIGFX::GAL.

Definition at line 318 of file cairo_gal.cpp.

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

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

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

◆ DrawArcSegment()

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

Draw an arc segment.

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

TODO: Unify Arc routines

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

Reimplemented from KIGFX::GAL.

Definition at line 354 of file cairo_gal.cpp.

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

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

◆ drawAxes()

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

Definition at line 1009 of file cairo_gal.cpp.

1010 {
1011  syncLineWidth();
1012 
1013  VECTOR2D p0 = roundp( xform( aStartPoint ) );
1014  VECTOR2D p1 = roundp( xform( aEndPoint ) );
1015  VECTOR2D org = roundp( xform( VECTOR2D( 0.0, 0.0 ) ) ); // Axis origin = 0,0 coord
1016 
1017  cairo_set_source_rgba( m_currentContext, m_axesColor.r, m_axesColor.g, m_axesColor.b,
1018  m_axesColor.a );
1019  cairo_move_to( m_currentContext, p0.x, org.y );
1020  cairo_line_to( m_currentContext, p1.x, org.y );
1021  cairo_move_to( m_currentContext, org.x, p0.y );
1022  cairo_line_to( m_currentContext, org.x, p1.y );
1023  cairo_stroke( m_currentContext );
1024 }
double g
Green component.
Definition: color4d.h:385
double b
Blue component.
Definition: color4d.h:386
double a
Alpha component.
Definition: color4d.h:387
VECTOR2< double > VECTOR2D
Definition: vector2d.h:621
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp:175
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:189
COLOR4D m_axesColor
Color of the axes.
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:212
double r
Red component.
Definition: color4d.h:384

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

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

◆ DrawBitmap()

void CAIRO_GAL_BASE::DrawBitmap ( const BITMAP_BASE aBitmap)
overridevirtualinherited

Draw a bitmap image.

Reimplemented from KIGFX::GAL.

Definition at line 475 of file cairo_gal.cpp.

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

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

◆ DrawCircle()

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

Draw a circle using world coordinates.

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

Reimplemented from KIGFX::GAL.

Definition at line 302 of file cairo_gal.cpp.

303 {
304  syncLineWidth();
305 
306  VECTOR2D c = roundp( xform( aCenterPoint ) );
307  double r = ::roundp( xform( aRadius ) );
308 
309  cairo_set_line_width( m_currentContext, std::min( 2.0 * r, m_lineWidthInPixels ) );
310  cairo_new_sub_path( m_currentContext );
311  cairo_arc( m_currentContext, c.x, c.y, r, 0.0, 2 * M_PI );
312  cairo_close_path( m_currentContext );
313  flushPath();
314  m_isElementAdded = true;
315 }
double m_lineWidthInPixels
Definition: cairo_gal.h:335
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:330
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
E_SERIE r
Definition: eserie.cpp:41
const double xform(double x)
Definition: cairo_gal.cpp:175
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:189
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:212

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

◆ DrawCursor()

void CAIRO_GAL_BASE::DrawCursor ( const VECTOR2D aCursorPosition)
overridevirtualinherited

Draw the cursor.

Parameters
aCursorPositionis the cursor position in screen coordinates.

Reimplemented from KIGFX::GAL.

Definition at line 966 of file cairo_gal.cpp.

967 {
968  m_cursorPosition = aCursorPosition;
969 }
VECTOR2D m_cursorPosition
Current cursor position (world coordinates)

References KIGFX::GAL::m_cursorPosition.

◆ DrawCurve()

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

Draw a cubic bezier spline.

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

Reimplemented from KIGFX::GAL.

Definition at line 453 of file cairo_gal.cpp.

456 {
457  // Note: aFilterValue is not used because the cubic Bezier curve is
458  // supported by Cairo.
459  syncLineWidth();
460 
461  const VECTOR2D sp = roundp( xform( aStartPoint ) );
462  const VECTOR2D cpa = roundp( xform( aControlPointA ) );
463  const VECTOR2D cpb = roundp( xform( aControlPointB ) );
464  const VECTOR2D ep = roundp( xform( aEndPoint ) );
465 
466  cairo_move_to( m_currentContext, sp.x, sp.y );
467  cairo_curve_to( m_currentContext, cpa.x, cpa.y, cpb.x, cpb.y, ep.x, ep.y );
468  cairo_line_to( m_currentContext, ep.x, ep.y );
469 
470  flushPath();
471  m_isElementAdded = true;
472 }
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:330
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp:175
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:189
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:212

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

◆ DrawGrid()

void CAIRO_GAL_BASE::DrawGrid ( )
overridevirtualinherited

Reimplemented from KIGFX::GAL.

Definition at line 1613 of file cairo_gal.cpp.

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

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

◆ drawGridCross()

void CAIRO_GAL_BASE::drawGridCross ( const VECTOR2D aPoint)
protectedinherited

Definition at line 1041 of file cairo_gal.cpp.

1042 {
1043  syncLineWidth();
1044  VECTOR2D offset( 0, 0 );
1045  double size = 2.0 * m_lineWidthInPixels + 0.5;
1046 
1047  VECTOR2D p0 = roundp( xform( aPoint ) ) - VECTOR2D( size, 0 ) + offset;
1048  VECTOR2D p1 = roundp( xform( aPoint ) ) + VECTOR2D( size, 0 ) + offset;
1049  VECTOR2D p2 = roundp( xform( aPoint ) ) - VECTOR2D( 0, size ) + offset;
1050  VECTOR2D p3 = roundp( xform( aPoint ) ) + VECTOR2D( 0, size ) + offset;
1051 
1052  cairo_set_source_rgba( m_currentContext, m_gridColor.r, m_gridColor.g, m_gridColor.b,
1053  m_gridColor.a );
1054  cairo_move_to( m_currentContext, p0.x, p0.y );
1055  cairo_line_to( m_currentContext, p1.x, p1.y );
1056  cairo_move_to( m_currentContext, p2.x, p2.y );
1057  cairo_line_to( m_currentContext, p3.x, p3.y );
1058  cairo_stroke( m_currentContext );
1059 }
double m_lineWidthInPixels
Definition: cairo_gal.h:335
double g
Green component.
Definition: color4d.h:385
double b
Blue component.
Definition: color4d.h:386
COLOR4D m_gridColor
Color of the grid.
double a
Alpha component.
Definition: color4d.h:387
VECTOR2< double > VECTOR2D
Definition: vector2d.h:621
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp:175
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:189
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:212
double r
Red component.
Definition: color4d.h:384

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

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

◆ drawGridLine()

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

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

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

Definition at line 1027 of file cairo_gal.cpp.

1028 {
1029  syncLineWidth();
1030  VECTOR2D p0 = roundp( xform( aStartPoint ) );
1031  VECTOR2D p1 = roundp( xform( aEndPoint ) );
1032 
1033  cairo_set_source_rgba( m_currentContext, m_gridColor.r, m_gridColor.g, m_gridColor.b,
1034  m_gridColor.a );
1035  cairo_move_to( m_currentContext, p0.x, p0.y );
1036  cairo_line_to( m_currentContext, p1.x, p1.y );
1037  cairo_stroke( m_currentContext );
1038 }
double g
Green component.
Definition: color4d.h:385
double b
Blue component.
Definition: color4d.h:386
COLOR4D m_gridColor
Color of the grid.
double a
Alpha component.
Definition: color4d.h:387
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp:175
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:189
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:212
double r
Red component.
Definition: color4d.h:384

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

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

◆ drawGridPoint()

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

Definition at line 1062 of file cairo_gal.cpp.

1063 {
1064  VECTOR2D p = roundp( xform( aPoint ) );
1065 
1066  double sw = std::max( 1.0, aWidth );
1067  double sh = std::max( 1.0, aHeight );
1068 
1069  cairo_set_source_rgba( m_currentContext, m_gridColor.r, m_gridColor.g, m_gridColor.b,
1070  m_gridColor.a );
1071  cairo_rectangle( m_currentContext, p.x - std::floor( sw / 2 ) - 0.5,
1072  p.y - std::floor( sh / 2 ) - 0.5, sw, sh );
1073 
1074  cairo_fill( m_currentContext );
1075 }
double g
Green component.
Definition: color4d.h:385
double b
Blue component.
Definition: color4d.h:386
COLOR4D m_gridColor
Color of the grid.
double a
Alpha component.
Definition: color4d.h:387
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp:175
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:189
double r
Red component.
Definition: color4d.h:384

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

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

◆ DrawGroup()

void CAIRO_GAL_BASE::DrawGroup ( int  aGroupNumber)
overridevirtualinherited

Draw the stored group.

Parameters
aGroupNumberis the group number.

Reimplemented from KIGFX::GAL.

Definition at line 792 of file cairo_gal.cpp.

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

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

◆ DrawLine()

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

Draw a line.

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

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

Reimplemented from KIGFX::GAL.

Definition at line 198 of file cairo_gal.cpp.

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

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

◆ drawPoly() [1/3]

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

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

Definition at line 1172 of file cairo_gal.cpp.

1173 {
1174  wxCHECK( aPointList.size() > 1, /* void */ );
1175 
1176  // Iterate over the point list and draw the segments
1177  std::deque<VECTOR2D>::const_iterator it = aPointList.begin();
1178 
1179  syncLineWidth();
1180 
1181  const VECTOR2D p = roundp( xform( it->x, it->y ) );
1182 
1183  cairo_move_to( m_currentContext, p.x, p.y );
1184 
1185  for( ++it; it != aPointList.end(); ++it )
1186  {
1187  const VECTOR2D p2 = roundp( xform( it->x, it->y ) );
1188 
1189  cairo_line_to( m_currentContext, p2.x, p2.y );
1190  }
1191 
1192  flushPath();
1193  m_isElementAdded = true;
1194 }
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:330
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp:175
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:189
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:212

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

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

◆ drawPoly() [2/3]

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

Definition at line 1197 of file cairo_gal.cpp.

1198 {
1199  wxCHECK( aListSize > 1, /* void */ );
1200 
1201  // Iterate over the point list and draw the segments
1202  const VECTOR2D* ptr = aPointList;
1203 
1204  syncLineWidth();
1205 
1206  const VECTOR2D p = roundp( xform( ptr->x, ptr->y ) );
1207  cairo_move_to( m_currentContext, p.x, p.y );
1208 
1209  for( int i = 1; i < aListSize; ++i )
1210  {
1211  ++ptr;
1212  const VECTOR2D p2 = roundp( xform( ptr->x, ptr->y ) );
1213  cairo_line_to( m_currentContext, p2.x, p2.y );
1214  }
1215 
1216  flushPath();
1217  m_isElementAdded = true;
1218 }
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:330
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp:175
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:189
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:212

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

◆ drawPoly() [3/3]

void CAIRO_GAL_BASE::drawPoly ( const SHAPE_LINE_CHAIN aLineChain)
protectedinherited

Definition at line 1221 of file cairo_gal.cpp.

1222 {
1223  wxCHECK( aLineChain.PointCount() > 1, /* void */ );
1224 
1225  syncLineWidth();
1226 
1227  auto numPoints = aLineChain.PointCount();
1228 
1229  if( aLineChain.IsClosed() )
1230  numPoints += 1;
1231 
1232  const VECTOR2I start = aLineChain.CPoint( 0 );
1233  const VECTOR2D p = roundp( xform( start.x, start.y ) );
1234  cairo_move_to( m_currentContext, p.x, p.y );
1235 
1236  for( int i = 1; i < numPoints; ++i )
1237  {
1238  const VECTOR2I& pw = aLineChain.CPoint( i );
1239  const VECTOR2D ps = roundp( xform( pw.x, pw.y ) );
1240  cairo_line_to( m_currentContext, ps.x, ps.y );
1241  }
1242 
1243  flushPath();
1244  m_isElementAdded = true;
1245 }
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:330
bool IsClosed() const override
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp:175
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:189
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:212

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

◆ DrawPolygon() [1/4]

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

Draw a polygon.

Parameters
aPointListis the list of the polygon points.

Reimplemented from KIGFX::GAL.

Definition at line 103 of file cairo_gal.h.

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

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolygon() [2/4]

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

Reimplemented from KIGFX::GAL.

Definition at line 104 of file cairo_gal.h.

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

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolygon() [3/4]

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

Reimplemented from KIGFX::GAL.

Definition at line 440 of file cairo_gal.cpp.

441 {
442  for( int i = 0; i < aPolySet.OutlineCount(); ++i )
443  drawPoly( aPolySet.COutline( i ) );
444 }
int OutlineCount() const
Return the number of vertices in a given outline/hole.
void drawPoly(const std::deque< VECTOR2D > &aPointList)
Drawing polygons & polylines is the same in Cairo, so here is the common code.
Definition: cairo_gal.cpp:1172
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 447 of file cairo_gal.cpp.

448 {
449  drawPoly( aPolygon );
450 }
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:1172

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolyline() [1/3]

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

Draw a polyline.

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

Reimplemented from KIGFX::GAL.

Definition at line 94 of file cairo_gal.h.

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

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolyline() [2/3]

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

Reimplemented from KIGFX::GAL.

Definition at line 95 of file cairo_gal.h.

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

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolyline() [3/3]

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

Reimplemented from KIGFX::GAL.

Definition at line 100 of file cairo_gal.h.

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

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

419 {
420  // Calculate the diagonal points
421  syncLineWidth();
422 
423  const VECTOR2D p0 = roundp( xform( aStartPoint ) );
424  const VECTOR2D p1 = roundp( xform( VECTOR2D( aEndPoint.x, aStartPoint.y ) ) );
425  const VECTOR2D p2 = roundp( xform( aEndPoint ) );
426  const VECTOR2D p3 = roundp( xform( VECTOR2D( aStartPoint.x, aEndPoint.y ) ) );
427 
428  // The path is composed from 4 segments
429  cairo_move_to( m_currentContext, p0.x, p0.y );
430  cairo_line_to( m_currentContext, p1.x, p1.y );
431  cairo_line_to( m_currentContext, p2.x, p2.y );
432  cairo_line_to( m_currentContext, p3.x, p3.y );
433  cairo_close_path( m_currentContext );
434  flushPath();
435 
436  m_isElementAdded = true;
437 }
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:330
VECTOR2< double > VECTOR2D
Definition: vector2d.h:621
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp:175
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:189
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:212

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

◆ DrawSegment()

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

Draw a rounded segment.

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

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

Reimplemented from KIGFX::GAL.

Definition at line 236 of file cairo_gal.cpp.

238 {
239  if( m_isFillEnabled )
240  {
241  syncLineWidth( true, aWidth );
242 
243  VECTOR2D p0 = roundp( xform( aStartPoint ) );
244  VECTOR2D p1 = roundp( xform( aEndPoint ) );
245 
246  cairo_move_to( m_currentContext, p0.x, p0.y );
247  cairo_line_to( m_currentContext, p1.x, p1.y );
248  cairo_set_source_rgba( m_currentContext, m_fillColor.r, m_fillColor.g, m_fillColor.b,
249  m_fillColor.a );
250  cairo_stroke( m_currentContext );
251  }
252  else
253  {
254  aWidth /= 2.0;
255  SetLineWidth( 1.0 );
256  syncLineWidth();
257 
258  // Outline mode for tracks
259  VECTOR2D startEndVector = aEndPoint - aStartPoint;
260  double lineAngle = atan2( startEndVector.y, startEndVector.x );
261 
262  double sa = sin( lineAngle + M_PI / 2.0 );
263  double ca = cos( lineAngle + M_PI / 2.0 );
264 
265  VECTOR2D pa0 = xform( aStartPoint + VECTOR2D( aWidth * ca, aWidth * sa ) );
266  VECTOR2D pa1 = xform( aStartPoint - VECTOR2D( aWidth * ca, aWidth * sa ) );
267  VECTOR2D pb0 = xform( aEndPoint + VECTOR2D( aWidth * ca, aWidth * sa ) );
268  VECTOR2D pb1 = xform( aEndPoint - VECTOR2D( aWidth * ca, aWidth * sa ) );
269 
270  cairo_set_source_rgba( m_currentContext, m_strokeColor.r, m_strokeColor.g, m_strokeColor.b,
271  m_strokeColor.a );
272 
273  cairo_move_to( m_currentContext, pa0.x, pa0.y );
274  cairo_line_to( m_currentContext, pb0.x, pb0.y );
275 
276  cairo_move_to( m_currentContext, pa1.x, pa1.y );
277  cairo_line_to( m_currentContext, pb1.x, pb1.y );
278  flushPath();
279 
280  // Calculate the segment angle and arc center in normal/mirrored transform for rounded ends.
281  VECTOR2D center_a = xform( aStartPoint );
282  VECTOR2D center_b = xform( aEndPoint );
283  startEndVector = center_b - center_a;
284  lineAngle = atan2( startEndVector.y, startEndVector.x );
285  double radius = ( pa0 - center_a ).EuclideanNorm();
286 
287  // Draw the rounded end point of the segment
288  double arcStartAngle = lineAngle - M_PI / 2.0;
289  cairo_arc( m_currentContext, center_b.x, center_b.y, radius, arcStartAngle, arcStartAngle + M_PI );
290 
291  // Draw the rounded start point of the segment
292  arcStartAngle = lineAngle + M_PI / 2.0;
293  cairo_arc( m_currentContext, center_a.x, center_a.y, radius, arcStartAngle, arcStartAngle + M_PI );
294 
295  flushPath();
296  }
297 
298  m_isElementAdded = true;
299 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:146
bool m_isFillEnabled
Is filling of graphic objects enabled ?
double g
Green component.
Definition: color4d.h:385
double b
Blue component.
Definition: color4d.h:386
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:330
double a
Alpha component.
Definition: color4d.h:387
COLOR4D m_strokeColor
The color of the outlines.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:621
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp:175
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:189
COLOR4D m_fillColor
The fill color.
void SetLineWidth(float aLineWidth) override
Set the line width.
Definition: cairo_gal.cpp:629
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:212
double r
Red component.
Definition: color4d.h:384

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

◆ EnableDepthTest()

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

Reimplemented from KIGFX::GAL.

Definition at line 972 of file cairo_gal.cpp.

973 {
974 }

◆ EndDiffLayer()

void CAIRO_GAL::EndDiffLayer ( )
overridevirtual

Ends rendering of a differential layer.

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

Reimplemented from KIGFX::GAL.

Definition at line 947 of file cairo_gal.cpp.

948 {
949  m_compositor->DrawBuffer( m_tempBuffer, m_mainBuffer, CAIRO_OPERATOR_ADD );
950 }
unsigned int m_tempBuffer
Handle to the temp buffer.
Definition: cairo_gal.h:478
unsigned int m_mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:476
std::shared_ptr< CAIRO_COMPOSITOR > m_compositor
Object for layers compositing.
Definition: cairo_gal.h:475

References m_compositor, m_mainBuffer, and m_tempBuffer.

◆ EndDrawing()

void CAIRO_GAL::EndDrawing ( )
overridevirtual

End the drawing, needs to be called for every new frame.

Use GAL_DRAWING_CONTEXT RAII object unless you know what you're doing.

Reimplemented from KIGFX::CAIRO_GAL_BASE.

Definition at line 1334 of file cairo_gal.cpp.

1335 {
1337 
1338  // Merge buffers on the screen
1339  m_compositor->DrawBuffer( m_mainBuffer );
1340  m_compositor->DrawBuffer( m_overlayBuffer );
1341 
1342  // Now translate the raw context data from the format stored
1343  // by cairo into a format understood by wxImage.
1344  pixman_image_t* dstImg = pixman_image_create_bits(
1345  wxPlatformInfo::Get().GetEndianness() == wxENDIAN_LITTLE ? PIXMAN_b8g8r8
1346  : PIXMAN_r8g8b8,
1347  m_screenSize.x, m_screenSize.y, (uint32_t*) m_wxOutput, m_wxBufferWidth * 3 );
1348  pixman_image_t* srcImg =
1349  pixman_image_create_bits( PIXMAN_a8r8g8b8, m_screenSize.x, m_screenSize.y,
1350  (uint32_t*) m_bitmapBuffer, m_wxBufferWidth * 4 );
1351 
1352  pixman_image_composite( PIXMAN_OP_SRC, srcImg, nullptr, dstImg, 0, 0, 0, 0, 0, 0,
1354 
1355  // Free allocated memory
1356  pixman_image_unref( srcImg );
1357  pixman_image_unref( dstImg );
1358 
1359  wxImage img( m_wxBufferWidth, m_screenSize.y, m_wxOutput, true );
1360  wxBitmap bmp( img );
1361  wxMemoryDC mdc( bmp );
1362  wxClientDC clientDC( this );
1363 
1364  // Now it is the time to blit the mouse cursor
1365  blitCursor( mdc );
1366  clientDC.Blit( 0, 0, m_screenSize.x, m_screenSize.y, &mdc, 0, 0, wxCOPY );
1367 
1368  deinitSurface();
1369 }
unsigned char * m_wxOutput
wxImage compatible buffer
Definition: cairo_gal.h:488
void deinitSurface()
Destroy Cairo surfaces when are not needed anymore.
Definition: cairo_gal.cpp:1495
unsigned char * m_bitmapBuffer
Storage of the Cairo image.
Definition: cairo_gal.h:491
void EndDrawing() override
End the drawing, needs to be called for every new frame.
Definition: cairo_gal.cpp:98
unsigned int m_mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:476
std::shared_ptr< CAIRO_COMPOSITOR > m_compositor
Object for layers compositing.
Definition: cairo_gal.h:475
unsigned int m_overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:477
VECTOR2I m_screenSize
Screen size in screen coordinates.
void blitCursor(wxMemoryDC &clientDC)
Blit cursor into the current screen.
Definition: cairo_gal.cpp:1155

References KIGFX::CAIRO_GAL_BASE::blitCursor(), deinitSurface(), KIGFX::CAIRO_GAL_BASE::EndDrawing(), m_bitmapBuffer, m_compositor, m_mainBuffer, m_overlayBuffer, KIGFX::GAL::m_screenSize, m_wxBufferWidth, m_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 1415 of file cairo_gal.cpp.

1416 {
1418  deinitSurface();
1419 }
void EndGroup() override
End the group.
Definition: cairo_gal.cpp:785
void deinitSurface()
Destroy Cairo surfaces when are not needed anymore.
Definition: cairo_gal.cpp:1495

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

◆ EndNegativesLayer()

void CAIRO_GAL::EndNegativesLayer ( )
overridevirtual

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

No-op in OpenGL.

Reimplemented from KIGFX::GAL.

Definition at line 960 of file cairo_gal.cpp.

961 {
962  m_compositor->DrawBuffer( m_tempBuffer, m_mainBuffer, CAIRO_OPERATOR_OVER );
963 }
unsigned int m_tempBuffer
Handle to the temp buffer.
Definition: cairo_gal.h:478
unsigned int m_mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:476
std::shared_ptr< CAIRO_COMPOSITOR > m_compositor
Object for layers compositing.
Definition: cairo_gal.h:475

References m_compositor, m_mainBuffer, and m_tempBuffer.

◆ endUpdate()

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

Disable item update mode.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1114 of file graphics_abstraction_layer.h.

1114 {}

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

550 {
551  storePath();
552 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1106

References KIGFX::CAIRO_GAL_BASE::storePath().

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

◆ flushPath()

void CAIRO_GAL_BASE::flushPath ( )
protectedinherited

Definition at line 1078 of file cairo_gal.cpp.

1079 {
1080  if( m_isFillEnabled )
1081  {
1082  cairo_set_source_rgba( m_currentContext, m_fillColor.r, m_fillColor.g, m_fillColor.b,
1083  m_fillColor.a );
1084 
1085  if( m_isStrokeEnabled )
1086  {
1087  cairo_set_line_width( m_currentContext, m_lineWidthInPixels );
1088  cairo_fill_preserve( m_currentContext );
1089  }
1090  else
1091  {
1092  cairo_fill( m_currentContext );
1093  }
1094  }
1095 
1096  if( m_isStrokeEnabled )
1097  {
1098  cairo_set_line_width( m_currentContext, m_lineWidthInPixels );
1099  cairo_set_source_rgba( m_currentContext, m_strokeColor.r, m_strokeColor.g, m_strokeColor.b,
1100  m_strokeColor.a );
1101  cairo_stroke( m_currentContext );
1102  }
1103 }
bool m_isFillEnabled
Is filling of graphic objects enabled ?
double m_lineWidthInPixels
Definition: cairo_gal.h:335
double g
Green component.
Definition: color4d.h:385
double b
Blue component.
Definition: color4d.h:386
double a
Alpha component.
Definition: color4d.h:387
bool m_isStrokeEnabled
Are the outlines stroked ?
COLOR4D m_strokeColor
The color of the outlines.
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
COLOR4D m_fillColor
The fill color.
double r
Red component.
Definition: color4d.h:384

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

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

◆ GetClearColor()

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

Definition at line 222 of file graphics_abstraction_layer.h.

223  {
224  return m_clearColor;
225  }

References KIGFX::GAL::m_clearColor.

Referenced by EDIT_POINTS::ViewDraw().

◆ getCursorColor()

COLOR4D GAL::getCursorColor ( ) const
protectedinherited

Get the actual cursor color to draw.

Definition at line 267 of file graphics_abstraction_layer.cpp.

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

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

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

◆ GetFillColor()

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

Get the fill color.

Returns
the color for filling a outline.

Definition at line 273 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_fillColor.

◆ GetGlyphSize()

◆ GetGridLineWidth()

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

Get the grid line width.

Returns
the grid line widthDraw the grid

Definition at line 969 of file graphics_abstraction_layer.h.

References KIGFX::GAL::m_gridLineWidth.

◆ GetGridOrigin()

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

Definition at line 894 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_gridOrigin.

Referenced by GRID_HELPER::GetOrigin().

◆ GetGridPoint()

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

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

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

Definition at line 245 of file graphics_abstraction_layer.cpp.

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

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

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

◆ GetGridSize()

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

◆ GetGridSnapping()

◆ GetGridVisibility()

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

Definition at line 866 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_gridVisibility.

Referenced by EDA_DRAW_PANEL_GAL::SwitchBackend().

◆ GetHorizontalJustify()

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

Return current text horizontal justification setting.

Definition at line 458 of file graphics_abstraction_layer.h.

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

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

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

◆ GetLineWidth()

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

◆ GetLookAtPoint()

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

Get the look at point.

Returns
the look at point.

Definition at line 663 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_lookAtPoint.

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

◆ GetMaxDepth()

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

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

Definition at line 732 of file graphics_abstraction_layer.h.

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

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

◆ GetMinDepth()

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

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

Definition at line 724 of file graphics_abstraction_layer.h.

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

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

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

◆ getNewGroupNumber()

unsigned int CAIRO_GAL_BASE::getNewGroupNumber ( )
protectedinherited

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

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

Definition at line 1248 of file cairo_gal.cpp.

1249 {
1250  wxASSERT_MSG( m_groups.size() < std::numeric_limits<unsigned int>::max(),
1251  wxT( "There are no free slots to store a group" ) );
1252 
1253  while( m_groups.find( m_groupCounter ) != m_groups.end() )
1254  m_groupCounter++;
1255 
1256  return m_groupCounter++;
1257 }
std::map< int, GROUP > m_groups
List of graphic groups.
Definition: cairo_gal.h:331
unsigned int m_groupCounter
Counter used for generating group keys.
Definition: cairo_gal.h:332

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

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

◆ GetRotation()

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

Get the rotation angle.

Returns
The rotation angle (radians).

Definition at line 703 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_rotation.

◆ GetScreenPixelSize()

◆ GetScreenWorldMatrix()

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

Get the screen <-> world transformation matrix.

Returns
the transformation matrix.

Definition at line 594 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_screenWorldMatrix.

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

◆ GetStrokeColor()

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

Get the stroke color.

Returns
the color for stroking the outline.

Definition at line 293 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_strokeColor.

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

◆ GetStrokeFont()

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

Definition at line 335 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_strokeFont.

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

◆ GetTarget()

RENDER_TARGET CAIRO_GAL::GetTarget ( ) const
overridevirtual

Get the currently used target for rendering.

Returns
The current rendering target.

Reimplemented from KIGFX::GAL.

Definition at line 1446 of file cairo_gal.cpp.

1447 {
1448  return m_currentTarget;
1449 }
RENDER_TARGET m_currentTarget
Current rendering target.
Definition: cairo_gal.h:480

References m_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 183 of file graphics_abstraction_layer.cpp.

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

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

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

◆ GetVerticalJustify()

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

Returns current text vertical justification setting.

Definition at line 476 of file graphics_abstraction_layer.h.

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

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

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

◆ GetVisibleWorldExtents()

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

Definition at line 222 of file graphics_abstraction_layer.cpp.

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

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

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

◆ GetWorldScale()

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

◆ GetWorldScreenMatrix()

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

Get the world <-> screen transformation matrix.

Returns
the transformation matrix.

Definition at line 584 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_worldScreenMatrix.

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

◆ GetZoomFactor()

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

Get the zoom factor.

Returns
the zoom factor.

Definition at line 683 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_zoomFactor.

Referenced by COMMON_TOOLS::doZoomInOut(), KIGFX::PCB_PAINTER::draw(), EDA_DRAW_FRAME::GetZoomLevelIndicator(), ZOOM_MENU::update(), and EDA_DRAW_FRAME::UpdateZoomSelectBox().

◆ HasTarget()

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

Return true if the target exists.

Parameters
aTargetis the target to be checked.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 805 of file graphics_abstraction_layer.h.

806  {
807  return true;
808  };

Referenced by EDA_DRAW_PANEL_GAL::DoRePaint().

◆ initSurface()

void CAIRO_GAL::initSurface ( )

Prepare Cairo surfaces for drawing.

Definition at line 1474 of file cairo_gal.cpp.

1475 {
1476  if( m_isInitialized )
1477  return;
1478 
1479  m_surface = cairo_image_surface_create_for_data( m_bitmapBuffer, GAL_FORMAT, m_wxBufferWidth,
1480  m_screenSize.y, m_stride );
1481 
1482  m_context = cairo_create( m_surface );
1483 
1484 #ifdef DEBUG
1485  cairo_status_t status = cairo_status( m_context );
1486  wxASSERT_MSG( status == CAIRO_STATUS_SUCCESS, wxT( "Cairo context creation error" ) );
1487 #endif /* DEBUG */
1488 
1490 
1491  m_isInitialized = true;
1492 }
bool m_isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:494
unsigned char * m_bitmapBuffer
Storage of the Cairo image.
Definition: cairo_gal.h:491
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
int m_stride
Stride value for Cairo.
Definition: cairo_gal.h:492
cairo_t * m_context
Cairo image.
Definition: cairo_gal.h:342
VECTOR2I m_screenSize
Screen size in screen coordinates.
cairo_surface_t * m_surface
Cairo surface.
Definition: cairo_gal.h:343
static constexpr cairo_format_t GAL_FORMAT
Format used to store pixels.
Definition: cairo_gal.h:350

References KIGFX::CAIRO_GAL_BASE::GAL_FORMAT, m_bitmapBuffer, KIGFX::CAIRO_GAL_BASE::m_context, KIGFX::CAIRO_GAL_BASE::m_currentContext, m_isInitialized, KIGFX::GAL::m_screenSize, m_stride, KIGFX::CAIRO_GAL_BASE::m_surface, m_wxBufferWidth, and VECTOR2< T >::y.

Referenced by BeginDrawing(), and BeginGroup().

◆ IsCairoEngine()

bool KIGFX::CAIRO_GAL_BASE::IsCairoEngine ( )
inlineoverridevirtualinherited

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

Reimplemented from KIGFX::GAL.

Definition at line 64 of file cairo_gal.h.

64 { return true; }

◆ IsContextLocked()

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

Checks the state of the context lock.

Returns
True if the context is currently locked

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1084 of file graphics_abstraction_layer.h.

1085  {
1086  return false;
1087  }

Referenced by EDA_DRAW_PANEL_GAL::onSize().

◆ IsCursorEnabled()

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

Return information about cursor visibility.

Returns
True if cursor is visible.

Definition at line 1030 of file graphics_abstraction_layer.h.

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

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

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

◆ IsFlippedX()

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

◆ IsFlippedY()

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

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

Definition at line 770 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_globalFlipY.

◆ IsFontBold()

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

Definition at line 424 of file graphics_abstraction_layer.h.

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

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

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

◆ IsFontItalic()

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

◆ IsFontUnderlined()

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

◆ IsInitialized()

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

Return the initialization status for the canvas.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 74 of file graphics_abstraction_layer.h.

74 { return true; }

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

◆ IsOpenGlEngine()

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

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

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 83 of file graphics_abstraction_layer.h.

83 { return false; }

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

◆ IsTextMirrored()

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

◆ IsVisible()

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

Return true if the GAL canvas is visible on the screen.

Reimplemented from KIGFX::GAL.

Definition at line 375 of file cairo_gal.h.

376  {
377  return IsShownOnScreen() && !GetClientRect().IsEmpty();
378  }

◆ LockContext()

virtual void KIGFX::GAL::LockContext ( int  aClientCookie)
inlinevirtualinherited

Use GAL_CONTEXT_LOCKER RAII object unless you know what you're doing.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1091 of file graphics_abstraction_layer.h.

1091 {}

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

◆ OnGalDisplayOptionsChanged()

void GAL::OnGalDisplayOptionsChanged ( const GAL_DISPLAY_OPTIONS aOptions)
overrideprotectedvirtualinherited

Handler for observer settings changes.

Implements KIGFX::GAL_DISPLAY_OPTIONS_OBSERVER.

Definition at line 101 of file graphics_abstraction_layer.cpp.

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

References KIGFX::GAL::updatedGalDisplayOptions().

◆ onPaint()

void CAIRO_GAL::onPaint ( wxPaintEvent &  aEvent)

Paint event handler.

Parameters
aEventis the paint event.

Definition at line 1554 of file cairo_gal.cpp.

1555 {
1556  PostPaint( aEvent );
1557 }
void PostPaint(wxPaintEvent &aEvent)
Post an event to m_paint_listener.
Definition: cairo_gal.cpp:1372

References PostPaint().

Referenced by CAIRO_GAL().

◆ onSetNativeCursor()

void CAIRO_GAL::onSetNativeCursor ( wxSetCursorEvent &  aEvent)

Give the correct cursor image when the native widget asks for it.

Parameters
aEventis the cursor event to plac the cursor into.Cairo-specific update handlers

Definition at line 1607 of file cairo_gal.cpp.

1608 {
1609  aEvent.SetCursor( m_currentwxCursor );
1610 }
wxCursor m_currentwxCursor
wxCursor showing the current native cursor
Definition: cairo_gal.h:496

References m_currentwxCursor.

Referenced by CAIRO_GAL().

◆ PopDepth()

void KIGFX::GAL::PopDepth ( )
inlineinherited

Restore previously stored drawing depth for the depth stack.

Definition at line 1072 of file graphics_abstraction_layer.h.

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

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

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

◆ PostPaint()

void CAIRO_GAL::PostPaint ( wxPaintEvent &  aEvent)

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

1373 {
1374  // posts an event to m_paint_listener to ask for redraw the canvas.
1375  if( m_paintListener )
1376  wxPostEvent( m_paintListener, aEvent );
1377 }
wxEvtHandler * m_paintListener
Paint listener.
Definition: cairo_gal.h:486

References m_paintListener.

Referenced by onPaint().

◆ PushDepth()

void KIGFX::GAL::PushDepth ( )
inlineinherited

Store current drawing depth on the depth stack.

Definition at line 1064 of file graphics_abstraction_layer.h.

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

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

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

◆ resetContext()

void CAIRO_GAL_BASE::resetContext ( )
protectedinherited

Definition at line 977 of file cairo_gal.cpp.

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

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

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

◆ ResetTextAttributes()

void GAL::ResetTextAttributes ( )
inherited

Reset text attributes to default styling.

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

Definition at line 167 of file graphics_abstraction_layer.cpp.

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

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

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

◆ ResizeScreen()

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

Resizes the canvas.

Reimplemented from KIGFX::CAIRO_GAL_BASE.

Definition at line 1380 of file cairo_gal.cpp.

1381 {
1382  CAIRO_GAL_BASE::ResizeScreen( aWidth, aHeight );
1383 
1384  // Recreate the bitmaps
1385  deleteBitmaps();
1386  allocateBitmaps();
1387 
1388  if( m_validCompositor )
1389  m_compositor->Resize( aWidth, aHeight );
1390 
1391  m_validCompositor = false;
1392 
1393  SetSize( wxSize( aWidth, aHeight ) );
1394 }
void ResizeScreen(int aWidth, int aHeight) override
Resizes the canvas.
Definition: cairo_gal.cpp:543
bool m_validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:481
std::shared_ptr< CAIRO_COMPOSITOR > m_compositor
Object for layers compositing.
Definition: cairo_gal.h:475
void deleteBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1528
void allocateBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1509

References allocateBitmaps(), deleteBitmaps(), m_compositor, m_validCompositor, and KIGFX::CAIRO_GAL_BASE::ResizeScreen().

◆ Restore()

void CAIRO_GAL_BASE::Restore ( )
overridevirtualinherited

Restore the context.

Reimplemented from KIGFX::GAL.

Definition at line 747 of file cairo_gal.cpp.

748 {
749  storePath();
750 
751  if( m_isGrouping )
752  {
753  GROUP_ELEMENT groupElement;
754  groupElement.m_Command = CMD_RESTORE;
755  m_currentGroup->push_back( groupElement );
756  }
757  else
758  {
759  if( !m_xformStack.empty() )
760  {
761  m_currentXform = m_xformStack.back();
762  m_xformStack.pop_back();
764  }
765  }
766 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1106
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:333
std::vector< cairo_matrix_t > m_xformStack
Definition: cairo_gal.h:348
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:105
cairo_matrix_t m_currentXform
Definition: cairo_gal.h:339
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:329
Restore the transformation matrix.
Definition: cairo_gal.h:310

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

◆ Rotate()

void CAIRO_GAL_BASE::Rotate ( double  aAngle)
overridevirtualinherited

Rotate the context.

Parameters
aAngleis the rotation angle in radians.

Reimplemented from KIGFX::GAL.

Definition at line 670 of file cairo_gal.cpp.

671 {
672  storePath();
673 
674  if( m_isGrouping )
675  {
676  GROUP_ELEMENT groupElement;
677  groupElement.m_Command = CMD_ROTATE;
678  groupElement.m_Argument.DblArg[0] = aAngle;
679  m_currentGroup->push_back( groupElement );
680  }
681  else
682  {
683  cairo_matrix_rotate( &m_currentXform, aAngle );
685  }
686 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1106
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:333
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:105
cairo_matrix_t m_currentXform
Definition: cairo_gal.h:339
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:329

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

◆ roundp()

◆ Save()

void CAIRO_GAL_BASE::Save ( )
overridevirtualinherited

Save the context.

Reimplemented from KIGFX::GAL.

Definition at line 729 of file cairo_gal.cpp.

730 {
731  storePath();
732 
733  if( m_isGrouping )
734  {
735  GROUP_ELEMENT groupElement;
736  groupElement.m_Command = CMD_SAVE;
737  m_currentGroup->push_back( groupElement );
738  }
739  else
740  {
741  m_xformStack.push_back( m_currentXform );
743  }
744 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1106
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:333
std::vector< cairo_matrix_t > m_xformStack
Definition: cairo_gal.h:348
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:105
Save the transformation matrix.
Definition: cairo_gal.h:309
cairo_matrix_t m_currentXform
Definition: cairo_gal.h:339
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:329

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

◆ Scale()

void CAIRO_GAL_BASE::Scale ( const VECTOR2D aScale)
overridevirtualinherited

Scale the context.

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

Reimplemented from KIGFX::GAL.

Definition at line 709 of file cairo_gal.cpp.

710 {
711  storePath();
712 
713  if( m_isGrouping )
714  {
715  GROUP_ELEMENT groupElement;
716  groupElement.m_Command = CMD_SCALE;
717  groupElement.m_Argument.DblArg[0] = aScale.x;
718  groupElement.m_Argument.DblArg[1] = aScale.y;
719  m_currentGroup->push_back( groupElement );
720  }
721  else
722  {
723  cairo_matrix_scale( &m_currentXform, aScale.x, aScale.y );
725  }
726 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1106
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:333
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:105
cairo_matrix_t m_currentXform
Definition: cairo_gal.h:339
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:329

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

◆ SetAxesColor()

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

◆ SetAxesEnabled()

◆ SetClearColor()

◆ SetCoarseGrid()

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

Draw every tick line wider.

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

Definition at line 959 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_gridTick.

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

◆ setCompositor()

void CAIRO_GAL::setCompositor ( )

Prepare the compositor.

Definition at line 1538 of file cairo_gal.cpp.

1539 {
1540  // Recreate the compositor with the new Cairo context
1543  m_compositor->SetAntialiasingMode( m_options.cairo_antialiasing_mode );
1544 
1545  // Prepare buffers
1546  m_mainBuffer = m_compositor->CreateBuffer();
1547  m_overlayBuffer = m_compositor->CreateBuffer();
1548  m_tempBuffer = m_compositor->CreateBuffer();
1549 
1550  m_validCompositor = true;
1551 }
unsigned int m_tempBuffer
Handle to the temp buffer.
Definition: cairo_gal.h:478
CAIRO_ANTIALIASING_MODE cairo_antialiasing_mode
GAL_DISPLAY_OPTIONS & m_options
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
bool m_validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:481
unsigned int m_mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:476
std::shared_ptr< CAIRO_COMPOSITOR > m_compositor
Object for layers compositing.
Definition: cairo_gal.h:475
unsigned int m_overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:477
VECTOR2I m_screenSize
Screen size in screen coordinates.

References KIGFX::GAL_DISPLAY_OPTIONS::cairo_antialiasing_mode, m_compositor, KIGFX::CAIRO_GAL_BASE::m_currentContext, m_mainBuffer, KIGFX::GAL::m_options, m_overlayBuffer, KIGFX::GAL::m_screenSize, m_tempBuffer, m_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 1040 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_cursorColor.

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

◆ SetCursorEnabled()

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

Enable/disable cursor.

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

Definition at line 1020 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_isCursorEnabled.

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

◆ SetDepthRange()

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

Set the range of the layer depth.

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

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

Definition at line 716 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_depthRange.

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

◆ SetFillColor()

void CAIRO_GAL_BASE::SetFillColor ( const COLOR4D aColor)
overridevirtualinherited

Set the fill color.

Parameters
aColoris the color for filling.

Reimplemented from KIGFX::GAL.

Definition at line 611 of file cairo_gal.cpp.

612 {
613  storePath();
614  m_fillColor = aColor;
615 
616  if( m_isGrouping )
617  {
618  GROUP_ELEMENT groupElement;
619  groupElement.m_Command = CMD_SET_FILLCOLOR;
620  groupElement.m_Argument.DblArg[0] = m_fillColor.r;
621  groupElement.m_Argument.DblArg[1] = m_fillColor.g;
622  groupElement.m_Argument.DblArg[2] = m_fillColor.b;
623  groupElement.m_Argument.DblArg[3] = m_fillColor.a;
624  m_currentGroup->push_back( groupElement );
625  }
626 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1106
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:333
double g
Green component.
Definition: color4d.h:385
double b
Blue component.
Definition: color4d.h:386
double a
Alpha component.
Definition: color4d.h:387
COLOR4D m_fillColor
The fill color.
double r
Red component.
Definition: color4d.h:384
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:329

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

◆ SetFlip()

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

Sets flipping of the screen.

Parameters
xAxisis the flip flag for the X axis.
yAxisis the flip flag for the Y axis.

Definition at line 753 of file graphics_abstraction_layer.h.

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

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

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

◆ SetFontBold()

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

Set bold property of current font.

Parameters
aBoldtells if the font should be bold or not.

Definition at line 423 of file graphics_abstraction_layer.h.

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

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

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

◆ SetFontItalic()

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

Set italic property of current font.

Parameters
aItalictells if the font should be italic or not.

Definition at line 431 of file graphics_abstraction_layer.h.

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

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

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

◆ SetFontUnderlined()

◆ SetGlyphSize()

◆ SetGridColor()

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

Set the grid color.

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

Definition at line 931 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_gridColor.

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

◆ SetGridOrigin()

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

Set the origin point for the grid.

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

Definition at line 879 of file graphics_abstraction_layer.h.

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

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

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

◆ SetGridSize()

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

Set the grid size.

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

Definition at line 904 of file graphics_abstraction_layer.h.

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

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

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

◆ SetGridVisibility()

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

Set the visibility setting of the grid.

Parameters
aVisibilityis the new visibility setting of the grid.

Definition at line 864 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_gridVisibility.

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

◆ SetHorizontalJustify()

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

Set the horizontal justify for text drawing.

Parameters
aHorizontalJustifyis the horizontal justify value.

Definition at line 450 of file graphics_abstraction_layer.h.

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

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

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

◆ SetIsFill()

void CAIRO_GAL_BASE::SetIsFill ( bool  aIsFillEnabled)
overridevirtualinherited

Enable/disable fill.

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

Reimplemented from KIGFX::GAL.

Definition at line 563 of file cairo_gal.cpp.

564 {
565  storePath();
566  m_isFillEnabled = aIsFillEnabled;
567 
568  if( m_isGrouping )
569  {
570  GROUP_ELEMENT groupElement;
571  groupElement.m_Command = CMD_SET_FILL;
572  groupElement.m_Argument.BoolArg = aIsFillEnabled;
573  m_currentGroup->push_back( groupElement );
574  }
575 }
bool m_isFillEnabled
Is filling of graphic objects enabled ?
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1106
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:333
Enable/disable filling.
Definition: cairo_gal.h:298
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:329

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

◆ SetIsStroke()

void CAIRO_GAL_BASE::SetIsStroke ( bool  aIsStrokeEnabled)
overridevirtualinherited

Enable/disable stroked outlines.

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

Reimplemented from KIGFX::GAL.

Definition at line 578 of file cairo_gal.cpp.

579 {
580  storePath();
581  m_isStrokeEnabled = aIsStrokeEnabled;
582 
583  if( m_isGrouping )
584  {
585  GROUP_ELEMENT groupElement;
586  groupElement.m_Command = CMD_SET_STROKE;
587  groupElement.m_Argument.BoolArg = aIsStrokeEnabled;
588  m_currentGroup->push_back( groupElement );
589  }
590 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1106
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:333
bool m_isStrokeEnabled
Are the outlines stroked ?
Enable/disable stroking.
Definition: cairo_gal.h:299
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:329

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

◆ SetLayerDepth()

void CAIRO_GAL_BASE::SetLayerDepth ( double  aLayerDepth)
overridevirtualinherited

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

Parameters
aLayerDepththe layer depth for the objects.

Reimplemented from KIGFX::GAL.

Definition at line 648 of file cairo_gal.cpp.

649 {
650  super::SetLayerDepth( aLayerDepth );
651  storePath();
652 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1106
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 629 of file cairo_gal.cpp.

630 {
631  storePath();
632  GAL::SetLineWidth( aLineWidth );
633 
634  if( m_isGrouping )
635  {
636  GROUP_ELEMENT groupElement;
637  groupElement.m_Command = CMD_SET_LINE_WIDTH;
638  groupElement.m_Argument.DblArg[0] = aLineWidth;
639  m_currentGroup->push_back( groupElement );
640  }
641  else
642  {
643  m_lineWidth = aLineWidth;
644  }
645 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1106
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:333
virtual void SetLineWidth(float aLineWidth)
Set the line width.
float m_lineWidth
The line width.
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:329

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

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

◆ SetLookAtPoint()

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

Set the Point in world space to look at.

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

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

Definition at line 653 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_lookAtPoint.

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

◆ SetMouseListener()

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

Definition at line 414 of file cairo_gal.h.

415  {
416  m_mouseListener = aMouseListener;
417  }
wxEvtHandler * m_mouseListener
Mouse listener.
Definition: cairo_gal.h:485

References m_mouseListener.

◆ SetNativeCursorStyle()

bool CAIRO_GAL::SetNativeCursorStyle ( KICURSOR  aCursor)
overridevirtual

Set the cursor in the native panel.

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

Reimplemented from KIGFX::GAL.

Definition at line 1592 of file cairo_gal.cpp.

1593 {
1594  // Store the current cursor type and get the wxCursor for it
1595  if( !GAL::SetNativeCursorStyle( aCursor ) )
1596  return false;
1597 
1599 
1600  // Update the cursor in the wx control
1601  wxWindow::SetCursor( m_currentwxCursor );
1602 
1603  return true;
1604 }
static const wxCursor GetCursor(KICURSOR aCursorType)
Definition: cursors.cpp:394
wxCursor m_currentwxCursor
wxCursor showing the current native cursor
Definition: cairo_gal.h:496
virtual bool SetNativeCursorStyle(KICURSOR aCursor)
Set the cursor in the native panel.
KICURSOR m_currentNativeCursor
Current cursor.

References CURSOR_STORE::GetCursor(), KIGFX::GAL::m_currentNativeCursor, m_currentwxCursor, and KIGFX::GAL::SetNativeCursorStyle().

◆ SetNegativeDrawMode()

void CAIRO_GAL_BASE::SetNegativeDrawMode ( bool  aSetting)
overridevirtualinherited

Set negative draw mode in the renderer.

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

Parameters
aSettingis true if negative mode should be enabled

Reimplemented from KIGFX::GAL.

Definition at line 934 of file cairo_gal.cpp.

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

References KIGFX::CAIRO_GAL_BASE::m_currentContext.

◆ SetPaintListener()

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

Definition at line 419 of file cairo_gal.h.

420  {
421  m_paintListener = aPaintListener;
422  }
wxEvtHandler * m_paintListener
Paint listener.
Definition: cairo_gal.h:486

References m_paintListener.

◆ SetRotation()

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

Set the rotation angle.

Parameters
aRotationis the new rotation angle (radians).

Definition at line 693 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_rotation.

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

◆ SetScreenDPI()

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

Set the dots per inch of the screen.

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

Parameters
aScreenDPIare the screen DPI.

Definition at line 641 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_screenDPI.

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

◆ SetScreenSize()

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

Definition at line 628 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_screenSize.

Referenced by 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 593 of file cairo_gal.cpp.

594 {
595  storePath();
596  m_strokeColor = aColor;
597 
598  if( m_isGrouping )
599  {
600  GROUP_ELEMENT groupElement;
601  groupElement.m_Command = CMD_SET_STROKECOLOR;
602  groupElement.m_Argument.DblArg[0] = m_strokeColor.r;
603  groupElement.m_Argument.DblArg[1] = m_strokeColor.g;
604  groupElement.m_Argument.DblArg[2] = m_strokeColor.b;
605  groupElement.m_Argument.DblArg[3] = m_strokeColor.a;
606  m_currentGroup->push_back( groupElement );
607  }
608 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1106
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:333
double g
Green component.
Definition: color4d.h:385
double b
Blue component.
Definition: color4d.h:386
double a
Alpha component.
Definition: color4d.h:387
COLOR4D m_strokeColor
The color of the outlines.
double r
Red component.
Definition: color4d.h:384
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:329

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

◆ SetTarget()

void CAIRO_GAL::SetTarget ( RENDER_TARGET  aTarget)
overridevirtual

Set the target for rendering.

Parameters
aTargetis the new target for rendering.

Reimplemented from KIGFX::GAL.

Definition at line 1422 of file cairo_gal.cpp.

1423 {
1424  // If the compositor is not set, that means that there is a recaching process going on
1425  // and we do not need the compositor now
1426  if( !m_validCompositor )
1427  return;
1428 
1429  // Cairo grouping prevents display of overlapping items on the same layer in the lighter color
1430  if( m_isInitialized )
1431  storePath();
1432 
1433  switch( aTarget )
1434  {
1435  default:
1436  case TARGET_CACHED:
1437  case TARGET_NONCACHED: m_compositor->SetBuffer( m_mainBuffer ); break;
1438  case TARGET_OVERLAY: m_compositor->SetBuffer( m_overlayBuffer ); break;
1439  case TARGET_TEMP: m_compositor->SetBuffer( m_tempBuffer ); break;
1440  }
1441 
1442  m_currentTarget = aTarget;
1443 }
bool m_isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:494
RENDER_TARGET m_currentTarget
Current rendering target.
Definition: cairo_gal.h:480
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1106
unsigned int m_tempBuffer
Handle to the temp buffer.
Definition: cairo_gal.h:478
Auxiliary rendering target (noncached)
Definition: definitions.h:49
Items that may change while the view stays the same (noncached)
Definition: definitions.h:50
bool m_validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:481
Main rendering target (cached)
Definition: definitions.h:48
Temporary target for drawing in separate layer.
Definition: definitions.h:51
unsigned int m_mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:476
std::shared_ptr< CAIRO_COMPOSITOR > m_compositor
Object for layers compositing.
Definition: cairo_gal.h:475
unsigned int m_overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:477

References m_compositor, m_currentTarget, m_isInitialized, m_mainBuffer, m_overlayBuffer, m_tempBuffer, m_validCompositor, KIGFX::CAIRO_GAL_BASE::storePath(), KIGFX::TARGET_CACHED, KIGFX::TARGET_NONCACHED, KIGFX::TARGET_OVERLAY, and KIGFX::TARGET_TEMP.

Referenced by CAIRO_GAL(), StartDiffLayer(), and StartNegativesLayer().

◆ SetTextAttributes()

void GAL::SetTextAttributes ( const EDA_TEXT aText)
virtualinherited

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

Parameters
aTextis the text item.

Definition at line 155 of file graphics_abstraction_layer.cpp.

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

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

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

◆ SetTextMirrored()

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

◆ SetVerticalJustify()

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

Set the vertical justify for text drawing.

Parameters
aVerticalJustifyis the vertical justify value.

Definition at line 468 of file graphics_abstraction_layer.h.

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

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

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

◆ SetWorldScreenMatrix()

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

Set the world <-> screen transformation matrix.

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

Definition at line 604 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_worldScreenMatrix.

◆ SetWorldUnitLength()

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

Set the unit length.

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

Parameters
aWorldUnitLengthis the world Unit length.

Definition at line 623 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_worldUnitLength.

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

◆ SetZoomFactor()

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

Set the zoom factor of the scene.

Parameters
aZoomFactoris the zoom factor.

Definition at line 673 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_zoomFactor.

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

◆ Show()

bool CAIRO_GAL::Show ( bool  aShow)
overridevirtual

Show/hide the GAL canvas.

Reimplemented from KIGFX::GAL.

Definition at line 1397 of file cairo_gal.cpp.

1398 {
1399  bool s = wxWindow::Show( aShow );
1400 
1401  if( aShow )
1402  wxWindow::Raise();
1403 
1404  return s;
1405 }

◆ skipMouseEvent()

void CAIRO_GAL::skipMouseEvent ( wxMouseEvent &  aEvent)

Mouse event handler, forwards the event to the child.

Parameters
aEventis the mouse event to be forwarded.

Definition at line 1560 of file cairo_gal.cpp.

1561 {
1562  // Post the mouse event to the event listener registered in constructor, if any
1563  if( m_mouseListener )
1564  wxPostEvent( m_mouseListener, aEvent );
1565 }
wxEvtHandler * m_mouseListener
Mouse listener.
Definition: cairo_gal.h:485

References m_mouseListener.

Referenced by CAIRO_GAL().

◆ StartDiffLayer()

void CAIRO_GAL::StartDiffLayer ( )
overridevirtual

Begins rendering of a differential layer.

Used by gerbview's differential mode.

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

Reimplemented from KIGFX::GAL.

Definition at line 940 of file cairo_gal.cpp.

941 {
944 }
void ClearTarget(RENDER_TARGET aTarget) override
Clear the target for rendering.
Definition: cairo_gal.cpp:1452
void SetTarget(RENDER_TARGET aTarget) override
Set the target for rendering.
Definition: cairo_gal.cpp:1422
Temporary target for drawing in separate layer.
Definition: definitions.h:51

References ClearTarget(), SetTarget(), and KIGFX::TARGET_TEMP.

◆ StartNegativesLayer()

void CAIRO_GAL::StartNegativesLayer ( )
overridevirtual

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

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

Reimplemented from KIGFX::GAL.

Definition at line 953 of file cairo_gal.cpp.

954 {
957 }
void ClearTarget(RENDER_TARGET aTarget) override
Clear the target for rendering.
Definition: cairo_gal.cpp:1452
void SetTarget(RENDER_TARGET aTarget) override
Set the target for rendering.
Definition: cairo_gal.cpp:1422
Temporary target for drawing in separate layer.
Definition: definitions.h:51

References ClearTarget(), SetTarget(), and KIGFX::TARGET_TEMP.

◆ storePath()

void CAIRO_GAL_BASE::storePath ( )
protectedinherited

Store the actual path.

Definition at line 1106 of file cairo_gal.cpp.

1107 {
1108  if( m_isElementAdded )
1109  {
1110  m_isElementAdded = false;
1111 
1112  if( !m_isGrouping )
1113  {
1114  if( m_isFillEnabled )