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
 
void endDrawing () override
 
void initSurface ()
 Prepare Cairo surfaces for drawing. More...
 
void deinitSurface ()
 Destroy Cairo surfaces when are not needed anymore. More...
 
void allocateBitmaps ()
 Allocate the bitmaps for drawing. More...
 
void deleteBitmaps ()
 Allocate the bitmaps for drawing. More...
 
void setCompositor ()
 Prepare the compositor. More...
 
void onPaint (wxPaintEvent &aEvent)
 Paint event handler. More...
 
void skipMouseEvent (wxMouseEvent &aEvent)
 Mouse event handler, forwards the event to the child. More...
 
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...
 

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 lockContext (int aClientCookie)
 Use GAL_CONTEXT_LOCKER RAII object. More...
 
virtual void unlockContext (int aClientCookie)
 
virtual void beginUpdate ()
 Enable item update mode. More...
 
virtual void endUpdate ()
 Disable item update mode. More...
 
void computeWorldScale ()
 Compute the scaling factor for the world->screen matrix. More...
 
double computeMinGridSpacing () const
 compute minimum grid spacing from the grid settings More...
 
COLOR4D getCursorColor () const
 Get the actual cursor color to draw. More...
 
void OnGalDisplayOptionsChanged (const GAL_DISPLAY_OPTIONS &aOptions) override
 Handler for observer settings changes. More...
 

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

1254  :
1255  CAIRO_GAL_BASE( aDisplayOptions ),
1256  wxWindow( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxEXPAND, aName )
1257 {
1258  // Initialise compositing state
1259  m_mainBuffer = 0;
1260  m_overlayBuffer = 0;
1261  m_tempBuffer = 0;
1262  m_savedBuffer = 0;
1263  m_validCompositor = false;
1265 
1266  m_bitmapBuffer = nullptr;
1267  m_wxOutput = nullptr;
1268 
1269  m_parentWindow = aParent;
1270  m_mouseListener = aMouseListener;
1271  m_paintListener = aPaintListener;
1272 
1273  // Connect the native cursor handler
1274  Connect( wxEVT_SET_CURSOR, wxSetCursorEventHandler( CAIRO_GAL::onSetNativeCursor ), nullptr,
1275  this );
1276 
1277  // Connecting the event handlers
1278  Connect( wxEVT_PAINT, wxPaintEventHandler( CAIRO_GAL::onPaint ) );
1279 
1280  // Mouse events are skipped to the parent
1281  Connect( wxEVT_MOTION, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1282  Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1283  Connect( wxEVT_LEFT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1284  Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1285  Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1286  Connect( wxEVT_MIDDLE_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1287  Connect( wxEVT_MIDDLE_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1288  Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1289  Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1290  Connect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1291  Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1292 #if defined _WIN32 || defined _WIN64
1293  Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1294 #endif
1295 
1296  SetSize( aParent->GetClientSize() );
1297  m_screenSize = VECTOR2I( aParent->GetClientSize() );
1298 
1299  // Allocate memory for pixel storage
1300  allocateBitmaps();
1301 
1302  m_isInitialized = false;
1303 }
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:1546
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:623
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:1599
void SetTarget(RENDER_TARGET aTarget) override
Set the target for rendering.
Definition: cairo_gal.cpp:1414
void skipMouseEvent(wxMouseEvent &aEvent)
Mouse event handler, forwards the event to the child.
Definition: cairo_gal.cpp:1552
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:1501
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 1306 of file cairo_gal.cpp.

1307 {
1308  deleteBitmaps();
1309 }
void deleteBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1520

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

1502 {
1504 
1505  while( ( ( m_wxBufferWidth * 3 ) % 4 ) != 0 )
1506  m_wxBufferWidth++;
1507 
1508  // Create buffer, use the system independent Cairo context backend
1509  m_stride = cairo_format_stride_for_width( GAL_FORMAT, m_wxBufferWidth );
1511 
1512  wxASSERT( m_bitmapBuffer == nullptr );
1513  m_bitmapBuffer = new unsigned char[m_bufferSize * 4];
1514 
1515  wxASSERT( m_wxOutput == nullptr );
1516  m_wxOutput = new unsigned char[m_wxBufferWidth * 3 * m_screenSize.y];
1517 }
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

Reimplemented from KIGFX::CAIRO_GAL_BASE.

Definition at line 1312 of file cairo_gal.cpp.

1313 {
1314  initSurface();
1315 
1317 
1318  if( !m_validCompositor )
1319  setCompositor();
1320 
1321  m_compositor->SetMainContext( m_context );
1322  m_compositor->SetBuffer( m_mainBuffer );
1323 }
void initSurface()
Prepare Cairo surfaces for drawing.
Definition: cairo_gal.cpp:1466
void setCompositor()
Prepare the compositor.
Definition: cairo_gal.cpp:1530
cairo_t * m_context
Cairo image.
Definition: cairo_gal.h:342
bool m_validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:481
void beginDrawing() override
Definition: cairo_gal.cpp:92
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 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 1400 of file cairo_gal.cpp.

1401 {
1402  initSurface();
1403  return CAIRO_GAL_BASE::BeginGroup();
1404 }
void initSurface()
Prepare Cairo surfaces for drawing.
Definition: cairo_gal.cpp:1466
int BeginGroup() override
Begin a group.
Definition: cairo_gal.cpp:761

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

1097 {}

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

◆ BitmapText()

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

Draw a text using a bitmap font.

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

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

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 361 of file graphics_abstraction_layer.h.

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

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

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

◆ blitCursor()

void CAIRO_GAL_BASE::blitCursor ( wxMemoryDC &  clientDC)
protectedinherited

Blit cursor into the current screen.

Definition at line 1147 of file cairo_gal.cpp.

1148 {
1149  if( !IsCursorEnabled() )
1150  return;
1151 
1153  const COLOR4D cColor = getCursorColor();
1154  const int cursorSize = m_fullscreenCursor ? 8000 : 80;
1155 
1156  wxColour color( cColor.r * cColor.a * 255, cColor.g * cColor.a * 255, cColor.b * cColor.a * 255,
1157  255 );
1158  clientDC.SetPen( wxPen( color ) );
1159  clientDC.DrawLine( p.x - cursorSize / 2, p.y, p.x + cursorSize / 2, p.y );
1160  clientDC.DrawLine( p.x, p.y - cursorSize / 2, p.x, p.y + cursorSize / 2 );
1161 }
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:378
double b
Blue component.
Definition: color4d.h:379
VECTOR2D m_cursorPosition
Current cursor position (world coordinates)
double a
Alpha component.
Definition: color4d.h:380
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:377
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 877 of file cairo_gal.cpp.

878 {
879  storePath();
880 
881  for( auto it = m_groups[aGroupNumber].begin(); it != m_groups[aGroupNumber].end(); ++it )
882  {
883  if( it->m_Command == CMD_SET_FILLCOLOR || it->m_Command == CMD_SET_STROKECOLOR )
884  {
885  it->m_Argument.DblArg[0] = aNewColor.r;
886  it->m_Argument.DblArg[1] = aNewColor.g;
887  it->m_Argument.DblArg[2] = aNewColor.b;
888  it->m_Argument.DblArg[3] = aNewColor.a;
889  }
890  }
891 }
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:1098
double g
Green component.
Definition: color4d.h:378
double b
Blue component.
Definition: color4d.h:379
double a
Alpha component.
Definition: color4d.h:380
double r
Red component.
Definition: color4d.h:377

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

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

◆ ClearCache()

void CAIRO_GAL_BASE::ClearCache ( )
overridevirtualinherited

Delete all data created during caching of graphic items.

Reimplemented from KIGFX::GAL.

Definition at line 919 of file cairo_gal.cpp.

920 {
921  for( auto it = m_groups.begin(); it != m_groups.end(); )
922  DeleteGroup( ( it++ )->first );
923 }
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:901

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

548 {
549  cairo_set_source_rgb( m_currentContext, m_clearColor.r, m_clearColor.g, m_clearColor.b );
550  cairo_rectangle( m_currentContext, 0.0, 0.0, m_screenSize.x, m_screenSize.y );
551  cairo_fill( m_currentContext );
552 }
double g
Green component.
Definition: color4d.h:378
double b
Blue component.
Definition: color4d.h:379
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
double r
Red component.
Definition: color4d.h:377
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 1444 of file cairo_gal.cpp.

1445 {
1446  // Save the current state
1447  unsigned int currentBuffer = m_compositor->GetBuffer();
1448 
1449  switch( aTarget )
1450  {
1451  // Cached and noncached items are rendered to the same buffer
1452  default:
1453  case TARGET_CACHED:
1454  case TARGET_NONCACHED: m_compositor->SetBuffer( m_mainBuffer ); break;
1455  case TARGET_OVERLAY: m_compositor->SetBuffer( m_overlayBuffer ); break;
1456  case TARGET_TEMP: m_compositor->SetBuffer( m_tempBuffer ); break;
1457  }
1458 
1459  m_compositor->ClearBuffer( COLOR4D::BLACK );
1460 
1461  // Restore the previous state
1462  m_compositor->SetBuffer( currentBuffer );
1463 }
static const COLOR4D BLACK
Definition: color4d.h:387
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 1111 of file graphics_abstraction_layer.h.

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

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

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

◆ ComputeWorldScreenMatrix()

void 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:622
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 1487 of file cairo_gal.cpp.

1488 {
1489  if( !m_isInitialized )
1490  return;
1491 
1492  cairo_destroy( m_context );
1493  m_context = nullptr;
1494  cairo_surface_destroy( m_surface );
1495  m_surface = nullptr;
1496 
1497  m_isInitialized = false;
1498 }
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 1520 of file cairo_gal.cpp.

1521 {
1522  delete[] m_bitmapBuffer;
1523  m_bitmapBuffer = nullptr;
1524 
1525  delete[] m_wxOutput;
1526  m_wxOutput = nullptr;
1527 }
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 901 of file cairo_gal.cpp.

902 {
903  storePath();
904 
905  // Delete the Cairo paths
906  std::deque<GROUP_ELEMENT>::iterator it, end;
907 
908  for( it = m_groups[aGroupNumber].begin(), end = m_groups[aGroupNumber].end(); it != end; ++it )
909  {
910  if( it->m_Command == CMD_FILL_PATH || it->m_Command == CMD_STROKE_PATH )
911  cairo_path_destroy( it->m_CairoPath );
912  }
913 
914  // Delete the group
915  m_groups.erase( aGroupNumber );
916 }
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:1098

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

312 {
313  syncLineWidth();
314 
315  // calculate start and end arc angles according to the rotation transform matrix
316  // and normalize:
317  arc_angles_xform_and_normalize( aStartAngle, aEndAngle );
318 
319  double r = xform( aRadius );
320 
321  // N.B. This is backwards. We set this because we want to adjust the center
322  // point that changes both endpoints. In the worst case, this is twice as far.
323  // We cannot adjust radius or center based on the other because this causes the
324  // whole arc to change position/size
325  m_lineWidthIsOdd = !( static_cast<int>( aRadius ) % 2 );
326 
327  auto mid = roundp( xform( aCenterPoint ) );
328 
329  cairo_set_line_width( m_currentContext, m_lineWidthInPixels );
330  cairo_new_sub_path( m_currentContext );
331 
332  if( m_isFillEnabled )
333  cairo_move_to( m_currentContext, mid.x, mid.y );
334 
335  cairo_arc( m_currentContext, mid.x, mid.y, r, aStartAngle, aEndAngle );
336 
337  if( m_isFillEnabled )
338  cairo_close_path( m_currentContext );
339 
340  flushPath();
341 
342  m_isElementAdded = true;
343 }
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 346 of file cairo_gal.cpp.

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

1002 {
1003  syncLineWidth();
1004 
1005  VECTOR2D p0 = roundp( xform( aStartPoint ) );
1006  VECTOR2D p1 = roundp( xform( aEndPoint ) );
1007  VECTOR2D org = roundp( xform( VECTOR2D( 0.0, 0.0 ) ) ); // Axis origin = 0,0 coord
1008 
1009  cairo_set_source_rgba( m_currentContext, m_axesColor.r, m_axesColor.g, m_axesColor.b,
1010  m_axesColor.a );
1011  cairo_move_to( m_currentContext, p0.x, org.y );
1012  cairo_line_to( m_currentContext, p1.x, org.y );
1013  cairo_move_to( m_currentContext, org.x, p0.y );
1014  cairo_line_to( m_currentContext, org.x, p1.y );
1015  cairo_stroke( m_currentContext );
1016 }
double g
Green component.
Definition: color4d.h:378
double b
Blue component.
Definition: color4d.h:379
double a
Alpha component.
Definition: color4d.h:380
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp: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:377

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

468 {
469  cairo_save( m_currentContext );
470 
471  // We have to calculate the pixel size in users units to draw the image.
472  // m_worldUnitLength is a factor used for converting IU to inches
473  double scale = 1.0 / ( aBitmap.GetPPI() * m_worldUnitLength );
474 
475  // The position of the bitmap is the bitmap center.
476  // move the draw origin to the top left bitmap corner:
477  int w = aBitmap.GetSizePixels().x;
478  int h = aBitmap.GetSizePixels().y;
479 
480  cairo_set_matrix( m_currentContext, &m_currentWorld2Screen );
481  cairo_scale( m_currentContext, scale, scale );
482  cairo_translate( m_currentContext, -w / 2.0, -h / 2.0 );
483 
484  cairo_new_path( m_currentContext );
485  cairo_surface_t* image = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, w, h );
486  cairo_surface_flush( image );
487 
488  unsigned char* pix_buffer = cairo_image_surface_get_data( image );
489 
490  // The pixel buffer of the initial bitmap:
491  const wxImage& bm_pix_buffer = *aBitmap.GetImageData();
492 
493  uint32_t mask_color = ( bm_pix_buffer.GetMaskRed() << 16 )
494  + ( bm_pix_buffer.GetMaskGreen() << 8 ) + ( bm_pix_buffer.GetMaskBlue() );
495 
496  // Copy the source bitmap to the cairo bitmap buffer.
497  // In cairo bitmap buffer, a ARGB32 bitmap is an ARGB pixel packed into a uint_32
498  // 24 low bits only are used for color, top 8 are transparency.
499  for( int row = 0; row < h; row++ )
500  {
501  for( int col = 0; col < w; col++ )
502  {
503  // Build the RGB24 pixel:
504  uint32_t pixel = bm_pix_buffer.GetRed( col, row ) << 16;
505  pixel += bm_pix_buffer.GetGreen( col, row ) << 8;
506  pixel += bm_pix_buffer.GetBlue( col, row );
507 
508  if( bm_pix_buffer.HasAlpha() )
509  pixel += bm_pix_buffer.GetAlpha( col, row ) << 24;
510  else if( bm_pix_buffer.HasMask() && pixel == mask_color )
511  pixel += ( wxALPHA_TRANSPARENT << 24 );
512  else
513  pixel += ( wxALPHA_OPAQUE << 24 );
514 
515  // Write the pixel to the cairo image buffer:
516  uint32_t* pix_ptr = (uint32_t*) pix_buffer;
517  *pix_ptr = pixel;
518  pix_buffer += 4;
519  }
520  }
521 
522  cairo_surface_mark_dirty( image );
523  cairo_set_source_surface( m_currentContext, image, 0, 0 );
524  cairo_paint( m_currentContext );
525 
526  // store the image handle so it can be destroyed later
527  m_imageSurfaces.push_back( image );
528 
529  m_isElementAdded = true;
530 
531  cairo_restore( m_currentContext );
532 }
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 294 of file cairo_gal.cpp.

295 {
296  syncLineWidth();
297 
298  VECTOR2D c = roundp( xform( aCenterPoint ) );
299  double r = ::roundp( xform( aRadius ) );
300 
301  cairo_set_line_width( m_currentContext, std::min( 2.0 * r, m_lineWidthInPixels ) );
302  cairo_new_sub_path( m_currentContext );
303  cairo_arc( m_currentContext, c.x, c.y, r, 0.0, 2 * M_PI );
304  cairo_close_path( m_currentContext );
305  flushPath();
306  m_isElementAdded = true;
307 }
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 958 of file cairo_gal.cpp.

959 {
960  m_cursorPosition = aCursorPosition;
961 }
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 445 of file cairo_gal.cpp.

448 {
449  // Note: aFilterValue is not used because the cubic Bezier curve is
450  // supported by Cairo.
451  syncLineWidth();
452 
453  const VECTOR2D sp = roundp( xform( aStartPoint ) );
454  const VECTOR2D cpa = roundp( xform( aControlPointA ) );
455  const VECTOR2D cpb = roundp( xform( aControlPointB ) );
456  const VECTOR2D ep = roundp( xform( aEndPoint ) );
457 
458  cairo_move_to( m_currentContext, sp.x, sp.y );
459  cairo_curve_to( m_currentContext, cpa.x, cpa.y, cpb.x, cpb.y, ep.x, ep.y );
460  cairo_line_to( m_currentContext, ep.x, ep.y );
461 
462  flushPath();
463  m_isElementAdded = true;
464 }
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 1605 of file cairo_gal.cpp.

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

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

1034 {
1035  syncLineWidth();
1036  VECTOR2D offset( 0, 0 );
1037  double size = 2.0 * m_lineWidthInPixels + 0.5;
1038 
1039  VECTOR2D p0 = roundp( xform( aPoint ) ) - VECTOR2D( size, 0 ) + offset;
1040  VECTOR2D p1 = roundp( xform( aPoint ) ) + VECTOR2D( size, 0 ) + offset;
1041  VECTOR2D p2 = roundp( xform( aPoint ) ) - VECTOR2D( 0, size ) + offset;
1042  VECTOR2D p3 = roundp( xform( aPoint ) ) + VECTOR2D( 0, size ) + offset;
1043 
1044  cairo_set_source_rgba( m_currentContext, m_gridColor.r, m_gridColor.g, m_gridColor.b,
1045  m_gridColor.a );
1046  cairo_move_to( m_currentContext, p0.x, p0.y );
1047  cairo_line_to( m_currentContext, p1.x, p1.y );
1048  cairo_move_to( m_currentContext, p2.x, p2.y );
1049  cairo_line_to( m_currentContext, p3.x, p3.y );
1050  cairo_stroke( m_currentContext );
1051 }
double m_lineWidthInPixels
Definition: cairo_gal.h:335
double g
Green component.
Definition: color4d.h:378
double b
Blue component.
Definition: color4d.h:379
COLOR4D m_gridColor
Color of the grid.
double a
Alpha component.
Definition: color4d.h:380
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp: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:377

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

1020 {
1021  syncLineWidth();
1022  VECTOR2D p0 = roundp( xform( aStartPoint ) );
1023  VECTOR2D p1 = roundp( xform( aEndPoint ) );
1024 
1025  cairo_set_source_rgba( m_currentContext, m_gridColor.r, m_gridColor.g, m_gridColor.b,
1026  m_gridColor.a );
1027  cairo_move_to( m_currentContext, p0.x, p0.y );
1028  cairo_line_to( m_currentContext, p1.x, p1.y );
1029  cairo_stroke( m_currentContext );
1030 }
double g
Green component.
Definition: color4d.h:378
double b
Blue component.
Definition: color4d.h:379
COLOR4D m_gridColor
Color of the grid.
double a
Alpha component.
Definition: color4d.h:380
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:377

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

1055 {
1056  VECTOR2D p = roundp( xform( aPoint ) );
1057 
1058  double sw = std::max( 1.0, aWidth );
1059  double sh = std::max( 1.0, aHeight );
1060 
1061  cairo_set_source_rgba( m_currentContext, m_gridColor.r, m_gridColor.g, m_gridColor.b,
1062  m_gridColor.a );
1063  cairo_rectangle( m_currentContext, p.x - std::floor( sw / 2 ) - 0.5,
1064  p.y - std::floor( sh / 2 ) - 0.5, sw, sh );
1065 
1066  cairo_fill( m_currentContext );
1067 }
double g
Green component.
Definition: color4d.h:378
double b
Blue component.
Definition: color4d.h:379
COLOR4D m_gridColor
Color of the grid.
double a
Alpha component.
Definition: color4d.h:380
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:377

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

785 {
786  // This method implements a small Virtual Machine - all stored commands
787  // are executed; nested calling is also possible
788 
789  storePath();
790 
791  for( auto it = m_groups[aGroupNumber].begin(); it != m_groups[aGroupNumber].end(); ++it )
792  {
793  switch( it->m_Command )
794  {
795  case CMD_SET_FILL:
796  m_isFillEnabled = it->m_Argument.BoolArg;
797  break;
798 
799  case CMD_SET_STROKE:
800  m_isStrokeEnabled = it->m_Argument.BoolArg;
801  break;
802 
803  case CMD_SET_FILLCOLOR:
804  m_fillColor = COLOR4D( it->m_Argument.DblArg[0], it->m_Argument.DblArg[1],
805  it->m_Argument.DblArg[2], it->m_Argument.DblArg[3] );
806  break;
807 
808  case CMD_SET_STROKECOLOR:
809  m_strokeColor = COLOR4D( it->m_Argument.DblArg[0], it->m_Argument.DblArg[1],
810  it->m_Argument.DblArg[2], it->m_Argument.DblArg[3] );
811  break;
812 
813  case CMD_SET_LINE_WIDTH:
814  {
815  // Make lines appear at least 1 pixel wide, no matter of zoom
816  double x = 1.0, y = 1.0;
817  cairo_device_to_user_distance( m_currentContext, &x, &y );
818  double minWidth = std::min( fabs( x ), fabs( y ) );
819  cairo_set_line_width( m_currentContext,
820  std::max( it->m_Argument.DblArg[0], minWidth ) );
821  break;
822  }
823 
824 
825  case CMD_STROKE_PATH:
826  cairo_set_source_rgba( m_currentContext, m_strokeColor.r, m_strokeColor.g,
828  cairo_append_path( m_currentContext, it->m_CairoPath );
829  cairo_stroke( m_currentContext );
830  break;
831 
832  case CMD_FILL_PATH:
833  cairo_set_source_rgba( m_currentContext, m_fillColor.r, m_fillColor.g, m_fillColor.b,
834  m_strokeColor.a );
835  cairo_append_path( m_currentContext, it->m_CairoPath );
836  cairo_fill( m_currentContext );
837  break;
838 
839  /*
840  case CMD_TRANSFORM:
841  cairo_matrix_t matrix;
842  cairo_matrix_init( &matrix, it->argument.DblArg[0], it->argument.DblArg[1],
843  it->argument.DblArg[2], it->argument.DblArg[3],
844  it->argument.DblArg[4], it->argument.DblArg[5] );
845  cairo_transform( m_currentContext, &matrix );
846  break;
847  */
848 
849  case CMD_ROTATE:
850  cairo_rotate( m_currentContext, it->m_Argument.DblArg[0] );
851  break;
852 
853  case CMD_TRANSLATE:
854  cairo_translate( m_currentContext, it->m_Argument.DblArg[0], it->m_Argument.DblArg[1] );
855  break;
856 
857  case CMD_SCALE:
858  cairo_scale( m_currentContext, it->m_Argument.DblArg[0], it->m_Argument.DblArg[1] );
859  break;
860 
861  case CMD_SAVE:
862  cairo_save( m_currentContext );
863  break;
864 
865  case CMD_RESTORE:
866  cairo_restore( m_currentContext );
867  break;
868 
869  case CMD_CALL_GROUP:
870  DrawGroup( it->m_Argument.IntArg );
871  break;
872  }
873  }
874 }
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:1098
double g
Green component.
Definition: color4d.h:378
Enable/disable filling.
Definition: cairo_gal.h:298
double b
Blue component.
Definition: color4d.h:379
double a
Alpha component.
Definition: color4d.h:380
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:784
double r
Red component.
Definition: color4d.h:377
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 1164 of file cairo_gal.cpp.

1165 {
1166  wxCHECK( aPointList.size() > 1, /* void */ );
1167 
1168  // Iterate over the point list and draw the segments
1169  std::deque<VECTOR2D>::const_iterator it = aPointList.begin();
1170 
1171  syncLineWidth();
1172 
1173  const VECTOR2D p = roundp( xform( it->x, it->y ) );
1174 
1175  cairo_move_to( m_currentContext, p.x, p.y );
1176 
1177  for( ++it; it != aPointList.end(); ++it )
1178  {
1179  const VECTOR2D p2 = roundp( xform( it->x, it->y ) );
1180 
1181  cairo_line_to( m_currentContext, p2.x, p2.y );
1182  }
1183 
1184  flushPath();
1185  m_isElementAdded = true;
1186 }
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 1189 of file cairo_gal.cpp.

1190 {
1191  wxCHECK( aListSize > 1, /* void */ );
1192 
1193  // Iterate over the point list and draw the segments
1194  const VECTOR2D* ptr = aPointList;
1195 
1196  syncLineWidth();
1197 
1198  const VECTOR2D p = roundp( xform( ptr->x, ptr->y ) );
1199  cairo_move_to( m_currentContext, p.x, p.y );
1200 
1201  for( int i = 1; i < aListSize; ++i )
1202  {
1203  ++ptr;
1204  const VECTOR2D p2 = roundp( xform( ptr->x, ptr->y ) );
1205  cairo_line_to( m_currentContext, p2.x, p2.y );
1206  }
1207 
1208  flushPath();
1209  m_isElementAdded = true;
1210 }
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 1213 of file cairo_gal.cpp.

1214 {
1215  wxCHECK( aLineChain.PointCount() > 1, /* void */ );
1216 
1217  syncLineWidth();
1218 
1219  auto numPoints = aLineChain.PointCount();
1220 
1221  if( aLineChain.IsClosed() )
1222  numPoints += 1;
1223 
1224  const VECTOR2I start = aLineChain.CPoint( 0 );
1225  const VECTOR2D p = roundp( xform( start.x, start.y ) );
1226  cairo_move_to( m_currentContext, p.x, p.y );
1227 
1228  for( int i = 1; i < numPoints; ++i )
1229  {
1230  const VECTOR2I& pw = aLineChain.CPoint( i );
1231  const VECTOR2D ps = roundp( xform( pw.x, pw.y ) );
1232  cairo_line_to( m_currentContext, ps.x, ps.y );
1233  }
1234 
1235  flushPath();
1236  m_isElementAdded = true;
1237 }
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:1164

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:1164

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

433 {
434  for( int i = 0; i < aPolySet.OutlineCount(); ++i )
435  drawPoly( aPolySet.COutline( i ) );
436 }
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:1164
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 439 of file cairo_gal.cpp.

440 {
441  drawPoly( aPolygon );
442 }
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:1164

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:1164

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:1164

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:1164

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

411 {
412  // Calculate the diagonal points
413  syncLineWidth();
414 
415  const VECTOR2D p0 = roundp( xform( aStartPoint ) );
416  const VECTOR2D p1 = roundp( xform( VECTOR2D( aEndPoint.x, aStartPoint.y ) ) );
417  const VECTOR2D p2 = roundp( xform( aEndPoint ) );
418  const VECTOR2D p3 = roundp( xform( VECTOR2D( aStartPoint.x, aEndPoint.y ) ) );
419 
420  // The path is composed from 4 segments
421  cairo_move_to( m_currentContext, p0.x, p0.y );
422  cairo_line_to( m_currentContext, p1.x, p1.y );
423  cairo_line_to( m_currentContext, p2.x, p2.y );
424  cairo_line_to( m_currentContext, p3.x, p3.y );
425  cairo_close_path( m_currentContext );
426  flushPath();
427 
428  m_isElementAdded = true;
429 }
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:330
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp: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  auto pa0 = xform( aStartPoint + VECTOR2D( aWidth * ca, aWidth * sa ) );
266  auto pa1 = xform( aStartPoint - VECTOR2D( aWidth * ca, aWidth * sa ) );
267  auto pb0 = xform( aEndPoint + VECTOR2D( aWidth * ca, aWidth * sa ) );
268  auto pb1 = xform( aEndPoint - VECTOR2D( aWidth * ca, aWidth * sa ) );
269  auto pa = xform( aStartPoint );
270  auto pb = xform( aEndPoint );
271  auto rb = ( pa0 - pa ).EuclideanNorm();
272 
273  cairo_set_source_rgba( m_currentContext, m_strokeColor.r, m_strokeColor.g, m_strokeColor.b,
274  m_strokeColor.a );
275 
276  cairo_move_to( m_currentContext, pa0.x, pa0.y );
277  cairo_line_to( m_currentContext, pb0.x, pb0.y );
278 
279  cairo_move_to( m_currentContext, pa1.x, pa1.y );
280  cairo_line_to( m_currentContext, pb1.x, pb1.y );
281 
282  cairo_arc( m_currentContext, pb.x, pb.y, rb, lineAngle - M_PI / 2.0,
283  lineAngle + M_PI / 2.0 );
284  cairo_arc( m_currentContext, pa.x, pa.y, rb, lineAngle + M_PI / 2.0,
285  lineAngle + 3.0 * M_PI / 2.0 );
286 
287  flushPath();
288  }
289 
290  m_isElementAdded = true;
291 }
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:378
double b
Blue component.
Definition: color4d.h:379
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:330
double a
Alpha component.
Definition: color4d.h:380
COLOR4D m_strokeColor
The color of the outlines.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:341
const double xform(double x)
Definition: cairo_gal.cpp: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:621
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:212
double r
Red component.
Definition: color4d.h:377

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

965 {
966 }

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

940 {
941  m_compositor->DrawBuffer( m_tempBuffer, m_mainBuffer, CAIRO_OPERATOR_ADD );
942 }
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

Reimplemented from KIGFX::CAIRO_GAL_BASE.

Definition at line 1326 of file cairo_gal.cpp.

1327 {
1329 
1330  // Merge buffers on the screen
1331  m_compositor->DrawBuffer( m_mainBuffer );
1332  m_compositor->DrawBuffer( m_overlayBuffer );
1333 
1334  // Now translate the raw context data from the format stored
1335  // by cairo into a format understood by wxImage.
1336  pixman_image_t* dstImg = pixman_image_create_bits(
1337  wxPlatformInfo::Get().GetEndianness() == wxENDIAN_LITTLE ? PIXMAN_b8g8r8
1338  : PIXMAN_r8g8b8,
1339  m_screenSize.x, m_screenSize.y, (uint32_t*) m_wxOutput, m_wxBufferWidth * 3 );
1340  pixman_image_t* srcImg =
1341  pixman_image_create_bits( PIXMAN_a8r8g8b8, m_screenSize.x, m_screenSize.y,
1342  (uint32_t*) m_bitmapBuffer, m_wxBufferWidth * 4 );
1343 
1344  pixman_image_composite( PIXMAN_OP_SRC, srcImg, nullptr, dstImg, 0, 0, 0, 0, 0, 0,
1346 
1347  // Free allocated memory
1348  pixman_image_unref( srcImg );
1349  pixman_image_unref( dstImg );
1350 
1351  wxImage img( m_wxBufferWidth, m_screenSize.y, m_wxOutput, true );
1352  wxBitmap bmp( img );
1353  wxMemoryDC mdc( bmp );
1354  wxClientDC clientDC( this );
1355 
1356  // Now it is the time to blit the mouse cursor
1357  blitCursor( mdc );
1358  clientDC.Blit( 0, 0, m_screenSize.x, m_screenSize.y, &mdc, 0, 0, wxCOPY );
1359 
1360  deinitSurface();
1361 }
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:1487
unsigned char * m_bitmapBuffer
Storage of the Cairo image.
Definition: cairo_gal.h:491
void endDrawing() override
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:1147

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

1408 {
1410  deinitSurface();
1411 }
void EndGroup() override
End the group.
Definition: cairo_gal.cpp:777
void deinitSurface()
Destroy Cairo surfaces when are not needed anymore.
Definition: cairo_gal.cpp:1487

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

953 {
954  m_compositor->DrawBuffer( m_tempBuffer, m_mainBuffer, CAIRO_OPERATOR_OVER );
955 }
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 1100 of file graphics_abstraction_layer.h.

1100 {}

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

◆ Flush()

void CAIRO_GAL_BASE::Flush ( )
overridevirtualinherited

Force all remaining objects to be drawn.

Reimplemented from KIGFX::GAL.

Definition at line 541 of file cairo_gal.cpp.

542 {
543  storePath();
544 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1098

References KIGFX::CAIRO_GAL_BASE::storePath().

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

◆ flushPath()

void CAIRO_GAL_BASE::flushPath ( )
protectedinherited

Definition at line 1070 of file cairo_gal.cpp.

1071 {
1072  if( m_isFillEnabled )
1073  {
1074  cairo_set_source_rgba( m_currentContext, m_fillColor.r, m_fillColor.g, m_fillColor.b,
1075  m_fillColor.a );
1076 
1077  if( m_isStrokeEnabled )
1078  {
1079  cairo_set_line_width( m_currentContext, m_lineWidthInPixels );
1080  cairo_fill_preserve( m_currentContext );
1081  }
1082  else
1083  {
1084  cairo_fill( m_currentContext );
1085  }
1086  }
1087 
1088  if( m_isStrokeEnabled )
1089  {
1090  cairo_set_line_width( m_currentContext, m_lineWidthInPixels );
1091  cairo_set_source_rgba( m_currentContext, m_strokeColor.r, m_strokeColor.g, m_strokeColor.b,
1092  m_strokeColor.a );
1093  cairo_stroke( m_currentContext );
1094  }
1095 }
bool m_isFillEnabled
Is filling of graphic objects enabled ?
double m_lineWidthInPixels
Definition: cairo_gal.h:335
double g
Green component.
Definition: color4d.h:378
double b
Blue component.
Definition: color4d.h:379
double a
Alpha component.
Definition: color4d.h:380
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:377

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:622
VECTOR2D m_gridOffset
The grid offset to compensate cursor position.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73

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

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

◆ GetGridSize()

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

◆ GetGridSnapping()

◆ GetGridVisibility()

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

Definition at line 866 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_gridVisibility.

Referenced by EDA_DRAW_PANEL_GAL::SwitchBackend().

◆ GetHorizontalJustify()

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

Return current text horizontal justification setting.

Definition at line 458 of file graphics_abstraction_layer.h.

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

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

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

◆ GetLineWidth()

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

◆ GetLookAtPoint()

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

Get the look at point.

Returns
the look at point.

Definition at line 663 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_lookAtPoint.

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

◆ GetMaxDepth()

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

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

Definition at line 732 of file graphics_abstraction_layer.h.

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

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

◆ GetMinDepth()

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

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

Definition at line 724 of file graphics_abstraction_layer.h.

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

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

Referenced by KIGFX::PREVIEW::RULER_ITEM::ViewDraw(), 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 1240 of file cairo_gal.cpp.

1241 {
1242  wxASSERT_MSG( m_groups.size() < std::numeric_limits<unsigned int>::max(),
1243  wxT( "There are no free slots to store a group" ) );
1244 
1245  while( m_groups.find( m_groupCounter ) != m_groups.end() )
1246  m_groupCounter++;
1247 
1248  return m_groupCounter++;
1249 }
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 1438 of file cairo_gal.cpp.

1439 {
1440  return m_currentTarget;
1441 }
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:622
const VECTOR2D & GetLookAtPoint() const
Get the look at point.
void SetOrigin(const Vec &pos)
Definition: box2.h:193
VECTOR2I m_screenSize
Screen size in screen coordinates.

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

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

◆ GetWorldScale()

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

◆ GetWorldScreenMatrix()

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

Get the world <-> screen transformation matrix.

Returns
the transformation matrix.

Definition at line 584 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_worldScreenMatrix.

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

◆ GetZoomFactor()

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

Get the zoom factor.

Returns
the zoom factor.

Definition at line 683 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_zoomFactor.

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

◆ HasTarget()

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

Return true if the target exists.

Parameters
aTargetis the target to be checked.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 805 of file graphics_abstraction_layer.h.

806  {
807  return true;
808  };

Referenced by EDA_DRAW_PANEL_GAL::DoRePaint().

◆ initSurface()

void CAIRO_GAL::initSurface ( )

Prepare Cairo surfaces for drawing.

Definition at line 1466 of file cairo_gal.cpp.

1467 {
1468  if( m_isInitialized )
1469  return;
1470 
1471  m_surface = cairo_image_surface_create_for_data( m_bitmapBuffer, GAL_FORMAT, m_wxBufferWidth,
1472  m_screenSize.y, m_stride );
1473 
1474  m_context = cairo_create( m_surface );
1475 
1476 #ifdef DEBUG
1477  cairo_status_t status = cairo_status( m_context );
1478  wxASSERT_MSG( status == CAIRO_STATUS_SUCCESS, wxT( "Cairo context creation error" ) );
1479 #endif /* DEBUG */
1480 
1482 
1483  m_isInitialized = true;
1484 }
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)
inlineprotectedvirtualinherited

Use GAL_CONTEXT_LOCKER RAII object.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1091 of file graphics_abstraction_layer.h.

1091 {}

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

◆ OnGalDisplayOptionsChanged()

void GAL::OnGalDisplayOptionsChanged ( const GAL_DISPLAY_OPTIONS aOptions)
overrideprotectedvirtualinherited

Handler for observer settings changes.

Implements KIGFX::GAL_DISPLAY_OPTIONS_OBSERVER.

Definition at line 101 of file graphics_abstraction_layer.cpp.

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

References KIGFX::GAL::updatedGalDisplayOptions().

◆ onPaint()

void CAIRO_GAL::onPaint ( wxPaintEvent &  aEvent)

Paint event handler.

Parameters
aEventis the paint event.

Definition at line 1546 of file cairo_gal.cpp.

1547 {
1548  PostPaint( aEvent );
1549 }
void PostPaint(wxPaintEvent &aEvent)
Post an event to m_paint_listener.
Definition: cairo_gal.cpp:1364

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

1600 {
1601  aEvent.SetCursor( m_currentwxCursor );
1602 }
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 1364 of file cairo_gal.cpp.

1365 {
1366  // posts an event to m_paint_listener to ask for redraw the canvas.
1367  if( m_paintListener )
1368  wxPostEvent( m_paintListener, aEvent );
1369 }
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 969 of file cairo_gal.cpp.

970 {
971  for( _cairo_surface* imageSurface : m_imageSurfaces )
972  cairo_surface_destroy( imageSurface );
973 
974  m_imageSurfaces.clear();
975 
976  ClearScreen();
977 
978  // Compute the world <-> screen transformations
980 
981  cairo_matrix_init( &m_cairoWorldScreenMatrix, m_worldScreenMatrix.m_data[0][0],
984  m_worldScreenMatrix.m_data[1][2] );
985 
986  // we work in screen-space coordinates and do the transforms outside.
987  cairo_identity_matrix( m_context );
988 
989  cairo_matrix_init_identity( &m_currentXform );
990 
991  // Start drawing with a new path
992  cairo_new_path( m_context );
993  m_isElementAdded = true;
994 
996 
997  m_lineWidth = 0;
998 }
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:547
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 1372 of file cairo_gal.cpp.

1373 {
1374  CAIRO_GAL_BASE::ResizeScreen( aWidth, aHeight );
1375 
1376  // Recreate the bitmaps
1377  deleteBitmaps();
1378  allocateBitmaps();
1379 
1380  if( m_validCompositor )
1381  m_compositor->Resize( aWidth, aHeight );
1382 
1383  m_validCompositor = false;
1384 
1385  SetSize( wxSize( aWidth, aHeight ) );
1386 }
void ResizeScreen(int aWidth, int aHeight) override
Resizes the canvas.
Definition: cairo_gal.cpp:535
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:1520
void allocateBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1501

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

740 {
741  storePath();
742 
743  if( m_isGrouping )
744  {
745  GROUP_ELEMENT groupElement;
746  groupElement.m_Command = CMD_RESTORE;
747  m_currentGroup->push_back( groupElement );
748  }
749  else
750  {
751  if( !m_xformStack.empty() )
752  {
753  m_currentXform = m_xformStack.back();
754  m_xformStack.pop_back();
756  }
757  }
758 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1098
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 662 of file cairo_gal.cpp.

663 {
664  storePath();
665 
666  if( m_isGrouping )
667  {
668  GROUP_ELEMENT groupElement;
669  groupElement.m_Command = CMD_ROTATE;
670  groupElement.m_Argument.DblArg[0] = aAngle;
671  m_currentGroup->push_back( groupElement );
672  }
673  else
674  {
675  cairo_matrix_rotate( &m_currentXform, aAngle );
677  }
678 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1098
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 721 of file cairo_gal.cpp.

722 {
723  storePath();
724 
725  if( m_isGrouping )
726  {
727  GROUP_ELEMENT groupElement;
728  groupElement.m_Command = CMD_SAVE;
729  m_currentGroup->push_back( groupElement );
730  }
731  else
732  {
733  m_xformStack.push_back( m_currentXform );
735  }
736 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1098
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 701 of file cairo_gal.cpp.

702 {
703  storePath();
704 
705  if( m_isGrouping )
706  {
707  GROUP_ELEMENT groupElement;
708  groupElement.m_Command = CMD_SCALE;
709  groupElement.m_Argument.DblArg[0] = aScale.x;
710  groupElement.m_Argument.DblArg[1] = aScale.y;
711  m_currentGroup->push_back( groupElement );
712  }
713  else
714  {
715  cairo_matrix_scale( &m_currentXform, aScale.x, aScale.y );
717  }
718 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1098
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 1530 of file cairo_gal.cpp.

1531 {
1532  // Recreate the compositor with the new Cairo context
1535  m_compositor->SetAntialiasingMode( m_options.cairo_antialiasing_mode );
1536 
1537  // Prepare buffers
1538  m_mainBuffer = m_compositor->CreateBuffer();
1539  m_overlayBuffer = m_compositor->CreateBuffer();
1540  m_tempBuffer = m_compositor->CreateBuffer();
1541 
1542  m_validCompositor = true;
1543 }
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 603 of file cairo_gal.cpp.

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

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

◆ SetFlip()

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

Sets flipping of the screen.

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

Definition at line 753 of file graphics_abstraction_layer.h.

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

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

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

◆ SetFontBold()

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

Set bold property of current font.

Parameters
aBoldtells if the font should be bold or not.

Definition at line 423 of file graphics_abstraction_layer.h.

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

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

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

◆ SetFontItalic()

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

Set italic property of current font.

Parameters
aItalictells if the font should be italic or not.

Definition at line 431 of file graphics_abstraction_layer.h.

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

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

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

◆ SetFontUnderlined()

◆ SetGlyphSize()

◆ SetGridColor()

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

Set the grid color.

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

Definition at line 931 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_gridColor.

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

◆ SetGridOrigin()

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

Set the origin point for the grid.

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

Definition at line 879 of file graphics_abstraction_layer.h.

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

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

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

◆ SetGridSize()

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

Set the grid size.

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

Definition at line 904 of file graphics_abstraction_layer.h.

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

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

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

◆ SetGridVisibility()

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

Set the visibility setting of the grid.

Parameters
aVisibilityis the new visibility setting of the grid.

Definition at line 864 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_gridVisibility.

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

◆ SetHorizontalJustify()

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

Set the horizontal justify for text drawing.

Parameters
aHorizontalJustifyis the horizontal justify value.

Definition at line 450 of file graphics_abstraction_layer.h.

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

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

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

◆ SetIsFill()

void CAIRO_GAL_BASE::SetIsFill ( bool  aIsFillEnabled)
overridevirtualinherited

Enable/disable fill.

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

Reimplemented from KIGFX::GAL.

Definition at line 555 of file cairo_gal.cpp.

556 {
557  storePath();
558  m_isFillEnabled = aIsFillEnabled;
559 
560  if( m_isGrouping )
561  {
562  GROUP_ELEMENT groupElement;
563  groupElement.m_Command = CMD_SET_FILL;
564  groupElement.m_Argument.BoolArg = aIsFillEnabled;
565  m_currentGroup->push_back( groupElement );
566  }
567 }
bool m_isFillEnabled
Is filling of graphic objects enabled ?
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1098
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 570 of file cairo_gal.cpp.

571 {
572  storePath();
573  m_isStrokeEnabled = aIsStrokeEnabled;
574 
575  if( m_isGrouping )
576  {
577  GROUP_ELEMENT groupElement;
578  groupElement.m_Command = CMD_SET_STROKE;
579  groupElement.m_Argument.BoolArg = aIsStrokeEnabled;
580  m_currentGroup->push_back( groupElement );
581  }
582 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1098
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 640 of file cairo_gal.cpp.

641 {
642  super::SetLayerDepth( aLayerDepth );
643  storePath();
644 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1098
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 621 of file cairo_gal.cpp.

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

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

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

◆ SetLookAtPoint()

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

Set the Point in world space to look at.

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

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

Definition at line 653 of file graphics_abstraction_layer.h.

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

References KIGFX::GAL::m_lookAtPoint.

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

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

1585 {
1586  // Store the current cursor type and get the wxCursor for it
1587  if( !GAL::SetNativeCursorStyle( aCursor ) )
1588  return false;
1589 
1591 
1592  // Update the cursor in the wx control
1593  wxWindow::SetCursor( m_currentwxCursor );
1594 
1595  return true;
1596 }
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 926 of file cairo_gal.cpp.

927 {
928  cairo_set_operator( m_currentContext, aSetting ? CAIRO_OPERATOR_CLEAR : CAIRO_OPERATOR_OVER );
929 }
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 585 of file cairo_gal.cpp.

586 {
587  storePath();
588  m_strokeColor = aColor;
589 
590  if( m_isGrouping )
591  {
592  GROUP_ELEMENT groupElement;
593  groupElement.m_Command = CMD_SET_STROKECOLOR;
594  groupElement.m_Argument.DblArg[0] = m_strokeColor.r;
595  groupElement.m_Argument.DblArg[1] = m_strokeColor.g;
596  groupElement.m_Argument.DblArg[2] = m_strokeColor.b;
597  groupElement.m_Argument.DblArg[3] = m_strokeColor.a;
598  m_currentGroup->push_back( groupElement );
599  }
600 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1098
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:333
double g
Green component.
Definition: color4d.h:378
double b
Blue component.
Definition: color4d.h:379
double a
Alpha component.
Definition: color4d.h:380
COLOR4D m_strokeColor
The color of the outlines.
double r
Red component.
Definition: color4d.h:377
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 1414 of file cairo_gal.cpp.

1415 {
1416  // If the compositor is not set, that means that there is a recaching process going on
1417  // and we do not need the compositor now
1418  if( !m_validCompositor )
1419  return;
1420 
1421  // Cairo grouping prevents display of overlapping items on the same layer in the lighter color
1422  if( m_isInitialized )
1423  storePath();
1424 
1425  switch( aTarget )
1426  {
1427  default:
1428  case TARGET_CACHED:
1429  case TARGET_NONCACHED: m_compositor->SetBuffer( m_mainBuffer ); break;
1430  case TARGET_OVERLAY: m_compositor->SetBuffer( m_overlayBuffer ); break;
1431  case TARGET_TEMP: m_compositor->SetBuffer( m_tempBuffer ); break;
1432  }
1433 
1434  m_currentTarget = aTarget;
1435 }
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:1098
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:183
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:199
bool IsMirrored() const
Definition: eda_text.h:189
void SetFontBold(bool aBold)
Set bold property of current font.
bool IsItalic() const
Definition: eda_text.h:180
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:198
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
const wxSize & GetTextSize() const
Definition: eda_text.h:238
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
void SetFontItalic(bool aItalic)
Set italic property of current font.
void SetGlyphSize(const VECTOR2D &aSize)
Set the font glyph size.
void SetTextMirrored(bool aMirrored)
Set a mirrored property of text.
void SetFontUnderlined(bool aUnderlined)
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.

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

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

◆ SetTextMirrored()

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

◆ SetVerticalJustify()

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

Set the vertical justify for text drawing.

Parameters
aVerticalJustifyis the vertical justify value.

Definition at line 468 of file graphics_abstraction_layer.h.

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

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

Referenced by KIGFX::SCH_PAINTER: