39#include <wx/dcbuffer.h> 
   72    void DrawLine( 
const VECTOR2D& aStartPoint, 
const VECTOR2D& aEndPoint ) 
override;
 
   76                      double aWidth ) 
override;
 
   79    void DrawCircle( 
const VECTOR2D& aCenterPoint, 
double aRadius ) 
override;
 
   82    void DrawHoleWall( 
const VECTOR2D& aCenterPoint, 
double aHoleRadius,
 
   83                       double aWallWidth ) 
override;
 
   86    void DrawArc( 
const VECTOR2D& aCenterPoint, 
double aRadius, 
const EDA_ANGLE& aStartAngle,
 
   91    void DrawArcSegment( 
const VECTOR2D& aCenterPoint, 
double aRadius, 
const EDA_ANGLE& aStartAngle,
 
   92                         const EDA_ANGLE& aAngle, 
double aWidth, 
double aMaxError ) 
override;
 
   95    void DrawRectangle( 
const VECTOR2D& aStartPoint, 
const VECTOR2D& aEndPoint ) 
override;
 
   98    void DrawSegmentChain( 
const std::vector<VECTOR2D>& aPointList, 
double aWidth ) 
override;
 
   99    void DrawSegmentChain( 
const SHAPE_LINE_CHAIN& aLineChain, 
double aWidth ) 
override;
 
  111    void DrawPolylines( 
const std::vector<std::vector<VECTOR2D>>& aPointLists )
 override 
  113        for( 
const std::vector<VECTOR2D>& points : aPointLists )
 
 
  124    void DrawPolygon( 
const SHAPE_POLY_SET& aPolySet, 
bool aStrokeTriangulation = 
false ) 
override;
 
  128    void DrawGlyph( 
const KIFONT::GLYPH& aPolySet, 
int aNth, 
int aTotal ) 
override;
 
  131    void DrawGlyphs( 
const std::vector<std::unique_ptr<KIFONT::GLYPH>>& aGlyphs )
 override 
  133        for( 
size_t i = 0; i < aGlyphs.size(); i++ )
 
  134            DrawGlyph( *aGlyphs[i], i, aGlyphs.size() );
 
 
  140                    double aFilterValue = 0.0 ) 
override;
 
  143    void DrawBitmap( 
const BITMAP_BASE& aBitmap, 
double alphaBlend = 1.0 ) 
override;
 
  150    void ResizeScreen( 
int aWidth, 
int aHeight ) 
override;
 
  153    void Flush() 
override;
 
  156    void ClearScreen() 
override;
 
  163    void SetIsFill( 
bool aIsFillEnabled ) 
override;
 
  166    void SetIsStroke( 
bool aIsStrokeEnabled ) 
override;
 
  169    void SetStrokeColor( 
const COLOR4D& aColor ) 
override;
 
  172    void SetFillColor( 
const COLOR4D& aColor ) 
override;
 
  175    void SetLineWidth( 
float aLineWidth ) 
override;
 
  178    void SetLayerDepth( 
double aLayerDepth ) 
override;
 
  185    void Transform( 
const MATRIX3x3D& aTransformation ) 
override;
 
  188    void Rotate( 
double aAngle ) 
override;
 
  191    void Translate( 
const VECTOR2D& aTranslation ) 
override;
 
  194    void Scale( 
const VECTOR2D& aScale ) 
override;
 
  197    void Save() 
override;
 
  200    void Restore() 
override;
 
  207    int BeginGroup() 
override;
 
  210    void EndGroup() 
override;
 
  213    void DrawGroup( 
int aGroupNumber ) 
override;
 
  216    void ChangeGroupColor( 
int aGroupNumber, 
const COLOR4D& aNewColor ) 
override;
 
  219    void ChangeGroupDepth( 
int aGroupNumber, 
int aDepth ) 
override;
 
  222    void DeleteGroup( 
int aGroupNumber ) 
override;
 
  225    void ClearCache() 
override;
 
  232    void SetNegativeDrawMode( 
bool aSetting ) 
override;
 
  239    void DrawCursor( 
const VECTOR2D& aCursorPosition ) 
override;
 
  241    void EnableDepthTest( 
bool aEnabled = 
false ) 
override;
 
  244    void DrawGrid() 
override;
 
  247    void BeginDrawing() 
override;
 
  250    void EndDrawing() 
override;
 
  255    double xform( 
double x );             
 
  256    const VECTOR2D xform( 
double x, 
double y ); 
 
  265    double angle_xform( 
double aAngle );
 
  274    void arc_angles_xform_and_normalize( 
double& aStartAngle, 
double& aEndAngle );
 
  284    void drawGridLine( 
const VECTOR2D& aStartPoint, 
const VECTOR2D& aEndPoint );
 
  285    void drawGridCross( 
const VECTOR2D& aPoint );
 
  286    void drawGridPoint( 
const VECTOR2D& aPoint, 
double aWidth, 
double aHeight );
 
  296    void blitCursor( wxMemoryDC& clientDC );
 
  299    void drawPoly( 
const std::deque<VECTOR2D>& aPointList );
 
  300    void drawPoly( 
const std::vector<VECTOR2D>& aPointList );
 
  301    void drawPoly( 
const VECTOR2D aPointList[], 
int aListSize );
 
  309    unsigned int getNewGroupNumber();
 
  311    void syncLineWidth( 
bool aForceWidth = 
false, 
double aWidth = 0.0 );
 
  312    void updateWorldScreenMatrix();
 
  352    typedef std::deque<GROUP_ELEMENT> 
GROUP;        
 
  376    static constexpr cairo_format_t 
GAL_FORMAT = CAIRO_FORMAT_ARGB32;
 
 
  395               wxEvtHandler* aMouseListener = 
nullptr, wxEvtHandler* aPaintListener = 
nullptr,
 
  396               const wxString& aName = wxT( 
"CairoCanvas" ) );
 
  403        return IsShownOnScreen() && !GetClientRect().IsEmpty();
 
 
  406    void ResizeScreen( 
int aWidth, 
int aHeight ) 
override;
 
  408    bool Show( 
bool aShow ) 
override;
 
  410    int BeginGroup() 
override;
 
  412    void EndGroup() 
override;
 
  421    void StartDiffLayer() 
override;
 
  424    void EndDiffLayer() 
override;
 
  427    void StartNegativesLayer() 
override;
 
  430    void EndNegativesLayer() 
override;
 
  438    void PostPaint( wxPaintEvent& aEvent );
 
  451    bool SetNativeCursorStyle( 
KICURSOR aCursor, 
bool aHiDPI ) 
override;
 
  454    void BeginDrawing() 
override;
 
  457    void EndDrawing() 
override;
 
  463    void deinitSurface();
 
  466    void allocateBitmaps();
 
  469    void deleteBitmaps();
 
  472    void setCompositor();
 
  480    void onPaint( wxPaintEvent& aEvent );
 
  487    void skipMouseEvent( wxMouseEvent& aEvent );
 
  494    void skipGestureEvent( wxGestureEvent& aEvent );
 
  501    void onSetNativeCursor( wxSetCursorEvent& aEvent );
 
 
static double roundp(double x)
 
This class handle bitmap images in KiCad.
 
void DrawGlyph(const KIFONT::GLYPH &aPolySet, int aNth, int aTotal) override
Draw a polygon representing a font glyph.
 
cairo_surface_t * m_surface
Cairo surface.
 
void DrawPolyline(const std::deque< VECTOR2D > &aPointList) override
Draw a polyline.
 
GAL super
Super class definition.
 
cairo_matrix_t m_cairoWorldScreenMatrix
Cairo world to screen transform matrix.
 
unsigned int m_groupCounter
Counter used for generating group keys.
 
bool m_isElementAdded
Was an graphic element added ?
 
std::deque< GROUP_ELEMENT > GROUP
A graphic group type definition.
 
bool IsCairoEngine() override
Return true if the GAL engine is a Cairo based type.
 
void DrawGlyphs(const std::vector< std::unique_ptr< KIFONT::GLYPH > > &aGlyphs) override
Draw polygons representing font glyphs.
 
CAIRO_GAL_BASE(GAL_DISPLAY_OPTIONS &aDisplayOptions)
 
std::vector< cairo_surface_t * > m_imageSurfaces
List of surfaces that were created by painting images, to be cleaned up later.
 
GROUP * m_currentGroup
Currently used group.
 
bool m_isGrouping
Is grouping enabled ?
 
static constexpr cairo_format_t GAL_FORMAT
Format used to store pixels.
 
cairo_matrix_t m_currentXform
 
static const int MAX_CAIRO_ARGUMENTS
Maximum number of arguments for one command.
 
void drawPoly(const std::deque< VECTOR2D > &aPointList)
Drawing polygons & polylines is the same in Cairo, so here is the common code.
 
void DrawPolygon(const VECTOR2D aPointList[], int aListSize) override
 
std::map< int, GROUP > m_groups
List of graphic groups.
 
cairo_t * m_context
Cairo image.
 
void DrawPolylines(const std::vector< std::vector< VECTOR2D > > &aPointLists) override
Draw multiple polylines.
 
void DrawPolyline(const SHAPE_LINE_CHAIN &aLineChain) override
 
std::vector< cairo_matrix_t > m_xformStack
 
void DrawPolyline(const VECTOR2D aPointList[], int aListSize) override
 
void DrawPolygon(const std::deque< VECTOR2D > &aPointList) override
Draw a polygon.
 
cairo_matrix_t m_currentWorld2Screen
 
cairo_t * m_currentContext
Currently used Cairo context for drawing.
 
GRAPHICS_COMMAND
Definitions for the command recorder.
 
@ CMD_SET_STROKE
Enable/disable stroking.
 
@ CMD_SAVE
Save the transformation matrix.
 
@ CMD_SCALE
Scale the context.
 
@ CMD_SET_LINE_WIDTH
Set the line width.
 
@ CMD_SET_FILL
Enable/disable filling.
 
@ CMD_CALL_GROUP
Call a group.
 
@ CMD_ROTATE
Rotate the context.
 
@ CMD_STROKE_PATH
Set the stroke path.
 
@ CMD_TRANSLATE
Translate the context.
 
@ CMD_SET_FILLCOLOR
Set the fill color.
 
@ CMD_FILL_PATH
Set the fill path.
 
@ CMD_RESTORE
Restore the transformation matrix.
 
@ CMD_SET_STROKECOLOR
Set the stroke color.
 
double m_lineWidthInPixels
 
unsigned int m_overlayBuffer
Handle to the overlay buffer.
 
unsigned int m_bufferSize
Size of buffers cairoOutput, bitmapBuffers.
 
CAIRO_GAL(GAL_DISPLAY_OPTIONS &aDisplayOptions, wxWindow *aParent, wxEvtHandler *aMouseListener=nullptr, wxEvtHandler *aPaintListener=nullptr, const wxString &aName=wxT("CairoCanvas"))
 
void SetPaintListener(wxEvtHandler *aPaintListener)
 
void SetMouseListener(wxEvtHandler *aMouseListener)
 
unsigned char * m_wxOutput
wxImage compatible buffer
 
bool m_isInitialized
Are Cairo image & surface ready to use.
 
bool m_validCompositor
Compositor initialization flag.
 
unsigned int m_mainBuffer
Handle to the main buffer.
 
int m_stride
Stride value for Cairo.
 
COLOR4D m_backgroundColor
Background color.
 
unsigned char * m_bitmapBuffer
Storage of the Cairo image.
 
wxEvtHandler * m_mouseListener
Mouse listener.
 
wxEvtHandler * m_paintListener
Paint listener.
 
bool IsVisible() const override
Return true if the GAL canvas is visible on the screen.
 
unsigned int m_tempBuffer
Handle to the temp buffer.
 
RENDER_TARGET m_currentTarget
Current rendering target.
 
wxWindow * m_parentWindow
Parent window.
 
std::shared_ptr< CAIRO_COMPOSITOR > m_compositor
Object for layers compositing.
 
WX_CURSOR_TYPE m_currentwxCursor
wx cursor showing the current native cursor
 
unsigned int m_savedBuffer
Handle to buffer to restore after rendering to temp buffer.
 
A color representation with 4 components: red, green, blue, alpha.
 
GAL(GAL_DISPLAY_OPTIONS &aOptions)
 
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
 
Represent a set of closed polygons.
 
wxCursor WX_CURSOR_TYPE
Represents either a wxCursorBundle for wx 3.3+ or a wxCursor for older versions.
 
MATRIX3x3< double > MATRIX3x3D
 
The Cairo implementation of the graphics abstraction layer.
 
RENDER_TARGET
RENDER_TARGET: Possible rendering targets.
 
void DrawSegment(const ROUND_SEGMENT_2D &aSegment, unsigned int aNrSidesPerCircle)
Draw a thick line segment with rounded ends.
 
Type definition for an graphics group element.
 
GRAPHICS_COMMAND m_Command
Command to execute.
 
cairo_path_t * m_CairoPath
Pointer to a Cairo path.
 
double DblArg[MAX_CAIRO_ARGUMENTS]
Arguments for Cairo commands.
 
bool BoolArg
A bool argument.
 
int IntArg
An int argument.
 
VECTOR2< double > VECTOR2D