38 #include <wx/dcbuffer.h> 55 class CAIRO_COMPOSITOR;
75 double aWidth )
override;
82 double aStartAngle,
double aEndAngle )
override;
87 double aStartAngle,
double aEndAngle,
double aWidth,
88 double aMaxError )
override;
115 double aFilterValue = 0.0 )
override;
128 void Flush()
override;
138 void SetIsFill(
bool aIsFillEnabled )
override;
141 void SetIsStroke(
bool aIsStrokeEnabled )
override;
163 void Rotate(
double aAngle )
override;
172 void Save()
override;
188 void DrawGroup(
int aGroupNumber )
override;
230 const double xform(
double x );
274 void drawPoly(
const std::deque<VECTOR2D>& aPointList );
285 void syncLineWidth(
bool aForceWidth =
false,
double aWidth = 0.0 );
326 typedef std::deque<GROUP_ELEMENT>
GROUP;
350 static constexpr cairo_format_t
GAL_FORMAT = CAIRO_FORMAT_ARGB32;
369 wxEvtHandler* aMouseListener =
nullptr, wxEvtHandler* aPaintListener =
nullptr,
370 const wxString& aName = wxT(
"CairoCanvas" ) );
377 return IsShownOnScreen() && !GetClientRect().IsEmpty();
382 bool Show(
bool aShow )
override;
454 void onPaint( wxPaintEvent& aEvent );
501 #endif // CAIROGAL_H_ void SetNegativeDrawMode(bool aSetting) override
Set negative draw mode in the renderer.
wxWindow * m_parentWindow
Parent window.
void initSurface()
Prepare Cairo surfaces for drawing.
unsigned char * m_wxOutput
wxImage compatible buffer
void DrawBitmap(const BITMAP_BASE &aBitmap) override
Draw a bitmap image.
std::map< int, GROUP > m_groups
List of graphic groups.
void ResizeScreen(int aWidth, int aHeight) override
Resizes the canvas.
CAIRO_GAL(GAL_DISPLAY_OPTIONS &aDisplayOptions, wxWindow *aParent, wxEvtHandler *aMouseListener=nullptr, wxEvtHandler *aPaintListener=nullptr, const wxString &aName=wxT("CairoCanvas"))
void EndGroup() override
End the group.
void ChangeGroupColor(int aGroupNumber, const COLOR4D &aNewColor) override
Change the color used to draw the group.
void EndDrawing() override
End the drawing, needs to be called for every new frame.
void EndDiffLayer() override
Ends rendering of a differential layer.
bool m_isInitialized
Are Cairo image & surface ready to use.
double m_lineWidthInPixels
bool updatedGalDisplayOptions(const GAL_DISPLAY_OPTIONS &aOptions) override
Handle updating display options.
The Cairo implementation of the graphics abstraction layer.
void ResizeScreen(int aWidth, int aHeight) override
Resizes the canvas.
void deinitSurface()
Destroy Cairo surfaces when are not needed anymore.
void SetIsStroke(bool aIsStrokeEnabled) override
Enable/disable stroked outlines.
RENDER_TARGET m_currentTarget
Current rendering target.
void EnableDepthTest(bool aEnabled=false) override
void ChangeGroupDepth(int aGroupNumber, int aDepth) override
Change the depth (Z-axis position) of the group.
void onPaint(wxPaintEvent &aEvent)
Paint event handler.
std::deque< GROUP_ELEMENT > GROUP
A graphic group type definition.
~CAIRO_GAL()
Return true if the GAL canvas is visible on the screen.
void Translate(const VECTOR2D &aTranslation) override
Translate the context.
CAIRO_GAL_BASE(GAL_DISPLAY_OPTIONS &aDisplayOptions)
void setCompositor()
Prepare the compositor.
void storePath()
Store the actual path.
unsigned int m_savedBuffer
Handle to buffer to restore after rendering to temp buffer.
GROUP * m_currentGroup
Currently used group.
Type definition for an graphics group element.
void DeleteGroup(int aGroupNumber) override
Delete the group from the memory.
static const int MAX_CAIRO_ARGUMENTS
Maximum number of arguments for one command.
unsigned int m_tempBuffer
Handle to the temp buffer.
void BeginDrawing() override
Start/end drawing functions, draw calls can be only made in between the calls to BeginDrawing()/EndDr...
unsigned char * m_bitmapBuffer
Storage of the Cairo image.
union KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::@26 m_Argument
void PostPaint(wxPaintEvent &aEvent)
Post an event to m_paint_listener.
void drawAxes(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
bool IsVisible() const override
Return true if the GAL canvas is visible on the screen.
cairo_matrix_t m_cairoWorldScreenMatrix
Cairo world to screen transform matrix.
void SetLayerDepth(double aLayerDepth) override
Set the depth of the layer (position on the z-axis)
GAL super
Super class definition.
unsigned int m_groupCounter
Counter used for generating group keys.
unsigned int m_bufferSize
Size of buffers cairoOutput, bitmapBuffers.
const double angle_xform(const double aAngle)
Transform according to the rotation from m_currentWorld2Screen transform matrix.
GRAPHICS_COMMAND
Definitions for the command recorder.
void DrawPolyline(const VECTOR2D aPointList[], int aListSize) override
This class handle bitmap images in KiCad.
void ClearCache() override
Delete all data created during caching of graphic items.
void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius) override
Draw a circle using world coordinates.
void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth) override
Draw a rounded segment.
void DrawPolygon(const VECTOR2D aPointList[], int aListSize) override
void drawGridPoint(const VECTOR2D &aPoint, double aWidth, double aHeight)
void ClearScreen() override
Clear the screen.
bool m_isElementAdded
Was an graphic element added ?
void EndDrawing() override
End the drawing, needs to be called for every new frame.
GRAPHICS_COMMAND m_Command
Command to execute.
void ClearTarget(RENDER_TARGET aTarget) override
Clear the target for rendering.
void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint) override
Draw a line.
std::vector< cairo_matrix_t > m_xformStack
Represent a set of closed polygons.
void SetPaintListener(wxEvtHandler *aPaintListener)
void DrawPolygon(const std::deque< VECTOR2D > &aPointList) override
Draw a polygon.
wxCursor m_currentwxCursor
wxCursor showing the current native cursor
cairo_t * m_currentContext
Currently used Cairo context for drawing.
bool SetNativeCursorStyle(KICURSOR aCursor) override
Set the cursor in the native panel.
void updateWorldScreenMatrix()
void DrawCursor(const VECTOR2D &aCursorPosition) override
Draw the cursor.
void onSetNativeCursor(wxSetCursorEvent &aEvent)
Give the correct cursor image when the native widget asks for it.
const double xform(double x)
int m_stride
Stride value for Cairo.
cairo_t * m_context
Cairo image.
void SetTarget(RENDER_TARGET aTarget) override
Set the target for rendering.
void skipMouseEvent(wxMouseEvent &aEvent)
Mouse event handler, forwards the event to the child.
Save the transformation matrix.
void SetIsFill(bool aIsFillEnabled) override
Enable/disable fill.
const VECTOR2D roundp(const VECTOR2D &v)
bool m_validCompositor
Compositor initialization flag.
cairo_matrix_t m_currentWorld2Screen
void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle) override
Draw an arc.
void DrawPolyline(const std::deque< VECTOR2D > &aPointList) override
Draw a polyline.
void SetStrokeColor(const COLOR4D &aColor) override
Set the stroke color.
int IntArg
An int argument.
void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint) override
Draw a rectangle.
void Restore() override
Restore the context.
bool Show(bool aShow) override
Show/hide the GAL canvas.
cairo_matrix_t m_currentXform
void StartDiffLayer() override
Begins rendering of a differential layer.
int BeginGroup() override
Begin a group.
bool BoolArg
A bool argument.
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...
wxEvtHandler * m_mouseListener
Mouse listener.
RENDER_TARGET GetTarget() const override
Get the currently used target for rendering.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void drawPoly(const std::deque< VECTOR2D > &aPointList)
Drawing polygons & polylines is the same in Cairo, so here is the common code.
void EndNegativesLayer() override
Ends rendering of a negatives layer and draws it to the main layer.
void Save() override
Save the context.
void SetMouseListener(wxEvtHandler *aMouseListener)
void drawGridLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a grid line (usually a simplified line function).
unsigned int m_mainBuffer
Handle to the main buffer.
cairo_path_t * m_CairoPath
Pointer to a Cairo path.
void SetLineWidth(float aLineWidth) override
Set the line width.
std::shared_ptr< CAIRO_COMPOSITOR > m_compositor
Object for layers compositing.
void Scale(const VECTOR2D &aScale) override
Scale the context.
void deleteBitmaps()
Allocate the bitmaps for drawing.
void DrawGroup(int aGroupNumber) override
Draw the stored group.
void syncLineWidth(bool aForceWidth=false, double aWidth=0.0)
int BeginGroup() override
Begin a group.
double DblArg[MAX_CAIRO_ARGUMENTS]
Arguments for Cairo commands.
RENDER_TARGET
RENDER_TARGET: Possible rendering targets.
void allocateBitmaps()
Allocate the bitmaps for drawing.
unsigned int m_overlayBuffer
Handle to the overlay buffer.
void Transform(const MATRIX3x3D &aTransformation) override
Transform the context.
bool IsCairoEngine() override
Return true if the GAL engine is a Cairo based type.
void DrawCurve(const VECTOR2D &startPoint, const VECTOR2D &controlPointA, const VECTOR2D &controlPointB, const VECTOR2D &endPoint, double aFilterValue=0.0) override
Draw a cubic bezier spline.
void DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth, double aMaxError) override
Draw an arc segment.
void EndGroup() override
End the group.
cairo_surface_t * m_surface
Cairo surface.
void BeginDrawing() override
Start/end drawing functions, draw calls can be only made in between the calls to BeginDrawing()/EndDr...
void Flush() override
Force all remaining objects to be drawn.
std::vector< cairo_surface_t * > m_imageSurfaces
List of surfaces that were created by painting images, to be cleaned up later.
unsigned int getNewGroupNumber()
Return a valid key that can be used as a new group number.
bool m_isGrouping
Is grouping enabled ?
void blitCursor(wxMemoryDC &clientDC)
Blit cursor into the current screen.
Restore the transformation matrix.
void SetFillColor(const COLOR4D &aColor) override
Set the fill color.
void drawGridCross(const VECTOR2D &aPoint)
Abstract interface for drawing on a 2D-surface.
void Rotate(double aAngle) override
Rotate the context.
static constexpr cairo_format_t GAL_FORMAT
Format used to store pixels.
A color representation with 4 components: red, green, blue, alpha.
COLOR4D m_backgroundColor
Background color.
void DrawPolyline(const SHAPE_LINE_CHAIN &aLineChain) override
wxEvtHandler * m_paintListener
Paint listener.
void StartNegativesLayer() override
Begins rendering in a new layer that will be copied to the main layer in EndNegativesLayer().