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=NULL, wxEvtHandler *aPaintListener=NULL, const wxString &aName=wxT("CairoCanvas"))
 Constructor CAIRO_GAL_BASE. More...
 
virtual ~CAIRO_GAL ()
 
bool IsVisible () const override
 > More...
 
virtual void ResizeScreen (int aWidth, int aHeight) override
 Resizes the canvas. More...
 
virtual bool Show (bool aShow) override
 Shows/hides the GAL canvas. More...
 
virtual void SaveScreen () override
 Save the screen contents. More...
 
virtual void RestoreScreen () override
 Restore the screen contents. More...
 
virtual int BeginGroup () override
 Begin a group. More...
 
virtual void EndGroup () override
 End the group. More...
 
virtual void SetTarget (RENDER_TARGET aTarget) override
 Sets the target for rendering. More...
 
virtual RENDER_TARGET GetTarget () const override
 Gets the currently used target for rendering. More...
 
virtual void ClearTarget (RENDER_TARGET aTarget) override
 Clears the target for rendering. More...
 
void PostPaint ()
 Function PostPaint posts an event to m_paint_listener. More...
 
void SetMouseListener (wxEvtHandler *aMouseListener)
 
void SetPaintListener (wxEvtHandler *aPaintListener)
 
virtual void DrawLine (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint) override
 Draw a line. More...
 
virtual void DrawSegment (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth) override
 Draw a rounded segment. More...
 
virtual void DrawCircle (const VECTOR2D &aCenterPoint, double aRadius) override
 Draw a circle using world coordinates. More...
 
virtual void DrawArc (const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle) override
 Draw an arc. More...
 
virtual void DrawArcSegment (const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth) override
 Draw an arc segment. More...
 
virtual void DrawRectangle (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint) override
 Draw a rectangle. More...
 
virtual void DrawPolyline (const std::deque< VECTOR2D > &aPointList) override
 Draw a polyline. More...
 
virtual void DrawPolyline (const VECTOR2D aPointList[], int aListSize) override
 
virtual void DrawPolyline (const SHAPE_LINE_CHAIN &aLineChain) override
 
virtual void DrawPolygon (const std::deque< VECTOR2D > &aPointList) override
 Draw a polygon. More...
 
virtual void DrawPolygon (const VECTOR2D aPointList[], int aListSize) override
 
virtual void DrawPolygon (const SHAPE_POLY_SET &aPolySet) override
 
virtual void DrawCurve (const VECTOR2D &startPoint, const VECTOR2D &controlPointA, const VECTOR2D &controlPointB, const VECTOR2D &endPoint) override
 Draw a cubic bezier spline. More...
 
virtual void DrawBitmap (const BITMAP_BASE &aBitmap) override
 Draw a bitmap image. More...
 
virtual void Flush () override
 Force all remaining objects to be drawn. More...
 
virtual void ClearScreen () override
 Clear the screen. More...
 
virtual void SetIsFill (bool aIsFillEnabled) override
 Enable/disable fill. More...
 
virtual void SetIsStroke (bool aIsStrokeEnabled) override
 Enable/disable stroked outlines. More...
 
virtual void SetStrokeColor (const COLOR4D &aColor) override
 Set the stroke color. More...
 
virtual void SetFillColor (const COLOR4D &aColor) override
 Set the fill color. More...
 
virtual void SetLineWidth (float aLineWidth) override
 Set the line width. More...
 
virtual void SetLayerDepth (double aLayerDepth) override
 Set the depth of the layer (position on the z-axis) More...
 
virtual void Transform (const MATRIX3x3D &aTransformation) override
 Transform the context. More...
 
virtual void Rotate (double aAngle) override
 Rotate the context. More...
 
virtual void Translate (const VECTOR2D &aTranslation) override
 Translate the context. More...
 
virtual void Scale (const VECTOR2D &aScale) override
 Scale the context. More...
 
virtual void Save () override
 Save the context. More...
 
virtual void Restore () override
 Restore the context. More...
 
virtual void DrawGroup (int aGroupNumber) override
 Draw the stored group. More...
 
virtual void ChangeGroupColor (int aGroupNumber, const COLOR4D &aNewColor) override
 Changes the color used to draw the group. More...
 
virtual void ChangeGroupDepth (int aGroupNumber, int aDepth) override
 Changes the depth (Z-axis position) of the group. More...
 
virtual void DeleteGroup (int aGroupNumber) override
 Delete the group from the memory. More...
 
virtual void ClearCache () override
 Delete all data created during caching of graphic items. More...
 
virtual void SetNegativeDrawMode (bool aSetting) override
 Sets negative draw mode in the renderer. More...
 
virtual void DrawCursor (const VECTOR2D &aCursorPosition) override
 Draw the cursor. More...
 
virtual void EnableDepthTest (bool aEnabled=false) override
 
virtual bool IsInitialized () const
 Returns the initalization status for the canvas. More...
 
const VECTOR2IGetScreenPixelSize () const
 Returns GAL canvas size in pixels. More...
 
void SetClearColor (const COLOR4D &aColor)
 
const COLOR4DGetClearColor () const
 
const COLOR4DGetFillColor () const
 Get the fill color. More...
 
const COLOR4DGetStrokeColor () const
 Get the stroke color. More...
 
float GetLineWidth () const
 Get the line width. More...
 
const STROKE_FONTGetStrokeFont () const
 
virtual void StrokeText (const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
 Draws a vector type text using preloaded Newstroke font. More...
 
virtual void BitmapText (const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
 Draws a text using a bitmap font. More...
 
VECTOR2D GetTextLineSize (const UTF8 &aText) const
 Compute the X and Y size of a given text. More...
 
double GetOverbarVerticalPosition () const
 Compute the vertical position of an overbar, sometimes used in texts. More...
 
virtual void SetTextAttributes (const EDA_TEXT *aText)
 Loads attributes of the given text (bold/italic/underline/mirrored and so on). More...
 
void ResetTextAttributes ()
 Reset text attributes to default styling. More...
 
void SetGlyphSize (const VECTOR2D aGlyphSize)
 Set the font glyph size. More...
 
const VECTOR2DGetGlyphSize () const
 
void SetFontBold (const bool aBold)
 Set bold property of current font. More...
 
bool IsFontBold () const
 Returns true if current font has 'bold' attribute enabled. More...
 
void SetFontItalic (const bool aItalic)
 Set italic property of current font. More...
 
bool IsFontItalic () const
 Returns true if current font has 'italic' attribute enabled. More...
 
void SetTextMirrored (const bool aMirrored)
 Set a mirrored property of text. More...
 
bool IsTextMirrored () const
 Returns true if text should displayed mirrored. More...
 
void SetHorizontalJustify (const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
 Set the horizontal justify for text drawing. More...
 
EDA_TEXT_HJUSTIFY_T GetHorizontalJustify () const
 Returns current text horizontal justification setting. More...
 
void SetVerticalJustify (const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
 Set the vertical justify for text drawing. More...
 
EDA_TEXT_VJUSTIFY_T GetVerticalJustify () const
 Returns current text vertical justification setting. More...
 
virtual void ComputeWorldScreenMatrix ()
 Compute the world <-> screen transformation matrix. More...
 
const MATRIX3x3DGetWorldScreenMatrix () const
 Get the world <-> screen transformation matrix. More...
 
const MATRIX3x3DGetScreenWorldMatrix () const
 Get the screen <-> world transformation matrix. More...
 
void SetWorldScreenMatrix (const MATRIX3x3D &aMatrix)
 Set the world <-> screen transformation matrix. More...
 
void SetWorldUnitLength (double aWorldUnitLength)
 Set the unit length. More...
 
void SetScreenSize (const VECTOR2I &aSize)
 
void SetScreenDPI (double aScreenDPI)
 Set the dots per inch of the screen. More...
 
void SetLookAtPoint (const VECTOR2D &aPoint)
 Set the Point in world space to look at. More...
 
const VECTOR2DGetLookAtPoint () const
 Get the look at point. More...
 
void SetZoomFactor (double aZoomFactor)
 Set the zoom factor of the scene. More...
 
double GetZoomFactor () const
 Get the zoom factor. More...
 
void SetRotation (double aRotation)
 Set the rotation angle. More...
 
double GetRotation () const
 Get the rotation angle. More...
 
void SetDepthRange (const VECTOR2D &aDepthRange)
 Set the range of the layer depth. More...
 
double GetMinDepth () const
 Returns the minimum depth in the currently used range (the top). More...
 
double GetMaxDepth () const
 Returns the maximum depth in the currently used range (the bottom). More...
 
double GetWorldScale () const
 Get the world scale. More...
 
void SetFlip (bool xAxis, bool yAxis)
 Sets flipping of the screen. More...
 
bool IsFlippedX () const
 Return true if flip flag for the X axis is set. More...
 
bool IsFlippedY () const
 Return true if flip flag for the Y axis is set. More...
 
void SetGridVisibility (bool aVisibility)
 Sets the visibility setting of the grid. More...
 
void SetGridOrigin (const VECTOR2D &aGridOrigin)
 Set the origin point for the grid. More...
 
void SetGridSize (const VECTOR2D &aGridSize)
 Set the grid size. More...
 
const VECTOR2DGetGridSize () const
 Returns 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)
 Enables drawing the axes. More...
 
void SetCoarseGrid (int aInterval)
 Draw every tick line wider. More...
 
float GetGridLineWidth () const
 Get the grid line width. More...
 
virtual void DrawGrid ()
 > More...
 
VECTOR2D GetGridPoint (const VECTOR2D &aPoint) const
 Function GetGridPoint() 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
 Returns information about cursor visibility. More...
 
void SetCursorColor (const COLOR4D &aCursorColor)
 Set the cursor color. More...
 
void AdvanceDepth ()
 Changes the current depth to deeper, so it is possible to draw objects right beneath other. More...
 
void PushDepth ()
 Stores current drawing depth on the depth stack. More...
 
void PopDepth ()
 Restores previously stored drawing depth for the depth stack. More...
 

Protected Types

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

Protected Member Functions

virtual void beginDrawing () override
 
virtual void endDrawing () override
 
void initSurface ()
 Prepare Cairo surfaces for drawing. More...
 
void deinitSurface ()
 Destroy Cairo surfaces when are not needed anymore. More...
 
void allocateBitmaps ()
 Allocate the bitmaps for drawing. More...
 
void deleteBitmaps ()
 Allocate the bitmaps for drawing. More...
 
void setCompositor ()
 Prepare the compositor. More...
 
void onPaint (wxPaintEvent &aEvent)
 Paint event handler. More...
 
void skipMouseEvent (wxMouseEvent &aEvent)
 Mouse event handler, forwards the event to the child. More...
 
bool updatedGalDisplayOptions (const GAL_DISPLAY_OPTIONS &aOptions) override
 

Cairo-specific update handlers

More...
 
void resetContext ()
 
virtual void drawGridLine (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint) override
 Draw a grid line (usually a simplified line function). More...
 
void flushPath ()
 
void storePath ()
 Store the actual path. More...
 
virtual void blitCursor (wxMemoryDC &clientDC)
 Blits cursor into the current screen. More...
 
void drawPoly (const std::deque< VECTOR2D > &aPointList)
 Drawing polygons & polylines is the same in cairo, so here is the common code. More...
 
void drawPoly (const VECTOR2D aPointList[], int aListSize)
 
void drawPoly (const SHAPE_LINE_CHAIN &aLineChain)
 
unsigned int getNewGroupNumber ()
 Returns a valid key that can be used as a new group number. More...
 
virtual void lockContext (int aClientCookie)
 Private: use GAL_CONTEXT_LOCKER RAII object. More...
 
virtual void unlockContext (int aClientCookie)
 
virtual void beginUpdate ()
 Enables item update mode. More...
 
virtual void endUpdate ()
 Disables 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
 Gets 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_COMPOSITORcompositor
 Object for layers compositing. More...
 
unsigned int mainBuffer
 Handle to the main buffer. More...
 
unsigned int overlayBuffer
 Handle to the overlay buffer. More...
 
RENDER_TARGET currentTarget
 Current rendering target. More...
 
bool validCompositor
 Compositor initialization flag. More...
 
wxWindow * parentWindow
 Parent window. More...
 
wxEvtHandler * mouseListener
 Mouse listener. More...
 
wxEvtHandler * paintListener
 Paint listener. More...
 
unsigned int bufferSize
 Size of buffers cairoOutput, bitmapBuffers. More...
 
unsigned char * wxOutput
 wxImage comaptible buffer More...
 
unsigned int * bitmapBuffer
 Storage of the cairo image. More...
 
unsigned int * bitmapBufferBackup
 Backup storage of the cairo image. More...
 
int stride
 Stride value for Cairo. More...
 
int wxBufferWidth
 
bool isInitialized
 Are Cairo image & surface ready to use. More...
 
COLOR4D backgroundColor
 Background color. More...
 
bool isGrouping
 Is grouping enabled ? More...
 
bool isElementAdded
 Was an graphic element added ? More...
 
std::map< int, GROUPgroups
 List of graphic groups. More...
 
unsigned int groupCounter
 Counter used for generating keys for groups. More...
 
GROUPcurrentGroup
 Currently used group. More...
 
cairo_matrix_t cairoWorldScreenMatrix
 Cairo world to screen transformation matrix. More...
 
cairo_t * currentContext
 Currently used Cairo context for drawing. More...
 
cairo_t * context
 Cairo image. More...
 
cairo_surface_t * surface
 Cairo surface. More...
 
GAL_DISPLAY_OPTIONSoptions
 
UTIL::LINK observerLink
 
std::stack< double > depthStack
 Stored depth values. More...
 
VECTOR2I screenSize
 Screen size in screen coordinates. More...
 
double worldUnitLength
 The unit length of the world coordinates [inch]. More...
 
double screenDPI
 The dots per inch of the screen. More...
 
VECTOR2D lookAtPoint
 Point to be looked at in world space. More...
 
double zoomFactor
 The zoom factor. More...
 
double rotation
 Rotation transformation (radians) More...
 
MATRIX3x3D worldScreenMatrix
 World transformation. More...
 
MATRIX3x3D screenWorldMatrix
 Screen transformation. More...
 
double worldScale
 The scale factor world->screen. More...
 
bool globalFlipX
 Flag for X axis flipping. More...
 
bool globalFlipY
 Flag for Y axis flipping. More...
 
float lineWidth
 The line width. More...
 
bool isFillEnabled
 Is filling of graphic objects enabled ? More...
 
bool isStrokeEnabled
 Are the outlines stroked ? More...
 
COLOR4D fillColor
 The fill color. More...
 
COLOR4D strokeColor
 The color of the outlines. More...
 
COLOR4D m_clearColor
 
double layerDepth
 The actual layer depth. More...
 
VECTOR2D depthRange
 Range of the depth. More...
 
bool gridVisibility
 Should the grid be shown. More...
 
GRID_STYLE gridStyle
 Grid display style. More...
 
VECTOR2D gridSize
 The grid size. More...
 
VECTOR2D gridOrigin
 The grid origin. More...
 
VECTOR2D gridOffset
 The grid offset to compensate cursor position. More...
 
COLOR4D gridColor
 Color of the grid. More...
 
COLOR4D axesColor
 Color of the axes. More...
 
bool axesEnabled
 Should the axes be drawn. More...
 
int gridTick
 Every tick line gets the double width. More...
 
float gridLineWidth
 Line width of the grid. More...
 
int gridMinSpacing
 Minimum screen size of the grid (pixels) below which the grid is not drawn. More...
 
bool isCursorEnabled
 Is the cursor enabled? More...
 
bool forceDisplayCursor
 Always show cursor. More...
 
COLOR4D cursorColor
 Cursor color. More...
 
bool fullscreenCursor
 Shape of the cursor (fullscreen or small cross) More...
 
VECTOR2D cursorPosition
 Current cursor position (world coordinates) More...
 
STROKE_FONT strokeFont
 Instance of object that stores information about how to draw texts. 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_RGB24
 Format used to store pixels. More...
 
static const int MIN_DEPTH = -1024
 Possible depth range. More...
 
static const int MAX_DEPTH = 1023
 
static const int GRID_DEPTH = MAX_DEPTH - 1
 Depth level on which the grid is drawn. More...
 

Detailed Description

Definition at line 300 of file cairo_gal.h.

Member Typedef Documentation

typedef std::deque<GROUP_ELEMENT> KIGFX::CAIRO_GAL_BASE::GROUP
protectedinherited

A graphic group type definition.

Definition at line 265 of file cairo_gal.h.

typedef GAL KIGFX::CAIRO_GAL_BASE::super
protectedinherited

Super class definition.

Definition at line 226 of file cairo_gal.h.

Member Enumeration Documentation

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

233  {
234  CMD_SET_FILL,
240  CMD_FILL_PATH,
241  //CMD_TRANSFORM, ///< Transform the actual context
242  CMD_ROTATE,
243  CMD_TRANSLATE,
244  CMD_SCALE,
245  CMD_SAVE,
246  CMD_RESTORE,
248  };
Rotate the context.
Definition: cairo_gal.h:242
Enable/disable filling.
Definition: cairo_gal.h:234
Save the transformation matrix.
Definition: cairo_gal.h:245
Translate the context.
Definition: cairo_gal.h:243
Enable/disable stroking.
Definition: cairo_gal.h:235
Restore the transformation matrix.
Definition: cairo_gal.h:246

Constructor & Destructor Documentation

CAIRO_GAL::CAIRO_GAL ( GAL_DISPLAY_OPTIONS aDisplayOptions,
wxWindow *  aParent,
wxEvtHandler *  aMouseListener = NULL,
wxEvtHandler *  aPaintListener = NULL,
const wxString &  aName = wxT( "CairoCanvas" ) 
)

Constructor CAIRO_GAL_BASE.

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

References allocateBitmaps(), isInitialized, mainBuffer, mouseListener, onPaint(), overlayBuffer, paintListener, parentWindow, KIGFX::GAL::screenSize, SetTarget(), skipMouseEvent(), KIGFX::TARGET_NONCACHED, and validCompositor.

931  :
932  CAIRO_GAL_BASE( aDisplayOptions ),
933  wxWindow( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxEXPAND, aName )
934 {
935  // Initialise compositing state
936  mainBuffer = 0;
937  overlayBuffer = 0;
938  validCompositor = false;
940 
941  parentWindow = aParent;
942  mouseListener = aMouseListener;
943  paintListener = aPaintListener;
944 
945  // Connecting the event handlers
946  Connect( wxEVT_PAINT, wxPaintEventHandler( CAIRO_GAL::onPaint ) );
947 
948  // Mouse events are skipped to the parent
949  Connect( wxEVT_MOTION, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
950  Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
951  Connect( wxEVT_LEFT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
952  Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
953  Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
954  Connect( wxEVT_MIDDLE_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
955  Connect( wxEVT_MIDDLE_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
956  Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
957  Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
958  Connect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
959  Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
960 #if defined _WIN32 || defined _WIN64
961  Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
962 #endif
963 
964  SetSize( aParent->GetClientSize() );
965  screenSize = VECTOR2I( aParent->GetClientSize() );
966 
967  // Allocate memory for pixel storage
968  allocateBitmaps();
969 
970  isInitialized = false;
971 }
void onPaint(wxPaintEvent &aEvent)
Paint event handler.
Definition: cairo_gal.cpp:1233
CAIRO_GAL_BASE(GAL_DISPLAY_OPTIONS &aDisplayOptions)
Definition: cairo_gal.cpp:46
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:392
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:376
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:378
Auxiliary rendering target (noncached)
Definition: definitions.h:42
wxEvtHandler * paintListener
Paint listener.
Definition: cairo_gal.h:383
virtual void SetTarget(RENDER_TARGET aTarget) override
Sets the target for rendering.
Definition: cairo_gal.cpp:1102
void skipMouseEvent(wxMouseEvent &aEvent)
Mouse event handler, forwards the event to the child.
Definition: cairo_gal.cpp:1239
VECTOR2I screenSize
Screen size in screen coordinates.
wxEvtHandler * mouseListener
Mouse listener.
Definition: cairo_gal.h:382
void allocateBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1196
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:375
wxWindow * parentWindow
Parent window.
Definition: cairo_gal.h:381
CAIRO_GAL::~CAIRO_GAL ( )
virtual

Definition at line 974 of file cairo_gal.cpp.

References deleteBitmaps().

975 {
976  deleteBitmaps();
977 }
void deleteBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1211

Member Function Documentation

void KIGFX::GAL::AdvanceDepth ( )
inlineinherited

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

Definition at line 1013 of file graphics_abstraction_layer.h.

References KIGFX::GAL::layerDepth.

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

1014  {
1015  layerDepth -= 0.05;
1016  }
double layerDepth
The actual layer depth.
void CAIRO_GAL::allocateBitmaps ( )
protected

Allocate the bitmaps for drawing.

Definition at line 1196 of file cairo_gal.cpp.

References bitmapBuffer, bitmapBufferBackup, bufferSize, KIGFX::CAIRO_GAL_BASE::GAL_FORMAT, KIGFX::GAL::screenSize, stride, wxBufferWidth, wxOutput, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by CAIRO_GAL(), and ResizeScreen().

1197 {
1199  while( ( ( wxBufferWidth * 3 ) % 4 ) != 0 ) wxBufferWidth++;
1200 
1201  // Create buffer, use the system independent Cairo context backend
1202  stride = cairo_format_stride_for_width( GAL_FORMAT, wxBufferWidth );
1204 
1205  bitmapBuffer = new unsigned int[bufferSize];
1206  bitmapBufferBackup = new unsigned int[bufferSize];
1207  wxOutput = new unsigned char[wxBufferWidth * 3 * screenSize.y];
1208 }
unsigned char * wxOutput
wxImage comaptible buffer
Definition: cairo_gal.h:385
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:388
int stride
Stride value for Cairo.
Definition: cairo_gal.h:390
unsigned int * bitmapBufferBackup
Backup storage of the cairo image.
Definition: cairo_gal.h:389
VECTOR2I screenSize
Screen size in screen coordinates.
unsigned int bufferSize
Size of buffers cairoOutput, bitmapBuffers.
Definition: cairo_gal.h:384
static constexpr cairo_format_t GAL_FORMAT
Format used to store pixels.
Definition: cairo_gal.h:296
void CAIRO_GAL::beginDrawing ( )
overrideprotectedvirtual

Reimplemented from KIGFX::CAIRO_GAL_BASE.

Definition at line 980 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::beginDrawing(), compositor, KIGFX::CAIRO_GAL_BASE::context, initSurface(), mainBuffer, setCompositor(), and validCompositor.

981 {
982  initSurface();
983 
985 
986  if( !validCompositor )
987  setCompositor();
988 
989  compositor->SetMainContext( context );
990  compositor->SetBuffer( mainBuffer );
991 }
void initSurface()
Prepare Cairo surfaces for drawing.
Definition: cairo_gal.cpp:1162
void setCompositor()
Prepare the compositor.
Definition: cairo_gal.cpp:1219
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:378
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:374
cairo_t * context
Cairo image.
Definition: cairo_gal.h:272
virtual void beginDrawing() override
Definition: cairo_gal.cpp:79
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:375
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 1088 of file cairo_gal.cpp.

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

1089 {
1090  initSurface();
1091  return CAIRO_GAL_BASE::BeginGroup();
1092 }
void initSurface()
Prepare Cairo surfaces for drawing.
Definition: cairo_gal.cpp:1162
virtual int BeginGroup() override
Begin a group.
Definition: cairo_gal.cpp:550
virtual void KIGFX::GAL::beginUpdate ( )
inlineprotectedvirtualinherited

Enables item update mode.

Private: use GAL_UPDATE_CONTEXT RAII object

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1101 of file graphics_abstraction_layer.h.

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

Draws a text using a bitmap font.

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

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

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 344 of file graphics_abstraction_layer.h.

References KIGFX::GAL::GetTextLineSize(), KIGFX::GAL::globalFlipX, KIGFX::GAL::TEXT_PROPERTIES::m_mirrored, KIGFX::GAL::StrokeText(), and KIGFX::GAL::textProperties.

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

346  {
347  // Fallback: use stroke font
348 
349  // Handle flipped view
350  if( globalFlipX )
352 
353  StrokeText( aText, aPosition, aRotationAngle );
354 
355  if( globalFlipX )
357  }
bool globalFlipX
Flag for X axis flipping.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
void CAIRO_GAL_BASE::blitCursor ( wxMemoryDC &  clientDC)
protectedvirtualinherited

Blits cursor into the current screen.

Definition at line 840 of file cairo_gal.cpp.

References color, KIGFX::GAL::cursorPosition, KIGFX::GAL::fullscreenCursor, KIGFX::GAL::getCursorColor(), KIGFX::GAL::IsCursorEnabled(), and KIGFX::GAL::ToScreen().

Referenced by endDrawing().

841 {
842  if( !IsCursorEnabled() )
843  return;
844 
845  auto p = ToScreen( cursorPosition );
846 
847  const auto cColor = getCursorColor();
848  const int cursorSize = fullscreenCursor ? 8000 : 80;
849 
850  wxColour color( cColor.r * cColor.a * 255, cColor.g * cColor.a * 255,
851  cColor.b * cColor.a * 255, 255 );
852  clientDC.SetPen( wxPen( color ) );
853  clientDC.DrawLine( p.x - cursorSize / 2, p.y, p.x + cursorSize / 2, p.y );
854  clientDC.DrawLine( p.x, p.y - cursorSize / 2, p.x, p.y + cursorSize / 2 );
855 }
bool IsCursorEnabled() const
Returns information about cursor visibility.
VECTOR2D cursorPosition
Current cursor position (world coordinates)
int color
Definition: DXF_plotter.cpp:62
VECTOR2D ToScreen(const VECTOR2D &aPoint) const
Compute the point position in screen coordinates from given world coordinates.
bool fullscreenCursor
Shape of the cursor (fullscreen or small cross)
COLOR4D getCursorColor() const
Gets the actual cursor color to draw.
void CAIRO_GAL_BASE::ChangeGroupColor ( int  aGroupNumber,
const COLOR4D aNewColor 
)
overridevirtualinherited

Changes the color used to draw the group.

Parameters
aGroupNumberis the group number.
aNewColoris the new color.

Reimplemented from KIGFX::GAL.

Definition at line 663 of file cairo_gal.cpp.

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::groups, KIGFX::COLOR4D::r, and KIGFX::CAIRO_GAL_BASE::storePath().

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

664 {
665  storePath();
666 
667  for( GROUP::iterator it = groups[aGroupNumber].begin();
668  it != groups[aGroupNumber].end(); ++it )
669  {
670  if( it->command == CMD_SET_FILLCOLOR || it->command == CMD_SET_STROKECOLOR )
671  {
672  it->argument.dblArg[0] = aNewColor.r;
673  it->argument.dblArg[1] = aNewColor.g;
674  it->argument.dblArg[2] = aNewColor.b;
675  it->argument.dblArg[3] = aNewColor.a;
676  }
677  }
678 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:792
double g
Green component.
Definition: color4d.h:288
double b
Blue component.
Definition: color4d.h:289
double a
Alpha component.
Definition: color4d.h:290
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:266
double r
Red component.
Definition: color4d.h:287
void CAIRO_GAL_BASE::ChangeGroupDepth ( int  aGroupNumber,
int  aDepth 
)
overridevirtualinherited

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

Parameters
aGroupNumberis the group number.
aDepthis the new depth.

Reimplemented from KIGFX::GAL.

Definition at line 681 of file cairo_gal.cpp.

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

682 {
683  // Cairo does not have any possibilities to change the depth coordinate of stored items,
684  // it depends only on the order of drawing
685 }
void CAIRO_GAL_BASE::ClearCache ( )
overridevirtualinherited

Delete all data created during caching of graphic items.

Reimplemented from KIGFX::GAL.

Definition at line 708 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::DeleteGroup(), KIGFX::CAIRO_GAL_BASE::groups, and i.

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

709 {
710  for( int i = groups.size() - 1; i >= 0; --i )
711  {
712  DeleteGroup( i );
713  }
714 }
virtual void DeleteGroup(int aGroupNumber) override
Delete the group from the memory.
Definition: cairo_gal.cpp:688
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:266
size_t i
Definition: json11.cpp:597
void CAIRO_GAL_BASE::ClearScreen ( )
overridevirtualinherited

Clear the screen.

Parameters
aColoris the color used for clearing.

Reimplemented from KIGFX::GAL.

Definition at line 340 of file cairo_gal.cpp.

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

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

341 {
342  cairo_set_source_rgb( currentContext, m_clearColor.r, m_clearColor.g, m_clearColor.b );
343  cairo_rectangle( currentContext, 0.0, 0.0, screenSize.x, screenSize.y );
344  cairo_fill( currentContext );
345 }
double g
Green component.
Definition: color4d.h:288
double b
Blue component.
Definition: color4d.h:289
VECTOR2I screenSize
Screen size in screen coordinates.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
double r
Red component.
Definition: color4d.h:287
void CAIRO_GAL::ClearTarget ( RENDER_TARGET  aTarget)
overridevirtual

Clears the target for rendering.

Parameters
aTargetis the target to be cleared.

Reimplemented from KIGFX::GAL.

Definition at line 1136 of file cairo_gal.cpp.

References KIGFX::COLOR4D::BLACK, compositor, mainBuffer, overlayBuffer, KIGFX::TARGET_CACHED, KIGFX::TARGET_NONCACHED, and KIGFX::TARGET_OVERLAY.

1137 {
1138  // Save the current state
1139  unsigned int currentBuffer = compositor->GetBuffer();
1140 
1141  switch( aTarget )
1142  {
1143  // Cached and noncached items are rendered to the same buffer
1144  default:
1145  case TARGET_CACHED:
1146  case TARGET_NONCACHED:
1147  compositor->SetBuffer( mainBuffer );
1148  break;
1149 
1150  case TARGET_OVERLAY:
1151  compositor->SetBuffer( overlayBuffer );
1152  break;
1153  }
1154 
1155  compositor->ClearBuffer( COLOR4D::BLACK );
1156 
1157  // Restore the previous state
1158  compositor->SetBuffer( currentBuffer );
1159 }
static const COLOR4D BLACK
Definition: color4d.h:297
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:376
Auxiliary rendering target (noncached)
Definition: definitions.h:42
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:374
Items that may change while the view stays the same (noncached)
Definition: definitions.h:43
Main rendering target (cached)
Definition: definitions.h:41
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:375
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 208 of file graphics_abstraction_layer.cpp.

References KIGFX::GAL::gridMinSpacing.

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

209 {
210  // just return the current value. This could be cleverer and take
211  // into account other settings in future
212  return gridMinSpacing;
213 }
int gridMinSpacing
Minimum screen size of the grid (pixels) below which the grid is not drawn.
void KIGFX::GAL::computeWorldScale ( )
inlineprotectedinherited

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

Definition at line 1115 of file graphics_abstraction_layer.h.

References KIGFX::GAL::computeMinGridSpacing(), and KIGFX::GAL::zoomFactor.

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

1116  {
1118  }
double zoomFactor
The zoom factor.
double worldUnitLength
The unit length of the world coordinates [inch].
double worldScale
The scale factor world->screen.
double screenDPI
The dots per inch of the screen.
void GAL::ComputeWorldScreenMatrix ( )
virtualinherited

Compute the world <-> screen transformation matrix.

Reimplemented in KIGFX::CAIRO_PRINT_GAL.

Definition at line 179 of file graphics_abstraction_layer.cpp.

References KIGFX::GAL::computeWorldScale(), KIGFX::GAL::globalFlipX, KIGFX::GAL::globalFlipY, MATRIX3x3< T >::Inverse(), KIGFX::GAL::lookAtPoint, KIGFX::GAL::rotation, scale, KIGFX::GAL::screenSize, KIGFX::GAL::screenWorldMatrix, MATRIX3x3< T >::SetIdentity(), MATRIX3x3< T >::SetRotation(), MATRIX3x3< T >::SetScale(), MATRIX3x3< T >::SetTranslation(), KIGFX::GAL::worldScale, and KIGFX::GAL::worldScreenMatrix.

Referenced by KIGFX::OPENGL_GAL::beginDrawing(), KIGFX::GAL::ClearCache(), KIGFX::CAIRO_GAL_BASE::resetContext(), KIGFX::VIEW::SetCenter(), and KIGFX::VIEW::SetScale().

180 {
182 
183  MATRIX3x3D translation;
184  translation.SetIdentity();
185  translation.SetTranslation( 0.5 * VECTOR2D( screenSize ) );
186 
187  MATRIX3x3D rotate;
188  rotate.SetIdentity();
189  rotate.SetRotation( rotation );
190 
192  scale.SetIdentity();
193  scale.SetScale( VECTOR2D( worldScale, worldScale ) );
194 
195  MATRIX3x3D flip;
196  flip.SetIdentity();
197  flip.SetScale( VECTOR2D( globalFlipX ? -1.0 : 1.0, globalFlipY ? -1.0 : 1.0 ) );
198 
199  MATRIX3x3D lookat;
200  lookat.SetIdentity();
201  lookat.SetTranslation( -lookAtPoint );
202 
203  worldScreenMatrix = translation * rotate * flip * scale * lookat;
205 }
MATRIX3x3 Inverse() const
Determine the inverse of the matrix.
Definition: matrix3x3.h:343
void SetRotation(T aAngle)
Set the rotation components of the matrix.
Definition: matrix3x3.h:249
double rotation
Rotation transformation (radians)
MATRIX3x3D screenWorldMatrix
Screen transformation.
bool globalFlipX
Flag for X axis flipping.
void SetIdentity()
Set the matrix to the identity matrix.
Definition: matrix3x3.h:214
VECTOR2D lookAtPoint
Point to be looked at in world space.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
MATRIX3x3D worldScreenMatrix
World transformation.
void computeWorldScale()
Compute the scaling factor for the world->screen matrix.
const int scale
void SetScale(VECTOR2< T > aScale)
Set the scale components of the matrix.
Definition: matrix3x3.h:261
bool globalFlipY
Flag for Y axis flipping.
double worldScale
The scale factor world->screen.
VECTOR2I screenSize
Screen size in screen coordinates.
void SetTranslation(VECTOR2< T > aTranslation)
Set the translation components of the matrix.
Definition: matrix3x3.h:230
void CAIRO_GAL::deinitSurface ( )
protected

Destroy Cairo surfaces when are not needed anymore.

Definition at line 1182 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::context, isInitialized, and KIGFX::CAIRO_GAL_BASE::surface.

Referenced by endDrawing(), and EndGroup().

1183 {
1184  if( !isInitialized )
1185  return;
1186 
1187  cairo_destroy( context );
1188  context = nullptr;
1189  cairo_surface_destroy( surface );
1190  surface = nullptr;
1191 
1192  isInitialized = false;
1193 }
cairo_surface_t * surface
Cairo surface.
Definition: cairo_gal.h:273
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:392
cairo_t * context
Cairo image.
Definition: cairo_gal.h:272
void CAIRO_GAL::deleteBitmaps ( )
protected

Allocate the bitmaps for drawing.

Definition at line 1211 of file cairo_gal.cpp.

References bitmapBuffer, bitmapBufferBackup, and wxOutput.

Referenced by ResizeScreen(), and ~CAIRO_GAL().

1212 {
1213  delete[] bitmapBuffer;
1214  delete[] bitmapBufferBackup;
1215  delete[] wxOutput;
1216 }
unsigned char * wxOutput
wxImage comaptible buffer
Definition: cairo_gal.h:385
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:388
unsigned int * bitmapBufferBackup
Backup storage of the cairo image.
Definition: cairo_gal.h:389
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 688 of file cairo_gal.cpp.

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

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

689 {
690  storePath();
691 
692  // Delete the Cairo paths
693  std::deque<GROUP_ELEMENT>::iterator it, end;
694 
695  for( it = groups[aGroupNumber].begin(), end = groups[aGroupNumber].end(); it != end; ++it )
696  {
697  if( it->command == CMD_FILL_PATH || it->command == CMD_STROKE_PATH )
698  {
699  cairo_path_destroy( it->cairoPath );
700  }
701  }
702 
703  // Delete the group
704  groups.erase( aGroupNumber );
705 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:792
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:266
void CAIRO_GAL_BASE::DrawArc ( const VECTOR2D aCenterPoint,
double  aRadius,
double  aStartAngle,
double  aEndAngle 
)
overridevirtualinherited

Draw an arc.

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

Reimplemented from KIGFX::GAL.

Definition at line 154 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::flushPath(), KIGFX::GAL::GetFillColor(), KIGFX::GAL::GetLineWidth(), KIGFX::GAL::GetStrokeColor(), KIGFX::CAIRO_GAL_BASE::isElementAdded, KIGFX::GAL::isFillEnabled, KIGFX::CAIRO_GAL_BASE::SetLineWidth(), KIGFX::CAIRO_GAL_BASE::SetStrokeColor(), SWAP, VECTOR2< T >::x, and VECTOR2< T >::y.

156 {
157  SWAP( aStartAngle, >, aEndAngle );
158 
159  if( isFillEnabled ) // Draw the filled area of the shape, before drawing the outline itself
160  {
161  double pen_size = GetLineWidth();
162  auto fgcolor = GetStrokeColor();
164 
165  SetLineWidth( 0 );
166  cairo_new_sub_path( currentContext );
167  cairo_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, aStartAngle, aEndAngle );
168  VECTOR2D startPoint( cos( aStartAngle ) * aRadius + aCenterPoint.x,
169  sin( aStartAngle ) * aRadius + aCenterPoint.y );
170  VECTOR2D endPoint( cos( aEndAngle ) * aRadius + aCenterPoint.x,
171  sin( aEndAngle ) * aRadius + aCenterPoint.y );
172 
173  cairo_move_to( currentContext, aCenterPoint.x, aCenterPoint.y );
174  cairo_line_to( currentContext, startPoint.x, startPoint.y );
175  cairo_line_to( currentContext, endPoint.x, endPoint.y );
176  cairo_close_path( currentContext );
177  flushPath();
178  SetLineWidth( pen_size );
179  SetStrokeColor( fgcolor );
180  }
181 
182  cairo_new_sub_path( currentContext );
183  cairo_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, aStartAngle, aEndAngle );
184  flushPath();
185 
186  isElementAdded = true;
187 }
const COLOR4D & GetStrokeColor() const
Get the stroke color.
const COLOR4D & GetFillColor() const
Get the fill color.
bool isFillEnabled
Is filling of graphic objects enabled ?
virtual void SetStrokeColor(const COLOR4D &aColor) override
Set the stroke color.
Definition: cairo_gal.cpp:378
#define SWAP(varA, condition, varB)
Swap the variables if a condition is met.
Definition: definitions.h:31
virtual void SetLineWidth(float aLineWidth) override
Set the line width.
Definition: cairo_gal.cpp:414
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:264
float GetLineWidth() const
Get the line width.
void CAIRO_GAL_BASE::DrawArcSegment ( const VECTOR2D aCenterPoint,
double  aRadius,
double  aStartAngle,
double  aEndAngle,
double  aWidth 
)
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.

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

Reimplemented from KIGFX::GAL.

Definition at line 190 of file cairo_gal.cpp.

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::GAL::fillColor, KIGFX::CAIRO_GAL_BASE::flushPath(), KIGFX::COLOR4D::g, KIGFX::CAIRO_GAL_BASE::isElementAdded, KIGFX::GAL::isFillEnabled, KIGFX::COLOR4D::r, KIGFX::CAIRO_GAL_BASE::SetLineWidth(), KIGFX::GAL::strokeColor, SWAP, VECTOR2< T >::x, and VECTOR2< T >::y.

192 {
193  SWAP( aStartAngle, >, aEndAngle );
194 
195  if( isFillEnabled )
196  {
197  // Filled segments mode
198  SetLineWidth( aWidth );
199  cairo_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, aStartAngle, aEndAngle );
200  cairo_set_source_rgba( currentContext, fillColor.r, fillColor.g, fillColor.b, fillColor.a );
201  cairo_stroke( currentContext );
202  }
203  else
204  {
205  double width = aWidth / 2.0;
206  VECTOR2D startPoint( cos( aStartAngle ) * aRadius,
207  sin( aStartAngle ) * aRadius );
208  VECTOR2D endPoint( cos( aEndAngle ) * aRadius,
209  sin( aEndAngle ) * aRadius );
210 
211  cairo_save( currentContext );
212 
213  cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
214 
215  cairo_translate( currentContext, aCenterPoint.x, aCenterPoint.y );
216 
217  cairo_new_sub_path( currentContext );
218  cairo_arc( currentContext, 0, 0, aRadius - width, aStartAngle, aEndAngle );
219 
220  cairo_new_sub_path( currentContext );
221  cairo_arc( currentContext, 0, 0, aRadius + width, aStartAngle, aEndAngle );
222 
223  cairo_new_sub_path( currentContext );
224  cairo_arc_negative( currentContext, startPoint.x, startPoint.y, width, aStartAngle, aStartAngle + M_PI );
225 
226  cairo_new_sub_path( currentContext );
227  cairo_arc( currentContext, endPoint.x, endPoint.y, width, aEndAngle, aEndAngle + M_PI );
228 
229  cairo_restore( currentContext );
230  flushPath();
231  }
232 
233  isElementAdded = true;
234 }
double g
Green component.
Definition: color4d.h:288
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:289
double a
Alpha component.
Definition: color4d.h:290
COLOR4D strokeColor
The color of the outlines.
bool isFillEnabled
Is filling of graphic objects enabled ?
#define SWAP(varA, condition, varB)
Swap the variables if a condition is met.
Definition: definitions.h:31
virtual void SetLineWidth(float aLineWidth) override
Set the line width.
Definition: cairo_gal.cpp:414
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
double r
Red component.
Definition: color4d.h:287
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:264
void CAIRO_GAL_BASE::DrawBitmap ( const BITMAP_BASE aBitmap)
overridevirtualinherited

Draw a bitmap image.

Reimplemented from KIGFX::GAL.

Definition at line 275 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::currentContext, BITMAP_BASE::GetPPI(), BITMAP_BASE::GetSizePixels(), KIGFX::CAIRO_GAL_BASE::isElementAdded, scale, and KIGFX::GAL::worldUnitLength.

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

276 {
277  cairo_save( currentContext );
278 
279  // We have to calculate the pixel size in users units to draw the image.
280  // worldUnitLength is a factor used for converting IU to inches
281  double scale = 1.0 / ( aBitmap.GetPPI() * worldUnitLength );
282  cairo_scale( currentContext, scale, scale );
283 
284  // The position of the bitmap is the bitmap center.
285  // move the draw origin to the top left bitmap corner:
286  int w = aBitmap.GetSizePixels().x;
287  int h = aBitmap.GetSizePixels().y;
288  cairo_translate( currentContext, -w/2, -h/2 );
289 
290  cairo_new_path( currentContext );
291  cairo_surface_t* image = cairo_image_surface_create( CAIRO_FORMAT_RGB24, w, h );
292  cairo_surface_flush( image );
293 
294  unsigned char* pix_buffer = cairo_image_surface_get_data( image );
295  // The pixel buffer of the initial bitmap:
296  auto bm_pix_buffer = (( BITMAP_BASE&)aBitmap).GetImageData();
297 
298  // Copy the source bitmap to the cairo bitmap buffer.
299  // In cairo bitmap buffer, a RGB24 bitmap is a RGB pixel packed into a uint_32
300  // 24 low bits only are used.
301  for( int row = 0; row < h; row++ )
302  {
303  for( int col = 0; col < w; col++ )
304  {
305  // Build the RGB24 pixel:
306  uint32_t pixel = bm_pix_buffer->GetRed( col, row ) << 16;
307  pixel += bm_pix_buffer->GetGreen( col, row ) << 8;
308  pixel += bm_pix_buffer->GetBlue( col, row );
309 
310  // Write the pixel to the cairo image buffer:
311  uint32_t* pix_ptr = (uint32_t*) pix_buffer;
312  *pix_ptr = pixel;
313  pix_buffer += 4;
314  }
315  }
316 
317  cairo_surface_mark_dirty( image );
318  cairo_set_source_surface( currentContext, image, 0, 0 );
319  cairo_paint( currentContext );
320  cairo_surface_destroy( image );
321 
322  isElementAdded = true;
323 
324  cairo_restore( currentContext );
325 }
This class handle bitmap images in KiCad.
Definition: bitmap_base.h:46
double worldUnitLength
The unit length of the world coordinates [inch].
wxSize GetSizePixels() const
Function GetSizePixels.
Definition: bitmap_base.h:133
const int scale
int GetPPI() const
Definition: bitmap_base.h:145
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:264
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 145 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::flushPath(), KIGFX::CAIRO_GAL_BASE::isElementAdded, VECTOR2< T >::x, and VECTOR2< T >::y.

146 {
147  cairo_new_sub_path( currentContext );
148  cairo_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, 0.0, 2 * M_PI );
149  flushPath();
150  isElementAdded = true;
151 }
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:264
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 723 of file cairo_gal.cpp.

References KIGFX::GAL::cursorPosition.

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

724 {
725  cursorPosition = aCursorPosition;
726 }
VECTOR2D cursorPosition
Current cursor position (world coordinates)
void CAIRO_GAL_BASE::DrawCurve ( const VECTOR2D startPoint,
const VECTOR2D controlPointA,
const VECTOR2D controlPointB,
const VECTOR2D endPoint 
)
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.

Reimplemented from KIGFX::GAL.

Definition at line 262 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::flushPath(), KIGFX::CAIRO_GAL_BASE::isElementAdded, VECTOR2< T >::x, and VECTOR2< T >::y.

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

264 {
265  cairo_move_to( currentContext, aStartPoint.x, aStartPoint.y );
266  cairo_curve_to( currentContext, aControlPointA.x, aControlPointA.y, aControlPointB.x,
267  aControlPointB.y, aEndPoint.x, aEndPoint.y );
268  cairo_line_to( currentContext, aEndPoint.x, aEndPoint.y );
269 
270  flushPath();
271  isElementAdded = true;
272 }
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:264
void GAL::DrawGrid ( )
virtualinherited

>

Draw the grid

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 216 of file graphics_abstraction_layer.cpp.

References KIGFX::GAL::axesColor, KIGFX::GAL::axesEnabled, KIGFX::GAL::computeMinGridSpacing(), KIGFX::GAL::depthRange, KIGFX::GAL::drawGridLine(), KIGFX::GAL::DrawRectangle(), KIGFX::GAL::GetLineWidth(), KIGFX::GAL::gridColor, KIGFX::GAL::gridLineWidth, KIGFX::GAL::gridOrigin, KIGFX::GAL::gridSize, KIGFX::GAL::gridStyle, KIGFX::GAL::gridTick, KIGFX::GAL::gridVisibility, i, KiROUND(), KIGFX::LINES, max, KIGFX::GAL::screenSize, KIGFX::GAL::screenWorldMatrix, KIGFX::GAL::SetFillColor(), KIGFX::GAL::SetIsFill(), KIGFX::GAL::SetIsStroke(), KIGFX::GAL::SetLayerDepth(), KIGFX::GAL::SetLineWidth(), KIGFX::GAL::SetStrokeColor(), KIGFX::GAL::SetTarget(), KIGFX::SMALL_CROSS, KIGFX::TARGET_NONCACHED, KIGFX::GAL::worldScale, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by KIGFX::GAL::GetGridLineWidth(), and EDA_DRAW_PANEL_GAL::onPaint().

217 {
219 
220  // Draw the grid
221  // For the drawing the start points, end points and increments have
222  // to be calculated in world coordinates
223  VECTOR2D worldStartPoint = screenWorldMatrix * VECTOR2D( 0.0, 0.0 );
224  VECTOR2D worldEndPoint = screenWorldMatrix * VECTOR2D( screenSize );
225 
226  const double gridThreshold = computeMinGridSpacing();
227 
228  int gridScreenSizeDense = KiROUND( gridSize.x * worldScale );
229  int gridScreenSizeCoarse = KiROUND( gridSize.x * static_cast<double>( gridTick ) * worldScale );
230 
231  // Compute the line marker or point radius of the grid
232  // Note: generic grids can't handle sub-pixel lines without
233  // either losing fine/course distinction or having some dots
234  // fail to render
235  float marker = std::fmax( 1.0f, gridLineWidth ) / worldScale;
236  float doubleMarker = 2.0f * marker;
237 
238  // Draw axes if desired
239  if( axesEnabled )
240  {
241  SetIsFill( false );
242  SetIsStroke( true );
244  SetLineWidth( marker );
245 
246  drawGridLine( VECTOR2D( worldStartPoint.x, 0 ),
247  VECTOR2D( worldEndPoint.x, 0 ) );
248 
249  drawGridLine( VECTOR2D( 0, worldStartPoint.y ),
250  VECTOR2D( 0, worldEndPoint.y ) );
251  }
252 
253  if( !gridVisibility )
254  return;
255 
256  // Check if the grid would not be too dense
257  if( std::max( gridScreenSizeDense, gridScreenSizeCoarse ) <= gridThreshold )
258  return;
259 
260  // Compute grid staring and ending indexes to draw grid points on the
261  // visible screen area
262  // Note: later any point coordinate will be offsetted by gridOrigin
263  int gridStartX = KiROUND( ( worldStartPoint.x - gridOrigin.x ) / gridSize.x );
264  int gridEndX = KiROUND( ( worldEndPoint.x - gridOrigin.x ) / gridSize.x );
265  int gridStartY = KiROUND( ( worldStartPoint.y - gridOrigin.y ) / gridSize.y );
266  int gridEndY = KiROUND( ( worldEndPoint.y - gridOrigin.y ) / gridSize.y );
267 
268  // Ensure start coordinate > end coordinate
269  if( gridStartX > gridEndX )
270  std::swap( gridStartX, gridEndX );
271 
272  if( gridStartY > gridEndY )
273  std::swap( gridStartY, gridEndY );
274 
275  // Ensure the grid fills the screen
276  --gridStartX; ++gridEndX;
277  --gridStartY; ++gridEndY;
278 
279  // Draw the grid behind all other layers
280  SetLayerDepth( depthRange.y * 0.75 );
281 
283  {
284  SetIsFill( false );
285  SetIsStroke( true );
287 
288  // Now draw the grid, every coarse grid line gets the double width
289 
290  // Vertical lines
291  for( int j = gridStartY; j <= gridEndY; j++ )
292  {
293  const double y = j * gridSize.y + gridOrigin.y;
294 
295  if( axesEnabled && y == 0 )
296  continue;
297 
298  if( j % gridTick == 0 && gridScreenSizeDense > gridThreshold )
299  SetLineWidth( doubleMarker );
300  else
301  SetLineWidth( marker );
302 
303  if( ( j % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
304  || gridScreenSizeDense > gridThreshold )
305  {
306  drawGridLine( VECTOR2D( gridStartX * gridSize.x + gridOrigin.x, y ),
307  VECTOR2D( gridEndX * gridSize.x + gridOrigin.x, y ) );
308  }
309  }
310 
311  // Horizontal lines
312  for( int i = gridStartX; i <= gridEndX; i++ )
313  {
314  const double x = i * gridSize.x + gridOrigin.x;
315 
316  if( axesEnabled && x == 0 )
317  continue;
318 
319  if( i % gridTick == 0 && gridScreenSizeDense > gridThreshold )
320  SetLineWidth( doubleMarker );
321  else
322  SetLineWidth( marker );
323 
324  if( ( i % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
325  || gridScreenSizeDense > gridThreshold )
326  {
327  drawGridLine( VECTOR2D( x, gridStartY * gridSize.y + gridOrigin.y ),
328  VECTOR2D( x, gridEndY * gridSize.y + gridOrigin.y ) );
329  }
330  }
331  }
332  else if( gridStyle == GRID_STYLE::SMALL_CROSS )
333  {
334  SetIsFill( false );
335  SetIsStroke( true );
337 
338  SetLineWidth( marker );
339  double lineLen = GetLineWidth() * 2;
340 
341  // Vertical positions:
342  for( int j = gridStartY; j <= gridEndY; j++ )
343  {
344  if( ( j % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
345  || gridScreenSizeDense > gridThreshold )
346  {
347  int posY = j * gridSize.y + gridOrigin.y;
348 
349  // Horizontal positions:
350  for( int i = gridStartX; i <= gridEndX; i++ )
351  {
352  if( ( i % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
353  || gridScreenSizeDense > gridThreshold )
354  {
355  int posX = i * gridSize.x + gridOrigin.x;
356 
357  drawGridLine( VECTOR2D( posX - lineLen, posY ),
358  VECTOR2D( posX + lineLen, posY ) );
359 
360  drawGridLine( VECTOR2D( posX, posY - lineLen ),
361  VECTOR2D( posX, posY + lineLen ) );
362  }
363  }
364  }
365  }
366  }
367  else // Dotted grid
368  {
369  bool tickX, tickY;
370  SetIsFill( true );
371  SetIsStroke( false );
373 
374  for( int j = gridStartY; j <= gridEndY; j++ )
375  {
376  if( j % gridTick == 0 && gridScreenSizeDense > gridThreshold )
377  tickY = true;
378  else
379  tickY = false;
380 
381  for( int i = gridStartX; i <= gridEndX; i++ )
382  {
383  if( i % gridTick == 0 && gridScreenSizeDense > gridThreshold )
384  tickX = true;
385  else
386  tickX = false;
387 
388  if( tickX || tickY || gridScreenSizeDense > gridThreshold )
389  {
390  double radius = ( ( tickX && tickY ) ? doubleMarker : marker ) / 2.0;
391  DrawRectangle( VECTOR2D( i * gridSize.x - radius + gridOrigin.x,
392  j * gridSize.y - radius + gridOrigin.y ),
393  VECTOR2D( i * gridSize.x + radius + gridOrigin.x,
394  j * gridSize.y + radius + gridOrigin.y ) );
395  }
396  }
397  }
398  }
399 }
double computeMinGridSpacing() const
compute minimum grid spacing from the grid settings
int gridTick
Every tick line gets the double width.
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
Use lines for the grid.
bool axesEnabled
Should the axes be drawn.
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:120
GRID_STYLE gridStyle
Grid display style.
Class VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
VECTOR2D depthRange
Range of the depth.
MATRIX3x3D screenWorldMatrix
Screen transformation.
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)
virtual void drawGridLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a grid line (usually a simplified line function).
virtual void SetLineWidth(float aLineWidth)
Set the line width.
Auxiliary rendering target (noncached)
Definition: definitions.h:42
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
COLOR4D axesColor
Color of the axes.
float gridLineWidth
Line width of the grid.
VECTOR2D gridOrigin
The grid origin.
Use small cross instead of dots for the grid.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
COLOR4D gridColor
Color of the grid.
bool gridVisibility
Should the grid be shown.
#define max(a, b)
Definition: auxiliary.h:86
double worldScale
The scale factor world->screen.
VECTOR2D gridSize
The grid size.
size_t i
Definition: json11.cpp:597
VECTOR2I screenSize
Screen size in screen coordinates.
float GetLineWidth() const
Get the line width.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual void SetTarget(RENDER_TARGET aTarget)
Sets the target for rendering.
void CAIRO_GAL_BASE::drawGridLine ( const VECTOR2D aStartPoint,
const VECTOR2D aEndPoint 
)
overrideprotectedvirtualinherited

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

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

Reimplemented from KIGFX::GAL.

Definition at line 761 of file cairo_gal.cpp.

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::COLOR4D::g, KIGFX::COLOR4D::r, KIGFX::GAL::strokeColor, VECTOR2< T >::x, and VECTOR2< T >::y.

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

762 {
763  cairo_move_to( currentContext, aStartPoint.x, aStartPoint.y );
764  cairo_line_to( currentContext, aEndPoint.x, aEndPoint.y );
765  cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
766  cairo_stroke( currentContext );
767 }
double g
Green component.
Definition: color4d.h:288
double b
Blue component.
Definition: color4d.h:289
double a
Alpha component.
Definition: color4d.h:290
COLOR4D strokeColor
The color of the outlines.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
double r
Red component.
Definition: color4d.h:287
void CAIRO_GAL_BASE::DrawGroup ( int  aGroupNumber)
overridevirtualinherited

Draw the stored group.

Parameters
aGroupNumberis the group number.

Reimplemented from KIGFX::GAL.

Definition at line 573 of file cairo_gal.cpp.

References 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::currentContext, KIGFX::GAL::fillColor, KIGFX::COLOR4D::g, KIGFX::CAIRO_GAL_BASE::groups, KIGFX::GAL::isFillEnabled, KIGFX::GAL::isStrokeEnabled, max, min, KIGFX::COLOR4D::r, KIGFX::CAIRO_GAL_BASE::storePath(), and KIGFX::GAL::strokeColor.

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

574 {
575  // This method implements a small Virtual Machine - all stored commands
576  // are executed; nested calling is also possible
577 
578  storePath();
579 
580  for( GROUP::iterator it = groups[aGroupNumber].begin();
581  it != groups[aGroupNumber].end(); ++it )
582  {
583  switch( it->command )
584  {
585  case CMD_SET_FILL:
586  isFillEnabled = it->argument.boolArg;
587  break;
588 
589  case CMD_SET_STROKE:
590  isStrokeEnabled = it->argument.boolArg;
591  break;
592 
593  case CMD_SET_FILLCOLOR:
594  fillColor = COLOR4D( it->argument.dblArg[0], it->argument.dblArg[1], it->argument.dblArg[2],
595  it->argument.dblArg[3] );
596  break;
597 
598  case CMD_SET_STROKECOLOR:
599  strokeColor = COLOR4D( it->argument.dblArg[0], it->argument.dblArg[1], it->argument.dblArg[2],
600  it->argument.dblArg[3] );
601  break;
602 
603  case CMD_SET_LINE_WIDTH:
604  {
605  // Make lines appear at least 1 pixel wide, no matter of zoom
606  double x = 1.0, y = 1.0;
607  cairo_device_to_user_distance( currentContext, &x, &y );
608  double minWidth = std::min( fabs( x ), fabs( y ) );
609  cairo_set_line_width( currentContext, std::max( it->argument.dblArg[0], minWidth ) );
610  }
611  break;
612 
613 
614  case CMD_STROKE_PATH:
615  cairo_set_source_rgb( currentContext, strokeColor.r, strokeColor.g, strokeColor.b );
616  cairo_append_path( currentContext, it->cairoPath );
617  cairo_stroke( currentContext );
618  break;
619 
620  case CMD_FILL_PATH:
621  cairo_set_source_rgb( currentContext, fillColor.r, fillColor.g, fillColor.b );
622  cairo_append_path( currentContext, it->cairoPath );
623  cairo_fill( currentContext );
624  break;
625 
626  /*
627  case CMD_TRANSFORM:
628  cairo_matrix_t matrix;
629  cairo_matrix_init( &matrix, it->argument.dblArg[0], it->argument.dblArg[1], it->argument.dblArg[2],
630  it->argument.dblArg[3], it->argument.dblArg[4], it->argument.dblArg[5] );
631  cairo_transform( currentContext, &matrix );
632  break;
633  */
634 
635  case CMD_ROTATE:
636  cairo_rotate( currentContext, it->argument.dblArg[0] );
637  break;
638 
639  case CMD_TRANSLATE:
640  cairo_translate( currentContext, it->argument.dblArg[0], it->argument.dblArg[1] );
641  break;
642 
643  case CMD_SCALE:
644  cairo_scale( currentContext, it->argument.dblArg[0], it->argument.dblArg[1] );
645  break;
646 
647  case CMD_SAVE:
648  cairo_save( currentContext );
649  break;
650 
651  case CMD_RESTORE:
652  cairo_restore( currentContext );
653  break;
654 
655  case CMD_CALL_GROUP:
656  DrawGroup( it->argument.intArg );
657  break;
658  }
659  }
660 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:792
Rotate the context.
Definition: cairo_gal.h:242
double g
Green component.
Definition: color4d.h:288
COLOR4D fillColor
The fill color.
Enable/disable filling.
Definition: cairo_gal.h:234
double b
Blue component.
Definition: color4d.h:289
bool isStrokeEnabled
Are the outlines stroked ?
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:266
COLOR4D strokeColor
The color of the outlines.
Save the transformation matrix.
Definition: cairo_gal.h:245
bool isFillEnabled
Is filling of graphic objects enabled ?
#define max(a, b)
Definition: auxiliary.h:86
Translate the context.
Definition: cairo_gal.h:243
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
virtual void DrawGroup(int aGroupNumber) override
Draw the stored group.
Definition: cairo_gal.cpp:573
double r
Red component.
Definition: color4d.h:287
Enable/disable stroking.
Definition: cairo_gal.h:235
Restore the transformation matrix.
Definition: cairo_gal.h:246
#define min(a, b)
Definition: auxiliary.h:85
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
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 92 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::flushPath(), KIGFX::CAIRO_GAL_BASE::isElementAdded, VECTOR2< T >::x, and VECTOR2< T >::y.

93 {
94  cairo_move_to( currentContext, aStartPoint.x, aStartPoint.y );
95  cairo_line_to( currentContext, aEndPoint.x, aEndPoint.y );
96  flushPath();
97  isElementAdded = true;
98 }
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:264
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 858 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::flushPath(), and KIGFX::CAIRO_GAL_BASE::isElementAdded.

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

859 {
860  // Iterate over the point list and draw the segments
861  std::deque<VECTOR2D>::const_iterator it = aPointList.begin();
862 
863  cairo_move_to( currentContext, it->x, it->y );
864 
865  for( ++it; it != aPointList.end(); ++it )
866  {
867  cairo_line_to( currentContext, it->x, it->y );
868  }
869 
870  flushPath();
871  isElementAdded = true;
872 }
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:264
void CAIRO_GAL_BASE::drawPoly ( const VECTOR2D  aPointList[],
int  aListSize 
)
protectedinherited

Definition at line 875 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::flushPath(), i, KIGFX::CAIRO_GAL_BASE::isElementAdded, VECTOR2< T >::x, and VECTOR2< T >::y.

876 {
877  // Iterate over the point list and draw the segments
878  const VECTOR2D* ptr = aPointList;
879 
880  cairo_move_to( currentContext, ptr->x, ptr->y );
881 
882  for( int i = 0; i < aListSize; ++i )
883  {
884  ++ptr;
885  cairo_line_to( currentContext, ptr->x, ptr->y );
886  }
887 
888  flushPath();
889  isElementAdded = true;
890 }
size_t i
Definition: json11.cpp:597
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:264
void CAIRO_GAL_BASE::drawPoly ( const SHAPE_LINE_CHAIN aLineChain)
protectedinherited

Definition at line 893 of file cairo_gal.cpp.

References SHAPE_LINE_CHAIN::CPoint(), KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::flushPath(), i, SHAPE_LINE_CHAIN::IsClosed(), KIGFX::CAIRO_GAL_BASE::isElementAdded, SHAPE_LINE_CHAIN::PointCount(), VECTOR2< T >::x, and VECTOR2< T >::y.

894 {
895  if( aLineChain.PointCount() < 2 )
896  return;
897 
898  auto numPoints = aLineChain.PointCount();
899 
900  if( aLineChain.IsClosed() )
901  numPoints += 1;
902 
903  const VECTOR2I start = aLineChain.CPoint( 0 );
904  cairo_move_to( currentContext, start.x, start.y );
905 
906  for( int i = 1; i < numPoints; ++i )
907  {
908  const VECTOR2I& p = aLineChain.CPoint( i );
909  cairo_line_to( currentContext, p.x, p.y );
910  }
911 
912  flushPath();
913  isElementAdded = true;
914 }
int PointCount() const
Function PointCount()
size_t i
Definition: json11.cpp:597
bool IsClosed() const
Function IsClosed()
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:264
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
virtual 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 105 of file cairo_gal.h.

References KIGFX::CAIRO_GAL_BASE::drawPoly().

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

105 { drawPoly( aPointList ); }
void drawPoly(const std::deque< VECTOR2D > &aPointList)
Drawing polygons & polylines is the same in cairo, so here is the common code.
Definition: cairo_gal.cpp:858
virtual void KIGFX::CAIRO_GAL_BASE::DrawPolygon ( const VECTOR2D  aPointList[],
int  aListSize 
)
inlineoverridevirtualinherited

Reimplemented from KIGFX::GAL.

Definition at line 106 of file cairo_gal.h.

References KIGFX::CAIRO_GAL_BASE::beginDrawing(), KIGFX::CAIRO_GAL_BASE::BeginGroup(), KIGFX::CAIRO_GAL_BASE::ChangeGroupColor(), KIGFX::CAIRO_GAL_BASE::ChangeGroupDepth(), KIGFX::CAIRO_GAL_BASE::ClearCache(), KIGFX::CAIRO_GAL_BASE::ClearScreen(), KIGFX::CAIRO_GAL_BASE::DeleteGroup(), KIGFX::CAIRO_GAL_BASE::DrawBitmap(), KIGFX::CAIRO_GAL_BASE::DrawCursor(), KIGFX::CAIRO_GAL_BASE::DrawCurve(), KIGFX::CAIRO_GAL_BASE::drawGridLine(), KIGFX::CAIRO_GAL_BASE::DrawGroup(), KIGFX::CAIRO_GAL_BASE::drawPoly(), KIGFX::CAIRO_GAL_BASE::DrawPolygon(), KIGFX::CAIRO_GAL_BASE::EnableDepthTest(), KIGFX::CAIRO_GAL_BASE::endDrawing(), KIGFX::CAIRO_GAL_BASE::EndGroup(), KIGFX::CAIRO_GAL_BASE::Flush(), KIGFX::CAIRO_GAL_BASE::resetContext(), KIGFX::CAIRO_GAL_BASE::ResizeScreen(), 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::SetNegativeDrawMode(), KIGFX::CAIRO_GAL_BASE::SetStrokeColor(), KIGFX::CAIRO_GAL_BASE::Transform(), and KIGFX::CAIRO_GAL_BASE::Translate().

106 { drawPoly( aPointList, aListSize ); }
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:858
void CAIRO_GAL_BASE::DrawPolygon ( const SHAPE_POLY_SET aPolySet)
overridevirtualinherited

Reimplemented from KIGFX::GAL.

Definition at line 255 of file cairo_gal.cpp.

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

256 {
257  for( int i = 0; i < aPolySet.OutlineCount(); ++i )
258  drawPoly( aPolySet.COutline( i ) );
259 }
int OutlineCount() const
Returns the number of outlines in the set
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
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:858
size_t i
Definition: json11.cpp:597
virtual 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 100 of file cairo_gal.h.

References KIGFX::CAIRO_GAL_BASE::drawPoly().

100 { drawPoly( aPointList ); }
void drawPoly(const std::deque< VECTOR2D > &aPointList)
Drawing polygons & polylines is the same in cairo, so here is the common code.
Definition: cairo_gal.cpp:858
virtual void KIGFX::CAIRO_GAL_BASE::DrawPolyline ( const VECTOR2D  aPointList[],
int  aListSize 
)
inlineoverridevirtualinherited

Reimplemented from KIGFX::GAL.

Definition at line 101 of file cairo_gal.h.

References KIGFX::CAIRO_GAL_BASE::drawPoly().

101 { drawPoly( aPointList, aListSize ); }
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:858
virtual void KIGFX::CAIRO_GAL_BASE::DrawPolyline ( const SHAPE_LINE_CHAIN aLineChain)
inlineoverridevirtualinherited

Reimplemented from KIGFX::GAL.

Definition at line 102 of file cairo_gal.h.

References KIGFX::CAIRO_GAL_BASE::drawPoly().

102 { drawPoly( aLineChain ); }
void drawPoly(const std::deque< VECTOR2D > &aPointList)
Drawing polygons & polylines is the same in cairo, so here is the common code.
Definition: cairo_gal.cpp:858
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 237 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::flushPath(), KIGFX::CAIRO_GAL_BASE::isElementAdded, VECTOR2< T >::x, and VECTOR2< T >::y.

238 {
239  // Calculate the diagonal points
240  VECTOR2D diagonalPointA( aEndPoint.x, aStartPoint.y );
241  VECTOR2D diagonalPointB( aStartPoint.x, aEndPoint.y );
242 
243  // The path is composed from 4 segments
244  cairo_move_to( currentContext, aStartPoint.x, aStartPoint.y );
245  cairo_line_to( currentContext, diagonalPointA.x, diagonalPointA.y );
246  cairo_line_to( currentContext, aEndPoint.x, aEndPoint.y );
247  cairo_line_to( currentContext, diagonalPointB.x, diagonalPointB.y );
248  cairo_close_path( currentContext );
249  flushPath();
250 
251  isElementAdded = true;
252 }
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:264
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 101 of file cairo_gal.cpp.

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, KIGFX::CAIRO_GAL_BASE::currentContext, VECTOR2< T >::EuclideanNorm(), KIGFX::GAL::fillColor, KIGFX::CAIRO_GAL_BASE::flushPath(), KIGFX::COLOR4D::g, KIGFX::CAIRO_GAL_BASE::isElementAdded, KIGFX::GAL::isFillEnabled, KIGFX::COLOR4D::r, KIGFX::CAIRO_GAL_BASE::SetLineWidth(), KIGFX::GAL::strokeColor, VECTOR2< T >::x, and VECTOR2< T >::y.

103 {
104  if( isFillEnabled )
105  {
106  // Filled tracks mode
107  SetLineWidth( aWidth );
108 
109  cairo_move_to( currentContext, (double) aStartPoint.x, (double) aStartPoint.y );
110  cairo_line_to( currentContext, (double) aEndPoint.x, (double) aEndPoint.y );
111  cairo_set_source_rgba( currentContext, fillColor.r, fillColor.g, fillColor.b, fillColor.a );
112  cairo_stroke( currentContext );
113  }
114  else
115  {
116  // Outline mode for tracks
117  VECTOR2D startEndVector = aEndPoint - aStartPoint;
118  double lineAngle = atan2( startEndVector.y, startEndVector.x );
119  double lineLength = startEndVector.EuclideanNorm();
120 
121  cairo_save( currentContext );
122 
123  cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
124 
125  cairo_translate( currentContext, aStartPoint.x, aStartPoint.y );
126  cairo_rotate( currentContext, lineAngle );
127 
128  cairo_arc( currentContext, 0.0, 0.0, aWidth / 2.0, M_PI / 2.0, 3.0 * M_PI / 2.0 );
129  cairo_arc( currentContext, lineLength, 0.0, aWidth / 2.0, -M_PI / 2.0, M_PI / 2.0 );
130 
131  cairo_move_to( currentContext, 0.0, aWidth / 2.0 );
132  cairo_line_to( currentContext, lineLength, aWidth / 2.0 );
133 
134  cairo_move_to( currentContext, 0.0, -aWidth / 2.0 );
135  cairo_line_to( currentContext, lineLength, -aWidth / 2.0 );
136 
137  cairo_restore( currentContext );
138  flushPath();
139  }
140 
141  isElementAdded = true;
142 }
double g
Green component.
Definition: color4d.h:288
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:289
double a
Alpha component.
Definition: color4d.h:290
T EuclideanNorm() const
Destructor.
Definition: vector2d.h:292
COLOR4D strokeColor
The color of the outlines.
bool isFillEnabled
Is filling of graphic objects enabled ?
virtual void SetLineWidth(float aLineWidth) override
Set the line width.
Definition: cairo_gal.cpp:414
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
double r
Red component.
Definition: color4d.h:287
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:264
void CAIRO_GAL_BASE::EnableDepthTest ( bool  aEnabled = false)
overridevirtualinherited

Reimplemented from KIGFX::GAL.

Definition at line 729 of file cairo_gal.cpp.

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

730 {
731 }
void CAIRO_GAL::endDrawing ( )
overrideprotectedvirtual

Reimplemented from KIGFX::CAIRO_GAL_BASE.

Definition at line 994 of file cairo_gal.cpp.

References bitmapBuffer, KIGFX::CAIRO_GAL_BASE::blitCursor(), compositor, deinitSurface(), KIGFX::CAIRO_GAL_BASE::endDrawing(), mainBuffer, overlayBuffer, KIGFX::GAL::screenSize, wxBufferWidth, wxOutput, VECTOR2< T >::x, and VECTOR2< T >::y.

995 {
997 
998  // Merge buffers on the screen
999  compositor->DrawBuffer( mainBuffer );
1000  compositor->DrawBuffer( overlayBuffer );
1001 
1002  // Now translate the raw context data from the format stored
1003  // by cairo into a format understood by wxImage.
1004  pixman_image_t* dstImg = pixman_image_create_bits( PIXMAN_r8g8b8,
1005  screenSize.x, screenSize.y, (uint32_t*) wxOutput, wxBufferWidth * 3 );
1006  pixman_image_t* srcImg = pixman_image_create_bits( PIXMAN_a8b8g8r8,
1007  screenSize.x, screenSize.y, (uint32_t*) bitmapBuffer, wxBufferWidth * 4 );
1008 
1009  pixman_image_composite( PIXMAN_OP_SRC, srcImg, NULL, dstImg,
1010  0, 0, 0, 0, 0, 0, screenSize.x, screenSize.y );
1011 
1012  // Free allocated memory
1013  pixman_image_unref( srcImg );
1014  pixman_image_unref( dstImg );
1015 
1016  wxImage img( wxBufferWidth, screenSize.y, (unsigned char*) wxOutput, true );
1017  wxBitmap bmp( img );
1018  wxMemoryDC mdc( bmp );
1019  wxClientDC clientDC( this );
1020 
1021  // Now it is the time to blit the mouse cursor
1022  blitCursor( mdc );
1023  clientDC.Blit( 0, 0, screenSize.x, screenSize.y, &mdc, 0, 0, wxCOPY );
1024 
1025  deinitSurface();
1026 }
void deinitSurface()
Destroy Cairo surfaces when are not needed anymore.
Definition: cairo_gal.cpp:1182
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:376
unsigned char * wxOutput
wxImage comaptible buffer
Definition: cairo_gal.h:385
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:374
virtual void endDrawing() override
Definition: cairo_gal.cpp:85
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:388
VECTOR2I screenSize
Screen size in screen coordinates.
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:375
virtual void blitCursor(wxMemoryDC &clientDC)
Blits cursor into the current screen.
Definition: cairo_gal.cpp:840
void CAIRO_GAL::EndGroup ( )
overridevirtual

End the group.

Reimplemented from KIGFX::CAIRO_GAL_BASE.

Definition at line 1095 of file cairo_gal.cpp.

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

1096 {
1098  deinitSurface();
1099 }
virtual void EndGroup() override
End the group.
Definition: cairo_gal.cpp:566
void deinitSurface()
Destroy Cairo surfaces when are not needed anymore.
Definition: cairo_gal.cpp:1182
virtual void KIGFX::GAL::endUpdate ( )
inlineprotectedvirtualinherited

Disables item update mode.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1104 of file graphics_abstraction_layer.h.

1104 {}
void CAIRO_GAL_BASE::Flush ( )
overridevirtualinherited

Force all remaining objects to be drawn.

Reimplemented from KIGFX::GAL.

Definition at line 334 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::storePath().

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

335 {
336  storePath();
337 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:792
void CAIRO_GAL_BASE::flushPath ( )
protectedinherited

Definition at line 770 of file cairo_gal.cpp.

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::GAL::fillColor, KIGFX::COLOR4D::g, KIGFX::GAL::isFillEnabled, KIGFX::GAL::isStrokeEnabled, KIGFX::COLOR4D::r, and KIGFX::GAL::strokeColor.

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

771 {
772  if( isFillEnabled )
773  {
774  cairo_set_source_rgba( currentContext,
776 
777  if( isStrokeEnabled )
778  cairo_fill_preserve( currentContext );
779  else
780  cairo_fill( currentContext );
781  }
782 
783  if( isStrokeEnabled )
784  {
785  cairo_set_source_rgba( currentContext,
787  cairo_stroke( currentContext );
788  }
789 }
double g
Green component.
Definition: color4d.h:288
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:289
double a
Alpha component.
Definition: color4d.h:290
bool isStrokeEnabled
Are the outlines stroked ?
COLOR4D strokeColor
The color of the outlines.
bool isFillEnabled
Is filling of graphic objects enabled ?
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
double r
Red component.
Definition: color4d.h:287
const COLOR4D& KIGFX::GAL::GetClearColor ( ) const
inlineinherited

Definition at line 206 of file graphics_abstraction_layer.h.

References KIGFX::GAL::m_clearColor.

207  {
208  return m_clearColor;
209  }
COLOR4D GAL::getCursorColor ( ) const
protectedinherited

Gets the actual cursor color to draw.

Definition at line 424 of file graphics_abstraction_layer.cpp.

References color, KIGFX::GAL::cursorColor, and KIGFX::GAL::isCursorEnabled.

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

425 {
426  auto color = cursorColor;
427 
428  // dim the cursor if it's only on because it was forced
429  // (this helps to provide a hint for active tools)
430  if( !isCursorEnabled )
431  {
432  color.a = color.a * 0.5;
433  }
434 
435  return color;
436 }
bool isCursorEnabled
Is the cursor enabled?
int color
Definition: DXF_plotter.cpp:62
COLOR4D cursorColor
Cursor color.
const COLOR4D& KIGFX::GAL::GetFillColor ( ) const
inlineinherited

Get the fill color.

Returns
the color for filling a outline.

Definition at line 256 of file graphics_abstraction_layer.h.

References KIGFX::GAL::fillColor.

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

257  {
258  return fillColor;
259  }
COLOR4D fillColor
The fill color.
float KIGFX::GAL::GetGridLineWidth ( ) const
inlineinherited

Get the grid line width.

Returns
the grid line width

Definition at line 934 of file graphics_abstraction_layer.h.

References KIGFX::GAL::DrawGrid(), KIGFX::GAL::GetGridPoint(), and KIGFX::GAL::gridLineWidth.

935  {
936  return gridLineWidth;
937  }
float gridLineWidth
Line width of the grid.
VECTOR2D GAL::GetGridPoint ( const VECTOR2D aPoint) const
inherited

Function GetGridPoint() 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 402 of file graphics_abstraction_layer.cpp.

References KIGFX::GAL::GRID_DEPTH, KIGFX::GAL::gridOffset, KIGFX::GAL::gridSize, KiROUND(), KIGFX::GAL::MAX_DEPTH, KIGFX::GAL::MIN_DEPTH, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by EDIT_POINTS_FACTORY::buildForPolyOutline(), KIGFX::GAL::GetGridLineWidth(), and KIGFX::WX_VIEW_CONTROLS::GetRawCursorPosition().

403 {
404 #if 0
405  // This old code expects a non zero grid size, which can be wrong here.
406  return VECTOR2D( KiROUND( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x,
407  KiROUND( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y );
408 #else
409  // if grid size == 0.0 there is no grid, so use aPoint as grid reference position
410  double cx = gridSize.x > 0.0 ? KiROUND( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x
411  : aPoint.x;
412  double cy = gridSize.y > 0.0 ? KiROUND( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y
413  : aPoint.y;
414 
415  return VECTOR2D( cx, cy );
416 #endif
417 }
VECTOR2D gridOffset
The grid offset to compensate cursor position.
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:120
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
VECTOR2D gridSize
The grid size.
const VECTOR2D& KIGFX::GAL::GetGridSize ( ) const
inlineinherited

Returns the grid size.

Returns
A vector containing the grid size in x and y direction.

Definition at line 886 of file graphics_abstraction_layer.h.

References KIGFX::GAL::gridSize.

Referenced by SCH_BASE_FRAME::SyncView().

887  {
888  return gridSize;
889  }
VECTOR2D gridSize
The grid size.
EDA_TEXT_HJUSTIFY_T KIGFX::GAL::GetHorizontalJustify ( ) const
inlineinherited

Returns current text horizontal justification setting.

Definition at line 478 of file graphics_abstraction_layer.h.

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

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

479  {
481  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
EDA_TEXT_HJUSTIFY_T m_horizontalJustify
Horizontal justification.
float KIGFX::GAL::GetLineWidth ( ) const
inlineinherited
const VECTOR2D& KIGFX::GAL::GetLookAtPoint ( ) const
inlineinherited

Get the look at point.

Returns
the look at point.

Definition at line 678 of file graphics_abstraction_layer.h.

References KIGFX::GAL::lookAtPoint.

679  {
680  return lookAtPoint;
681  }
VECTOR2D lookAtPoint
Point to be looked at in world space.
double KIGFX::GAL::GetMaxDepth ( ) const
inlineinherited

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

Definition at line 747 of file graphics_abstraction_layer.h.

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

748  {
749  return depthRange.y;
750  }
VECTOR2D depthRange
Range of the depth.
double KIGFX::GAL::GetMinDepth ( ) const
inlineinherited

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

Definition at line 739 of file graphics_abstraction_layer.h.

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

740  {
741  return depthRange.x;
742  }
VECTOR2D depthRange
Range of the depth.
unsigned int CAIRO_GAL_BASE::getNewGroupNumber ( )
protectedinherited

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

References KIGFX::CAIRO_GAL_BASE::groupCounter, KIGFX::CAIRO_GAL_BASE::groups, and max.

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

918 {
919  wxASSERT_MSG( groups.size() < std::numeric_limits<unsigned int>::max(),
920  wxT( "There are no free slots to store a group" ) );
921 
922  while( groups.find( groupCounter ) != groups.end() )
923  groupCounter++;
924 
925  return groupCounter++;
926 }
unsigned int groupCounter
Counter used for generating keys for groups.
Definition: cairo_gal.h:267
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:266
#define max(a, b)
Definition: auxiliary.h:86
double KIGFX::GAL::GetOverbarVerticalPosition ( ) const
inlineinherited

Compute the vertical position of an overbar, sometimes used in texts.

This is the distance between the text base line and the overbar.

Returns
the relative position of the overbar axis.

Definition at line 373 of file graphics_abstraction_layer.h.

References KIGFX::STROKE_FONT::computeOverbarVerticalPosition(), KIGFX::GAL::ResetTextAttributes(), KIGFX::GAL::SetTextAttributes(), and KIGFX::GAL::strokeFont.

374  {
376  }
STROKE_FONT strokeFont
Instance of object that stores information about how to draw texts.
double computeOverbarVerticalPosition() const
Compute the vertical position of an overbar, sometimes used in texts.
double KIGFX::GAL::GetRotation ( ) const
inlineinherited

Get the rotation angle.

Returns
The rotation angle (radians).

Definition at line 718 of file graphics_abstraction_layer.h.

References KIGFX::GAL::rotation.

719  {
720  return rotation;
721  }
double rotation
Rotation transformation (radians)
const VECTOR2I& KIGFX::GAL::GetScreenPixelSize ( ) const
inlineinherited
const MATRIX3x3D& KIGFX::GAL::GetScreenWorldMatrix ( ) const
inlineinherited

Get the screen <-> world transformation matrix.

Returns
the transformation matrix.

Definition at line 614 of file graphics_abstraction_layer.h.

References KIGFX::GAL::screenWorldMatrix.

Referenced by KIGFX::OPENGL_GAL::getWorldPixelSize(), and KIGFX::VIEW::ToWorld().

615  {
616  return screenWorldMatrix;
617  }
MATRIX3x3D screenWorldMatrix
Screen transformation.
const COLOR4D& KIGFX::GAL::GetStrokeColor ( ) const
inlineinherited

Get the stroke color.

Returns
the color for stroking the outline.

Definition at line 276 of file graphics_abstraction_layer.h.

References KIGFX::GAL::strokeColor.

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

277  {
278  return strokeColor;
279  }
COLOR4D strokeColor
The color of the outlines.
const STROKE_FONT& KIGFX::GAL::GetStrokeFont ( ) const
inlineinherited

Definition at line 318 of file graphics_abstraction_layer.h.

References KIGFX::GAL::strokeFont.

Referenced by EDA_TEXT::GetTextBox().

319  {
320  return strokeFont;
321  }
STROKE_FONT strokeFont
Instance of object that stores information about how to draw texts.
RENDER_TARGET CAIRO_GAL::GetTarget ( ) const
overridevirtual

Gets the currently used target for rendering.

Returns
The current rendering target.

Reimplemented from KIGFX::GAL.

Definition at line 1130 of file cairo_gal.cpp.

References currentTarget.

1131 {
1132  return currentTarget;
1133 }
RENDER_TARGET currentTarget
Current rendering target.
Definition: cairo_gal.h:377
VECTOR2D GAL::GetTextLineSize ( const UTF8 aText) const
inherited

Compute the X and Y size of a given text.

The text is expected to be a only one line text.

Parameters
aTextis the text string (one line).
Returns
is the text size.

Definition at line 170 of file graphics_abstraction_layer.cpp.

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

Referenced by KIGFX::GAL::BitmapText(), GraphicTextWidth(), and EDA_TEXT::LenSize().

171 {
172  // Compute the X and Y size of a given text.
173  // Because computeTextLineSize expects a one line text,
174  // aText is expected to be only one line text.
175  return strokeFont.computeTextLineSize( aText );
176 }
STROKE_FONT strokeFont
Instance of object that stores information about how to draw texts.
VECTOR2D computeTextLineSize(const UTF8 &aText) const
Compute the X and Y size of a given text.
EDA_TEXT_VJUSTIFY_T KIGFX::GAL::GetVerticalJustify ( ) const
inlineinherited

Returns current text vertical justification setting.

Definition at line 496 of file graphics_abstraction_layer.h.

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

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

497  {
499  }
EDA_TEXT_VJUSTIFY_T m_verticalJustify
Vertical justification.
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
double KIGFX::GAL::GetWorldScale ( ) const
inlineinherited

Get the world scale.

Returns
the actual world scale factor.

Definition at line 757 of file graphics_abstraction_layer.h.

References KIGFX::GAL::worldScale.

Referenced by GRID_HELPER::BestDragOrigin(), GRID_HELPER::BestSnapAnchor(), KIGFX::PCB_PAINTER::draw(), SCH_BASE_FRAME::RedrawScreen(), SCH_BASE_FRAME::RedrawScreen2(), and KIGFX::PREVIEW::SetConstantGlyphHeight().

758  {
759  return worldScale;
760  }
double worldScale
The scale factor world->screen.
const MATRIX3x3D& KIGFX::GAL::GetWorldScreenMatrix ( ) const
inlineinherited

Get the world <-> screen transformation matrix.

Returns
the transformation matrix.

Definition at line 604 of file graphics_abstraction_layer.h.

References KIGFX::GAL::worldScreenMatrix.

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

605  {
606  return worldScreenMatrix;
607  }
MATRIX3x3D worldScreenMatrix
World transformation.
double KIGFX::GAL::GetZoomFactor ( ) const
inlineinherited

Get the zoom factor.

Returns
the zoom factor.

Definition at line 698 of file graphics_abstraction_layer.h.

References KIGFX::GAL::zoomFactor.

Referenced by EDA_DRAW_PANEL_GAL::GetLegacyZoom(), EDA_DRAW_FRAME::GetZoomLevelIndicator(), SCH_BASE_FRAME::RedrawScreen(), and SCH_BASE_FRAME::RedrawScreen2().

699  {
700  return zoomFactor;
701  }
double zoomFactor
The zoom factor.
void CAIRO_GAL::initSurface ( )
protected

Prepare Cairo surfaces for drawing.

Definition at line 1162 of file cairo_gal.cpp.

References bitmapBuffer, KIGFX::CAIRO_GAL_BASE::context, KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::GAL_FORMAT, isInitialized, KIGFX::GAL::screenSize, stride, KIGFX::CAIRO_GAL_BASE::surface, wxBufferWidth, and VECTOR2< T >::y.

Referenced by beginDrawing(), and BeginGroup().

1163 {
1164  if( isInitialized )
1165  return;
1166 
1167  surface = cairo_image_surface_create_for_data( (unsigned char*) bitmapBuffer, GAL_FORMAT,
1169 
1170  context = cairo_create( surface );
1171 
1172 #ifdef __WXDEBUG__
1173  cairo_status_t status = cairo_status( context );
1174  wxASSERT_MSG( status == CAIRO_STATUS_SUCCESS, wxT( "Cairo context creation error" ) );
1175 #endif /* __WXDEBUG__ */
1177 
1178  isInitialized = true;
1179 }
cairo_surface_t * surface
Cairo surface.
Definition: cairo_gal.h:273
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:392
cairo_t * context
Cairo image.
Definition: cairo_gal.h:272
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:388
int stride
Stride value for Cairo.
Definition: cairo_gal.h:390
VECTOR2I screenSize
Screen size in screen coordinates.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
static constexpr cairo_format_t GAL_FORMAT
Format used to store pixels.
Definition: cairo_gal.h:296
bool KIGFX::GAL::IsCursorEnabled ( ) const
inlineinherited

Returns information about cursor visibility.

Returns
True if cursor is visible.

Definition at line 987 of file graphics_abstraction_layer.h.

References KIGFX::GAL::forceDisplayCursor, and KIGFX::GAL::isCursorEnabled.

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

988  {
990  }
bool isCursorEnabled
Is the cursor enabled?
bool forceDisplayCursor
Always show cursor.
bool KIGFX::GAL::IsFlippedX ( ) const
inlineinherited

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

Definition at line 777 of file graphics_abstraction_layer.h.

References KIGFX::GAL::globalFlipX.

778  {
779  return globalFlipX;
780  }
bool globalFlipX
Flag for X axis flipping.
bool KIGFX::GAL::IsFlippedY ( ) const
inlineinherited

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

Definition at line 785 of file graphics_abstraction_layer.h.

References KIGFX::GAL::globalFlipY.

786  {
787  return globalFlipY;
788  }
bool globalFlipY
Flag for Y axis flipping.
bool KIGFX::GAL::IsFontBold ( ) const
inlineinherited

Returns true if current font has 'bold' attribute enabled.

Definition at line 424 of file graphics_abstraction_layer.h.

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

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

425  {
426  return textProperties.m_bold;
427  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
bool KIGFX::GAL::IsFontItalic ( ) const
inlineinherited

Returns true if current font has 'italic' attribute enabled.

Definition at line 442 of file graphics_abstraction_layer.h.

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

Referenced by KIGFX::STROKE_FONT::ComputeStringBoundaryLimits(), and KIGFX::STROKE_FONT::drawSingleLineText().

443  {
444  return textProperties.m_italic;
445  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
virtual bool KIGFX::GAL::IsInitialized ( ) const
inlinevirtualinherited

Returns the initalization status for the canvas.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 73 of file graphics_abstraction_layer.h.

Referenced by EDA_DRAW_PANEL_GAL::onRefreshTimer().

73 { return true; }
bool KIGFX::GAL::IsTextMirrored ( ) const
inlineinherited

Returns true if text should displayed mirrored.

Definition at line 460 of file graphics_abstraction_layer.h.

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

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

461  {
462  return textProperties.m_mirrored;
463  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
bool KIGFX::CAIRO_GAL::IsVisible ( ) const
inlineoverridevirtual

>

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

Reimplemented from KIGFX::GAL.

Definition at line 325 of file cairo_gal.h.

References KIGFX::CAIRO_GAL_BASE::BeginGroup(), KIGFX::GAL::ClearTarget(), KIGFX::CAIRO_GAL_BASE::EndGroup(), KIGFX::GAL::GetTarget(), KIGFX::CAIRO_GAL_BASE::ResizeScreen(), KIGFX::GAL::RestoreScreen(), KIGFX::GAL::SaveScreen(), KIGFX::GAL::SetTarget(), and KIGFX::GAL::Show().

326  {
327  return IsShownOnScreen() && !GetClientRect().IsEmpty();
328  }
virtual void KIGFX::GAL::lockContext ( int  aClientCookie)
inlineprotectedvirtualinherited

Private: use GAL_CONTEXT_LOCKER RAII object.

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1095 of file graphics_abstraction_layer.h.

1095 {}
void GAL::OnGalDisplayOptionsChanged ( const GAL_DISPLAY_OPTIONS aOptions)
overrideprotectedvirtualinherited

Handler for observer settings changes.

Implements KIGFX::GAL_DISPLAY_OPTIONS_OBSERVER.

Definition at line 90 of file graphics_abstraction_layer.cpp.

References KIGFX::GAL::updatedGalDisplayOptions().

91 {
92  // defer to the child class first
93  updatedGalDisplayOptions( aOptions );
94 
95  // there is no refresh to do at this level
96 }
virtual bool updatedGalDisplayOptions(const GAL_DISPLAY_OPTIONS &aOptions)
Function updatedGalDisplayOptions.
void CAIRO_GAL::onPaint ( wxPaintEvent &  aEvent)
protected

Paint event handler.

Parameters
aEventis the paint event.

Definition at line 1233 of file cairo_gal.cpp.

References PostPaint().

Referenced by CAIRO_GAL().

1234 {
1235  PostPaint();
1236 }
void PostPaint()
Function PostPaint posts an event to m_paint_listener.
Definition: cairo_gal.h:353
void KIGFX::GAL::PopDepth ( )
inlineinherited

Restores previously stored drawing depth for the depth stack.

Definition at line 1029 of file graphics_abstraction_layer.h.

References KIGFX::GAL::depthStack, and KIGFX::GAL::layerDepth.

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

1030  {
1031  layerDepth = depthStack.top();
1032  depthStack.pop();
1033  }
double layerDepth
The actual layer depth.
std::stack< double > depthStack
Stored depth values.
void KIGFX::CAIRO_GAL::PostPaint ( )
inline

Function PostPaint posts 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.

Definition at line 353 of file cairo_gal.h.

Referenced by onPaint().

354  {
355  if( paintListener )
356  {
357  wxPaintEvent redrawEvent;
358  wxPostEvent( paintListener, redrawEvent );
359  }
360  }
wxEvtHandler * paintListener
Paint listener.
Definition: cairo_gal.h:383
void KIGFX::GAL::PushDepth ( )
inlineinherited

Stores current drawing depth on the depth stack.

Definition at line 1021 of file graphics_abstraction_layer.h.

References KIGFX::GAL::depthStack, and KIGFX::GAL::layerDepth.

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

1022  {
1023  depthStack.push( layerDepth );
1024  }
double layerDepth
The actual layer depth.
std::stack< double > depthStack
Stored depth values.
void CAIRO_GAL_BASE::resetContext ( )
protectedinherited

Definition at line 734 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::cairoWorldScreenMatrix, KIGFX::CAIRO_GAL_BASE::ClearScreen(), KIGFX::GAL::ComputeWorldScreenMatrix(), KIGFX::CAIRO_GAL_BASE::context, KIGFX::CAIRO_GAL_BASE::isElementAdded, KIGFX::GAL::lineWidth, MATRIX3x3< T >::m_data, and KIGFX::GAL::worldScreenMatrix.

Referenced by KIGFX::CAIRO_GAL_BASE::beginDrawing(), KIGFX::CAIRO_PRINT_GAL::CAIRO_PRINT_GAL(), and KIGFX::CAIRO_GAL_BASE::DrawPolygon().

735 {
736  cairo_set_antialias( context, CAIRO_ANTIALIAS_NONE );
737 
738  ClearScreen();
739 
740  // Compute the world <-> screen transformations
742 
743  cairo_matrix_init( &cairoWorldScreenMatrix, worldScreenMatrix.m_data[0][0],
746  worldScreenMatrix.m_data[1][2] );
747 
748  cairo_set_matrix( context, &cairoWorldScreenMatrix );
749 
750  // Start drawing with a new path
751  cairo_new_path( context );
752  isElementAdded = true;
753 
754  cairo_set_line_join( context, CAIRO_LINE_JOIN_ROUND );
755  cairo_set_line_cap( context, CAIRO_LINE_CAP_ROUND );
756 
757  lineWidth = 0;
758 }
virtual void ComputeWorldScreenMatrix()
Compute the world <-> screen transformation matrix.
T m_data[3][3]
Definition: matrix3x3.h:64
virtual void ClearScreen() override
Clear the screen.
Definition: cairo_gal.cpp:340
cairo_t * context
Cairo image.
Definition: cairo_gal.h:272
MATRIX3x3D worldScreenMatrix
World transformation.
float lineWidth
The line width.
cairo_matrix_t cairoWorldScreenMatrix
Cairo world to screen transformation matrix.
Definition: cairo_gal.h:270
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:264
void GAL::ResetTextAttributes ( )
inherited

Reset text attributes to default styling.

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

Definition at line 155 of file graphics_abstraction_layer.cpp.

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

Referenced by KIGFX::PCB_PAINTER::draw(), KIGFX::GAL::GAL(), and KIGFX::GAL::GetOverbarVerticalPosition().

156 {
157  // Tiny but non-zero - this will always need setting
158  // there is no built-in default
159  SetGlyphSize( { 1.0, 1.0 } );
160 
163 
164  SetFontBold( false );
165  SetFontItalic( false );
166  SetTextMirrored( false );
167 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
void SetFontBold(const bool aBold)
Set bold property of current font.
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
void CAIRO_GAL::ResizeScreen ( int  aWidth,
int  aHeight 
)
overridevirtual

Resizes the canvas.

Reimplemented from KIGFX::CAIRO_GAL_BASE.

Definition at line 1029 of file cairo_gal.cpp.

References allocateBitmaps(), compositor, deleteBitmaps(), KIGFX::CAIRO_GAL_BASE::ResizeScreen(), and validCompositor.

1030 {
1031  CAIRO_GAL_BASE::ResizeScreen( aWidth, aHeight );
1032 
1033  // Recreate the bitmaps
1034  deleteBitmaps();
1035  allocateBitmaps();
1036 
1037  if( validCompositor )
1038  compositor->Resize( aWidth, aHeight );
1039 
1040  validCompositor = false;
1041 
1042  SetSize( wxSize( aWidth, aHeight ) );
1043 }
virtual void ResizeScreen(int aWidth, int aHeight) override
Resizes the canvas.
Definition: cairo_gal.cpp:328
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:378
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:374
void deleteBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1211
void allocateBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1196
void CAIRO_GAL_BASE::Restore ( )
overridevirtualinherited

Restore the context.

Reimplemented from KIGFX::GAL.

Definition at line 533 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::CMD_RESTORE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::currentGroup, KIGFX::CAIRO_GAL_BASE::isGrouping, and KIGFX::CAIRO_GAL_BASE::storePath().

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

534 {
535  storePath();
536 
537  if( isGrouping )
538  {
539  GROUP_ELEMENT groupElement;
540  groupElement.command = CMD_RESTORE;
541  currentGroup->push_back( groupElement );
542  }
543  else
544  {
545  cairo_restore( currentContext );
546  }
547 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:792
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:268
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:263
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
Restore the transformation matrix.
Definition: cairo_gal.h:246
void CAIRO_GAL::RestoreScreen ( )
overridevirtual

Restore the screen contents.

Reimplemented from KIGFX::GAL.

Definition at line 1073 of file cairo_gal.cpp.

References bitmapBuffer, bitmapBufferBackup, i, KIGFX::GAL::screenSize, stride, and VECTOR2< T >::y.

1074 {
1075  int offset = 0;
1076 
1077  for( int j = 0; j < screenSize.y; j++ )
1078  {
1079  for( int i = 0; i < stride; i++ )
1080  {
1081  bitmapBuffer[offset + i] = bitmapBufferBackup[offset + i];
1082  offset += stride;
1083  }
1084  }
1085 }
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:388
int stride
Stride value for Cairo.
Definition: cairo_gal.h:390
unsigned int * bitmapBufferBackup
Backup storage of the cairo image.
Definition: cairo_gal.h:389
size_t i
Definition: json11.cpp:597
VECTOR2I screenSize
Screen size in screen coordinates.
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 460 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::argument, KIGFX::CAIRO_GAL_BASE::CMD_ROTATE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::currentGroup, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::dblArg, KIGFX::CAIRO_GAL_BASE::isGrouping, and KIGFX::CAIRO_GAL_BASE::storePath().

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

461 {
462  storePath();
463 
464  if( isGrouping )
465  {
466  GROUP_ELEMENT groupElement;
467  groupElement.command = CMD_ROTATE;
468  groupElement.argument.dblArg[0] = aAngle;
469  currentGroup->push_back( groupElement );
470  }
471  else
472  {
473  cairo_rotate( currentContext, aAngle );
474  }
475 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:792
Rotate the context.
Definition: cairo_gal.h:242
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:268
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:263
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
void CAIRO_GAL_BASE::Save ( )
overridevirtualinherited

Save the context.

Reimplemented from KIGFX::GAL.

Definition at line 516 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::CMD_SAVE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::currentGroup, KIGFX::CAIRO_GAL_BASE::isGrouping, and KIGFX::CAIRO_GAL_BASE::storePath().

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

517 {
518  storePath();
519 
520  if( isGrouping )
521  {
522  GROUP_ELEMENT groupElement;
523  groupElement.command = CMD_SAVE;
524  currentGroup->push_back( groupElement );
525  }
526  else
527  {
528  cairo_save( currentContext );
529  }
530 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:792
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:268
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:263
Save the transformation matrix.
Definition: cairo_gal.h:245
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
void CAIRO_GAL::SaveScreen ( )
overridevirtual

Save the screen contents.

Reimplemented from KIGFX::GAL.

Definition at line 1057 of file cairo_gal.cpp.

References bitmapBuffer, bitmapBufferBackup, i, KIGFX::GAL::screenSize, stride, and VECTOR2< T >::y.

1058 {
1059  // Copy the current bitmap to the backup buffer
1060  int offset = 0;
1061 
1062  for( int j = 0; j < screenSize.y; j++ )
1063  {
1064  for( int i = 0; i < stride; i++ )
1065  {
1066  bitmapBufferBackup[offset + i] = bitmapBuffer[offset + i];
1067  offset += stride;
1068  }
1069  }
1070 }
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:388
int stride
Stride value for Cairo.
Definition: cairo_gal.h:390
unsigned int * bitmapBufferBackup
Backup storage of the cairo image.
Definition: cairo_gal.h:389
size_t i
Definition: json11.cpp:597
VECTOR2I screenSize
Screen size in screen coordinates.
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 497 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::argument, KIGFX::CAIRO_GAL_BASE::CMD_SCALE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::currentGroup, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::dblArg, KIGFX::CAIRO_GAL_BASE::isGrouping, KIGFX::CAIRO_GAL_BASE::storePath(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

498 {
499  storePath();
500 
501  if( isGrouping )
502  {
503  GROUP_ELEMENT groupElement;
504  groupElement.command = CMD_SCALE;
505  groupElement.argument.dblArg[0] = aScale.x;
506  groupElement.argument.dblArg[1] = aScale.y;
507  currentGroup->push_back( groupElement );
508  }
509  else
510  {
511  cairo_scale( currentContext, aScale.x, aScale.y );
512  }
513 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:792
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:268
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:263
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
void KIGFX::GAL::SetAxesColor ( const COLOR4D aAxesColor)
inlineinherited

Set the axes color.

Parameters
aAxesColoris the color to draw the axes if enabled.

Definition at line 906 of file graphics_abstraction_layer.h.

References KIGFX::GAL::axesColor.

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

907  {
908  axesColor = aAxesColor;
909  }
COLOR4D axesColor
Color of the axes.
void KIGFX::GAL::SetAxesEnabled ( bool  aAxesEnabled)
inlineinherited

Enables drawing the axes.

Definition at line 914 of file graphics_abstraction_layer.h.

References KIGFX::GAL::axesEnabled.

Referenced by FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME(), KIGFX::GAL::GAL(), and FOOTPRINT_EDIT_FRAME::UseGalCanvas().

915  {
916  axesEnabled = aAxesEnabled;
917  }
bool axesEnabled
Should the axes be drawn.
void KIGFX::GAL::SetClearColor ( const COLOR4D aColor)
inlineinherited

Definition at line 201 of file graphics_abstraction_layer.h.

References KIGFX::GAL::m_clearColor.

Referenced by EDA_DRAW_PANEL_GAL::onPaint().

202  {
203  m_clearColor = aColor;
204  }
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 924 of file graphics_abstraction_layer.h.

References KIGFX::GAL::gridTick.

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

925  {
926  gridTick = aInterval;
927  }
int gridTick
Every tick line gets the double width.
void CAIRO_GAL::setCompositor ( )
protected

Prepare the compositor.

Definition at line 1219 of file cairo_gal.cpp.

References compositor, KIGFX::CAIRO_GAL_BASE::currentContext, mainBuffer, overlayBuffer, KIGFX::GAL::screenSize, validCompositor, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by beginDrawing().

1220 {
1221  // Recreate the compositor with the new Cairo context
1222  compositor.reset( new CAIRO_COMPOSITOR( &currentContext ) );
1223  compositor->Resize( screenSize.x, screenSize.y );
1224 
1225  // Prepare buffers
1226  mainBuffer = compositor->CreateBuffer();
1227  overlayBuffer = compositor->CreateBuffer();
1228 
1229  validCompositor = true;
1230 }
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:376
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:378
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:374
VECTOR2I screenSize
Screen size in screen coordinates.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:375
void KIGFX::GAL::SetCursorColor ( const COLOR4D aCursorColor)
inlineinherited

Set the cursor color.

Parameters
aCursorColoris the color of the cursor.

Definition at line 997 of file graphics_abstraction_layer.h.

References KIGFX::GAL::cursorColor.

Referenced by KIGFX::GAL::GAL(), EDA_DRAW_PANEL_GAL::onPaint(), SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL(), and PCB_DRAW_PANEL_GAL::UseColorScheme().

998  {
999  cursorColor = aCursorColor;
1000  }
COLOR4D cursorColor
Cursor color.
void KIGFX::GAL::SetCursorEnabled ( bool  aCursorEnabled)
inlineinherited

Enable/disable cursor.

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

Definition at line 978 of file graphics_abstraction_layer.h.

References KIGFX::GAL::isCursorEnabled.

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

979  {
980  isCursorEnabled = aCursorEnabled;
981  }
bool isCursorEnabled
Is the cursor enabled?
void KIGFX::GAL::SetDepthRange ( const VECTOR2D aDepthRange)
inlineinherited

Set the range of the layer depth.

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

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

Definition at line 731 of file graphics_abstraction_layer.h.

References KIGFX::GAL::depthRange.

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

732  {
733  depthRange = aDepthRange;
734  }
VECTOR2D depthRange
Range of the depth.
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 396 of file cairo_gal.cpp.

References KIGFX::COLOR4D::a, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::argument, KIGFX::COLOR4D::b, KIGFX::CAIRO_GAL_BASE::CMD_SET_FILLCOLOR, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, KIGFX::CAIRO_GAL_BASE::currentGroup, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::dblArg, KIGFX::GAL::fillColor, KIGFX::COLOR4D::g, KIGFX::CAIRO_GAL_BASE::isGrouping, KIGFX::COLOR4D::r, and KIGFX::CAIRO_GAL_BASE::storePath().

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

397 {
398  storePath();
399  fillColor = aColor;
400 
401  if( isGrouping )
402  {
403  GROUP_ELEMENT groupElement;
404  groupElement.command = CMD_SET_FILLCOLOR;
405  groupElement.argument.dblArg[0] = fillColor.r;
406  groupElement.argument.dblArg[1] = fillColor.g;
407  groupElement.argument.dblArg[2] = fillColor.b;
408  groupElement.argument.dblArg[3] = fillColor.a;
409  currentGroup->push_back( groupElement );
410  }
411 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:792
double g
Green component.
Definition: color4d.h:288
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:289
double a
Alpha component.
Definition: color4d.h:290
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:268
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:263
double r
Red component.
Definition: color4d.h:287
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 768 of file graphics_abstraction_layer.h.

References KIGFX::GAL::globalFlipX, and KIGFX::GAL::globalFlipY.

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

769  {
770  globalFlipX = xAxis;
771  globalFlipY = yAxis;
772  }
bool globalFlipX
Flag for X axis flipping.
bool globalFlipY
Flag for Y axis flipping.
void KIGFX::GAL::SetFontBold ( const bool  aBold)
inlineinherited

Set bold property of current font.

Parameters
aBoldtells if the font should be bold or not.

Definition at line 416 of file graphics_abstraction_layer.h.

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

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

417  {
418  textProperties.m_bold = aBold;
419  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
void KIGFX::GAL::SetFontItalic ( const bool  aItalic)
inlineinherited

Set italic property of current font.

Parameters
aItalictells if the font should be italic or not.

Definition at line 434 of file graphics_abstraction_layer.h.

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

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

435  {
436  textProperties.m_italic = aItalic;
437  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
void KIGFX::GAL::SetGlyphSize ( const VECTOR2D  aGlyphSize)
inlineinherited

Set the font glyph size.

Parameters
aGlyphSizeis the new font glyph size.

Definition at line 398 of file graphics_abstraction_layer.h.

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

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

399  {
400  textProperties.m_glyphSize = aGlyphSize;
401  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
VECTOR2D m_glyphSize
Size of the glyphs.
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 896 of file graphics_abstraction_layer.h.

References KIGFX::GAL::gridColor.

Referenced by KIGFX::CAIRO_GAL_BASE::CAIRO_GAL_BASE(), EDA_DRAW_PANEL_GAL::onPaint(), PCB_LAYER_WIDGET::OnRenderColorChange(), KIGFX::OPENGL_GAL::OPENGL_GAL(), SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL(), GERBVIEW_FRAME::SetGridColor(), PCB_DRAW_PANEL_GAL::UseColorScheme(), and GERBVIEW_FRAME::UseGalCanvas().

897  {
898  gridColor = aGridColor;
899  }
COLOR4D gridColor
Color of the grid.
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 857 of file graphics_abstraction_layer.h.

References KIGFX::GAL::gridOffset, KIGFX::GAL::gridOrigin, KIGFX::GAL::gridSize, VECTOR2< T >::x, and VECTOR2< T >::y.

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

858  {
859  gridOrigin = aGridOrigin;
860 
861  if( gridSize.x == 0.0 || gridSize.y == 0.0 )
862  gridOffset = VECTOR2D(0.0, 0.0);
863  else
864  gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
865  (long) gridOrigin.y % (long) gridSize.y );
866  }
VECTOR2D gridOffset
The grid offset to compensate cursor position.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
VECTOR2D gridOrigin
The grid origin.
VECTOR2D gridSize
The grid size.
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 873 of file graphics_abstraction_layer.h.

References KIGFX::GAL::gridOffset, KIGFX::GAL::gridOrigin, KIGFX::GAL::gridSize, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by DIALOG_SET_GRID::DIALOG_SET_GRID(), DIALOG_PAD_PROPERTIES::prepareCanvas(), SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL(), EDA_DRAW_FRAME::SetPresetGrid(), COMMON_TOOLS::updateGrid(), and PCBNEW_CONTROL::updateGrid().

874  {
875  gridSize = aGridSize;
876 
877  gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
878  (long) gridOrigin.y % (long) gridSize.y );
879  }
VECTOR2D gridOffset
The grid offset to compensate cursor position.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
VECTOR2D gridOrigin
The grid origin.
VECTOR2D gridSize
The grid size.
void KIGFX::GAL::SetGridVisibility ( bool  aVisibility)
inlineinherited

Sets the visibility setting of the grid.

Parameters
aVisibilityis the new visibility setting of the grid.

Definition at line 847 of file graphics_abstraction_layer.h.

References KIGFX::GAL::gridVisibility.

Referenced by KIGFX::GAL::GAL(), PCB_LAYER_WIDGET::OnRenderEnable(), GERBER_LAYER_WIDGET::OnRenderEnable(), EDA_DRAW_FRAME::OnToggleGridState(), and SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET().

848  {
849  gridVisibility = aVisibility;
850  }
bool gridVisibility
Should the grid be shown.
void KIGFX::GAL::SetHorizontalJustify ( const EDA_TEXT_HJUSTIFY_T  aHorizontalJustify)
inlineinherited

Set the horizontal justify for text drawing.

Parameters
aHorizontalJustifyis the horizontal justify value.

Definition at line 470 of file graphics_abstraction_layer.h.

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

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

471  {
472  textProperties.m_horizontalJustify = aHorizontalJustify;
473  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
EDA_TEXT_HJUSTIFY_T m_horizontalJustify
Horizontal justification.
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 348 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::argument, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::boolArg, KIGFX::CAIRO_GAL_BASE::CMD_SET_FILL, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, KIGFX::CAIRO_GAL_BASE::currentGroup, KIGFX::GAL::isFillEnabled, KIGFX::CAIRO_GAL_BASE::isGrouping, and KIGFX::CAIRO_GAL_BASE::storePath().

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

349 {
350  storePath();
351  isFillEnabled = aIsFillEnabled;
352 
353  if( isGrouping )
354  {
355  GROUP_ELEMENT groupElement;
356  groupElement.command = CMD_SET_FILL;
357  groupElement.argument.boolArg = aIsFillEnabled;
358  currentGroup->push_back( groupElement );
359  }
360 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:792
Enable/disable filling.
Definition: cairo_gal.h:234
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:268
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:263
bool isFillEnabled
Is filling of graphic objects enabled ?
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 363 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::argument, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::boolArg, KIGFX::CAIRO_GAL_BASE::CMD_SET_STROKE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, KIGFX::CAIRO_GAL_BASE::currentGroup, KIGFX::CAIRO_GAL_BASE::isGrouping, KIGFX::GAL::isStrokeEnabled, and KIGFX::CAIRO_GAL_BASE::storePath().

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

364 {
365  storePath();
366  isStrokeEnabled = aIsStrokeEnabled;
367 
368  if( isGrouping )
369  {
370  GROUP_ELEMENT groupElement;
371  groupElement.command = CMD_SET_STROKE;
372  groupElement.argument.boolArg = aIsStrokeEnabled;
373  currentGroup->push_back( groupElement );
374  }
375 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:792
bool isStrokeEnabled
Are the outlines stroked ?
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:268
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:263
Enable/disable stroking.
Definition: cairo_gal.h:235
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 437 of file cairo_gal.cpp.

References KIGFX::GAL::SetLayerDepth(), and KIGFX::CAIRO_GAL_BASE::storePath().

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

438 {
439  super::SetLayerDepth( aLayerDepth );
440  storePath();
441 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:792
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)
void CAIRO_GAL_BASE::SetLineWidth ( float  aLineWidth)
overridevirtualinherited

Set the line width.

Parameters
aLineWidthis the line width.

Reimplemented from KIGFX::GAL.

Reimplemented in KIGFX::CAIRO_PRINT_GAL.

Definition at line 414 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::argument, KIGFX::CAIRO_GAL_BASE::CMD_SET_LINE_WIDTH, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::currentGroup, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::dblArg, KIGFX::CAIRO_GAL_BASE::isGrouping, min, KIGFX::GAL::SetLineWidth(), and KIGFX::CAIRO_GAL_BASE::storePath().

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

415 {
416  storePath();
417  GAL::SetLineWidth( aLineWidth );
418 
419  if( isGrouping )
420  {
421  GROUP_ELEMENT groupElement;
422  groupElement.command = CMD_SET_LINE_WIDTH;
423  groupElement.argument.dblArg[0] = aLineWidth;
424  currentGroup->push_back( groupElement );
425  }
426  else
427  {
428  // Make lines appear at least 1 pixel wide, no matter of zoom
429  double x = 1.0, y = 1.0;
430  cairo_device_to_user_distance( currentContext, &x, &y );
431  float minWidth = std::min( fabs( x ), fabs( y ) );
432  cairo_set_line_width( currentContext, std::fmax( aLineWidth, minWidth ) );
433  }
434 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:792
virtual void SetLineWidth(float aLineWidth)
Set the line width.
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:268
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:263
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
#define min(a, b)
Definition: auxiliary.h:85
void KIGFX::GAL::SetLookAtPoint ( const VECTOR2D aPoint)
inlineinherited

Set the Point in world space to look at.

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

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

Definition at line 668 of file graphics_abstraction_layer.h.

References KIGFX::GAL::lookAtPoint.

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

669  {
670  lookAtPoint = aPoint;
671  }
VECTOR2D lookAtPoint
Point to be looked at in world space.
void KIGFX::CAIRO_GAL::SetMouseListener ( wxEvtHandler *  aMouseListener)
inline

Definition at line 362 of file cairo_gal.h.

363  {
364  mouseListener = aMouseListener;
365  }
wxEvtHandler * mouseListener
Mouse listener.
Definition: cairo_gal.h:382
void CAIRO_GAL_BASE::SetNegativeDrawMode ( bool  aSetting)
overridevirtualinherited

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

References KIGFX::CAIRO_GAL_BASE::currentContext.

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

718 {
719  cairo_set_operator( currentContext, aSetting ? CAIRO_OPERATOR_CLEAR : CAIRO_OPERATOR_OVER );
720 }
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
void KIGFX::CAIRO_GAL::SetPaintListener ( wxEvtHandler *  aPaintListener)
inline

Definition at line 367 of file cairo_gal.h.

368  {
369  paintListener = aPaintListener;
370  }
wxEvtHandler * paintListener
Paint listener.
Definition: cairo_gal.h:383
void KIGFX::GAL::SetRotation ( double  aRotation)
inlineinherited

Set the rotation angle.

Parameters
aRotationis the new rotation angle (radians).

Definition at line 708 of file graphics_abstraction_layer.h.

References KIGFX::GAL::rotation.

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

709  {
710  rotation = aRotation;
711  }
double rotation
Rotation transformation (radians)
void KIGFX::GAL::SetScreenDPI ( double  aScreenDPI)
inlineinherited

Set the dots per inch of the screen.

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

Parameters
aScreenDPIare the screen DPI.

Definition at line 656 of file graphics_abstraction_layer.h.

References KIGFX::GAL::screenDPI.

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

657  {
658  screenDPI = aScreenDPI;
659  }
double screenDPI
The dots per inch of the screen.
void KIGFX::GAL::SetScreenSize ( const VECTOR2I aSize)
inlineinherited

Definition at line 643 of file graphics_abstraction_layer.h.

References KIGFX::GAL::screenSize.

Referenced by KIGFX::CAIRO_PRINT_GAL::SetSheetSize().

644  {
645  screenSize = aSize;
646  }
VECTOR2I screenSize
Screen size in screen coordinates.
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 378 of file cairo_gal.cpp.

References KIGFX::COLOR4D::a, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::argument, KIGFX::COLOR4D::b, KIGFX::CAIRO_GAL_BASE::CMD_SET_STROKECOLOR, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, KIGFX::CAIRO_GAL_BASE::currentGroup, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::dblArg, KIGFX::COLOR4D::g, KIGFX::CAIRO_GAL_BASE::isGrouping, KIGFX::COLOR4D::r, KIGFX::CAIRO_GAL_BASE::storePath(), and KIGFX::GAL::strokeColor.

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

379 {
380  storePath();
381  strokeColor = aColor;
382 
383  if( isGrouping )
384  {
385  GROUP_ELEMENT groupElement;
386  groupElement.command = CMD_SET_STROKECOLOR;
387  groupElement.argument.dblArg[0] = strokeColor.r;
388  groupElement.argument.dblArg[1] = strokeColor.g;
389  groupElement.argument.dblArg[2] = strokeColor.b;
390  groupElement.argument.dblArg[3] = strokeColor.a;
391  currentGroup->push_back( groupElement );
392  }
393 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:792
double g
Green component.
Definition: color4d.h:288
double b
Blue component.
Definition: color4d.h:289
double a
Alpha component.
Definition: color4d.h:290
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:268
COLOR4D strokeColor
The color of the outlines.
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:263
double r
Red component.
Definition: color4d.h:287
void CAIRO_GAL::SetTarget ( RENDER_TARGET  aTarget)
overridevirtual

Sets the target for rendering.

Parameters
aTargetis the new target for rendering.

Reimplemented from KIGFX::GAL.

Definition at line 1102 of file cairo_gal.cpp.

References compositor, currentTarget, isInitialized, mainBuffer, overlayBuffer, KIGFX::CAIRO_GAL_BASE::storePath(), KIGFX::TARGET_CACHED, KIGFX::TARGET_NONCACHED, KIGFX::TARGET_OVERLAY, and validCompositor.

Referenced by CAIRO_GAL().

1103 {
1104  // If the compositor is not set, that means that there is a recaching process going on
1105  // and we do not need the compositor now
1106  if( !validCompositor )
1107  return;
1108 
1109  // Cairo grouping prevents display of overlapping items on the same layer in the lighter color
1110  if( isInitialized )
1111  storePath();
1112 
1113  switch( aTarget )
1114  {
1115  default:
1116  case TARGET_CACHED:
1117  case TARGET_NONCACHED:
1118  compositor->SetBuffer( mainBuffer );
1119  break;
1120 
1121  case TARGET_OVERLAY:
1122  compositor->SetBuffer( overlayBuffer );
1123  break;
1124  }
1125 
1126  currentTarget = aTarget;
1127 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:792
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:392
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:376
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:378
Auxiliary rendering target (noncached)
Definition: definitions.h:42
RENDER_TARGET currentTarget
Current rendering target.
Definition: cairo_gal.h:377
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:374
Items that may change while the view stays the same (noncached)
Definition: definitions.h:43
Main rendering target (cached)
Definition: definitions.h:41
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:375
void GAL::SetTextAttributes ( const EDA_TEXT aText)
virtualinherited

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

Parameters
aTextis the text item.

Definition at line 144 of file graphics_abstraction_layer.cpp.

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

Referenced by KIGFX::SCH_PAINTER::draw(), KIGFX::WORKSHEET_VIEWITEM::draw(), KIGFX::PCB_PAINTER::draw(), DrawGraphicText(), and KIGFX::GAL::GetOverbarVerticalPosition().

145 {
146  SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
149  SetFontBold( aText->IsBold() );
150  SetFontItalic( aText->IsItalic() );
151  SetTextMirrored( aText->IsMirrored() );
152 }
void SetFontItalic(const bool aItalic)
Set italic property of current font.
bool IsItalic() const
Definition: eda_text.h:183
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:203
bool IsBold() const
Definition: eda_text.h:186
void SetFontBold(const bool aBold)
Set bold property of current font.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:204
bool IsMirrored() const
Definition: eda_text.h:192
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
const wxSize & GetTextSize() const
Definition: eda_text.h:228
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
void KIGFX::GAL::SetTextMirrored ( const bool  aMirrored)
inlineinherited

Set a mirrored property of text.

Parameters
aMirroredtells if the text should be mirrored or not.

Definition at line 452 of file graphics_abstraction_layer.h.

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

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

453  {
454  textProperties.m_mirrored = aMirrored;
455  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
void KIGFX::GAL::SetVerticalJustify ( const EDA_TEXT_VJUSTIFY_T  aVerticalJustify)
inlineinherited

Set the vertical justify for text drawing.

Parameters
aVerticalJustifyis the vertical justify value.

Definition at line 488 of file graphics_abstraction_layer.h.

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

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

489  {
490  textProperties.m_verticalJustify = aVerticalJustify;
491  }
EDA_TEXT_VJUSTIFY_T m_verticalJustify
Vertical justification.
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
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 624 of file graphics_abstraction_layer.h.

References KIGFX::GAL::worldScreenMatrix.

625  {
626  worldScreenMatrix = aMatrix;
627  }
MATRIX3x3D worldScreenMatrix
World transformation.
void KIGFX::GAL::SetWorldUnitLength ( double  aWorldUnitLength)
inlineinherited

Set the unit length.

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

Parameters
aWorldUnitLengthis the world Unit length.

Definition at line 638 of file graphics_abstraction_layer.h.

References KIGFX::GAL::worldUnitLength.

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

639  {
640  worldUnitLength = aWorldUnitLength;
641  }
double worldUnitLength
The unit length of the world coordinates [inch].
void KIGFX::GAL::SetZoomFactor ( double  aZoomFactor)
inlineinherited

Set the zoom factor of the scene.

Parameters
aZoomFactoris the zoom factor.

Definition at line 688 of file graphics_abstraction_layer.h.

References KIGFX::GAL::zoomFactor.

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

689  {
690  zoomFactor = aZoomFactor;
691  }
double zoomFactor
The zoom factor.
bool CAIRO_GAL::Show ( bool  aShow)
overridevirtual

Shows/hides the GAL canvas.

Reimplemented from KIGFX::GAL.

Definition at line 1046 of file cairo_gal.cpp.

1047 {
1048  bool s = wxWindow::Show( aShow );
1049 
1050  if( aShow )
1051  wxWindow::Raise();
1052 
1053  return s;
1054 }
void CAIRO_GAL::skipMouseEvent ( wxMouseEvent &  aEvent)
protected

Mouse event handler, forwards the event to the child.

Parameters
aEventis the mouse event to be forwarded.

Definition at line 1239 of file cairo_gal.cpp.

References mouseListener.

Referenced by CAIRO_GAL().

1240 {
1241  // Post the mouse event to the event listener registered in constructor, if any
1242  if( mouseListener )
1243  wxPostEvent( mouseListener, aEvent );
1244 }
wxEvtHandler * mouseListener
Mouse listener.
Definition: cairo_gal.h:382
void CAIRO_GAL_BASE::storePath ( )
protectedinherited

Store the actual path.

Definition at line 792 of file cairo_gal.cpp.

References KIGFX::COLOR4D::b, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::cairoPath, KIGFX::CAIRO_GAL_BASE::CMD_FILL_PATH, KIGFX::CAIRO_GAL_BASE::CMD_STROKE_PATH, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::currentGroup, KIGFX::GAL::fillColor, KIGFX::COLOR4D::g, KIGFX::CAIRO_GAL_BASE::isElementAdded, KIGFX::GAL::isFillEnabled, KIGFX::CAIRO_GAL_BASE::isGrouping, KIGFX::GAL::isStrokeEnabled, KIGFX::COLOR4D::r, and KIGFX::GAL::strokeColor.

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_PRINT_GAL::SetLineWidth(), KIGFX::CAIRO_GAL_BASE::SetLineWidth(), KIGFX::CAIRO_GAL_BASE::SetStrokeColor(), SetTarget(), and KIGFX::CAIRO_GAL_BASE::Translate().

793 {
794  if( isElementAdded )
795  {
796  isElementAdded = false;
797 
798  if( !isGrouping )
799  {
800  if( isFillEnabled )
801  {
802  cairo_set_source_rgb( currentContext, fillColor.r, fillColor.g, fillColor.b );
803  cairo_fill_preserve( currentContext );
804  }
805 
806  if( isStrokeEnabled )
807  {
808  cairo_set_source_rgb( currentContext, strokeColor.r, strokeColor.g,
809  strokeColor.b );
810  cairo_stroke_preserve( currentContext );
811  }
812  }
813  else
814  {
815  // Copy the actual path, append it to the global path list
816  // then check, if the path needs to be stroked/filled and
817  // add this command to the group list;
818  if( isStrokeEnabled )
819  {
820  GROUP_ELEMENT groupElement;
821  groupElement.cairoPath = cairo_copy_path( currentContext );
822  groupElement.command = CMD_STROKE_PATH;
823  currentGroup->push_back( groupElement );
824  }
825 
826  if( isFillEnabled )
827  {
828  GROUP_ELEMENT groupElement;
829  groupElement.cairoPath = cairo_copy_path( currentContext );
830  groupElement.command = CMD_FILL_PATH;
831  currentGroup->push_back( groupElement );
832  }
833  }
834 
835  cairo_new_path( currentContext );
836  }
837 }
double g
Green component.
Definition: color4d.h:288
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:289
bool isStrokeEnabled
Are the outlines stroked ?
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:268
COLOR4D strokeColor
The color of the outlines.
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:263
bool isFillEnabled
Is filling of graphic objects enabled ?
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
double r
Red component.
Definition: color4d.h:287
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:264
virtual void KIGFX::GAL::StrokeText ( const wxString &  aText,
const VECTOR2D aPosition,
double  aRotationAngle 
)
inlinevirtualinherited

Draws a vector type text using preloaded Newstroke font.

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

Definition at line 330 of file graphics_abstraction_layer.h.

References KIGFX::STROKE_FONT::Draw(), and KIGFX::GAL::strokeFont.

Referenced by KIGFX::GAL::BitmapText(), KIGFX::SCH_PAINTER::draw(), KIGFX::WORKSHEET_VIEWITEM::draw(), KIGFX::PCB_PAINTER::draw(), and DrawGraphicText().

332  {
333  strokeFont.Draw( aText, aPosition, aRotationAngle );
334  }
STROKE_FONT strokeFont
Instance of object that stores information about how to draw texts.
void Draw(const UTF8 &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draw a string.
VECTOR2D KIGFX::GAL::ToScreen ( const VECTOR2D aPoint) const
inlineinherited

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

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

Definition at line 968 of file graphics_abstraction_layer.h.

References KIGFX::GAL::worldScreenMatrix.

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

969  {
970  return VECTOR2D( worldScreenMatrix * aPoint );
971  }
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
MATRIX3x3D worldScreenMatrix
World transformation.
VECTOR2D KIGFX::GAL::ToWorld ( const VECTOR2D aPoint) const
inlineinherited

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

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

Definition at line 957 of file graphics_abstraction_layer.h.

References KIGFX::GAL::screenWorldMatrix.

958  {
959  return VECTOR2D( screenWorldMatrix * aPoint );
960  }
MATRIX3x3D screenWorldMatrix
Screen transformation.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
void CAIRO_GAL_BASE::Transform ( const MATRIX3x3D aTransformation)
overridevirtualinherited

Transform the context.

Parameters
aTransformationis the transformation matrix.

Reimplemented from KIGFX::GAL.

Definition at line 444 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::currentContext, and MATRIX3x3< T >::m_data.

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

445 {
446  cairo_matrix_t cairoTransformation;
447 
448  cairo_matrix_init( &cairoTransformation,
449  aTransformation.m_data[0][0],
450  aTransformation.m_data[1][0],
451  aTransformation.m_data[0][1],
452  aTransformation.m_data[1][1],
453  aTransformation.m_data[0][2],
454  aTransformation.m_data[1][2] );
455 
456  cairo_transform( currentContext, &cairoTransformation );
457 }
T m_data[3][3]
Definition: matrix3x3.h:64
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
void CAIRO_GAL_BASE::Translate ( const VECTOR2D aTranslation)
overridevirtualinherited

Translate the context.

Parameters
aTranslationis the translation vector.

Reimplemented from KIGFX::GAL.

Definition at line 478 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::argument, KIGFX::CAIRO_GAL_BASE::CMD_TRANSLATE, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::command, KIGFX::CAIRO_GAL_BASE::currentContext, KIGFX::CAIRO_GAL_BASE::currentGroup, KIGFX::CAIRO_GAL_BASE::GROUP_ELEMENT::dblArg, KIGFX::CAIRO_GAL_BASE::isGrouping, KIGFX::CAIRO_GAL_BASE::storePath(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

479 {
480  storePath();
481 
482  if( isGrouping )
483  {
484  GROUP_ELEMENT groupElement;
485  groupElement.command = CMD_TRANSLATE;
486  groupElement.argument.dblArg[0] = aTranslation.x;
487  groupElement.argument.dblArg[1] = aTranslation.y;
488  currentGroup->push_back( groupElement );
489  }
490  else
491  {
492  cairo_translate( currentContext, aTranslation.x, aTranslation.y );
493  }
494 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:792
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:268
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:263
Translate the context.
Definition: cairo_gal.h:243
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:271
virtual void KIGFX::GAL::unlockContext ( int  aClientCookie)
inlineprotectedvirtualinherited

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1097 of file graphics_abstraction_layer.h.

1097 {}
bool CAIRO_GAL::updatedGalDisplayOptions ( const GAL_DISPLAY_OPTIONS aOptions)
overrideprotectedvirtual

Cairo-specific update handlers

Reimplemented from KIGFX::GAL.

Definition at line 1247 of file cairo_gal.cpp.

References Refresh(), and KIGFX::GAL::updatedGalDisplayOptions().

1248 {
1249  bool refresh = false;
1250 
1251  if( super::updatedGalDisplayOptions( aOptions ) )
1252  {
1253  Refresh();
1254  refresh = true;
1255  }
1256 
1257  return refresh;
1258 }
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
virtual bool updatedGalDisplayOptions(const GAL_DISPLAY_OPTIONS &aOptions)
Function updatedGalDisplayOptions.

Member Data Documentation

COLOR4D KIGFX::GAL::axesColor
protectedinherited

Color of the axes.

Definition at line 1077 of file graphics_abstraction_layer.h.

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

bool KIGFX::GAL::axesEnabled
protectedinherited
COLOR4D KIGFX::CAIRO_GAL::backgroundColor
protected

Background color.

Definition at line 393 of file cairo_gal.h.

unsigned int* KIGFX::CAIRO_GAL::bitmapBuffer
protected

Storage of the cairo image.

Definition at line 388 of file cairo_gal.h.

Referenced by allocateBitmaps(), deleteBitmaps(), endDrawing(), initSurface(), RestoreScreen(), and SaveScreen().

unsigned int* KIGFX::CAIRO_GAL::bitmapBufferBackup
protected

Backup storage of the cairo image.

Definition at line 389 of file cairo_gal.h.

Referenced by allocateBitmaps(), deleteBitmaps(), RestoreScreen(), and SaveScreen().

unsigned int KIGFX::CAIRO_GAL::bufferSize
protected

Size of buffers cairoOutput, bitmapBuffers.

Definition at line 384 of file cairo_gal.h.

Referenced by allocateBitmaps().

cairo_matrix_t KIGFX::CAIRO_GAL_BASE::cairoWorldScreenMatrix
protectedinherited

Cairo world to screen transformation matrix.

Definition at line 270 of file cairo_gal.h.

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

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

Object for layers compositing.

Definition at line 374 of file cairo_gal.h.

Referenced by beginDrawing(), ClearTarget(), endDrawing(), ResizeScreen(), setCompositor(), and SetTarget().

RENDER_TARGET KIGFX::CAIRO_GAL::currentTarget
protected

Current rendering target.

Definition at line 377 of file cairo_gal.h.

Referenced by GetTarget(), and SetTarget().

COLOR4D KIGFX::GAL::cursorColor
protectedinherited

Cursor color.

Definition at line 1087 of file graphics_abstraction_layer.h.

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

VECTOR2D KIGFX::GAL::cursorPosition
protectedinherited
std::stack<double> KIGFX::GAL::depthStack
protectedinherited

Stored depth values.

Definition at line 1042 of file graphics_abstraction_layer.h.

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

bool KIGFX::GAL::forceDisplayCursor
protectedinherited
bool KIGFX::GAL::fullscreenCursor
protectedinherited

Shape of the cursor (fullscreen or small cross)

Definition at line 1088 of file graphics_abstraction_layer.h.

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

constexpr cairo_format_t KIGFX::CAIRO_GAL_BASE::GAL_FORMAT = CAIRO_FORMAT_RGB24
staticprotectedinherited

Format used to store pixels.

Definition at line 296 of file cairo_gal.h.

Referenced by allocateBitmaps(), and initSurface().

bool KIGFX::GAL::globalFlipY
protectedinherited
const int GAL::GRID_DEPTH = MAX_DEPTH - 1
staticprotectedinherited

Depth level on which the grid is drawn.

Definition at line 1140 of file graphics_abstraction_layer.h.

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

COLOR4D KIGFX::GAL::gridColor
protectedinherited

Color of the grid.

Definition at line 1076 of file graphics_abstraction_layer.h.

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

float KIGFX::GAL::gridLineWidth
protectedinherited
int KIGFX::GAL::gridMinSpacing
protectedinherited

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

Definition at line 1081 of file graphics_abstraction_layer.h.

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

VECTOR2D KIGFX::GAL::gridOffset
protectedinherited

The grid offset to compensate cursor position.

Definition at line 1075 of file graphics_abstraction_layer.h.

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

VECTOR2D KIGFX::GAL::gridOrigin
protectedinherited
GRID_STYLE KIGFX::GAL::gridStyle
protectedinherited
int KIGFX::GAL::gridTick
protectedinherited

Every tick line gets the double width.

Definition at line 1079 of file graphics_abstraction_layer.h.

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

bool KIGFX::GAL::gridVisibility
protectedinherited

Should the grid be shown.

Definition at line 1071 of file graphics_abstraction_layer.h.

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

unsigned int KIGFX::CAIRO_GAL_BASE::groupCounter
protectedinherited

Counter used for generating keys for groups.

Definition at line 267 of file cairo_gal.h.

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

bool KIGFX::GAL::isCursorEnabled
protectedinherited
bool KIGFX::CAIRO_GAL::isInitialized
protected

Are Cairo image & surface ready to use.

Definition at line 392 of file cairo_gal.h.

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

VECTOR2D KIGFX::GAL::lookAtPoint
protectedinherited
unsigned int KIGFX::CAIRO_GAL::mainBuffer
protected

Handle to the main buffer.

Definition at line 375 of file cairo_gal.h.

Referenced by beginDrawing(), CAIRO_GAL(), ClearTarget(), endDrawing(), setCompositor(), and SetTarget().

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

Maximum number of arguments for one command.

Definition at line 229 of file cairo_gal.h.

const int GAL::MAX_DEPTH = 1023
staticprotectedinherited

Definition at line 1137 of file graphics_abstraction_layer.h.

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

const int GAL::MIN_DEPTH = -1024
staticprotectedinherited

Possible depth range.

Definition at line 1133 of file graphics_abstraction_layer.h.

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

wxEvtHandler* KIGFX::CAIRO_GAL::mouseListener
protected

Mouse listener.

Definition at line 382 of file cairo_gal.h.

Referenced by CAIRO_GAL(), and skipMouseEvent().

UTIL::LINK KIGFX::GAL::observerLink
protectedinherited

Definition at line 1040 of file graphics_abstraction_layer.h.

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

unsigned int KIGFX::CAIRO_GAL::overlayBuffer
protected

Handle to the overlay buffer.

Definition at line 376 of file cairo_gal.h.

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

wxEvtHandler* KIGFX::CAIRO_GAL::paintListener
protected

Paint listener.

Definition at line 383 of file cairo_gal.h.

Referenced by CAIRO_GAL().

wxWindow* KIGFX::CAIRO_GAL::parentWindow
protected

Parent window.

Definition at line 381 of file cairo_gal.h.

Referenced by CAIRO_GAL().

double KIGFX::GAL::rotation
protectedinherited

Rotation transformation (radians)

Definition at line 1050 of file graphics_abstraction_layer.h.

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

double KIGFX::GAL::screenDPI
protectedinherited
int KIGFX::CAIRO_GAL::stride
protected

Stride value for Cairo.

Definition at line 390 of file cairo_gal.h.

Referenced by allocateBitmaps(), initSurface(), RestoreScreen(), and SaveScreen().

STROKE_FONT KIGFX::GAL::strokeFont
protectedinherited

Instance of object that stores information about how to draw texts.

Definition at line 1092 of file graphics_abstraction_layer.h.

Referenced by KIGFX::GAL::GAL(), KIGFX::GAL::GetOverbarVerticalPosition(), KIGFX::GAL::GetStrokeFont(), KIGFX::GAL::GetTextLineSize(), and KIGFX::GAL::StrokeText().

cairo_surface_t* KIGFX::CAIRO_GAL_BASE::surface
protectedinherited
bool KIGFX::CAIRO_GAL::validCompositor
protected

Compositor initialization flag.

Definition at line 378 of file cairo_gal.h.

Referenced by beginDrawing(), CAIRO_GAL(), ResizeScreen(), setCompositor(), and SetTarget().

double KIGFX::GAL::worldUnitLength
protectedinherited
int KIGFX::CAIRO_GAL::wxBufferWidth
protected

Definition at line 391 of file cairo_gal.h.

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

unsigned char* KIGFX::CAIRO_GAL::wxOutput
protected

wxImage comaptible buffer

Definition at line 385 of file cairo_gal.h.

Referenced by allocateBitmaps(), deleteBitmaps(), and endDrawing().

double KIGFX::GAL::zoomFactor
protectedinherited

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