KiCad PCB EDA Suite
KIGFX::CAIRO_GAL Class Reference

#include <cairo_gal.h>

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

Public Member Functions

 CAIRO_GAL (GAL_DISPLAY_OPTIONS &aDisplayOptions, wxWindow *aParent, wxEvtHandler *aMouseListener=nullptr, wxEvtHandler *aPaintListener=nullptr, const wxString &aName=wxT("CairoCanvas"))
 
 ~CAIRO_GAL ()
 Return true if the GAL canvas is visible on the screen. More...
 
bool IsVisible () const override
 Return true if the GAL canvas is visible on the screen. More...
 
void ResizeScreen (int aWidth, int aHeight) override
 Resizes the canvas. More...
 
bool Show (bool aShow) override
 Show/hide the GAL canvas. More...
 
int BeginGroup () override
 Begin a group. More...
 
void EndGroup () override
 End the group. More...
 
void SetTarget (RENDER_TARGET aTarget) override
 Set the target for rendering. More...
 
RENDER_TARGET GetTarget () const override
 Get the currently used target for rendering. More...
 
void ClearTarget (RENDER_TARGET aTarget) override
 Clear the target for rendering. More...
 
void StartDiffLayer () override
 Begins rendering of a differential layer. More...
 
void EndDiffLayer () override
 Ends rendering of a differential layer. More...
 
void StartNegativesLayer () override
 Begins rendering in a new layer that will be copied to the main layer in EndNegativesLayer(). More...
 
void EndNegativesLayer () override
 Ends rendering of a negatives layer and draws it to the main layer. More...
 
void PostPaint (wxPaintEvent &aEvent)
 Post an event to m_paint_listener. More...
 
void SetMouseListener (wxEvtHandler *aMouseListener)
 
void SetPaintListener (wxEvtHandler *aPaintListener)
 
bool SetNativeCursorStyle (KICURSOR aCursor) override
 Set the cursor in the native panel. More...
 
void BeginDrawing () override
 Start/end drawing functions, draw calls can be only made in between the calls to BeginDrawing()/EndDrawing(). More...
 
void EndDrawing () override
 End the drawing, needs to be called for every new frame. More...
 
void initSurface ()
 Prepare Cairo surfaces for drawing. More...
 
void deinitSurface ()
 Destroy Cairo surfaces when are not needed anymore. More...
 
void allocateBitmaps ()
 Allocate the bitmaps for drawing. More...
 
void deleteBitmaps ()
 Allocate the bitmaps for drawing. More...
 
void setCompositor ()
 Prepare the compositor. More...
 
void onPaint (wxPaintEvent &aEvent)
 Paint event handler. More...
 
void skipMouseEvent (wxMouseEvent &aEvent)
 Mouse event handler, forwards the event to the child. More...
 
void onSetNativeCursor (wxSetCursorEvent &aEvent)
 Give the correct cursor image when the native widget asks for it. More...
 
bool updatedGalDisplayOptions (const GAL_DISPLAY_OPTIONS &aOptions) override
 Handle updating display options. More...
 
bool IsCairoEngine () override
 Return true if the GAL engine is a Cairo based type. More...
 
void DrawLine (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint) override
 Draw a line. More...
 
void DrawSegment (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth) override
 Draw a rounded segment. More...
 
void DrawCircle (const VECTOR2D &aCenterPoint, double aRadius) override
 Draw a circle using world coordinates. More...
 
void DrawArc (const VECTOR2D &aCenterPoint, double aRadius, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aEndAngle) override
 Draw an arc. More...
 
void DrawArcSegment (const VECTOR2D &aCenterPoint, double aRadius, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &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 DrawRectangle (const BOX2I &aRect)
 
void DrawSegmentChain (const std::vector< VECTOR2D > &aPointList, double aWidth) override
 Draw a chain of rounded segments. More...
 
void DrawSegmentChain (const SHAPE_LINE_CHAIN &aLineChain, double aWidth) override
 
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
 
virtual void DrawPolyline (const std::vector< VECTOR2D > &aPointList)
 
void DrawPolylines (const std::vector< std::vector< VECTOR2D > > &aPointLists) override
 Draw multiple polylines. More...
 
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 DrawGlyph (const KIFONT::GLYPH &aPolySet, int aNth, int aTotal) override
 Draw a polygon representing a font glyph. More...
 
void DrawGlyphs (const std::vector< std::unique_ptr< KIFONT::GLYPH > > &aGlyphs) override
 Draw polygons representing font glyphs. More...
 
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, double alphaBlend=1.0) 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...
 
virtual int GetSwapInterval () const
 Return the swap interval. -1 for adaptive, 0 for disabled/unknown. 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...
 
virtual void BitmapText (const wxString &aText, const VECTOR2I &aPosition, const EDA_ANGLE &aAngle)
 Draw a text using a bitmap font. More...
 
void ResetTextAttributes ()
 Reset text attributes to default styling. More...
 
void SetGlyphSize (const VECTOR2I aSize)
 
const VECTOR2IGetGlyphSize () const
 
void SetFontBold (const bool aBold)
 
bool IsFontBold () const
 
void SetFontItalic (bool aItalic)
 
bool IsFontItalic () const
 
void SetFontUnderlined (bool aUnderlined)
 
bool IsFontUnderlined () const
 
void SetTextMirrored (const bool aMirrored)
 
bool IsTextMirrored () const
 
void SetHorizontalJustify (const GR_TEXT_H_ALIGN_T aHorizontalJustify)
 
GR_TEXT_H_ALIGN_T GetHorizontalJustify () const
 
void SetVerticalJustify (const GR_TEXT_V_ALIGN_T aVerticalJustify)
 
GR_TEXT_V_ALIGN_T GetVerticalJustify () const
 
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)
 Get/set the Point in world space to look at. More...
 
const VECTOR2DGetLookAtPoint () const
 
void SetZoomFactor (double aZoomFactor)
 
double GetZoomFactor () const
 
void SetRotation (double aRotation)
 Get/set the rotation angle (in radians). More...
 
double GetRotation () const
 
void SetDepthRange (const VECTOR2D &aDepthRange)
 Set the range of the layer depth. More...
 
double GetMinDepth () const
 
double GetMaxDepth () const
 
double GetWorldScale () const
 Get the world scale. More...
 
void SetFlip (bool xAxis, bool yAxis)
 Sets flipping of the screen. More...
 
bool IsFlippedX () const
 
bool IsFlippedY () const
 
virtual bool HasTarget (RENDER_TARGET aTarget)
 Return true if the target exists. More...
 
void SetGridVisibility (bool aVisibility)
 Set the visibility setting of the grid. More...
 
bool GetGridVisibility () const
 
bool GetGridSnapping () const
 
void SetGridOrigin (const VECTOR2D &aGridOrigin)
 Set the origin point for the grid. More...
 
const VECTOR2DGetGridOrigin () const
 
void SetGridSize (const VECTOR2D &aGridSize)
 Set the grid size. More...
 
const VECTOR2DGetGridSize () const
 Return the grid size. More...
 
void SetGridColor (const COLOR4D &aGridColor)
 Set the grid color. More...
 
void SetAxesColor (const COLOR4D &aAxesColor)
 Set the axes color. More...
 
void SetAxesEnabled (bool aAxesEnabled)
 Enable drawing the axes. More...
 
void SetCoarseGrid (int aInterval)
 Draw every tick line wider. More...
 
float GetGridLineWidth () const
 Get the grid line width. More...
 
VECTOR2D GetGridPoint (const VECTOR2D &aPoint) const
 For a given point it returns the nearest point belonging to the grid in world coordinates. More...
 
VECTOR2D ToWorld (const VECTOR2D &aPoint) const
 Compute the point position in world coordinates from given screen coordinates. More...
 
VECTOR2D ToScreen (const VECTOR2D &aPoint) const
 Compute the point position in screen coordinates from given world coordinates. More...
 
void SetCursorEnabled (bool aCursorEnabled)
 Enable/disable cursor. More...
 
bool IsCursorEnabled () const
 Return information about cursor visibility. More...
 
void SetCursorColor (const COLOR4D &aCursorColor)
 Set the cursor color. More...
 
void AdvanceDepth ()
 Change the current depth to deeper, so it is possible to draw objects right beneath other. More...
 
void PushDepth ()
 Store current drawing depth on the depth stack. More...
 
void PopDepth ()
 Restore previously stored drawing depth for the depth stack. More...
 
virtual bool IsContextLocked ()
 Checks the state of the context lock. More...
 
virtual void LockContext (int aClientCookie)
 Use GAL_CONTEXT_LOCKER RAII object unless you know what you're doing. More...
 
virtual void UnlockContext (int aClientCookie)
 

Protected Types

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

Protected Member Functions

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

Protected Attributes

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

Static Protected Attributes

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

Private Attributes

TEXT_ATTRIBUTES m_attributes
 

Detailed Description

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

◆ super

typedef GAL KIGFX::CAIRO_GAL_BASE::super
protectedinherited

Super class definition.

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

319 {
327 //CMD_TRANSFORM, ///< Transform the actual context
328 CMD_ROTATE,
330 CMD_SCALE,
331 CMD_SAVE,
334 };
@ CMD_SET_STROKE
Enable/disable stroking.
Definition: cairo_gal.h:321
@ CMD_SAVE
Save the transformation matrix.
Definition: cairo_gal.h:331
@ CMD_SCALE
Scale the context.
Definition: cairo_gal.h:330
@ CMD_SET_LINE_WIDTH
Set the line width.
Definition: cairo_gal.h:324
@ CMD_SET_FILL
Enable/disable filling.
Definition: cairo_gal.h:320
@ CMD_CALL_GROUP
Call a group.
Definition: cairo_gal.h:333
@ CMD_ROTATE
Rotate the context.
Definition: cairo_gal.h:328
@ CMD_STROKE_PATH
Set the stroke path.
Definition: cairo_gal.h:325
@ CMD_TRANSLATE
Translate the context.
Definition: cairo_gal.h:329
@ CMD_SET_FILLCOLOR
Set the fill color.
Definition: cairo_gal.h:322
@ CMD_FILL_PATH
Set the fill path.
Definition: cairo_gal.h:326
@ CMD_RESTORE
Restore the transformation matrix.
Definition: cairo_gal.h:332
@ CMD_SET_STROKECOLOR
Set the stroke color.
Definition: cairo_gal.h:323

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

1316 :
1317 CAIRO_GAL_BASE( aDisplayOptions ),
1318 wxWindow( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxEXPAND, aName )
1319{
1320 // Initialise compositing state
1321 m_mainBuffer = 0;
1322 m_overlayBuffer = 0;
1323 m_tempBuffer = 0;
1324 m_savedBuffer = 0;
1325 m_validCompositor = false;
1328
1329 m_bitmapBuffer = nullptr;
1330 m_wxOutput = nullptr;
1331
1332 m_parentWindow = aParent;
1333 m_mouseListener = aMouseListener;
1334 m_paintListener = aPaintListener;
1335
1336 // Connect the native cursor handler
1337 Connect( wxEVT_SET_CURSOR, wxSetCursorEventHandler( CAIRO_GAL::onSetNativeCursor ), nullptr,
1338 this );
1339
1340 // Connecting the event handlers
1341 Connect( wxEVT_PAINT, wxPaintEventHandler( CAIRO_GAL::onPaint ) );
1342
1343 // Mouse events are skipped to the parent
1344 Connect( wxEVT_MOTION, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1345 Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1346 Connect( wxEVT_LEFT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1347 Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1348 Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1349 Connect( wxEVT_MIDDLE_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1350 Connect( wxEVT_MIDDLE_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1351 Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1352 Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1353 Connect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1354 Connect( wxEVT_AUX1_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1355 Connect( wxEVT_AUX1_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1356 Connect( wxEVT_AUX1_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1357 Connect( wxEVT_AUX2_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1358 Connect( wxEVT_AUX2_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1359 Connect( wxEVT_AUX2_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1360 Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1361#if defined _WIN32 || defined _WIN64
1362 Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
1363#endif
1364
1365 SetSize( aParent->GetClientSize() );
1366 m_screenSize = VECTOR2I( aParent->GetClientSize() );
1367
1368 // Allocate memory for pixel storage
1370
1371 m_isInitialized = false;
1372}
CAIRO_GAL_BASE(GAL_DISPLAY_OPTIONS &aDisplayOptions)
Definition: cairo_gal.cpp:50
void SetTarget(RENDER_TARGET aTarget) override
Set the target for rendering.
Definition: cairo_gal.cpp:1483
void skipMouseEvent(wxMouseEvent &aEvent)
Mouse event handler, forwards the event to the child.
Definition: cairo_gal.cpp:1621
unsigned int m_overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:499
unsigned char * m_wxOutput
wxImage compatible buffer
Definition: cairo_gal.h:510
bool m_isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:516
bool m_validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:503
unsigned int m_mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:498
void onSetNativeCursor(wxSetCursorEvent &aEvent)
Give the correct cursor image when the native widget asks for it.
Definition: cairo_gal.cpp:1668
void allocateBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1570
void onPaint(wxPaintEvent &aEvent)
Paint event handler.
Definition: cairo_gal.cpp:1615
unsigned char * m_bitmapBuffer
Storage of the Cairo image.
Definition: cairo_gal.h:513
wxEvtHandler * m_mouseListener
Mouse listener.
Definition: cairo_gal.h:507
wxEvtHandler * m_paintListener
Paint listener.
Definition: cairo_gal.h:508
unsigned int m_tempBuffer
Handle to the temp buffer.
Definition: cairo_gal.h:500
RENDER_TARGET m_currentTarget
Current rendering target.
Definition: cairo_gal.h:502
wxWindow * m_parentWindow
Parent window.
Definition: cairo_gal.h:506
unsigned int m_savedBuffer
Handle to buffer to restore after rendering to temp buffer.
Definition: cairo_gal.h:501
VECTOR2I m_screenSize
Screen size in screen coordinates.
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
Definition: definitions.h:49
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References allocateBitmaps(), m_bitmapBuffer, m_currentTarget, 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 1375 of file cairo_gal.cpp.

1376{
1377 deleteBitmaps();
1378}
void deleteBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1589

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

909 {
910 m_layerDepth -= 0.05;
911 }
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 1570 of file cairo_gal.cpp.

1571{
1573
1574 while( ( ( m_wxBufferWidth * 3 ) % 4 ) != 0 )
1576
1577 // Create buffer, use the system independent Cairo context backend
1578 m_stride = cairo_format_stride_for_width( GAL_FORMAT, m_wxBufferWidth );
1580
1581 wxASSERT( m_bitmapBuffer == nullptr );
1582 m_bitmapBuffer = new unsigned char[m_bufferSize * 4];
1583
1584 wxASSERT( m_wxOutput == nullptr );
1585 m_wxOutput = new unsigned char[m_wxBufferWidth * 3 * m_screenSize.y];
1586}
static constexpr cairo_format_t GAL_FORMAT
Format used to store pixels.
Definition: cairo_gal.h:372
unsigned int m_bufferSize
Size of buffers cairoOutput, bitmapBuffers.
Definition: cairo_gal.h:509
int m_stride
Stride value for Cairo.
Definition: cairo_gal.h:514

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

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

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

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

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

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

◆ BeginDrawing()

void CAIRO_GAL::BeginDrawing ( )
overridevirtual

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

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

Reimplemented from KIGFX::CAIRO_GAL_BASE.

Definition at line 1381 of file cairo_gal.cpp.

1382{
1383 initSurface();
1384
1386
1387 if( !m_validCompositor )
1388 setCompositor();
1389
1390 m_compositor->SetMainContext( m_context );
1391 m_compositor->SetBuffer( m_mainBuffer );
1392}
void BeginDrawing() override
Start/end drawing functions, draw calls can be only made in between the calls to BeginDrawing()/EndDr...
Definition: cairo_gal.cpp:93
cairo_t * m_context
Cairo image.
Definition: cairo_gal.h:364
void initSurface()
Prepare Cairo surfaces for drawing.
Definition: cairo_gal.cpp:1535
void setCompositor()
Prepare the compositor.
Definition: cairo_gal.cpp:1599
std::shared_ptr< CAIRO_COMPOSITOR > m_compositor
Object for layers compositing.
Definition: cairo_gal.h:497

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

1470{
1471 initSurface();
1473}
int BeginGroup() override
Begin a group.
Definition: cairo_gal.cpp:798

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

963{}

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

◆ BitmapText()

void GAL::BitmapText ( const wxString &  aText,
const VECTOR2I aPosition,
const EDA_ANGLE aAngle 
)
virtualinherited

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.
aAngleis the text rotation angle.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 260 of file graphics_abstraction_layer.cpp.

261{
263
264 if( aText.IsEmpty() )
265 return;
266
268 attrs.m_Angle = aAngle;
269 attrs.m_Mirrored = m_globalFlipX; // Prevent text flipping when view is flipped
270
271 // Bitmap font has different metrics than the stroke font so we compensate a bit before
272 // stroking
274 attrs.m_StrokeWidth = GetLineWidth() * 0.74;
275
276 font->Draw( this, aText, aPosition, attrs );
277}
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:105
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
Definition: font.cpp:65
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttrs) const
Draw a string.
Definition: font.cpp:159
TEXT_ATTRIBUTES m_attributes
float GetLineWidth() const
Get the line width.
bool m_globalFlipX
Flag for X axis flipping.

References KIFONT::FONT::Draw(), KIFONT::FONT::GetFont(), KIGFX::GAL::GetLineWidth(), TEXT_ATTRIBUTES::m_Angle, KIGFX::GAL::m_attributes, KIGFX::GAL::m_globalFlipX, TEXT_ATTRIBUTES::m_Mirrored, TEXT_ATTRIBUTES::m_Size, TEXT_ATTRIBUTES::m_StrokeWidth, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by KIGFX::OPENGL_GAL::BitmapText(), KIGFX::PCB_PAINTER::draw(), KIGFX::GERBVIEW_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 1184 of file cairo_gal.cpp.

1185{
1186 if( !IsCursorEnabled() )
1187 return;
1188
1190 const COLOR4D cColor = getCursorColor();
1191 const int cursorSize = m_fullscreenCursor ? 8000 : 80;
1192
1193 wxColour color( cColor.r * cColor.a * 255, cColor.g * cColor.a * 255, cColor.b * cColor.a * 255,
1194 255 );
1195 clientDC.SetPen( wxPen( color ) );
1196 clientDC.DrawLine( p.x - cursorSize / 2, p.y, p.x + cursorSize / 2, p.y );
1197 clientDC.DrawLine( p.x, p.y - cursorSize / 2, p.x, p.y + cursorSize / 2 );
1198}
int color
Definition: DXF_plotter.cpp:57
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
double r
Red component.
Definition: color4d.h:384
double g
Green component.
Definition: color4d.h:385
double a
Alpha component.
Definition: color4d.h:387
double b
Blue component.
Definition: color4d.h:386
bool IsCursorEnabled() const
Return information about cursor visibility.
VECTOR2D ToScreen(const VECTOR2D &aPoint) const
Compute the point position in screen coordinates from given world coordinates.
COLOR4D getCursorColor() const
Get the actual cursor color to draw.
VECTOR2D m_cursorPosition
Current cursor position (world coordinates)
bool m_fullscreenCursor
Shape of the cursor (fullscreen or small cross)

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

915{
916 storePath();
917
918 for( auto it = m_groups[aGroupNumber].begin(); it != m_groups[aGroupNumber].end(); ++it )
919 {
920 if( it->m_Command == CMD_SET_FILLCOLOR || it->m_Command == CMD_SET_STROKECOLOR )
921 {
922 it->m_Argument.DblArg[0] = aNewColor.r;
923 it->m_Argument.DblArg[1] = aNewColor.g;
924 it->m_Argument.DblArg[2] = aNewColor.b;
925 it->m_Argument.DblArg[3] = aNewColor.a;
926 }
927 }
928}
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:1135
std::map< int, GROUP > m_groups
List of graphic groups.
Definition: cairo_gal.h:353

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

932{
933 // Cairo does not have any possibilities to change the depth coordinate of stored items,
934 // it depends only on the order of drawing
935}

◆ ClearCache()

void CAIRO_GAL_BASE::ClearCache ( )
overridevirtualinherited

Delete all data created during caching of graphic items.

Reimplemented from KIGFX::GAL.

Definition at line 956 of file cairo_gal.cpp.

957{
958 for( auto it = m_groups.begin(); it != m_groups.end(); )
959 DeleteGroup( ( it++ )->first );
960}
void DeleteGroup(int aGroupNumber) override
Delete the group from the memory.
Definition: cairo_gal.cpp:938

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

585{
586 cairo_set_source_rgb( m_currentContext, m_clearColor.r, m_clearColor.g, m_clearColor.b );
587 cairo_rectangle( m_currentContext, 0.0, 0.0, m_screenSize.x, m_screenSize.y );
588 cairo_fill( m_currentContext );
589}
cairo_t * m_currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:363

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

1514{
1515 // Save the current state
1516 unsigned int currentBuffer = m_compositor->GetBuffer();
1517
1518 switch( aTarget )
1519 {
1520 // Cached and noncached items are rendered to the same buffer
1521 default:
1522 case TARGET_CACHED:
1523 case TARGET_NONCACHED: m_compositor->SetBuffer( m_mainBuffer ); break;
1524 case TARGET_OVERLAY: m_compositor->SetBuffer( m_overlayBuffer ); break;
1525 case TARGET_TEMP: m_compositor->SetBuffer( m_tempBuffer ); break;
1526 }
1527
1528 m_compositor->ClearBuffer( COLOR4D::BLACK );
1529
1530 // Restore the previous state
1531 m_compositor->SetBuffer( currentBuffer );
1532}
static const COLOR4D BLACK
Definition: color4d.h:394
@ TARGET_TEMP
Temporary target for drawing in separate layer.
Definition: definitions.h:51
@ TARGET_CACHED
Main rendering target (cached)
Definition: definitions.h:48
@ TARGET_OVERLAY
Items that may change while the view stays the same (noncached)
Definition: definitions.h:50

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

215{
216 // just return the current value. This could be cleverer and take
217 // into account other settings in future
218 return m_gridMinSpacing;
219}
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::CAIRO_GAL_BASE::DrawGrid(), and KIGFX::OPENGL_GAL::DrawGrid().

◆ computeWorldScale()

void KIGFX::GAL::computeWorldScale ( )
inlineprotectedinherited

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

Definition at line 971 of file graphics_abstraction_layer.h.

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

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

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

◆ ComputeWorldScreenMatrix()

void GAL::ComputeWorldScreenMatrix ( )
virtualinherited

Compute the world <-> screen transformation matrix.

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

Definition at line 169 of file graphics_abstraction_layer.cpp.

170{
172
173 MATRIX3x3D translation;
174 translation.SetIdentity();
175 // We're deliberately dividing integers to avoid fractional pixel offsets.
176 translation.SetTranslation( VECTOR2D( m_screenSize.x/2, m_screenSize.y/2 ) );
177
178 MATRIX3x3D rotate;
179 rotate.SetIdentity();
180 rotate.SetRotation( m_rotation );
181
183 scale.SetIdentity();
184 scale.SetScale( VECTOR2D( m_worldScale, m_worldScale ) );
185
186 MATRIX3x3D flip;
187 flip.SetIdentity();
188 flip.SetScale( VECTOR2D( m_globalFlipX ? -1.0 : 1.0, m_globalFlipY ? -1.0 : 1.0 ) );
189
190 MATRIX3x3D lookat;
191 lookat.SetIdentity();
192 lookat.SetTranslation( -m_lookAtPoint );
193
194 m_worldScreenMatrix = translation * rotate * flip * scale * lookat;
196}
MATRIX3x3D m_worldScreenMatrix
World transformation.
MATRIX3x3D m_screenWorldMatrix
Screen transformation.
void computeWorldScale()
Compute the scaling factor for the world->screen matrix.
double m_rotation
Rotation transformation (radians)
bool m_globalFlipY
Flag for Y axis flipping.
VECTOR2D m_lookAtPoint
Point to be looked at in world space.
void SetIdentity()
Set the matrix to the identity matrix.
Definition: matrix3x3.h:210
void SetRotation(T aAngle)
Set the rotation components of the matrix.
Definition: matrix3x3.h:245
void SetScale(VECTOR2< T > aScale)
Set the scale components of the matrix.
Definition: matrix3x3.h:257
void SetTranslation(VECTOR2< T > aTranslation)
Set the translation components of the matrix.
Definition: matrix3x3.h:226
MATRIX3x3 Inverse() const
Determine the inverse of the matrix.
Definition: matrix3x3.h:339
const int scale
VECTOR2< double > VECTOR2D
Definition: vector2d.h:617

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

1557{
1558 if( !m_isInitialized )
1559 return;
1560
1561 cairo_destroy( m_context );
1562 m_context = nullptr;
1563 cairo_surface_destroy( m_surface );
1564 m_surface = nullptr;
1565
1566 m_isInitialized = false;
1567}
cairo_surface_t * m_surface
Cairo surface.
Definition: cairo_gal.h:365

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

1590{
1591 delete[] m_bitmapBuffer;
1592 m_bitmapBuffer = nullptr;
1593
1594 delete[] m_wxOutput;
1595 m_wxOutput = nullptr;
1596}

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

939{
940 storePath();
941
942 // Delete the Cairo paths
943 std::deque<GROUP_ELEMENT>::iterator it, end;
944
945 for( it = m_groups[aGroupNumber].begin(), end = m_groups[aGroupNumber].end(); it != end; ++it )
946 {
947 if( it->m_Command == CMD_FILL_PATH || it->m_Command == CMD_STROKE_PATH )
948 cairo_path_destroy( it->m_CairoPath );
949 }
950
951 // Delete the group
952 m_groups.erase( aGroupNumber );
953}

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,
const EDA_ANGLE aStartAngle,
const EDA_ANGLE 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 340 of file cairo_gal.cpp.

342{
344
345 double startAngle = aStartAngle.AsRadians();
346 double endAngle = aEndAngle.AsRadians();
347
348 // calculate start and end arc angles according to the rotation transform matrix
349 // and normalize:
350 arc_angles_xform_and_normalize( startAngle, endAngle );
351
352 double r = xform( aRadius );
353
354 // N.B. This is backwards. We set this because we want to adjust the center
355 // point that changes both endpoints. In the worst case, this is twice as far.
356 // We cannot adjust radius or center based on the other because this causes the
357 // whole arc to change position/size
358 m_lineWidthIsOdd = !( static_cast<int>( aRadius ) % 2 );
359
360 auto mid = roundp( xform( aCenterPoint ) );
361
362 cairo_set_line_width( m_currentContext, m_lineWidthInPixels );
363 cairo_new_sub_path( m_currentContext );
364
365 if( m_isFillEnabled )
366 cairo_move_to( m_currentContext, mid.x, mid.y );
367
368 cairo_arc( m_currentContext, mid.x, mid.y, r, startAngle, endAngle );
369
370 if( m_isFillEnabled )
371 cairo_close_path( m_currentContext );
372
373 flushPath();
374
375 m_isElementAdded = true;
376}
double AsRadians() const
Definition: eda_angle.h:153
bool m_isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:352
const double xform(double x)
Definition: cairo_gal.cpp:176
const VECTOR2D roundp(const VECTOR2D &v)
Definition: cairo_gal.cpp:190
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:142
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
Definition: cairo_gal.cpp:213
double m_lineWidthInPixels
Definition: cairo_gal.h:357
bool m_isFillEnabled
Is filling of graphic objects enabled ?
E_SERIE r
Definition: eserie.cpp:41

References KIGFX::CAIRO_GAL_BASE::arc_angles_xform_and_normalize(), EDA_ANGLE::AsRadians(), 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,
const EDA_ANGLE aStartAngle,
const EDA_ANGLE 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 379 of file cairo_gal.cpp.

382{
383 // Note: aMaxError is not used because Cairo can draw true arcs
384 if( m_isFillEnabled )
385 {
386 m_lineWidth = aWidth;
387 m_isStrokeEnabled = true;
388 m_isFillEnabled = false;
389 DrawArc( aCenterPoint, aRadius, aStartAngle, aEndAngle );
390 m_isFillEnabled = true;
391 m_isStrokeEnabled = false;
392 return;
393 }
394
396
397 // calculate start and end arc angles according to the rotation transform matrix
398 // and normalize:
399 double startAngleS = aStartAngle.AsRadians();
400 double endAngleS = aEndAngle.AsRadians();
401 arc_angles_xform_and_normalize( startAngleS, endAngleS );
402
403 double r = xform( aRadius );
404
405 // N.B. This is backwards. We set this because we want to adjust the center
406 // point that changes both endpoints. In the worst case, this is twice as far.
407 // We cannot adjust radius or center based on the other because this causes the
408 // whole arc to change position/size
409 m_lineWidthIsOdd = !( static_cast<int>( aRadius ) % 2 );
410
411 VECTOR2D mid = roundp( xform( aCenterPoint ) );
412 double width = xform( aWidth / 2.0 );
413 VECTOR2D startPointS = VECTOR2D( r, 0.0 );
414 VECTOR2D endPointS = VECTOR2D( r, 0.0 );
415 RotatePoint( startPointS, -EDA_ANGLE( startAngleS, RADIANS_T ) );
416 RotatePoint( endPointS, -EDA_ANGLE( endAngleS, RADIANS_T ) );
417
418 cairo_save( m_currentContext );
419
422
423 cairo_translate( m_currentContext, mid.x, mid.y );
424
425 cairo_new_sub_path( m_currentContext );
426 cairo_arc( m_currentContext, 0, 0, r - width, startAngleS, endAngleS );
427
428 cairo_new_sub_path( m_currentContext );
429 cairo_arc( m_currentContext, 0, 0, r + width, startAngleS, endAngleS );
430
431 cairo_new_sub_path( m_currentContext );
432 cairo_arc_negative( m_currentContext, startPointS.x, startPointS.y, width, startAngleS,
433 startAngleS + M_PI );
434
435 cairo_new_sub_path( m_currentContext );
436 cairo_arc( m_currentContext, endPointS.x, endPointS.y, width, endAngleS, endAngleS + M_PI );
437
438 cairo_restore( m_currentContext );
439 flushPath();
440
441 m_isElementAdded = true;
442}
void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aEndAngle) override
Draw an arc.
Definition: cairo_gal.cpp:340
float m_lineWidth
The line width.
COLOR4D m_strokeColor
The color of the outlines.
bool m_isStrokeEnabled
Are the outlines stroked ?
@ RADIANS_T
Definition: eda_angle.h:32
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183

References KIGFX::COLOR4D::a, KIGFX::CAIRO_GAL_BASE::arc_angles_xform_and_normalize(), EDA_ANGLE::AsRadians(), KIGFX::COLOR4D::b, KIGFX::CAIRO_GAL_BASE::DrawArc(), KIGFX::CAIRO_GAL_BASE::flushPath(), KIGFX::COLOR4D::g, KIGFX::CAIRO_GAL_BASE::m_currentContext, KIGFX::CAIRO_GAL_BASE::m_isElementAdded, KIGFX::GAL::m_isFillEnabled, KIGFX::GAL::m_isStrokeEnabled, KIGFX::GAL::m_lineWidth, KIGFX::CAIRO_GAL_BASE::m_lineWidthIsOdd, KIGFX::GAL::m_strokeColor, KIGFX::COLOR4D::r, r, RADIANS_T, RotatePoint(), 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 1038 of file cairo_gal.cpp.

1039{
1040 syncLineWidth();
1041
1042 VECTOR2D p0 = roundp( xform( aStartPoint ) );
1043 VECTOR2D p1 = roundp( xform( aEndPoint ) );
1044 VECTOR2D org = roundp( xform( VECTOR2D( 0.0, 0.0 ) ) ); // Axis origin = 0,0 coord
1045
1046 cairo_set_source_rgba( m_currentContext, m_axesColor.r, m_axesColor.g, m_axesColor.b,
1047 m_axesColor.a );
1048 cairo_move_to( m_currentContext, p0.x, org.y );
1049 cairo_line_to( m_currentContext, p1.x, org.y );
1050 cairo_move_to( m_currentContext, org.x, p0.y );
1051 cairo_line_to( m_currentContext, org.x, p1.y );
1052 cairo_stroke( m_currentContext );
1053}
COLOR4D m_axesColor
Color of the axes.

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,
double  alphaBlend = 1.0 
)
overridevirtualinherited

Draw a bitmap image.

Reimplemented from KIGFX::GAL.

Definition at line 502 of file cairo_gal.cpp.

503{
504 cairo_save( m_currentContext );
505
506 alphaBlend = std::clamp( alphaBlend, 0.0, 1.0 );
507
508 // We have to calculate the pixel size in users units to draw the image.
509 // m_worldUnitLength is a factor used for converting IU to inches
510 double scale = 1.0 / ( aBitmap.GetPPI() * m_worldUnitLength );
511
512 // The position of the bitmap is the bitmap center.
513 // move the draw origin to the top left bitmap corner:
514 int w = aBitmap.GetSizePixels().x;
515 int h = aBitmap.GetSizePixels().y;
516
517 cairo_set_matrix( m_currentContext, &m_currentWorld2Screen );
518 cairo_scale( m_currentContext, scale, scale );
519 cairo_translate( m_currentContext, -w / 2.0, -h / 2.0 );
520
521 cairo_new_path( m_currentContext );
522 cairo_surface_t* image = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, w, h );
523 cairo_surface_flush( image );
524
525 unsigned char* pix_buffer = cairo_image_surface_get_data( image );
526
527 // The pixel buffer of the initial bitmap:
528 const wxImage& bm_pix_buffer = *aBitmap.GetImageData();
529
530 uint32_t mask_color = ( bm_pix_buffer.GetMaskRed() << 16 )
531 + ( bm_pix_buffer.GetMaskGreen() << 8 ) + ( bm_pix_buffer.GetMaskBlue() );
532
533 // Copy the source bitmap to the cairo bitmap buffer.
534 // In cairo bitmap buffer, a ARGB32 bitmap is an ARGB pixel packed into a uint_32
535 // 24 low bits only are used for color, top 8 are transparency.
536 for( int row = 0; row < h; row++ )
537 {
538 for( int col = 0; col < w; col++ )
539 {
540 // Build the RGB24 pixel:
541 uint32_t pixel = bm_pix_buffer.GetRed( col, row ) << 16;
542 pixel += bm_pix_buffer.GetGreen( col, row ) << 8;
543 pixel += bm_pix_buffer.GetBlue( col, row );
544
545 if( bm_pix_buffer.HasAlpha() )
546 pixel += bm_pix_buffer.GetAlpha( col, row ) << 24;
547 else if( bm_pix_buffer.HasMask() && pixel == mask_color )
548 pixel += ( wxALPHA_TRANSPARENT << 24 );
549 else
550 pixel += ( wxALPHA_OPAQUE << 24 );
551
552 // Write the pixel to the cairo image buffer:
553 uint32_t* pix_ptr = (uint32_t*) pix_buffer;
554 *pix_ptr = pixel;
555 pix_buffer += 4;
556 }
557 }
558
559 cairo_surface_mark_dirty( image );
560 cairo_set_source_surface( m_currentContext, image, 0, 0 );
561 cairo_paint_with_alpha( m_currentContext, alphaBlend );
562
563 // store the image handle so it can be destroyed later
564 m_imageSurfaces.push_back( image );
565
566 m_isElementAdded = true;
567
568 cairo_restore( m_currentContext );
569}
wxSize GetSizePixels() const
Definition: bitmap_base.h:123
int GetPPI() const
Definition: bitmap_base.h:134
wxImage * GetImageData()
Definition: bitmap_base.h:69
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:368

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

325{
327
328 VECTOR2D c = roundp( xform( aCenterPoint ) );
329 double r = ::roundp( xform( aRadius ) );
330
331 cairo_set_line_width( m_currentContext, std::min( 2.0 * r, m_lineWidthInPixels ) );
332 cairo_new_sub_path( m_currentContext );
333 cairo_arc( m_currentContext, c.x, c.y, r, 0.0, 2 * M_PI );
334 cairo_close_path( m_currentContext );
335 flushPath();
336 m_isElementAdded = true;
337}

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

996{
997 m_cursorPosition = aCursorPosition;
998}

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

483{
484 // Note: aFilterValue is not used because the cubic Bezier curve is
485 // supported by Cairo.
487
488 const VECTOR2D sp = roundp( xform( aStartPoint ) );
489 const VECTOR2D cpa = roundp( xform( aControlPointA ) );
490 const VECTOR2D cpb = roundp( xform( aControlPointB ) );
491 const VECTOR2D ep = roundp( xform( aEndPoint ) );
492
493 cairo_move_to( m_currentContext, sp.x, sp.y );
494 cairo_curve_to( m_currentContext, cpa.x, cpa.y, cpb.x, cpb.y, ep.x, ep.y );
495 cairo_line_to( m_currentContext, ep.x, ep.y );
496
497 flushPath();
498 m_isElementAdded = true;
499}

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.

◆ DrawGlyph()

void CAIRO_GAL_BASE::DrawGlyph ( const KIFONT::GLYPH aPolySet,
int  aNth,
int  aTotal 
)
overridevirtualinherited

Draw a polygon representing a font glyph.

Reimplemented from KIGFX::GAL.

Definition at line 1798 of file cairo_gal.cpp.

1799{
1800 if( aGlyph.IsStroke() )
1801 {
1802 const KIFONT::STROKE_GLYPH& glyph = static_cast<const KIFONT::STROKE_GLYPH&>( aGlyph );
1803
1804 for( const std::vector<VECTOR2D>& pointList : glyph )
1805 drawPoly( pointList );
1806 }
1807 else if( aGlyph.IsOutline() )
1808 {
1809 const KIFONT::OUTLINE_GLYPH& glyph = static_cast<const KIFONT::OUTLINE_GLYPH&>( aGlyph );
1810
1811 if( aNth == 0 )
1812 {
1813 cairo_close_path( m_currentContext );
1814 flushPath();
1815
1816 cairo_new_path( m_currentContext );
1817 SetIsFill( true );
1818 SetIsStroke( false );
1819 }
1820
1821 // eventually glyphs should not be drawn as polygons at all,
1822 // but as bitmaps with antialiasing, this is just a stopgap measure
1823 // of getting some form of outline font display
1824
1825 glyph.Triangulate(
1826 [&]( const VECTOR2D& aVertex1, const VECTOR2D& aVertex2, const VECTOR2D& aVertex3 )
1827 {
1828 syncLineWidth();
1829
1830 const VECTOR2D p0 = roundp( xform( aVertex1 ) );
1831 const VECTOR2D p1 = roundp( xform( aVertex2 ) );
1832 const VECTOR2D p2 = roundp( xform( aVertex3 ) );
1833
1834 cairo_move_to( m_currentContext, p0.x, p0.y );
1835 cairo_line_to( m_currentContext, p1.x, p1.y );
1836 cairo_line_to( m_currentContext, p2.x, p2.y );
1837 cairo_close_path( m_currentContext );
1838 cairo_set_fill_rule( m_currentContext, CAIRO_FILL_RULE_EVEN_ODD );
1839 flushPath();
1840 cairo_fill( m_currentContext );
1841 } );
1842
1843 if( aNth == aTotal - 1 )
1844 {
1845 /*
1846 cairo_close_path( currentContext );
1847 setSourceRgba( currentContext, fillColor );
1848 cairo_set_fill_rule( currentContext, CAIRO_FILL_RULE_EVEN_ODD );
1849 cairo_fill_preserve( currentContext );
1850 setSourceRgba( currentContext, strokeColor );
1851 cairo_stroke( currentContext );
1852 */
1853 flushPath();
1854 m_isElementAdded = true;
1855 }
1856 }
1857}
void Triangulate(std::function< void(const VECTOR2I &aPt1, const VECTOR2I &aPt2, const VECTOR2I &aPt3)> aCallback) const
Definition: glyph.cpp:121
void SetIsStroke(bool aIsStrokeEnabled) override
Enable/disable stroked outlines.
Definition: cairo_gal.cpp:607
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:1201
void SetIsFill(bool aIsFillEnabled) override
Enable/disable fill.
Definition: cairo_gal.cpp:592

References KIGFX::CAIRO_GAL_BASE::drawPoly(), KIGFX::CAIRO_GAL_BASE::flushPath(), KIFONT::GLYPH::IsOutline(), KIFONT::GLYPH::IsStroke(), KIGFX::CAIRO_GAL_BASE::m_currentContext, KIGFX::CAIRO_GAL_BASE::m_isElementAdded, KIGFX::CAIRO_GAL_BASE::roundp(), KIGFX::CAIRO_GAL_BASE::SetIsFill(), KIGFX::CAIRO_GAL_BASE::SetIsStroke(), KIGFX::CAIRO_GAL_BASE::syncLineWidth(), KIFONT::OUTLINE_GLYPH::Triangulate(), VECTOR2< T >::x, KIGFX::CAIRO_GAL_BASE::xform(), and VECTOR2< T >::y.

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

◆ DrawGlyphs()

void KIGFX::CAIRO_GAL_BASE::DrawGlyphs ( const std::vector< std::unique_ptr< KIFONT::GLYPH > > &  aGlyphs)
inlineoverridevirtualinherited

Draw polygons representing font glyphs.

Reimplemented from KIGFX::GAL.

Definition at line 127 of file cairo_gal.h.

128 {
129 for( size_t i = 0; i < aGlyphs.size(); i++ )
130 DrawGlyph( *aGlyphs[i], i, aGlyphs.size() );
131 }
void DrawGlyph(const KIFONT::GLYPH &aPolySet, int aNth, int aTotal) override
Draw a polygon representing a font glyph.
Definition: cairo_gal.cpp:1798

References KIGFX::CAIRO_GAL_BASE::DrawGlyph().

◆ DrawGrid()

void CAIRO_GAL_BASE::DrawGrid ( )
overridevirtualinherited

Reimplemented from KIGFX::GAL.

Definition at line 1674 of file cairo_gal.cpp.

1675{
1677
1678 // Draw the grid
1679 // For the drawing the start points, end points and increments have
1680 // to be calculated in world coordinates
1681 VECTOR2D worldStartPoint = m_screenWorldMatrix * VECTOR2D( 0.0, 0.0 );
1683
1684 // Compute the line marker or point radius of the grid
1685 // Note: generic grids can't handle sub-pixel lines without
1686 // either losing fine/course distinction or having some dots
1687 // fail to render
1688 float marker = std::fmax( 1.0f, m_gridLineWidth ) / m_worldScale;
1689 float doubleMarker = 2.0f * marker;
1690
1691 // Draw axes if desired
1692 if( m_axesEnabled )
1693 {
1694 SetLineWidth( marker );
1695 drawAxes( worldStartPoint, worldEndPoint );
1696 }
1697
1698 if( !m_gridVisibility || m_gridSize.x == 0 || m_gridSize.y == 0 )
1699 return;
1700
1701 VECTOR2D gridScreenSize( m_gridSize );
1702
1703 double gridThreshold = KiROUND( computeMinGridSpacing() / m_worldScale );
1704
1706 gridThreshold *= 2.0;
1707
1708 // If we cannot display the grid density, scale down by a tick size and
1709 // try again. Eventually, we get some representation of the grid
1710 while( std::min( gridScreenSize.x, gridScreenSize.y ) <= gridThreshold )
1711 {
1712 gridScreenSize = gridScreenSize * static_cast<double>( m_gridTick );
1713 }
1714
1715 // Compute grid starting and ending indexes to draw grid points on the
1716 // visible screen area
1717 // Note: later any point coordinate will be offsetted by m_gridOrigin
1718 int gridStartX = KiROUND( ( worldStartPoint.x - m_gridOrigin.x ) / gridScreenSize.x );
1719 int gridEndX = KiROUND( ( worldEndPoint.x - m_gridOrigin.x ) / gridScreenSize.x );
1720 int gridStartY = KiROUND( ( worldStartPoint.y - m_gridOrigin.y ) / gridScreenSize.y );
1721 int gridEndY = KiROUND( ( worldEndPoint.y - m_gridOrigin.y ) / gridScreenSize.y );
1722
1723 // Ensure start coordinate > end coordinate
1724 SWAP( gridStartX, >, gridEndX );
1725 SWAP( gridStartY, >, gridEndY );
1726
1727 // Ensure the grid fills the screen
1728 --gridStartX;
1729 ++gridEndX;
1730 --gridStartY;
1731 ++gridEndY;
1732
1733 // Draw the grid behind all other layers
1734 SetLayerDepth( m_depthRange.y * 0.75 );
1735
1737 {
1738 // Now draw the grid, every coarse grid line gets the double width
1739
1740 // Vertical lines
1741 for( int j = gridStartY; j <= gridEndY; j++ )
1742 {
1743 const double y = j * gridScreenSize.y + m_gridOrigin.y;
1744
1745 if( m_axesEnabled && y == 0.0 )
1746 continue;
1747
1748 SetLineWidth( ( j % m_gridTick ) ? marker : doubleMarker );
1749 drawGridLine( VECTOR2D( gridStartX * gridScreenSize.x + m_gridOrigin.x, y ),
1750 VECTOR2D( gridEndX * gridScreenSize.x + m_gridOrigin.x, y ) );
1751 }
1752
1753 // Horizontal lines
1754 for( int i = gridStartX; i <= gridEndX; i++ )
1755 {
1756 const double x = i * gridScreenSize.x + m_gridOrigin.x;
1757
1758 if( m_axesEnabled && x == 0.0 )
1759 continue;
1760
1761 SetLineWidth( ( i % m_gridTick ) ? marker : doubleMarker );
1762 drawGridLine( VECTOR2D( x, gridStartY * gridScreenSize.y + m_gridOrigin.y ),
1763 VECTOR2D( x, gridEndY * gridScreenSize.y + m_gridOrigin.y ) );
1764 }
1765 }
1766 else // Dots or Crosses grid
1767 {
1768 m_lineWidthIsOdd = true;
1769 m_isStrokeEnabled = true;
1770
1771 for( int j = gridStartY; j <= gridEndY; j++ )
1772 {
1773 bool tickY = ( j % m_gridTick == 0 );
1774
1775 for( int i = gridStartX; i <= gridEndX; i++ )
1776 {
1777 bool tickX = ( i % m_gridTick == 0 );
1778 VECTOR2D pos{ i * gridScreenSize.x + m_gridOrigin.x,
1779 j * gridScreenSize.y + m_gridOrigin.y };
1780
1782 {
1783 SetLineWidth( ( tickX && tickY ) ? doubleMarker : marker );
1784 drawGridCross( pos );
1785 }
1786 else if( m_gridStyle == GRID_STYLE::DOTS )
1787 {
1788 double doubleGridLineWidth = m_gridLineWidth * 2.0f;
1789 drawGridPoint( pos, ( tickX ) ? doubleGridLineWidth : m_gridLineWidth,
1790 ( tickY ) ? doubleGridLineWidth : m_gridLineWidth );
1791 }
1792 }
1793 }
1794 }
1795}
void drawGridLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a grid line (usually a simplified line function).
Definition: cairo_gal.cpp:1056
void drawAxes(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Definition: cairo_gal.cpp:1038
void SetLayerDepth(double aLayerDepth) override
Set the depth of the layer (position on the z-axis)
Definition: cairo_gal.cpp:677
void drawGridCross(const VECTOR2D &aPoint)
Definition: cairo_gal.cpp:1070
void SetLineWidth(float aLineWidth) override
Set the line width.
Definition: cairo_gal.cpp:658
void drawGridPoint(const VECTOR2D &aPoint, double aWidth, double aHeight)
Definition: cairo_gal.cpp:1091
bool m_axesEnabled
Should the axes be drawn.
float m_gridLineWidth
Line width of the grid.
VECTOR2D m_depthRange
Range of the depth.
GRID_STYLE m_gridStyle
Grid display style.
VECTOR2D m_gridSize
The grid size.
int m_gridTick
Every tick line gets the double width.
VECTOR2D m_gridOrigin
The grid origin.
double computeMinGridSpacing() const
compute minimum grid spacing from the grid settings
bool m_gridVisibility
Should the grid be shown.
virtual void SetTarget(RENDER_TARGET aTarget)
Set the target for rendering.
@ SMALL_CROSS
Use small cross instead of dots for the grid.
@ DOTS
Use dots for the grid.
@ LINES
Use lines for the grid.
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:85

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

1071{
1072 syncLineWidth();
1073 VECTOR2D offset( 0, 0 );
1074 double size = 2.0 * m_lineWidthInPixels + 0.5;
1075
1076 VECTOR2D p0 = roundp( xform( aPoint ) ) - VECTOR2D( size, 0 ) + offset;
1077 VECTOR2D p1 = roundp( xform( aPoint ) ) + VECTOR2D( size, 0 ) + offset;
1078 VECTOR2D p2 = roundp( xform( aPoint ) ) - VECTOR2D( 0, size ) + offset;
1079 VECTOR2D p3 = roundp( xform( aPoint ) ) + VECTOR2D( 0, size ) + offset;
1080
1081 cairo_set_source_rgba( m_currentContext, m_gridColor.r, m_gridColor.g, m_gridColor.b,
1082 m_gridColor.a );
1083 cairo_move_to( m_currentContext, p0.x, p0.y );
1084 cairo_line_to( m_currentContext, p1.x, p1.y );
1085 cairo_move_to( m_currentContext, p2.x, p2.y );
1086 cairo_line_to( m_currentContext, p3.x, p3.y );
1087 cairo_stroke( m_currentContext );
1088}
COLOR4D m_gridColor
Color of the grid.

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

1057{
1058 syncLineWidth();
1059 VECTOR2D p0 = roundp( xform( aStartPoint ) );
1060 VECTOR2D p1 = roundp( xform( aEndPoint ) );
1061
1062 cairo_set_source_rgba( m_currentContext, m_gridColor.r, m_gridColor.g, m_gridColor.b,
1063 m_gridColor.a );
1064 cairo_move_to( m_currentContext, p0.x, p0.y );
1065 cairo_line_to( m_currentContext, p1.x, p1.y );
1066 cairo_stroke( m_currentContext );
1067}

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

1092{
1093 VECTOR2D p = roundp( xform( aPoint ) );
1094
1095 double sw = std::max( 1.0, aWidth );
1096 double sh = std::max( 1.0, aHeight );
1097
1098 cairo_set_source_rgba( m_currentContext, m_gridColor.r, m_gridColor.g, m_gridColor.b,
1099 m_gridColor.a );
1100 cairo_rectangle( m_currentContext, p.x - std::floor( sw / 2 ) - 0.5,
1101 p.y - std::floor( sh / 2 ) - 0.5, sw, sh );
1102
1103 cairo_fill( m_currentContext );
1104}

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

822{
823 // This method implements a small Virtual Machine - all stored commands
824 // are executed; nested calling is also possible
825
826 storePath();
827
828 for( auto it = m_groups[aGroupNumber].begin(); it != m_groups[aGroupNumber].end(); ++it )
829 {
830 switch( it->m_Command )
831 {
832 case CMD_SET_FILL:
833 m_isFillEnabled = it->m_Argument.BoolArg;
834 break;
835
836 case CMD_SET_STROKE:
837 m_isStrokeEnabled = it->m_Argument.BoolArg;
838 break;
839
841 m_fillColor = COLOR4D( it->m_Argument.DblArg[0], it->m_Argument.DblArg[1],
842 it->m_Argument.DblArg[2], it->m_Argument.DblArg[3] );
843 break;
844
846 m_strokeColor = COLOR4D( it->m_Argument.DblArg[0], it->m_Argument.DblArg[1],
847 it->m_Argument.DblArg[2], it->m_Argument.DblArg[3] );
848 break;
849
851 {
852 // Make lines appear at least 1 pixel wide, no matter of zoom
853 double x = 1.0, y = 1.0;
854 cairo_device_to_user_distance( m_currentContext, &x, &y );
855 double minWidth = std::min( fabs( x ), fabs( y ) );
856 cairo_set_line_width( m_currentContext,
857 std::max( it->m_Argument.DblArg[0], minWidth ) );
858 break;
859 }
860
861
862 case CMD_STROKE_PATH:
863 cairo_set_source_rgba( m_currentContext, m_strokeColor.r, m_strokeColor.g,
865 cairo_append_path( m_currentContext, it->m_CairoPath );
866 cairo_stroke( m_currentContext );
867 break;
868
869 case CMD_FILL_PATH:
870 cairo_set_source_rgba( m_currentContext, m_fillColor.r, m_fillColor.g, m_fillColor.b,
872 cairo_append_path( m_currentContext, it->m_CairoPath );
873 cairo_fill( m_currentContext );
874 break;
875
876 /*
877 case CMD_TRANSFORM:
878 cairo_matrix_t matrix;
879 cairo_matrix_init( &matrix, it->argument.DblArg[0], it->argument.DblArg[1],
880 it->argument.DblArg[2], it->argument.DblArg[3],
881 it->argument.DblArg[4], it->argument.DblArg[5] );
882 cairo_transform( m_currentContext, &matrix );
883 break;
884 */
885
886 case CMD_ROTATE:
887 cairo_rotate( m_currentContext, it->m_Argument.DblArg[0] );
888 break;
889
890 case CMD_TRANSLATE:
891 cairo_translate( m_currentContext, it->m_Argument.DblArg[0], it->m_Argument.DblArg[1] );
892 break;
893
894 case CMD_SCALE:
895 cairo_scale( m_currentContext, it->m_Argument.DblArg[0], it->m_Argument.DblArg[1] );
896 break;
897
898 case CMD_SAVE:
899 cairo_save( m_currentContext );
900 break;
901
902 case CMD_RESTORE:
903 cairo_restore( m_currentContext );
904 break;
905
906 case CMD_CALL_GROUP:
907 DrawGroup( it->m_Argument.IntArg );
908 break;
909 }
910 }
911}
void DrawGroup(int aGroupNumber) override
Draw the stored group.
Definition: cairo_gal.cpp:821
COLOR4D m_fillColor
The fill color.

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, KIGFX::CAIRO_GAL_BASE::CMD_CALL_GROUP, KIGFX::CAIRO_GAL_BASE::CMD_FILL_PATH, KIGFX::CAIRO_GAL_BASE::CMD_RESTORE, KIGFX::CAIRO_GAL_BASE::CMD_ROTATE, KIGFX::CAIRO_GAL_BASE::CMD_SAVE, KIGFX::CAIRO_GAL_BASE::CMD_SCALE, KIGFX::CAIRO_GAL_BASE::CMD_SET_FILL, KIGFX::CAIRO_GAL_BASE::CMD_SET_FILLCOLOR, KIGFX::CAIRO_GAL_BASE::CMD_SET_LINE_WIDTH, KIGFX::CAIRO_GAL_BASE::CMD_SET_STROKE, KIGFX::CAIRO_GAL_BASE::CMD_SET_STROKECOLOR, KIGFX::CAIRO_GAL_BASE::CMD_STROKE_PATH, KIGFX::CAIRO_GAL_BASE::CMD_TRANSLATE, KIGFX::CAIRO_GAL_BASE::DrawGroup(), 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().

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

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

200{
202
203 VECTOR2D p0 = roundp( xform( aStartPoint ) );
204 VECTOR2D p1 = roundp( xform( aEndPoint ) );
205
206 cairo_move_to( m_currentContext, p0.x, p0.y );
207 cairo_line_to( m_currentContext, p1.x, p1.y );
208 flushPath();
209 m_isElementAdded = true;
210}

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

◆ drawPoly() [1/4]

void CAIRO_GAL_BASE::drawPoly ( const SHAPE_LINE_CHAIN aLineChain)
protectedinherited

Definition at line 1275 of file cairo_gal.cpp.

1276{
1277 wxCHECK( aLineChain.PointCount() > 1, /* void */ );
1278
1279 syncLineWidth();
1280
1281 auto numPoints = aLineChain.PointCount();
1282
1283 if( aLineChain.IsClosed() )
1284 numPoints += 1;
1285
1286 const VECTOR2I start = aLineChain.CPoint( 0 );
1287 const VECTOR2D p = roundp( xform( start.x, start.y ) );
1288 cairo_move_to( m_currentContext, p.x, p.y );
1289
1290 for( int i = 1; i < numPoints; ++i )
1291 {
1292 const VECTOR2I& pw = aLineChain.CPoint( i );
1293 const VECTOR2D ps = roundp( xform( pw.x, pw.y ) );
1294 cairo_line_to( m_currentContext, ps.x, ps.y );
1295 }
1296
1297 flushPath();
1298 m_isElementAdded = true;
1299}
bool IsClosed() const override
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.

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.

◆ drawPoly() [2/4]

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

1202{
1203 wxCHECK( aPointList.size() > 1, /* void */ );
1204
1205 // Iterate over the point list and draw the segments
1206 std::deque<VECTOR2D>::const_iterator it = aPointList.begin();
1207
1208 syncLineWidth();
1209
1210 const VECTOR2D p = roundp( xform( it->x, it->y ) );
1211
1212 cairo_move_to( m_currentContext, p.x, p.y );
1213
1214 for( ++it; it != aPointList.end(); ++it )
1215 {
1216 const VECTOR2D p2 = roundp( xform( it->x, it->y ) );
1217
1218 cairo_line_to( m_currentContext, p2.x, p2.y );
1219 }
1220
1221 flushPath();
1222 m_isElementAdded = true;
1223}

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::DrawGlyph(), KIGFX::CAIRO_GAL_BASE::DrawPolygon(), KIGFX::CAIRO_GAL_BASE::DrawPolyline(), and KIGFX::CAIRO_GAL_BASE::DrawPolylines().

◆ drawPoly() [3/4]

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

Definition at line 1226 of file cairo_gal.cpp.

1227{
1228 wxCHECK( aPointList.size() > 1, /* void */ );
1229
1230 // Iterate over the point list and draw the segments
1231 std::vector<VECTOR2D>::const_iterator it = aPointList.begin();
1232
1233 syncLineWidth();
1234
1235 const VECTOR2D p = roundp( xform( it->x, it->y ) );
1236
1237 cairo_move_to( m_currentContext, p.x, p.y );
1238
1239 for( ++it; it != aPointList.end(); ++it )
1240 {
1241 const VECTOR2D p2 = roundp( xform( it->x, it->y ) );
1242
1243 cairo_line_to( m_currentContext, p2.x, p2.y );
1244 }
1245
1246 flushPath();
1247 m_isElementAdded = true;
1248}

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() [4/4]

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

Definition at line 1251 of file cairo_gal.cpp.

1252{
1253 wxCHECK( aListSize > 1, /* void */ );
1254
1255 // Iterate over the point list and draw the segments
1256 const VECTOR2D* ptr = aPointList;
1257
1258 syncLineWidth();
1259
1260 const VECTOR2D p = roundp( xform( ptr->x, ptr->y ) );
1261 cairo_move_to( m_currentContext, p.x, p.y );
1262
1263 for( int i = 1; i < aListSize; ++i )
1264 {
1265 ++ptr;
1266 const VECTOR2D p2 = roundp( xform( ptr->x, ptr->y ) );
1267 cairo_line_to( m_currentContext, p2.x, p2.y );
1268 }
1269
1270 flushPath();
1271 m_isElementAdded = true;
1272}

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.

◆ DrawPolygon() [1/4]

void CAIRO_GAL_BASE::DrawPolygon ( const SHAPE_LINE_CHAIN aPolySet)
overridevirtualinherited

Reimplemented from KIGFX::GAL.

Definition at line 474 of file cairo_gal.cpp.

475{
476 drawPoly( aPolygon );
477}

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolygon() [2/4]

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

Reimplemented from KIGFX::GAL.

Definition at line 467 of file cairo_gal.cpp.

468{
469 for( int i = 0; i < aPolySet.OutlineCount(); ++i )
470 drawPoly( aPolySet.COutline( i ) );
471}
int OutlineCount() const
Return the number of vertices in a given outline/hole.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const

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

◆ DrawPolygon() [3/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 114 of file cairo_gal.h.

114{ drawPoly( aPointList ); }

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolygon() [4/4]

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

Reimplemented from KIGFX::GAL.

Definition at line 115 of file cairo_gal.h.

116 {
117 drawPoly( aPointList, aListSize );
118 }

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolyline() [1/4]

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

Reimplemented from KIGFX::GAL.

Definition at line 104 of file cairo_gal.h.

104{ drawPoly( aLineChain ); }

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolyline() [2/4]

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

98{ drawPoly( aPointList ); }

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolyline() [3/4]

virtual void KIGFX::GAL::DrawPolyline ( const std::vector< VECTOR2D > &  aPointList)
inlinevirtualinherited

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 126 of file graphics_abstraction_layer.h.

126{};

◆ DrawPolyline() [4/4]

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

Reimplemented from KIGFX::GAL.

Definition at line 99 of file cairo_gal.h.

100 {
101 drawPoly( aPointList, aListSize );
102 }

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawPolylines()

void KIGFX::CAIRO_GAL_BASE::DrawPolylines ( const std::vector< std::vector< VECTOR2D > > &  aPointLists)
inlineoverridevirtualinherited

Draw multiple polylines.

Parameters
aPointListsare lists of 2D-Vectors containing the polyline points.

Reimplemented from KIGFX::GAL.

Definition at line 107 of file cairo_gal.h.

108 {
109 for( const std::vector<VECTOR2D>& points : aPointLists )
110 drawPoly( points );
111 }

References KIGFX::CAIRO_GAL_BASE::drawPoly().

◆ DrawRectangle() [1/2]

void KIGFX::GAL::DrawRectangle ( const BOX2I aRect)
inlineinherited

Definition at line 186 of file graphics_abstraction_layer.h.

187 {
188 DrawRectangle( aRect.GetOrigin(), aRect.GetEnd() );
189 }
const Vec & GetOrigin() const
Definition: box2.h:183
const Vec GetEnd() const
Definition: box2.h:185
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.

References KIGFX::GAL::DrawRectangle(), BOX2< Vec >::GetEnd(), and BOX2< Vec >::GetOrigin().

◆ DrawRectangle() [2/2]

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

446{
447 // Calculate the diagonal points
449
450 const VECTOR2D p0 = roundp( xform( aStartPoint ) );
451 const VECTOR2D p1 = roundp( xform( VECTOR2D( aEndPoint.x, aStartPoint.y ) ) );
452 const VECTOR2D p2 = roundp( xform( aEndPoint ) );
453 const VECTOR2D p3 = roundp( xform( VECTOR2D( aStartPoint.x, aEndPoint.y ) ) );
454
455 // The path is composed from 4 segments
456 cairo_move_to( m_currentContext, p0.x, p0.y );
457 cairo_line_to( m_currentContext, p1.x, p1.y );
458 cairo_line_to( m_currentContext, p2.x, p2.y );
459 cairo_line_to( m_currentContext, p3.x, p3.y );
460 cairo_close_path( m_currentContext );
461 flushPath();
462
463 m_isElementAdded = true;
464}

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

258{
259 if( m_isFillEnabled )
260 {
261 syncLineWidth( true, aWidth );
262
263 VECTOR2D p0 = roundp( xform( aStartPoint ) );
264 VECTOR2D p1 = roundp( xform( aEndPoint ) );
265
266 cairo_move_to( m_currentContext, p0.x, p0.y );
267 cairo_line_to( m_currentContext, p1.x, p1.y );
268 cairo_set_source_rgba( m_currentContext, m_fillColor.r, m_fillColor.g, m_fillColor.b,
269 m_fillColor.a );
270 cairo_stroke( m_currentContext );
271 }
272 else
273 {
274 aWidth /= 2.0;
275 SetLineWidth( 1.0 );
277
278 // Outline mode for tracks
279 VECTOR2D startEndVector = aEndPoint - aStartPoint;
280 double lineAngle = atan2( startEndVector.y, startEndVector.x );
281
282 double sa = sin( lineAngle + M_PI / 2.0 );
283 double ca = cos( lineAngle + M_PI / 2.0 );
284
285 VECTOR2D pa0 = xform( aStartPoint + VECTOR2D( aWidth * ca, aWidth * sa ) );
286 VECTOR2D pa1 = xform( aStartPoint - VECTOR2D( aWidth * ca, aWidth * sa ) );
287 VECTOR2D pb0 = xform( aEndPoint + VECTOR2D( aWidth * ca, aWidth * sa ) );
288 VECTOR2D pb1 = xform( aEndPoint - VECTOR2D( aWidth * ca, aWidth * sa ) );
289
292
293 cairo_move_to( m_currentContext, pa0.x, pa0.y );
294 cairo_line_to( m_currentContext, pb0.x, pb0.y );
295
296 cairo_move_to( m_currentContext, pa1.x, pa1.y );
297 cairo_line_to( m_currentContext, pb1.x, pb1.y );
298 flushPath();
299
300 // Calculate the segment angle and arc center in normal/mirrored transform for rounded ends.
301 VECTOR2D center_a = xform( aStartPoint );
302 VECTOR2D center_b = xform( aEndPoint );
303 startEndVector = center_b - center_a;
304 lineAngle = atan2( startEndVector.y, startEndVector.x );
305 double radius = ( pa0 - center_a ).EuclideanNorm();
306
307 // Draw the rounded end point of the segment
308 double arcStartAngle = lineAngle - M_PI / 2.0;
309 cairo_arc( m_currentContext, center_b.x, center_b.y, radius, arcStartAngle,
310 arcStartAngle + M_PI );
311
312 // Draw the rounded start point of the segment
313 arcStartAngle = lineAngle + M_PI / 2.0;
314 cairo_arc( m_currentContext, center_a.x, center_a.y, radius, arcStartAngle,
315 arcStartAngle + M_PI );
316
317 flushPath();
318 }
319
320 m_isElementAdded = true;
321}
double EuclideanNorm(const VECTOR2I &vector)
Definition: trigo.h:129

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.

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

◆ DrawSegmentChain() [1/2]

void CAIRO_GAL_BASE::DrawSegmentChain ( const SHAPE_LINE_CHAIN aLineChain,
double  aWidth 
)
overridevirtualinherited

Reimplemented from KIGFX::GAL.

Definition at line 244 of file cairo_gal.cpp.

245{
246 int numPoints = aLineChain.PointCount();
247
248 if( aLineChain.IsClosed() )
249 numPoints += 1;
250
251 for( int i = 0; i + 1 < numPoints; ++i )
252 DrawSegment( aLineChain.CPoint( i ), aLineChain.CPoint( i + 1 ), aWidth );
253}
void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth) override
Draw a rounded segment.
Definition: cairo_gal.cpp:256

References SHAPE_LINE_CHAIN::CPoint(), KIGFX::CAIRO_GAL_BASE::DrawSegment(), SHAPE_LINE_CHAIN::IsClosed(), and SHAPE_LINE_CHAIN::PointCount().

◆ DrawSegmentChain() [2/2]

void CAIRO_GAL_BASE::DrawSegmentChain ( const std::vector< VECTOR2D > &  aPointList,
double  aWidth 
)
overridevirtualinherited

Draw a chain of rounded segments.

Parameters
aPointListis a list of 2D-Vectors containing the chain points.
aWidthis a width of the segments

Reimplemented from KIGFX::GAL.

Definition at line 237 of file cairo_gal.cpp.

238{
239 for( size_t i = 0; i + 1 < aPointList.size(); ++i )
240 DrawSegment( aPointList[i], aPointList[i + 1], aWidth );
241}

References KIGFX::CAIRO_GAL_BASE::DrawSegment().

◆ EnableDepthTest()

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

Reimplemented from KIGFX::GAL.

Definition at line 1001 of file cairo_gal.cpp.

1002{
1003}

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

977{
978 m_compositor->DrawBuffer( m_tempBuffer, m_mainBuffer, CAIRO_OPERATOR_ADD );
979}

References m_compositor, m_mainBuffer, and m_tempBuffer.

◆ EndDrawing()

void CAIRO_GAL::EndDrawing ( )
overridevirtual

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

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

Reimplemented from KIGFX::CAIRO_GAL_BASE.

Definition at line 1395 of file cairo_gal.cpp.

1396{
1398
1399 // Merge buffers on the screen
1400 m_compositor->DrawBuffer( m_mainBuffer );
1401 m_compositor->DrawBuffer( m_overlayBuffer );
1402
1403 // Now translate the raw context data from the format stored
1404 // by cairo into a format understood by wxImage.
1405 pixman_image_t* dstImg = pixman_image_create_bits(
1406 wxPlatformInfo::Get().GetEndianness() == wxENDIAN_LITTLE ? PIXMAN_b8g8r8
1407 : PIXMAN_r8g8b8,
1409 pixman_image_t* srcImg =
1410 pixman_image_create_bits( PIXMAN_a8r8g8b8, m_screenSize.x, m_screenSize.y,
1411 (uint32_t*) m_bitmapBuffer, m_wxBufferWidth * 4 );
1412
1413 pixman_image_composite( PIXMAN_OP_SRC, srcImg, nullptr, dstImg, 0, 0, 0, 0, 0, 0,
1415
1416 // Free allocated memory
1417 pixman_image_unref( srcImg );
1418 pixman_image_unref( dstImg );
1419
1420 wxImage img( m_wxBufferWidth, m_screenSize.y, m_wxOutput, true );
1421 wxBitmap bmp( img );
1422 wxMemoryDC mdc( bmp );
1423 wxClientDC clientDC( this );
1424
1425 // Now it is the time to blit the mouse cursor
1426 blitCursor( mdc );
1427 clientDC.Blit( 0, 0, m_screenSize.x, m_screenSize.y, &mdc, 0, 0, wxCOPY );
1428
1429 deinitSurface();
1430}
void blitCursor(wxMemoryDC &clientDC)
Blit cursor into the current screen.
Definition: cairo_gal.cpp:1184
void EndDrawing() override
End the drawing, needs to be called for every new frame.
Definition: cairo_gal.cpp:99
void deinitSurface()
Destroy Cairo surfaces when are not needed anymore.
Definition: cairo_gal.cpp:1556

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

1477{
1479 deinitSurface();
1480}
void EndGroup() override
End the group.
Definition: cairo_gal.cpp:814

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

990{
991 m_compositor->DrawBuffer( m_tempBuffer, m_mainBuffer, CAIRO_OPERATOR_OVER );
992}

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

966{}

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

579{
580 storePath();
581}

References KIGFX::CAIRO_GAL_BASE::storePath().

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

◆ flushPath()

◆ GetClearColor()

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

Definition at line 263 of file graphics_abstraction_layer.h.

264 {
265 return m_clearColor;
266 }

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

245{
247
248 // dim the cursor if it's only on because it was forced
249 // (this helps to provide a hint for active tools)
250 if( !m_isCursorEnabled )
251 color.a = color.a * 0.5;
252
253 return color;
254}
bool m_isCursorEnabled
Is the cursor enabled?
COLOR4D m_cursorColor
Cursor color.

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

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

◆ GetFillColor()

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

Get the fill color.

Returns
the color for filling a outline.

Definition at line 314 of file graphics_abstraction_layer.h.

315 {
316 return m_fillColor;
317 }

References KIGFX::GAL::m_fillColor.

◆ GetGlyphSize()

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

◆ GetGridLineWidth()

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

Get the grid line width.

Returns
the grid line width Draw the grid

Definition at line 821 of file graphics_abstraction_layer.h.

References KIGFX::GAL::m_gridLineWidth.

◆ GetGridOrigin()

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

Definition at line 746 of file graphics_abstraction_layer.h.

747 {
748 return m_gridOrigin;
749 }

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

223{
224#if 0
225 // This old code expects a non zero grid size, which can be wrong here.
226 return VECTOR2D( KiROUND( ( aPoint.x - m_gridOffset.x ) / m_gridSize.x ) * m_gridSize.x + m_gridOffset.x,
227 KiROUND( ( aPoint.y - m_gridOffset.y ) / m_gridSize.y ) * m_gridSize.y + m_gridOffset.y );
228#else
229 // if grid size == 0.0 there is no grid, so use aPoint as grid reference position
230 double cx = m_gridSize.x > 0.0 ? KiROUND( ( aPoint.x - m_gridOffset.x ) / m_gridSize.x ) * m_gridSize.x + m_gridOffset.x
231 : aPoint.x;
232 double cy = m_gridSize.y > 0.0 ? KiROUND( ( aPoint.y - m_gridOffset.y ) / m_gridSize.y ) * m_gridSize.y + m_gridOffset.y
233 : aPoint.y;
234
235 return VECTOR2D( cx, cy );
236#endif
237}
VECTOR2D m_gridOffset
The grid offset to compensate cursor position.

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

◆ GetGridSnapping()

◆ GetGridVisibility()

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

Definition at line 718 of file graphics_abstraction_layer.h.

718{ return m_gridVisibility; }

References KIGFX::GAL::m_gridVisibility.

Referenced by EDA_DRAW_PANEL_GAL::SwitchBackend().

◆ GetHorizontalJustify()

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

Definition at line 415 of file graphics_abstraction_layer.h.

415{ return m_attributes.m_Halign; }
GR_TEXT_H_ALIGN_T m_Halign

References KIGFX::GAL::m_attributes, and TEXT_ATTRIBUTES::m_Halign.

Referenced by KIGFX::OPENGL_GAL::BitmapText().

◆ GetLineWidth()

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

Get the line width.

Returns
the actual line width.

Definition at line 354 of file graphics_abstraction_layer.h.

355 {
356 return m_lineWidth;
357 }

References KIGFX::GAL::m_lineWidth.

Referenced by KIGFX::GAL::BitmapText(), CALLBACK_GAL::DrawGlyph(), and KIGFX::OPENGL_GAL::DrawGrid().

◆ GetLookAtPoint()

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

Definition at line 582 of file graphics_abstraction_layer.h.

582{ return m_lookAtPoint; }

References KIGFX::GAL::m_lookAtPoint.

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

◆ GetMaxDepth()

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

◆ GetMinDepth()

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

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

1303{
1304 wxASSERT_MSG( m_groups.size() < std::numeric_limits<unsigned int>::max(),
1305 wxT( "There are no free slots to store a group" ) );
1306
1307 while( m_groups.find( m_groupCounter ) != m_groups.end() )
1309
1310 return m_groupCounter++;
1311}
unsigned int m_groupCounter
Counter used for generating group keys.
Definition: cairo_gal.h:354

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

Definition at line 591 of file graphics_abstraction_layer.h.

591{ return m_rotation; }

References KIGFX::GAL::m_rotation.

◆ GetScreenPixelSize()

◆ GetScreenWorldMatrix()

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

◆ GetStrokeColor()

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

Get the stroke color.

Returns
the color for stroking the outline.

Definition at line 334 of file graphics_abstraction_layer.h.

335 {
336 return m_strokeColor;
337 }

References KIGFX::GAL::m_strokeColor.

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

◆ GetSwapInterval()

virtual int KIGFX::GAL::GetSwapInterval ( ) const
inlinevirtualinherited

Return the swap interval. -1 for adaptive, 0 for disabled/unknown.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 253 of file graphics_abstraction_layer.h.

253{ return 0; };

Referenced by EDA_DRAW_PANEL_GAL::SwitchBackend().

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

1508{
1509 return m_currentTarget;
1510}

References m_currentTarget.

◆ GetVerticalJustify()

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

Definition at line 422 of file graphics_abstraction_layer.h.

422{ return m_attributes.m_Valign; }
GR_TEXT_V_ALIGN_T m_Valign

References KIGFX::GAL::m_attributes, and TEXT_ATTRIBUTES::m_Valign.

Referenced by KIGFX::OPENGL_GAL::BitmapText().

◆ GetVisibleWorldExtents()

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

Definition at line 199 of file graphics_abstraction_layer.cpp.

200{
201 const MATRIX3x3D& matrix = GetScreenWorldMatrix();
202
203 VECTOR2D halfSize = VECTOR2D( matrix.GetScale().x * m_screenSize.x * 0.5,
204 matrix.GetScale().y * m_screenSize.y * 0.5 );
205
206 BOX2D extents;
207 extents.SetOrigin( GetLookAtPoint() - halfSize );
208 extents.SetSize( halfSize * 2 );
209
210 return extents;
211}
void SetOrigin(const Vec &pos)
Definition: box2.h:202
void SetSize(const Vec &size)
Definition: box2.h:213
const VECTOR2D & GetLookAtPoint() const
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
VECTOR2< T > GetScale() const
Get the scale components of the matrix.
Definition: matrix3x3.h:265

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

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

◆ GetWorldScale()

◆ GetWorldScreenMatrix()

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

Get the world <-> screen transformation matrix.

Returns
the transformation matrix.

Definition at line 527 of file graphics_abstraction_layer.h.

528 {
529 return m_worldScreenMatrix;
530 }

References KIGFX::GAL::m_worldScreenMatrix.

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

◆ GetZoomFactor()

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

658 {
659 return true;
660 };

Referenced by EDA_DRAW_PANEL_GAL::DoRePaint().

◆ initSurface()

void CAIRO_GAL::initSurface ( )

Prepare Cairo surfaces for drawing.

Definition at line 1535 of file cairo_gal.cpp.

1536{
1537 if( m_isInitialized )
1538 return;
1539
1540 m_surface = cairo_image_surface_create_for_data( m_bitmapBuffer, GAL_FORMAT, m_wxBufferWidth,
1542
1543 m_context = cairo_create( m_surface );
1544
1545#ifdef DEBUG
1546 cairo_status_t status = cairo_status( m_context );
1547 wxASSERT_MSG( status == CAIRO_STATUS_SUCCESS, wxT( "Cairo context creation error" ) );
1548#endif /* DEBUG */
1549
1551
1552 m_isInitialized = true;
1553}

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

937 {
938 return false;
939 }

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

883 {
885 }
bool m_forceDisplayCursor
Always show cursor.

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

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

◆ IsFlippedX()

◆ IsFlippedY()

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

Definition at line 625 of file graphics_abstraction_layer.h.

625{ return m_globalFlipY; }

References KIGFX::GAL::m_globalFlipY.

◆ IsFontBold()

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

◆ 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::PCB_PAINTER::draw(), and KIGFX::GERBVIEW_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 397 of file cairo_gal.h.

398 {
399 return IsShownOnScreen() && !GetClientRect().IsEmpty();
400 }

◆ LockContext()

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

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

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 943 of file graphics_abstraction_layer.h.

943{}

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

100{
101 // defer to the child class first
102 updatedGalDisplayOptions( aOptions );
103
104 // there is no refresh to do at this level
105}
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 1615 of file cairo_gal.cpp.

1616{
1617 PostPaint( aEvent );
1618}
void PostPaint(wxPaintEvent &aEvent)
Post an event to m_paint_listener.
Definition: cairo_gal.cpp:1433

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

1669{
1670 aEvent.SetCursor( m_currentwxCursor );
1671}
wxCursor m_currentwxCursor
wxCursor showing the current native cursor
Definition: cairo_gal.h:518

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

925 {
927 m_depthStack.pop();
928 }
std::stack< double > m_depthStack
Stored depth values.

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

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

1434{
1435 // posts an event to m_paint_listener to ask for redraw the canvas.
1436 if( m_paintListener )
1437 wxPostEvent( m_paintListener, aEvent );
1438}

References m_paintListener.

Referenced by onPaint().

◆ PushDepth()

void KIGFX::GAL::PushDepth ( )
inlineinherited

Store current drawing depth on the depth stack.

Definition at line 916 of file graphics_abstraction_layer.h.

917 {
919 }

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

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

◆ resetContext()

void CAIRO_GAL_BASE::resetContext ( )
protectedinherited

Definition at line 1006 of file cairo_gal.cpp.

1007{
1008 for( _cairo_surface* imageSurface : m_imageSurfaces )
1009 cairo_surface_destroy( imageSurface );
1010
1011 m_imageSurfaces.clear();
1012
1013 ClearScreen();
1014
1015 // Compute the world <-> screen transformations
1017
1018 cairo_matrix_init( &m_cairoWorldScreenMatrix, m_worldScreenMatrix.m_data[0][0],
1022
1023 // we work in screen-space coordinates and do the transforms outside.
1024 cairo_identity_matrix( m_context );
1025
1026 cairo_matrix_init_identity( &m_currentXform );
1027
1028 // Start drawing with a new path
1029 cairo_new_path( m_context );
1030 m_isElementAdded = true;
1031
1033
1034 m_lineWidth = 0;
1035}
cairo_matrix_t m_cairoWorldScreenMatrix
Cairo world to screen transform matrix.
Definition: cairo_gal.h:360
void ClearScreen() override
Clear the screen.
Definition: cairo_gal.cpp:584
cairo_matrix_t m_currentXform
Definition: cairo_gal.h:361
void updateWorldScreenMatrix()
Definition: cairo_gal.cpp:106
virtual void ComputeWorldScreenMatrix()
Compute the world <-> screen transformation matrix.
T m_data[3][3]
Definition: matrix3x3.h:64

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.

FONT TODO: do we need any of this in GAL anymore?

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

Definition at line 153 of file graphics_abstraction_layer.cpp.

154{
155 // Tiny but non-zero - this will always need setting
156 // there is no built-in default
157 SetGlyphSize( { 1, 1 } );
158
161
162 SetFontBold( false );
163 SetFontItalic( false );
164 SetFontUnderlined( false );
165 SetTextMirrored( false );
166}
void SetVerticalJustify(const GR_TEXT_V_ALIGN_T aVerticalJustify)
void SetFontBold(const bool aBold)
void SetFontUnderlined(bool aUnderlined)
void SetHorizontalJustify(const GR_TEXT_H_ALIGN_T aHorizontalJustify)
void SetTextMirrored(const bool aMirrored)
void SetGlyphSize(const VECTOR2I aSize)
void SetFontItalic(bool aItalic)
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_CENTER

References GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_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::ARC_ASSISTANT::ViewDraw(), KIGFX::PREVIEW::RULER_ITEM::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 1441 of file cairo_gal.cpp.

1442{
1443 CAIRO_GAL_BASE::ResizeScreen( aWidth, aHeight );
1444
1445 // Recreate the bitmaps
1446 deleteBitmaps();
1448
1449 if( m_validCompositor )
1450 m_compositor->Resize( aWidth, aHeight );
1451
1452 m_validCompositor = false;
1453
1454 SetSize( wxSize( aWidth, aHeight ) );
1455}
void ResizeScreen(int aWidth, int aHeight) override
Resizes the canvas.
Definition: cairo_gal.cpp:572

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

777{
778 storePath();
779
780 if( m_isGrouping )
781 {
782 GROUP_ELEMENT groupElement;
783 groupElement.m_Command = CMD_RESTORE;
784 m_currentGroup->push_back( groupElement );
785 }
786 else
787 {
788 if( !m_xformStack.empty() )
789 {
791 m_xformStack.pop_back();
793 }
794 }
795}
GROUP * m_currentGroup
Currently used group.
Definition: cairo_gal.h:355
bool m_isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:351
std::vector< cairo_matrix_t > m_xformStack
Definition: cairo_gal.h:370

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

700{
701 storePath();
702
703 if( m_isGrouping )
704 {
705 GROUP_ELEMENT groupElement;
706 groupElement.m_Command = CMD_ROTATE;
707 groupElement.m_Argument.DblArg[0] = aAngle;
708 m_currentGroup->push_back( groupElement );
709 }
710 else
711 {
712 cairo_matrix_rotate( &m_currentXform, aAngle );
714 }
715}

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

759{
760 storePath();
761
762 if( m_isGrouping )
763 {
764 GROUP_ELEMENT groupElement;
765 groupElement.m_Command = CMD_SAVE;
766 m_currentGroup->push_back( groupElement );
767 }
768 else
769 {
770 m_xformStack.push_back( m_currentXform );
772 }
773}

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

739{
740 storePath();
741
742 if( m_isGrouping )
743 {
744 GROUP_ELEMENT groupElement;
745 groupElement.m_Command = CMD_SCALE;
746 groupElement.m_Argument.DblArg[0] = aScale.x;
747 groupElement.m_Argument.DblArg[1] = aScale.y;
748 m_currentGroup->push_back( groupElement );
749 }
750 else
751 {
752 cairo_matrix_scale( &m_currentXform, aScale.x, aScale.y );
754 }
755}

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

812 {
813 m_gridTick = aInterval;
814 }

References KIGFX::GAL::m_gridTick.

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

◆ setCompositor()

void CAIRO_GAL::setCompositor ( )

Prepare the compositor.

Definition at line 1599 of file cairo_gal.cpp.

1600{
1601 // Recreate the compositor with the new Cairo context
1604 m_compositor->SetAntialiasingMode( m_options.cairo_antialiasing_mode );
1605
1606 // Prepare buffers
1607 m_mainBuffer = m_compositor->CreateBuffer();
1608 m_overlayBuffer = m_compositor->CreateBuffer();
1609 m_tempBuffer = m_compositor->CreateBuffer();
1610
1611 m_validCompositor = true;
1612}
CAIRO_ANTIALIASING_MODE cairo_antialiasing_mode

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

893 {
894 m_cursorColor = aCursorColor;
895 }

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

873 {
874 m_isCursorEnabled = aCursorEnabled;
875 }

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.

The MinDepth (x) is closest to the clipping plane (top) while the MaxDepth (y) is farthest from the clipping plane (bottom).

Definition at line 601 of file graphics_abstraction_layer.h.

601{ m_depthRange = aDepthRange; }

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

641{
642 storePath();
643 m_fillColor = aColor;
644
645 if( m_isGrouping )
646 {
647 GROUP_ELEMENT groupElement;
648 groupElement.m_Command = CMD_SET_FILLCOLOR;
649 groupElement.m_Argument.DblArg[0] = m_fillColor.r;
650 groupElement.m_Argument.DblArg[1] = m_fillColor.g;
651 groupElement.m_Argument.DblArg[2] = m_fillColor.b;
652 groupElement.m_Argument.DblArg[3] = m_fillColor.a;
653 m_currentGroup->push_back( groupElement );
654 }
655}

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

619 {
620 m_globalFlipX = xAxis;
621 m_globalFlipY = yAxis;
622 }

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 ( const bool  aBold)
inlineinherited

◆ SetFontItalic()

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

◆ SetFontUnderlined()

void KIGFX::GAL::SetFontUnderlined ( bool  aUnderlined)
inlineinherited

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

784 {
785 m_gridColor = aGridColor;
786 }

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(), PCB_EDIT_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 731 of file graphics_abstraction_layer.h.

732 {
733 m_gridOrigin = aGridOrigin;
734
735 if( m_gridSize.x == 0.0 || m_gridSize.y == 0.0 )
736 {
737 m_gridOffset = VECTOR2D( 0.0, 0.0);
738 }
739 else
740 {
741 m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x,
742 (long) m_gridOrigin.y % (long) m_gridSize.y );
743 }
744 }

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

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

◆ SetGridSize()

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

Set the grid size.

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

Definition at line 756 of file graphics_abstraction_layer.h.

757 {
758 m_gridSize = aGridSize;
759
760 // Avoid stupid grid size values: a grid size should be >= 1 in internal units
761 m_gridSize.x = std::max( 1.0, m_gridSize.x );
762 m_gridSize.y = std::max( 1.0, m_gridSize.y );
763
764 m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x,
765 (long) m_gridOrigin.y % (long) m_gridSize.y );
766 }

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

◆ SetHorizontalJustify()

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

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

593{
594 storePath();
595 m_isFillEnabled = aIsFillEnabled;
596
597 if( m_isGrouping )
598 {
599 GROUP_ELEMENT groupElement;
600 groupElement.m_Command = CMD_SET_FILL;
601 groupElement.m_Argument.BoolArg = aIsFillEnabled;
602 m_currentGroup->push_back( groupElement );
603 }
604}

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

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

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

608{
609 storePath();
610 m_isStrokeEnabled = aIsStrokeEnabled;
611
612 if( m_isGrouping )
613 {
614 GROUP_ELEMENT groupElement;
615 groupElement.m_Command = CMD_SET_STROKE;
616 groupElement.m_Argument.BoolArg = aIsStrokeEnabled;
617 m_currentGroup->push_back( groupElement );
618 }
619}

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

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

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

678{
679 super::SetLayerDepth( aLayerDepth );
680 storePath();
681}
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 658 of file cairo_gal.cpp.

659{
660 storePath();
661 GAL::SetLineWidth( aLineWidth );
662
663 if( m_isGrouping )
664 {
665 GROUP_ELEMENT groupElement;
666 groupElement.m_Command = CMD_SET_LINE_WIDTH;
667 groupElement.m_Argument.DblArg[0] = aLineWidth;
668 m_currentGroup->push_back( groupElement );
669 }
670 else
671 {
672 m_lineWidth = aLineWidth;
673 }
674}
virtual void SetLineWidth(float aLineWidth)
Set the line width.

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

Get/set the Point in world space to look at.

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

Definition at line 581 of file graphics_abstraction_layer.h.

581{ m_lookAtPoint = aPoint; }

References KIGFX::GAL::m_lookAtPoint.

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

◆ SetMouseListener()

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

Definition at line 436 of file cairo_gal.h.

437 {
438 m_mouseListener = aMouseListener;
439 }

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

1654{
1655 // Store the current cursor type and get the wxCursor for it
1656 if( !GAL::SetNativeCursorStyle( aCursor ) )
1657 return false;
1658
1660
1661 // Update the cursor in the wx control
1662 wxWindow::SetCursor( m_currentwxCursor );
1663
1664 return true;
1665}
static const wxCursor GetCursor(KICURSOR aCursorType)
Definition: cursors.cpp:394
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 963 of file cairo_gal.cpp.

964{
965 cairo_set_operator( m_currentContext, aSetting ? CAIRO_OPERATOR_CLEAR : CAIRO_OPERATOR_OVER );
966}

References KIGFX::CAIRO_GAL_BASE::m_currentContext.

◆ SetPaintListener()

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

Definition at line 441 of file cairo_gal.h.

442 {
443 m_paintListener = aPaintListener;
444 }

References m_paintListener.

◆ SetRotation()

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

Get/set the rotation angle (in radians).

Definition at line 590 of file graphics_abstraction_layer.h.

590{ m_rotation = aRotation; }

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.

Definition at line 574 of file graphics_abstraction_layer.h.

574{ m_screenDPI = aScreenDPI; }

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

566{ m_screenSize = aSize; }

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

623{
624 storePath();
625 m_strokeColor = aColor;
626
627 if( m_isGrouping )
628 {
629 GROUP_ELEMENT groupElement;
630 groupElement.m_Command = CMD_SET_STROKECOLOR;
631 groupElement.m_Argument.DblArg[0] = m_strokeColor.r;
632 groupElement.m_Argument.DblArg[1] = m_strokeColor.g;
633 groupElement.m_Argument.DblArg[2] = m_strokeColor.b;
634 groupElement.m_Argument.DblArg[3] = m_strokeColor.a;
635 m_currentGroup->push_back( groupElement );
636 }
637}

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

1484{
1485 // If the compositor is not set, that means that there is a recaching process going on
1486 // and we do not need the compositor now
1487 if( !m_validCompositor )
1488 return;
1489
1490 // Cairo grouping prevents display of overlapping items on the same layer in the lighter color
1491 if( m_isInitialized )
1492 storePath();
1493
1494 switch( aTarget )
1495 {
1496 default:
1497 case TARGET_CACHED:
1498 case TARGET_NONCACHED: m_compositor->SetBuffer( m_mainBuffer ); break;
1499 case TARGET_OVERLAY: m_compositor->SetBuffer( m_overlayBuffer ); break;
1500 case TARGET_TEMP: m_compositor->SetBuffer( m_tempBuffer ); break;
1501 }
1502
1503 m_currentTarget = aTarget;
1504}

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

◆ SetTextMirrored()

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

◆ SetVerticalJustify()

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

◆ SetWorldScreenMatrix()

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

Set the world <-> screen transformation matrix.

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

Definition at line 547 of file graphics_abstraction_layer.h.

548 {
549 m_worldScreenMatrix = aMatrix;
550 }

References KIGFX::GAL::m_worldScreenMatrix.

◆ SetWorldUnitLength()

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

Set the unit length.

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

Definition at line 564 of file graphics_abstraction_layer.h.

564{ m_worldUnitLength = aWorldUnitLength; }

References KIGFX::GAL::m_worldUnitLength.

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

◆ SetZoomFactor()

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

Definition at line 584 of file graphics_abstraction_layer.h.

584{ m_zoomFactor = aZoomFactor; }

References KIGFX::GAL::m_zoomFactor.

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

◆ Show()

bool CAIRO_GAL::Show ( bool  aShow)
overridevirtual

Show/hide the GAL canvas.

Reimplemented from KIGFX::GAL.

Definition at line 1458 of file cairo_gal.cpp.

1459{
1460 bool s = wxWindow::Show( aShow );
1461
1462 if( aShow )
1463 wxWindow::Raise();
1464
1465 return s;
1466}

◆ skipMouseEvent()

void CAIRO_GAL::skipMouseEvent ( wxMouseEvent &  aEvent)

Mouse event handler, forwards the event to the child.

Parameters
aEventis the mouse event to be forwarded.

Definition at line 1621 of file cairo_gal.cpp.

1622{
1623 // Post the mouse event to the event listener registered in constructor, if any
1624 if( m_mouseListener )
1625 wxPostEvent( m_mouseListener, aEvent );
1626}

References m_mouseListener.

Referenced by CAIRO_GAL().

◆ StartDiffLayer()

void CAIRO_GAL::StartDiffLayer ( )
overridevirtual

Begins rendering of a differential layer.

Used by gerbview's differential mode.

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

Reimplemented from KIGFX::GAL.

Definition at line 969 of file cairo_gal.cpp.

970{
973}
void ClearTarget(RENDER_TARGET aTarget) override
Clear the target for rendering.
Definition: cairo_gal.cpp:1513

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

◆ StartNegativesLayer()

void CAIRO_GAL::StartNegativesLayer ( )
overridevirtual

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

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

Reimplemented from KIGFX::GAL.

Definition at line 982 of file cairo_gal.cpp.

983{
986}

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

◆ storePath()

void CAIRO_GAL_BASE::storePath ( )
protectedinherited

Store the actual path.

Definition at line 1135 of file cairo_gal.cpp.

1136{
1137 if( m_isElementAdded )
1138 {
1139 m_isElementAdded = false;
1140
1141 if( !m_isGrouping )
1142 {
1143 if( m_isFillEnabled )
1144 {
1145 cairo_set_source_rgba( m_currentContext, m_fillColor.r, m_fillColor.g,
1147 cairo_fill_preserve( m_currentContext );
1148 }
1149
1150 if( m_isStrokeEnabled )
1151 {
1152 cairo_set_source_rgba( m_currentContext, m_strokeColor.r, m_strokeColor.g,
1154 cairo_stroke_preserve( m_currentContext );
1155 }
1156 }
1157 else
1158 {
1159 // Copy the actual path, append it to the global path list
1160 // then check, if the path needs to be stroked/filled and
1161 // add this command to the group list;
1162 if( m_isStrokeEnabled )
1163 {
1164 GROUP_ELEMENT groupElement;
1165 groupElement.m_CairoPath = cairo_copy_path( m_currentContext );
1166 groupElement.m_Command = CMD_STROKE_PATH;
1167 m_currentGroup->push_back( groupElement );
1168 }
1169
1170 if( m_isFillEnabled )
1171 {
1172 GROUP_ELEMENT groupElement;
1173 groupElement.m_CairoPath = cairo_copy_path( m_currentContext );
1174 groupElement.m_Command = CMD_FILL_PATH;
1175 m_currentGroup->push_back( groupElement );
1176 }
1177 }
1178
1179 cairo_new_path( m_currentContext );
1180 }
1181}

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

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

◆ syncLineWidth()

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

Definition at line 213 of file cairo_gal.cpp.

214{
215 double w = floor( xform( aForceWidth ? aWidth : m_lineWidth ) + 0.5 );
216
217 if( w <= 1.0 )
218 {
219 w = 1.0;
220 cairo_set_line_join( m_currentContext, CAIRO_LINE_JOIN_MITER );
221 cairo_set_line_cap( m_currentContext, CAIRO_LINE_CAP_BUTT );
222 cairo_set_line_width( m_currentContext, 1.0 );
223 m_lineWidthIsOdd = true;
224 }
225 else
226 {
227 cairo_set_line_join( m_currentContext, CAIRO_LINE_JOIN_ROUND );
228 cairo_set_line_cap( m_currentContext, CAIRO_LINE_CAP_ROUND );
229 cairo_set_line_width( m_currentContext, w );
230 m_lineWidthIsOdd = ( (int) w % 2 ) == 1;
231 }
232
234}

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

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

◆ ToScreen()

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

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

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

Definition at line 854 of file graphics_abstraction_layer.h.

855 {
856 return VECTOR2D( m_worldScreenMatrix * aPoint );
857 }

References KIGFX::GAL::m_worldScreenMatrix.

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

◆ ToWorld()

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

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

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

Definition at line 843 of file graphics_abstraction_layer.h.

844 {
845 return VECTOR2D( m_screenWorldMatrix * aPoint );
846 }

References KIGFX::GAL::m_screenWorldMatrix.

◆ Transform()

void CAIRO_GAL_BASE::Transform ( const MATRIX3x3D aTransformation)
overridevirtualinherited

Transform the context.

Parameters
aTransformationis the transformation matrix.

Reimplemented from KIGFX::GAL.

Definition at line 684 of file cairo_gal.cpp.

685{
686 cairo_matrix_t cairoTransformation, newXform;
687
688 cairo_matrix_init( &cairoTransformation, aTransformation.m_data[0][0],
689 aTransformation.m_data[1][0], aTransformation.m_data[0][1],
690 aTransformation.m_data[1][1], aTransformation.m_data[0][2],
691 aTransformation.m_data[1][2] );
692
693 cairo_matrix_multiply( &newXform, &m_currentXform, &cairoTransformation );
694 m_currentXform = newXform;
696}

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

◆ Translate()

void CAIRO_GAL_BASE::Translate ( const VECTOR2D aTranslation)
overridevirtualinherited

Translate the context.

Parameters
aTranslationis the translation vector.

Reimplemented from KIGFX::GAL.

Definition at line 718 of file cairo_gal.cpp.

719{
720 storePath();
721
722 if( m_isGrouping )
723 {
724 GROUP_ELEMENT groupElement;
725 groupElement.m_Command = CMD_TRANSLATE;
726 groupElement.m_Argument.DblArg[0] = aTranslation.x;
727 groupElement.m_Argument.DblArg[1] = aTranslation.y;
728 m_currentGroup->push_back( groupElement );
729 }
730 else
731 {
732 cairo_matrix_translate( &m_currentXform, aTranslation.x, aTranslation.y );
734 }
735}

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

◆ UnlockContext()

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

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 945 of file graphics_abstraction_layer.h.

945{}

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

◆ updatedGalDisplayOptions()

bool CAIRO_GAL::updatedGalDisplayOptions ( const GAL_DISPLAY_OPTIONS aOptions)
overridevirtual

Handle updating display options.

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

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

Reimplemented from KIGFX::GAL.

Definition at line 1629 of file cairo_gal.cpp.

1630{
1631 bool refresh = false;
1632
1633 if( m_validCompositor &&
1634 aOptions.cairo_antialiasing_mode != m_compositor->GetAntialiasingMode() )
1635 {
1636 m_compositor->SetAntialiasingMode( m_options.cairo_antialiasing_mode );
1637 m_validCompositor = false;
1638 deinitSurface();
1639
1640 refresh = true;
1641 }
1642
1643 if( super::updatedGalDisplayOptions( aOptions ) )
1644 {
1645 Refresh();
1646 refresh = true;
1647 }
1648
1649 return refresh;
1650}
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...

References KIGFX::GAL_DISPLAY_OPTIONS::cairo_antialiasing_mode, deinitSurface(), m_compositor, KIGFX::GAL::m_options, m_validCompositor, refresh, Refresh(), and KIGFX::GAL::updatedGalDisplayOptions().

◆ updateWorldScreenMatrix()

◆ xform() [1/3]

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

Definition at line 122 of file cairo_gal.cpp.

123{
124 return xform( aP.x, aP.y );
125}

References VECTOR2< T >::x, KIGFX::CAIRO_GAL_BASE::xform(), and VECTOR2< T >::y.

◆ xform() [2/3]

◆ xform() [3/3]

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

Definition at line 112 of file cairo_gal.cpp.

113{
114 VECTOR2D rv;
115
118 return rv;
119}

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

Member Data Documentation

◆ GAL_FORMAT

constexpr cairo_format_t KIGFX::CAIRO_GAL_BASE::GAL_FORMAT = CAIRO_FORMAT_ARGB32
staticconstexprprotectedinherited

Format used to store pixels.

Definition at line 372 of file cairo_gal.h.

Referenced by allocateBitmaps(), and initSurface().

◆ GRID_DEPTH

const int GAL::GRID_DEPTH = MAX_DEPTH - 1
staticprotectedinherited

Depth level on which the grid is drawn.

Definition at line 988 of file graphics_abstraction_layer.h.

◆ m_attributes

◆ m_axesColor

COLOR4D KIGFX::GAL::m_axesColor
protectedinherited

◆ m_axesEnabled

bool KIGFX::GAL::m_axesEnabled
protectedinherited

◆ m_backgroundColor

COLOR4D KIGFX::CAIRO_GAL::m_backgroundColor
protected

Background color.

Definition at line 517 of file cairo_gal.h.

◆ m_bitmapBuffer

unsigned char* KIGFX::CAIRO_GAL::m_bitmapBuffer
protected

Storage of the Cairo image.

Definition at line 513 of file cairo_gal.h.

Referenced by allocateBitmaps(), CAIRO_GAL(), deleteBitmaps(), EndDrawing(), and initSurface().

◆ m_bufferSize

unsigned int KIGFX::CAIRO_GAL::m_bufferSize
protected

Size of buffers cairoOutput, bitmapBuffers.

Definition at line 509 of file cairo_gal.h.

Referenced by allocateBitmaps().

◆ m_cairoWorldScreenMatrix

cairo_matrix_t KIGFX::CAIRO_GAL_BASE::m_cairoWorldScreenMatrix
protectedinherited

Cairo world to screen transform matrix.

Definition at line 360 of file cairo_gal.h.

Referenced by KIGFX::CAIRO_GAL_BASE::CAIRO_GAL_BASE(), KIGFX::CAIRO_GAL_BASE::resetContext(), and KIGFX::CAIRO_GAL_BASE::updateWorldScreenMatrix().

◆ m_clearColor

◆ m_compositor

std::shared_ptr<CAIRO_COMPOSITOR> KIGFX::CAIRO_GAL::m_compositor
protected

◆ m_context

◆ m_currentContext

◆ m_currentGroup

◆ m_currentNativeCursor

KICURSOR KIGFX::GAL::m_currentNativeCursor
protectedinherited

◆ m_currentTarget

RENDER_TARGET KIGFX::CAIRO_GAL::m_currentTarget
protected

Current rendering target.

Definition at line 502 of file cairo_gal.h.

Referenced by CAIRO_GAL(), GetTarget(), and SetTarget().

◆ m_currentWorld2Screen

cairo_matrix_t KIGFX::CAIRO_GAL_BASE::m_currentWorld2Screen
protectedinherited

◆ m_currentwxCursor

wxCursor KIGFX::CAIRO_GAL::m_currentwxCursor
protected

wxCursor showing the current native cursor

Definition at line 518 of file cairo_gal.h.

Referenced by onSetNativeCursor(), and SetNativeCursorStyle().

◆ m_currentXform

◆ m_cursorColor

COLOR4D KIGFX::GAL::m_cursorColor
protectedinherited

Cursor color.

Definition at line 1061 of file graphics_abstraction_layer.h.

Referenced by KIGFX::GAL::getCursorColor(), and KIGFX::GAL::SetCursorColor().

◆ m_cursorPosition

VECTOR2D KIGFX::GAL::m_cursorPosition
protectedinherited

◆ m_depthRange

◆ m_depthStack

std::stack<double> KIGFX::GAL::m_depthStack
protectedinherited

Stored depth values.

Definition at line 1016 of file graphics_abstraction_layer.h.

Referenced by KIGFX::GAL::PopDepth(), and KIGFX::GAL::PushDepth().

◆ m_fillColor

◆ m_forceDisplayCursor

bool KIGFX::GAL::m_forceDisplayCursor
protectedinherited

◆ m_fullscreenCursor

bool KIGFX::GAL::m_fullscreenCursor
protectedinherited

Shape of the cursor (fullscreen or small cross)

Definition at line 1062 of file graphics_abstraction_layer.h.

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

◆ m_globalFlipX

◆ m_globalFlipY

bool KIGFX::GAL::m_globalFlipY
protectedinherited

◆ m_gridColor

◆ m_gridLineWidth

float KIGFX::GAL::m_gridLineWidth
protectedinherited

◆ m_gridMinSpacing

int KIGFX::GAL::m_gridMinSpacing
protectedinherited

Minimum screen size of the grid (pixels) below which the grid is not drawn.

Definition at line 1055 of file graphics_abstraction_layer.h.

Referenced by KIGFX::GAL::computeMinGridSpacing(), KIGFX::GAL::GAL(), and KIGFX::GAL::updatedGalDisplayOptions().

◆ m_gridOffset

VECTOR2D KIGFX::GAL::m_gridOffset
protectedinherited

The grid offset to compensate cursor position.

Definition at line 1049 of file graphics_abstraction_layer.h.

Referenced by KIGFX::GAL::GetGridPoint(), KIGFX::GAL::SetGridOrigin(), and KIGFX::GAL::SetGridSize().

◆ m_gridOrigin

VECTOR2D KIGFX::GAL::m_gridOrigin
protectedinherited

◆ m_gridSize

◆ m_gridStyle

GRID_STYLE KIGFX::GAL::m_gridStyle
protectedinherited

◆ m_gridTick

int KIGFX::GAL::m_gridTick
protectedinherited

Every tick line gets the double width.

Definition at line 1053 of file graphics_abstraction_layer.h.

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

◆ m_gridVisibility

bool KIGFX::GAL::m_gridVisibility
protectedinherited

◆ m_groupCounter

unsigned int KIGFX::CAIRO_GAL_BASE::m_groupCounter
protectedinherited

Counter used for generating group keys.

Definition at line 354 of file cairo_gal.h.

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

◆ m_groups

◆ m_imageSurfaces

std::vector<cairo_surface_t*> KIGFX::CAIRO_GAL_BASE::m_imageSurfaces
protectedinherited

List of surfaces that were created by painting images, to be cleaned up later.

Definition at line 368 of file cairo_gal.h.

Referenced by KIGFX::CAIRO_GAL_BASE::DrawBitmap(), KIGFX::CAIRO_GAL_BASE::resetContext(), and KIGFX::CAIRO_GAL_BASE::~CAIRO_GAL_BASE().

◆ m_isCursorEnabled

bool KIGFX::GAL::m_isCursorEnabled
protectedinherited

◆ m_isElementAdded

◆ m_isFillEnabled

◆ m_isGrouping

◆ m_isInitialized

bool KIGFX::CAIRO_GAL::m_isInitialized
protected

Are Cairo image & surface ready to use.

Definition at line 516 of file cairo_gal.h.

Referenced by CAIRO_GAL(), deinitSurface(), initSurface(), and SetTarget().

◆ m_isStrokeEnabled

◆ m_layerDepth

◆ m_lineWidth

◆ m_lineWidthInPixels

◆ m_lineWidthIsOdd

◆ m_lookAtPoint

◆ m_mainBuffer

unsigned int KIGFX::CAIRO_GAL::m_mainBuffer
protected

Handle to the main buffer.

Definition at line 498 of file cairo_gal.h.

Referenced by BeginDrawing(), CAIRO_GAL(), ClearTarget(), EndDiffLayer(), EndDrawing(), EndNegativesLayer(), setCompositor(), and SetTarget().

◆ m_mouseListener

wxEvtHandler* KIGFX::CAIRO_GAL::m_mouseListener
protected

Mouse listener.

Definition at line 507 of file cairo_gal.h.

Referenced by CAIRO_GAL(), SetMouseListener(), and skipMouseEvent().

◆ m_observerLink

UTIL::LINK KIGFX::GAL::m_observerLink
protectedinherited

Definition at line 1014 of file graphics_abstraction_layer.h.

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

◆ m_options

◆ m_overlayBuffer

unsigned int KIGFX::CAIRO_GAL::m_overlayBuffer
protected

Handle to the overlay buffer.

Definition at line 499 of file cairo_gal.h.

Referenced by CAIRO_GAL(), ClearTarget(), EndDrawing(), setCompositor(), and SetTarget().

◆ m_paintListener

wxEvtHandler* KIGFX::CAIRO_GAL::m_paintListener
protected

Paint listener.

Definition at line 508 of file cairo_gal.h.

Referenced by CAIRO_GAL(), PostPaint(), and SetPaintListener().

◆ m_parentWindow

wxWindow* KIGFX::CAIRO_GAL::m_parentWindow
protected

Parent window.

Definition at line 506 of file cairo_gal.h.

Referenced by CAIRO_GAL().

◆ m_rotation

double KIGFX::GAL::m_rotation
protectedinherited

Rotation transformation (radians)

Definition at line 1024 of file graphics_abstraction_layer.h.

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

◆ m_savedBuffer

unsigned int KIGFX::CAIRO_GAL::m_savedBuffer
protected

Handle to buffer to restore after rendering to temp buffer.

Definition at line 501 of file cairo_gal.h.

Referenced by CAIRO_GAL().

◆ m_screenDPI

double KIGFX::GAL::m_screenDPI
protectedinherited

◆ m_screenSize

◆ m_screenWorldMatrix

◆ m_stride

int KIGFX::CAIRO_GAL::m_stride
protected

Stride value for Cairo.

Definition at line 514 of file cairo_gal.h.

Referenced by allocateBitmaps(), and initSurface().

◆ m_strokeColor

◆ m_surface

cairo_surface_t* KIGFX::CAIRO_GAL_BASE::m_surface
protectedinherited

◆ m_tempBuffer

unsigned int KIGFX::CAIRO_GAL::m_tempBuffer
protected

Handle to the temp buffer.

Definition at line 500 of file cairo_gal.h.

Referenced by CAIRO_GAL(), ClearTarget(), EndDiffLayer(), EndNegativesLayer(), setCompositor(), and SetTarget().

◆ m_validCompositor

bool KIGFX::CAIRO_GAL::m_validCompositor
protected

Compositor initialization flag.

Definition at line 503 of file cairo_gal.h.

Referenced by BeginDrawing(), CAIRO_GAL(), ResizeScreen(), setCompositor(), SetTarget(), and updatedGalDisplayOptions().

◆ m_worldScale

◆ m_worldScreenMatrix

◆ m_worldUnitLength

double KIGFX::GAL::m_worldUnitLength
protectedinherited

◆ m_wxBufferWidth

int KIGFX::CAIRO_GAL::m_wxBufferWidth
protected

Definition at line 515 of file cairo_gal.h.

Referenced by allocateBitmaps(), EndDrawing(), and initSurface().

◆ m_wxOutput

unsigned char* KIGFX::CAIRO_GAL::m_wxOutput
protected

wxImage compatible buffer

Definition at line 510 of file cairo_gal.h.

Referenced by allocateBitmaps(), CAIRO_GAL(), deleteBitmaps(), and EndDrawing().

◆ m_xformStack

std::vector<cairo_matrix_t> KIGFX::CAIRO_GAL_BASE::m_xformStack
protectedinherited

Definition at line 370 of file cairo_gal.h.

Referenced by KIGFX::CAIRO_GAL_BASE::Restore(), and KIGFX::CAIRO_GAL_BASE::Save().

◆ m_zoomFactor

double KIGFX::GAL::m_zoomFactor
protectedinherited

◆ MAX_CAIRO_ARGUMENTS

const int KIGFX::CAIRO_GAL_BASE::MAX_CAIRO_ARGUMENTS = 4
staticprotectedinherited

Maximum number of arguments for one command.

Definition at line 315 of file cairo_gal.h.

◆ MAX_DEPTH

const int GAL::MAX_DEPTH = 1023
staticprotectedinherited

Definition at line 985 of file graphics_abstraction_layer.h.

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

◆ MIN_DEPTH

const int GAL::MIN_DEPTH = -1024
staticprotectedinherited

Possible depth range.

Definition at line 984 of file graphics_abstraction_layer.h.

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


The documentation for this class was generated from the following files: