KiCad PCB EDA Suite
KIGFX::CAIRO_GAL Class Reference

#include <cairo_gal.h>

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

Classes

struct  GROUP_ELEMENT
 Type definition for an graphics group element. More...
 

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. More...
 
virtual ~CAIRO_GAL ()
 
bool IsVisible () const override
 > More...
 
virtual void BeginDrawing () override
 Begin the drawing, needs to be called for every new frame. More...
 
virtual void EndDrawing () override
 End the drawing, needs to be called for every new frame. More...
 
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 ResizeScreen (int aWidth, int aHeight) override
 Resizes the canvas. More...
 
virtual bool Show (bool aShow) override
 Shows/hides the GAL canvas. 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 (double 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 int BeginGroup () override
 Begin a group. More...
 
virtual void EndGroup () override
 End the group. 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 SaveScreen () override
 Save the screen contents. More...
 
virtual void RestoreScreen () override
 Restore the screen contents. 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...
 
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...
 
void PostPaint ()
 Function PostPaint posts an event to m_paint_listener. More...
 
void SetMouseListener (wxEvtHandler *aMouseListener)
 
void SetPaintListener (wxEvtHandler *aPaintListener)
 
virtual void EnableDepthTest (bool aEnabled=false) override
 
virtual bool IsInitialized () const
 Returns the initalization status for the canvas. More...
 
virtual void BeginUpdate ()
 Enables item update mode. More...
 
virtual void EndUpdate ()
 Disables item update mode. 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...
 
double 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 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 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...
 
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...
 
double 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...
 

Static Public Attributes

static const double METRIC_UNIT_LENGTH = 1e9
 

Protected Member Functions

virtual void drawGridLine (const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint) override
 Draw a grid line (usually a simplified line function). More...
 
virtual void lockContext ()
 
virtual void unlockContext ()
 
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

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...
 
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...
 
double 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...
 
double 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 MIN_DEPTH = -1024
 Possible depth range. More...
 
static const int MAX_DEPTH = 1023
 
static const int GRID_DEPTH = MAX_DEPTH - 1
 Depth level on which the grid is drawn. More...
 

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

Private Member Functions

bool updatedGalDisplayOptions (const GAL_DISPLAY_OPTIONS &aOptions) override
 

Cairo-specific update handlers

More...
 
void flushPath ()
 
void storePath ()
 Store the actual path. More...
 
void onPaint (wxPaintEvent &aEvent)
 Paint event handler. More...
 
void skipMouseEvent (wxMouseEvent &aEvent)
 Mouse event handler, forwards the event to the child. More...
 
virtual void blitCursor (wxMemoryDC &clientDC)
 Blits cursor into the current screen. More...
 
void initSurface ()
 Prepare Cairo surfaces for drawing. More...
 
void deinitSurface ()
 Destroy Cairo surfaces when are not needed anymore. More...
 
void allocateBitmaps ()
 Allocate the bitmaps for drawing. More...
 
void deleteBitmaps ()
 Allocate the bitmaps for drawing. More...
 
void setCompositor ()
 Prepare the compositor. More...
 
void 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...
 

Private 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...
 
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...
 
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...
 
bool isInitialized
 Are Cairo image & surface ready to use. More...
 
COLOR4D backgroundColor
 Background color. More...
 
int wxBufferWidth
 

Static Private Attributes

static const int MAX_CAIRO_ARGUMENTS = 4
 Maximum number of arguments for one command. More...
 
static const cairo_format_t GAL_FORMAT = CAIRO_FORMAT_RGB24
 Format used to store pixels. More...
 
static const float LAYER_ALPHA
 

Opacity of a single layer

More...
 

Detailed Description

Definition at line 66 of file cairo_gal.h.

Member Typedef Documentation

typedef std::deque<GROUP_ELEMENT> KIGFX::CAIRO_GAL::GROUP
private

A graphic group type definition.

Definition at line 341 of file cairo_gal.h.

typedef GAL KIGFX::CAIRO_GAL::super
private

Super class definition.

Definition at line 288 of file cairo_gal.h.

Member Enumeration Documentation

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

309  {
310  CMD_SET_FILL,
316  CMD_FILL_PATH,
317  //CMD_TRANSFORM, ///< Transform the actual context
318  CMD_ROTATE,
319  CMD_TRANSLATE,
320  CMD_SCALE,
321  CMD_SAVE,
322  CMD_RESTORE,
324  };
Scale the context.
Definition: cairo_gal.h:320
Set the stroke path.
Definition: cairo_gal.h:315
Translate the context.
Definition: cairo_gal.h:319
Enable/disable stroking.
Definition: cairo_gal.h:311
Restore the transformation matrix.
Definition: cairo_gal.h:322
Rotate the context.
Definition: cairo_gal.h:318
Enable/disable filling.
Definition: cairo_gal.h:310
Set the fill path.
Definition: cairo_gal.h:316
Save the transformation matrix.
Definition: cairo_gal.h:321

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.

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

References allocateBitmaps(), BLUE, cairoWorldScreenMatrix, context, currentContext, currentGroup, groupCounter, isElementAdded, isGrouping, isInitialized, mainBuffer, mouseListener, onPaint(), overlayBuffer, paintListener, parentWindow, KIGFX::GAL::screenSize, KIGFX::GAL::SetAxesColor(), KIGFX::GAL::SetGridColor(), SetTarget(), skipMouseEvent(), surface, KIGFX::TARGET_NONCACHED, and validCompositor.

48  :
49  GAL( aDisplayOptions ),
50  wxWindow( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxEXPAND, aName )
51 {
52  parentWindow = aParent;
53  mouseListener = aMouseListener;
54  paintListener = aPaintListener;
55 
56  // Initialise grouping
57  isGrouping = false;
58  isElementAdded = false;
59  groupCounter = 0;
60  currentGroup = nullptr;
61 
62  // Initialise compositing state
63  mainBuffer = 0;
64  overlayBuffer = 0;
65  validCompositor = false;
67 
68  // Initialise Cairo state
69  cairo_matrix_init_identity( &cairoWorldScreenMatrix );
70  currentContext = nullptr;
71  context = nullptr;
72  surface = nullptr;
73  isInitialized = false;
74 
75  // Connecting the event handlers
76  Connect( wxEVT_PAINT, wxPaintEventHandler( CAIRO_GAL::onPaint ) );
77 
78  // Mouse events are skipped to the parent
79  Connect( wxEVT_MOTION, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
80  Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
81  Connect( wxEVT_LEFT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
82  Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
83  Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
84  Connect( wxEVT_MIDDLE_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
85  Connect( wxEVT_MIDDLE_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
86  Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
87  Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
88  Connect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
89  Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
90 #if defined _WIN32 || defined _WIN64
91  Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
92 #endif
93 
94  SetSize( aParent->GetClientSize() );
95  screenSize = VECTOR2I( aParent->GetClientSize() );
96 
97  // Grid color settings are different in Cairo and OpenGL
98  SetGridColor( COLOR4D( 0.1, 0.1, 0.1, 0.8 ) );
100 
101  // Allocate memory for pixel storage
102  allocateBitmaps();
103 }
unsigned int groupCounter
Counter used for generating keys for groups.
Definition: cairo_gal.h:343
Definition: colors.h:57
void onPaint(wxPaintEvent &aEvent)
Paint event handler.
Definition: cairo_gal.cpp:1020
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:354
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:293
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:295
Auxiliary rendering target (noncached)
Definition: definitions.h:42
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:344
GAL(GAL_DISPLAY_OPTIONS &aOptions)
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:339
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
cairo_surface_t * surface
Cairo surface.
Definition: cairo_gal.h:350
cairo_t * context
Cairo image.
Definition: cairo_gal.h:349
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:340
wxEvtHandler * paintListener
Paint listener.
Definition: cairo_gal.h:300
virtual void SetTarget(RENDER_TARGET aTarget) override
Sets the target for rendering.
Definition: cairo_gal.cpp:869
void skipMouseEvent(wxMouseEvent &aEvent)
Mouse event handler, forwards the event to the child.
Definition: cairo_gal.cpp:1026
cairo_matrix_t cairoWorldScreenMatrix
Cairo world to screen transformation matrix.
Definition: cairo_gal.h:347
VECTOR2I screenSize
Screen size in screen coordinates.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
wxEvtHandler * mouseListener
Mouse listener.
Definition: cairo_gal.h:299
void allocateBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1052
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:292
wxWindow * parentWindow
Parent window.
Definition: cairo_gal.h:298
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
CAIRO_GAL::~CAIRO_GAL ( )
virtual

Definition at line 106 of file cairo_gal.cpp.

References ClearCache(), deinitSurface(), and deleteBitmaps().

107 {
108  deinitSurface();
109  deleteBitmaps();
110 
111  ClearCache();
112 }
void deinitSurface()
Destroy Cairo surfaces when are not needed anymore.
Definition: cairo_gal.cpp:1119
virtual void ClearCache() override
Delete all data created during caching of graphic items.
Definition: cairo_gal.cpp:829
void deleteBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1067

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

References KIGFX::GAL::layerDepth.

Referenced by KIGFX::SCH_PAINTER::draw(), and KIGFX::VIEW_GROUP::ViewDraw().

982  {
983  layerDepth -= 0.05;
984  }
double layerDepth
The actual layer depth.
void CAIRO_GAL::allocateBitmaps ( )
private

Allocate the bitmaps for drawing.

Definition at line 1052 of file cairo_gal.cpp.

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

Referenced by CAIRO_GAL(), and ResizeScreen().

1053 {
1055  while( ( ( wxBufferWidth * 3 ) % 4 ) != 0 ) wxBufferWidth++;
1056 
1057  // Create buffer, use the system independent Cairo context backend
1058  stride = cairo_format_stride_for_width( GAL_FORMAT, wxBufferWidth );
1060 
1061  bitmapBuffer = new unsigned int[bufferSize];
1062  bitmapBufferBackup = new unsigned int[bufferSize];
1063  wxOutput = new unsigned char[wxBufferWidth * 3 * screenSize.y];
1064 }
unsigned char * wxOutput
wxImage comaptible buffer
Definition: cairo_gal.h:302
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:351
static const cairo_format_t GAL_FORMAT
Format used to store pixels.
Definition: cairo_gal.h:414
int stride
Stride value for Cairo.
Definition: cairo_gal.h:353
unsigned int * bitmapBufferBackup
Backup storage of the cairo image.
Definition: cairo_gal.h:352
VECTOR2I screenSize
Screen size in screen coordinates.
unsigned int bufferSize
Size of buffers cairoOutput, bitmapBuffers.
Definition: cairo_gal.h:301
void CAIRO_GAL::BeginDrawing ( )
overridevirtual

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

Reimplemented from KIGFX::GAL.

Definition at line 129 of file cairo_gal.cpp.

References compositor, context, initSurface(), mainBuffer, setCompositor(), and validCompositor.

Referenced by IsVisible().

130 {
131  initSurface();
132 
133  if( !validCompositor )
134  setCompositor();
135 
136  compositor->SetMainContext( context );
137  compositor->SetBuffer( mainBuffer );
138 }
void initSurface()
Prepare Cairo surfaces for drawing.
Definition: cairo_gal.cpp:1075
void setCompositor()
Prepare the compositor.
Definition: cairo_gal.cpp:1132
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:295
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:291
cairo_t * context
Cairo image.
Definition: cairo_gal.h:349
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:292
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::GAL.

Definition at line 667 of file cairo_gal.cpp.

References currentGroup, getNewGroupNumber(), groups, initSurface(), isGrouping, and storePath().

Referenced by DrawPolygon().

668 {
669  initSurface();
670 
671  // If the grouping is started: the actual path is stored in the group, when
672  // a attribute was changed or when grouping stops with the end group method.
673  storePath();
674 
675  GROUP group;
676  int groupNumber = getNewGroupNumber();
677  groups.insert( std::make_pair( groupNumber, group ) );
678  currentGroup = &groups[groupNumber];
679  isGrouping = true;
680 
681  return groupNumber;
682 }
void initSurface()
Prepare Cairo surfaces for drawing.
Definition: cairo_gal.cpp:1075
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:344
unsigned int getNewGroupNumber()
Returns a valid key that can be used as a new group number.
Definition: cairo_gal.cpp:1205
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:339
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:342
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:972
std::deque< GROUP_ELEMENT > GROUP
A graphic group type definition.
Definition: cairo_gal.h:341
virtual void KIGFX::GAL::BeginUpdate ( )
inlinevirtualinherited
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 352 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().

354  {
355  // Fallback: use stroke font
356 
357  // Handle flipped view
358  if( globalFlipX )
360 
361  StrokeText( aText, aPosition, aRotationAngle );
362 
363  if( globalFlipX )
365  }
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::blitCursor ( wxMemoryDC &  clientDC)
privatevirtual

Blits cursor into the current screen.

Definition at line 1034 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().

1035 {
1036  if( !IsCursorEnabled() )
1037  return;
1038 
1039  auto p = ToScreen( cursorPosition );
1040 
1041  const auto cColor = getCursorColor();
1042  const int cursorSize = fullscreenCursor ? 8000 : 80;
1043 
1044  wxColour color( cColor.r * cColor.a * 255, cColor.g * cColor.a * 255,
1045  cColor.b * cColor.a * 255, 255 );
1046  clientDC.SetPen( wxPen( color ) );
1047  clientDC.DrawLine( p.x - cursorSize / 2, p.y, p.x + cursorSize / 2, p.y );
1048  clientDC.DrawLine( p.x, p.y - cursorSize / 2, p.x, p.y + cursorSize / 2 );
1049 }
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::ChangeGroupColor ( int  aGroupNumber,
const COLOR4D aNewColor 
)
overridevirtual

Changes the color used to draw the group.

Parameters
aGroupNumberis the group number.
aNewColoris the new color.

Reimplemented from KIGFX::GAL.

Definition at line 784 of file cairo_gal.cpp.

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, CMD_SET_FILLCOLOR, CMD_SET_STROKECOLOR, KIGFX::COLOR4D::g, groups, KIGFX::COLOR4D::r, and storePath().

Referenced by DrawPolygon().

785 {
786  storePath();
787 
788  for( GROUP::iterator it = groups[aGroupNumber].begin();
789  it != groups[aGroupNumber].end(); ++it )
790  {
791  if( it->command == CMD_SET_FILLCOLOR || it->command == CMD_SET_STROKECOLOR )
792  {
793  it->argument.dblArg[0] = aNewColor.r;
794  it->argument.dblArg[1] = aNewColor.g;
795  it->argument.dblArg[2] = aNewColor.b;
796  it->argument.dblArg[3] = aNewColor.a;
797  }
798  }
799 }
double g
Green component.
Definition: color4d.h:292
double b
Blue component.
Definition: color4d.h:293
double a
Alpha component.
Definition: color4d.h:294
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:342
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:972
double r
Red component.
Definition: color4d.h:291
void CAIRO_GAL::ChangeGroupDepth ( int  aGroupNumber,
int  aDepth 
)
overridevirtual

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

Referenced by DrawPolygon().

803 {
804  // Cairo does not have any possibilities to change the depth coordinate of stored items,
805  // it depends only on the order of drawing
806 }
void CAIRO_GAL::ClearCache ( )
overridevirtual

Delete all data created during caching of graphic items.

Reimplemented from KIGFX::GAL.

Definition at line 829 of file cairo_gal.cpp.

References DeleteGroup(), groups, and i.

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

830 {
831  for( int i = groups.size() - 1; i >= 0; --i )
832  {
833  DeleteGroup( i );
834  }
835 }
virtual void DeleteGroup(int aGroupNumber) override
Delete the group from the memory.
Definition: cairo_gal.cpp:809
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:342
size_t i
Definition: json11.cpp:597
void CAIRO_GAL::ClearScreen ( )
overridevirtual

Clear the screen.

Parameters
aColoris the color used for clearing.

Reimplemented from KIGFX::GAL.

Definition at line 453 of file cairo_gal.cpp.

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

Referenced by DrawPolygon(), and initSurface().

454 {
457  cairo_rectangle( currentContext, 0.0, 0.0, screenSize.x, screenSize.y );
458  cairo_fill( currentContext );
459 }
double g
Green component.
Definition: color4d.h:292
double b
Blue component.
Definition: color4d.h:293
COLOR4D backgroundColor
Background color.
Definition: cairo_gal.h:355
VECTOR2I screenSize
Screen size in screen coordinates.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
double r
Red component.
Definition: color4d.h:291
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 903 of file cairo_gal.cpp.

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

Referenced by DrawPolygon().

904 {
905  // Save the current state
906  unsigned int currentBuffer = compositor->GetBuffer();
907 
908  switch( aTarget )
909  {
910  // Cached and noncached items are rendered to the same buffer
911  default:
912  case TARGET_CACHED:
913  case TARGET_NONCACHED:
914  compositor->SetBuffer( mainBuffer );
915  break;
916 
917  case TARGET_OVERLAY:
918  compositor->SetBuffer( overlayBuffer );
919  break;
920  }
921 
922  compositor->ClearBuffer( COLOR4D::BLACK );
923 
924  // Restore the previous state
925  compositor->SetBuffer( currentBuffer );
926 }
static const COLOR4D BLACK
Definition: color4d.h:301
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:293
Auxiliary rendering target (noncached)
Definition: definitions.h:42
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:291
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:292
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 205 of file graphics_abstraction_layer.cpp.

References KIGFX::GAL::gridMinSpacing.

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

206 {
207  // just return the current value. This could be cleverer and take
208  // into account other settings in future
209  return gridMinSpacing;
210 }
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 1068 of file graphics_abstraction_layer.h.

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

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

1069  {
1071  }
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.

Definition at line 177 of file graphics_abstraction_layer.cpp.

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

Referenced by KIGFX::OPENGL_GAL::BeginDrawing(), KIGFX::GAL::ClearCache(), initSurface(), KIGFX::VIEW::SetCenter(), and KIGFX::VIEW::SetScale().

178 {
180 
182 
183  MATRIX3x3D translation;
184  translation.SetIdentity();
185  translation.SetTranslation( 0.5 * VECTOR2D( screenSize ) );
186 
188  scale.SetIdentity();
189  scale.SetScale( VECTOR2D( worldScale, worldScale ) );
190 
191  MATRIX3x3D flip;
192 
193  flip.SetIdentity();
194  flip.SetScale( VECTOR2D( globalFlipX ? -1.0 : 1.0, globalFlipY ? -1.0 : 1.0 ) );
195 
196  MATRIX3x3D lookat;
197  lookat.SetIdentity();
198  lookat.SetTranslation( -lookAtPoint );
199 
200  worldScreenMatrix = translation * flip * scale * lookat * worldScreenMatrix;
201  screenWorldMatrix = worldScreenMatrix.Inverse();
202 }
MATRIX3x3 Inverse() const
Determine the inverse of the matrix.
Definition: matrix3x3.h:343
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 ( )
private

Destroy Cairo surfaces when are not needed anymore.

Definition at line 1119 of file cairo_gal.cpp.

References context, isInitialized, and surface.

Referenced by EndDrawing(), EndGroup(), and ~CAIRO_GAL().

1120 {
1121  if( !isInitialized )
1122  return;
1123 
1124  // Destroy Cairo objects
1125  cairo_destroy( context );
1126  cairo_surface_destroy( surface );
1127 
1128  isInitialized = false;
1129 }
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:354
cairo_surface_t * surface
Cairo surface.
Definition: cairo_gal.h:350
cairo_t * context
Cairo image.
Definition: cairo_gal.h:349
void CAIRO_GAL::deleteBitmaps ( )
private

Allocate the bitmaps for drawing.

Definition at line 1067 of file cairo_gal.cpp.

References bitmapBuffer, bitmapBufferBackup, and wxOutput.

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

1068 {
1069  delete[] bitmapBuffer;
1070  delete[] bitmapBufferBackup;
1071  delete[] wxOutput;
1072 }
unsigned char * wxOutput
wxImage comaptible buffer
Definition: cairo_gal.h:302
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:351
unsigned int * bitmapBufferBackup
Backup storage of the cairo image.
Definition: cairo_gal.h:352
void CAIRO_GAL::DeleteGroup ( int  aGroupNumber)
overridevirtual

Delete the group from the memory.

Parameters
aGroupNumberis the group number.

Reimplemented from KIGFX::GAL.

Definition at line 809 of file cairo_gal.cpp.

References CMD_FILL_PATH, CMD_STROKE_PATH, groups, and storePath().

Referenced by ClearCache(), and DrawPolygon().

810 {
811  storePath();
812 
813  // Delete the Cairo paths
814  std::deque<GROUP_ELEMENT>::iterator it, end;
815 
816  for( it = groups[aGroupNumber].begin(), end = groups[aGroupNumber].end(); it != end; ++it )
817  {
818  if( it->command == CMD_FILL_PATH || it->command == CMD_STROKE_PATH )
819  {
820  cairo_path_destroy( it->cairoPath );
821  }
822  }
823 
824  // Delete the group
825  groups.erase( aGroupNumber );
826 }
Set the stroke path.
Definition: cairo_gal.h:315
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:342
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:972
Set the fill path.
Definition: cairo_gal.h:316
void CAIRO_GAL::DrawArc ( const VECTOR2D aCenterPoint,
double  aRadius,
double  aStartAngle,
double  aEndAngle 
)
overridevirtual

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

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

Referenced by IsVisible().

241 {
242  SWAP( aStartAngle, >, aEndAngle );
243 
244  if( isFillEnabled ) // Draw the filled area of the shape, before drawing the outline itself
245  {
246  double pen_size = GetLineWidth();
247  auto fgcolor = GetStrokeColor();
249 
250  SetLineWidth( 0 );
251  cairo_new_sub_path( currentContext );
252  cairo_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, aStartAngle, aEndAngle );
253  VECTOR2D startPoint( cos( aStartAngle ) * aRadius + aCenterPoint.x,
254  sin( aStartAngle ) * aRadius + aCenterPoint.y );
255  VECTOR2D endPoint( cos( aEndAngle ) * aRadius + aCenterPoint.x,
256  sin( aEndAngle ) * aRadius + aCenterPoint.y );
257 
258  cairo_move_to( currentContext, aCenterPoint.x, aCenterPoint.y );
259  cairo_line_to( currentContext, startPoint.x, startPoint.y );
260  cairo_line_to( currentContext, endPoint.x, endPoint.y );
261  cairo_close_path( currentContext );
262  flushPath();
263  SetLineWidth( pen_size );
264  SetStrokeColor( fgcolor );
265  }
266 
267  cairo_new_sub_path( currentContext );
268  cairo_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, aStartAngle, aEndAngle );
269  flushPath();
270 
271  isElementAdded = true;
272 }
const COLOR4D & GetStrokeColor() const
Get the stroke color.
virtual void SetStrokeColor(const COLOR4D &aColor) override
Set the stroke color.
Definition: cairo_gal.cpp:492
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:340
virtual void SetLineWidth(double aLineWidth) override
Set the line width.
Definition: cairo_gal.cpp:528
const COLOR4D & GetFillColor() const
Get the fill color.
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
double GetLineWidth() const
Get the line width.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
void CAIRO_GAL::DrawArcSegment ( const VECTOR2D aCenterPoint,
double  aRadius,
double  aStartAngle,
double  aEndAngle,
double  aWidth 
)
overridevirtual

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

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

Referenced by IsVisible().

277 {
278  SWAP( aStartAngle, >, aEndAngle );
279 
280  if( isFillEnabled )
281  {
282  // Filled segments mode
283  SetLineWidth( aWidth );
284  cairo_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, aStartAngle, aEndAngle );
285  cairo_set_source_rgba( currentContext, fillColor.r, fillColor.g, fillColor.b, fillColor.a );
286  cairo_stroke( currentContext );
287  }
288  else
289  {
290  double width = aWidth / 2.0;
291  VECTOR2D startPoint( cos( aStartAngle ) * aRadius,
292  sin( aStartAngle ) * aRadius );
293  VECTOR2D endPoint( cos( aEndAngle ) * aRadius,
294  sin( aEndAngle ) * aRadius );
295 
296  cairo_save( currentContext );
297 
298  cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
299 
300  cairo_translate( currentContext, aCenterPoint.x, aCenterPoint.y );
301 
302  cairo_new_sub_path( currentContext );
303  cairo_arc( currentContext, 0, 0, aRadius - width, aStartAngle, aEndAngle );
304 
305  cairo_new_sub_path( currentContext );
306  cairo_arc( currentContext, 0, 0, aRadius + width, aStartAngle, aEndAngle );
307 
308  cairo_new_sub_path( currentContext );
309  cairo_arc_negative( currentContext, startPoint.x, startPoint.y, width, aStartAngle, aStartAngle + M_PI );
310 
311  cairo_new_sub_path( currentContext );
312  cairo_arc( currentContext, endPoint.x, endPoint.y, width, aEndAngle, aEndAngle + M_PI );
313 
314  cairo_restore( currentContext );
315  flushPath();
316  }
317 
318  isElementAdded = true;
319 }
double g
Green component.
Definition: color4d.h:292
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:293
double a
Alpha component.
Definition: color4d.h:294
COLOR4D strokeColor
The color of the outlines.
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:340
virtual void SetLineWidth(double aLineWidth) override
Set the line width.
Definition: cairo_gal.cpp:528
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
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
double r
Red component.
Definition: color4d.h:291
void CAIRO_GAL::DrawBitmap ( const BITMAP_BASE aBitmap)
overridevirtual

Draw a bitmap image.

Reimplemented from KIGFX::GAL.

Definition at line 360 of file cairo_gal.cpp.

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

Referenced by DrawPolygon().

361 {
362  int ppi = aBitmap.GetPPI();
363  // We have to calculate the pixel size in users units to draw the image.
364  // worldUnitLength is the user unit in GAL unit value
365  // (GAL unit = 0.1 inch in nanometer = 2.54/1000 in mm).
366  // worldUnitLength * 1000 / 2.54 is the user unit in mm
367  double worldIU_per_mm = 1/( worldUnitLength / 0.00254 );
368  double pix_size_iu = worldIU_per_mm * ( 25.4 / ppi );
369  int w = aBitmap.GetSizePixels().x;
370  int h = aBitmap.GetSizePixels().y;
371 
372  cairo_save( currentContext );
373 
374  // Set the pixel scaling factor:
375  cairo_scale( currentContext, pix_size_iu, pix_size_iu );
376  // The position of the bitmap is the bitmap center.
377  // move the draw origin to the top left bitmap corner:
378  cairo_translate( currentContext, -w/2, -h/2 );
379 
380  cairo_new_path( currentContext );
381  cairo_surface_t *image;
382  image = cairo_image_surface_create( CAIRO_FORMAT_RGB24, w, h );
383  cairo_surface_flush( image );
384 
385  unsigned char* pix_buffer = cairo_image_surface_get_data( image );
386  // The pixel buffer of the initial bitmap:
387  auto bm_pix_buffer = (( BITMAP_BASE&)aBitmap).GetImageData();
388 
389  // Copy the source bitmap to the cairo bitmap buffer.
390  // In cairo bitmap buffer, a RGB24 bitmap is a RGB pixel packed into a uint_32
391  // 24 low bits only are used.
392  for( int row = 0; row < h; row++ )
393  {
394  for( int col = 0; col < w; col++ )
395  {
396  // Build the RGB24 pixel:
397  uint32_t pixel = bm_pix_buffer->GetRed( col, row ) << 16;
398  pixel += bm_pix_buffer->GetGreen( col, row ) << 8;
399  pixel += bm_pix_buffer->GetBlue( col, row );
400 
401  // Write the pixel to the cairo image buffer:
402  uint32_t* pix_ptr = (uint32_t*) pix_buffer;
403  *pix_ptr = pixel;
404  pix_buffer += 4;
405  }
406  }
407 
408  cairo_surface_mark_dirty( image );
409  cairo_set_source_surface( currentContext, image, 0, 0 );
410  cairo_paint( currentContext );
411  cairo_surface_destroy( image );
412 
413  isElementAdded = true;
414 
415  cairo_restore( currentContext );
416 }
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
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:340
int GetPPI() const
Definition: bitmap_base.h:145
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
void CAIRO_GAL::DrawCircle ( const VECTOR2D aCenterPoint,
double  aRadius 
)
overridevirtual

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

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

Referenced by IsVisible().

231 {
232  cairo_new_sub_path( currentContext );
233  cairo_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, 0.0, 2 * M_PI );
234  flushPath();
235  isElementAdded = true;
236 }
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:340
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
void CAIRO_GAL::DrawCursor ( const VECTOR2D aCursorPosition)
overridevirtual

Draw the cursor.

Parameters
aCursorPositionis the cursor position in screen coordinates.

Reimplemented from KIGFX::GAL.

Definition at line 935 of file cairo_gal.cpp.

References KIGFX::GAL::cursorPosition.

Referenced by DrawPolygon().

936 {
937  cursorPosition = aCursorPosition;
938 }
VECTOR2D cursorPosition
Current cursor position (world coordinates)
void CAIRO_GAL::DrawCurve ( const VECTOR2D startPoint,
const VECTOR2D controlPointA,
const VECTOR2D controlPointB,
const VECTOR2D endPoint 
)
overridevirtual

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

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

Referenced by DrawPolygon().

349 {
350  cairo_move_to( currentContext, aStartPoint.x, aStartPoint.y );
351  cairo_curve_to( currentContext, aControlPointA.x, aControlPointA.y, aControlPointB.x,
352  aControlPointB.y, aEndPoint.x, aEndPoint.y );
353  cairo_line_to( currentContext, aEndPoint.x, aEndPoint.y );
354 
355  flushPath();
356  isElementAdded = true;
357 }
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:340
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
void GAL::DrawGrid ( )
virtualinherited

>

Draw the grid

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 213 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().

214 {
216 
217  // Draw the grid
218  // For the drawing the start points, end points and increments have
219  // to be calculated in world coordinates
220  VECTOR2D worldStartPoint = screenWorldMatrix * VECTOR2D( 0.0, 0.0 );
221  VECTOR2D worldEndPoint = screenWorldMatrix * VECTOR2D( screenSize );
222 
223  const double gridThreshold = computeMinGridSpacing();
224 
225  int gridScreenSizeDense = KiROUND( gridSize.x * worldScale );
226  int gridScreenSizeCoarse = KiROUND( gridSize.x * static_cast<double>( gridTick ) * worldScale );
227 
228  // Compute the line marker or point radius of the grid
229  // Note: generic grids can't handle sub-pixel lines without
230  // either losing fine/course distinction or having some dots
231  // fail to render
232  double marker = std::max( 1.0, gridLineWidth ) / worldScale;
233  double doubleMarker = 2.0 * marker;
234 
235  // Draw axes if desired
236  if( axesEnabled )
237  {
238  SetIsFill( false );
239  SetIsStroke( true );
241  SetLineWidth( marker );
242 
243  drawGridLine( VECTOR2D( worldStartPoint.x, 0 ),
244  VECTOR2D( worldEndPoint.x, 0 ) );
245 
246  drawGridLine( VECTOR2D( 0, worldStartPoint.y ),
247  VECTOR2D( 0, worldEndPoint.y ) );
248  }
249 
250  if( !gridVisibility )
251  return;
252 
253  // Check if the grid would not be too dense
254  if( std::max( gridScreenSizeDense, gridScreenSizeCoarse ) <= gridThreshold )
255  return;
256 
257  // Compute grid staring and ending indexes to draw grid points on the
258  // visible screen area
259  // Note: later any point coordinate will be offsetted by gridOrigin
260  int gridStartX = KiROUND( ( worldStartPoint.x - gridOrigin.x ) / gridSize.x );
261  int gridEndX = KiROUND( ( worldEndPoint.x - gridOrigin.x ) / gridSize.x );
262  int gridStartY = KiROUND( ( worldStartPoint.y - gridOrigin.y ) / gridSize.y );
263  int gridEndY = KiROUND( ( worldEndPoint.y - gridOrigin.y ) / gridSize.y );
264 
265  // Ensure start coordinate > end coordinate
266  if( gridStartX > gridEndX )
267  std::swap( gridStartX, gridEndX );
268 
269  if( gridStartY > gridEndY )
270  std::swap( gridStartY, gridEndY );
271 
272  // Ensure the grid fills the screen
273  --gridStartX; ++gridEndX;
274  --gridStartY; ++gridEndY;
275 
276  // Draw the grid behind all other layers
277  SetLayerDepth( depthRange.y * 0.75 );
278 
280  {
281  SetIsFill( false );
282  SetIsStroke( true );
284 
285  // Now draw the grid, every coarse grid line gets the double width
286 
287  // Vertical lines
288  for( int j = gridStartY; j <= gridEndY; j++ )
289  {
290  const double y = j * gridSize.y + gridOrigin.y;
291 
292  if( axesEnabled && y == 0 )
293  continue;
294 
295  if( j % gridTick == 0 && gridScreenSizeDense > gridThreshold )
296  SetLineWidth( doubleMarker );
297  else
298  SetLineWidth( marker );
299 
300  if( ( j % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
301  || gridScreenSizeDense > gridThreshold )
302  {
303  drawGridLine( VECTOR2D( gridStartX * gridSize.x + gridOrigin.x, y ),
304  VECTOR2D( gridEndX * gridSize.x + gridOrigin.x, y ) );
305  }
306  }
307 
308  // Horizontal lines
309  for( int i = gridStartX; i <= gridEndX; i++ )
310  {
311  const double x = i * gridSize.x + gridOrigin.x;
312 
313  if( axesEnabled && x == 0 )
314  continue;
315 
316  if( i % gridTick == 0 && gridScreenSizeDense > gridThreshold )
317  SetLineWidth( doubleMarker );
318  else
319  SetLineWidth( marker );
320 
321  if( ( i % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
322  || gridScreenSizeDense > gridThreshold )
323  {
324  drawGridLine( VECTOR2D( x, gridStartY * gridSize.y + gridOrigin.y ),
325  VECTOR2D( x, gridEndY * gridSize.y + gridOrigin.y ) );
326  }
327  }
328  }
329  else if( gridStyle == GRID_STYLE::SMALL_CROSS )
330  {
331  SetIsFill( false );
332  SetIsStroke( true );
334 
335  SetLineWidth( marker );
336  double lineLen = GetLineWidth() * 2;
337 
338  // Vertical positions:
339  for( int j = gridStartY; j <= gridEndY; j++ )
340  {
341  if( ( j % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
342  || gridScreenSizeDense > gridThreshold )
343  {
344  int posY = j * gridSize.y + gridOrigin.y;
345 
346  // Horizontal positions:
347  for( int i = gridStartX; i <= gridEndX; i++ )
348  {
349  if( ( i % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
350  || gridScreenSizeDense > gridThreshold )
351  {
352  int posX = i * gridSize.x + gridOrigin.x;
353 
354  drawGridLine( VECTOR2D( posX - lineLen, posY ),
355  VECTOR2D( posX + lineLen, posY ) );
356 
357  drawGridLine( VECTOR2D( posX, posY - lineLen ),
358  VECTOR2D( posX, posY + lineLen ) );
359  }
360  }
361  }
362  }
363  }
364  else // Dotted grid
365  {
366  bool tickX, tickY;
367  SetIsFill( true );
368  SetIsStroke( false );
370 
371  for( int j = gridStartY; j <= gridEndY; j++ )
372  {
373  if( j % gridTick == 0 && gridScreenSizeDense > gridThreshold )
374  tickY = true;
375  else
376  tickY = false;
377 
378  for( int i = gridStartX; i <= gridEndX; i++ )
379  {
380  if( i % gridTick == 0 && gridScreenSizeDense > gridThreshold )
381  tickX = true;
382  else
383  tickX = false;
384 
385  if( tickX || tickY || gridScreenSizeDense > gridThreshold )
386  {
387  double radius = ( ( tickX && tickY ) ? doubleMarker : marker ) / 2.0;
388  DrawRectangle( VECTOR2D( i * gridSize.x - radius + gridOrigin.x,
389  j * gridSize.y - radius + gridOrigin.y ),
390  VECTOR2D( i * gridSize.x + radius + gridOrigin.x,
391  j * gridSize.y + radius + gridOrigin.y ) );
392  }
393  }
394  }
395  }
396 }
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).
Auxiliary rendering target (noncached)
Definition: definitions.h:42
virtual void SetLineWidth(double aLineWidth)
Set the line width.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
COLOR4D axesColor
Color of the axes.
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.
double 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.
double gridLineWidth
Line width of the grid.
void CAIRO_GAL::drawGridLine ( const VECTOR2D aStartPoint,
const VECTOR2D aEndPoint 
)
overrideprotectedvirtual

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

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

Referenced by SetPaintListener().

942 {
943  cairo_move_to( currentContext, aStartPoint.x, aStartPoint.y );
944  cairo_line_to( currentContext, aEndPoint.x, aEndPoint.y );
945  cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
946  cairo_stroke( currentContext );
947 }
double g
Green component.
Definition: color4d.h:292
double b
Blue component.
Definition: color4d.h:293
double a
Alpha component.
Definition: color4d.h:294
COLOR4D strokeColor
The color of the outlines.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
double r
Red component.
Definition: color4d.h:291
void CAIRO_GAL::DrawGroup ( int  aGroupNumber)
overridevirtual

Draw the stored group.

Parameters
aGroupNumberis the group number.

Reimplemented from KIGFX::GAL.

Definition at line 694 of file cairo_gal.cpp.

References KIGFX::COLOR4D::b, CMD_CALL_GROUP, CMD_FILL_PATH, CMD_RESTORE, CMD_ROTATE, CMD_SAVE, CMD_SCALE, CMD_SET_FILL, CMD_SET_FILLCOLOR, CMD_SET_LINE_WIDTH, CMD_SET_STROKE, CMD_SET_STROKECOLOR, CMD_STROKE_PATH, CMD_TRANSLATE, currentContext, KIGFX::GAL::fillColor, KIGFX::COLOR4D::g, groups, KIGFX::GAL::isFillEnabled, KIGFX::GAL::isStrokeEnabled, max, min, KIGFX::COLOR4D::r, storePath(), and KIGFX::GAL::strokeColor.

Referenced by DrawPolygon().

695 {
696  // This method implements a small Virtual Machine - all stored commands
697  // are executed; nested calling is also possible
698 
699  storePath();
700 
701  for( GROUP::iterator it = groups[aGroupNumber].begin();
702  it != groups[aGroupNumber].end(); ++it )
703  {
704  switch( it->command )
705  {
706  case CMD_SET_FILL:
707  isFillEnabled = it->argument.boolArg;
708  break;
709 
710  case CMD_SET_STROKE:
711  isStrokeEnabled = it->argument.boolArg;
712  break;
713 
714  case CMD_SET_FILLCOLOR:
715  fillColor = COLOR4D( it->argument.dblArg[0], it->argument.dblArg[1], it->argument.dblArg[2],
716  it->argument.dblArg[3] );
717  break;
718 
719  case CMD_SET_STROKECOLOR:
720  strokeColor = COLOR4D( it->argument.dblArg[0], it->argument.dblArg[1], it->argument.dblArg[2],
721  it->argument.dblArg[3] );
722  break;
723 
724  case CMD_SET_LINE_WIDTH:
725  {
726  // Make lines appear at least 1 pixel wide, no matter of zoom
727  double x = 1.0, y = 1.0;
728  cairo_device_to_user_distance( currentContext, &x, &y );
729  double minWidth = std::min( fabs( x ), fabs( y ) );
730  cairo_set_line_width( currentContext, std::max( it->argument.dblArg[0], minWidth ) );
731  }
732  break;
733 
734 
735  case CMD_STROKE_PATH:
736  cairo_set_source_rgb( currentContext, strokeColor.r, strokeColor.g, strokeColor.b );
737  cairo_append_path( currentContext, it->cairoPath );
738  cairo_stroke( currentContext );
739  break;
740 
741  case CMD_FILL_PATH:
742  cairo_set_source_rgb( currentContext, fillColor.r, fillColor.g, fillColor.b );
743  cairo_append_path( currentContext, it->cairoPath );
744  cairo_fill( currentContext );
745  break;
746 
747  /*
748  case CMD_TRANSFORM:
749  cairo_matrix_t matrix;
750  cairo_matrix_init( &matrix, it->argument.dblArg[0], it->argument.dblArg[1], it->argument.dblArg[2],
751  it->argument.dblArg[3], it->argument.dblArg[4], it->argument.dblArg[5] );
752  cairo_transform( currentContext, &matrix );
753  break;
754  */
755 
756  case CMD_ROTATE:
757  cairo_rotate( currentContext, it->argument.dblArg[0] );
758  break;
759 
760  case CMD_TRANSLATE:
761  cairo_translate( currentContext, it->argument.dblArg[0], it->argument.dblArg[1] );
762  break;
763 
764  case CMD_SCALE:
765  cairo_scale( currentContext, it->argument.dblArg[0], it->argument.dblArg[1] );
766  break;
767 
768  case CMD_SAVE:
769  cairo_save( currentContext );
770  break;
771 
772  case CMD_RESTORE:
773  cairo_restore( currentContext );
774  break;
775 
776  case CMD_CALL_GROUP:
777  DrawGroup( it->argument.intArg );
778  break;
779  }
780  }
781 }
Scale the context.
Definition: cairo_gal.h:320
double g
Green component.
Definition: color4d.h:292
COLOR4D fillColor
The fill color.
Set the stroke path.
Definition: cairo_gal.h:315
double b
Blue component.
Definition: color4d.h:293
Translate the context.
Definition: cairo_gal.h:319
bool isStrokeEnabled
Are the outlines stroked ?
Enable/disable stroking.
Definition: cairo_gal.h:311
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:342
COLOR4D strokeColor
The color of the outlines.
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:972
Restore the transformation matrix.
Definition: cairo_gal.h:322
Rotate the context.
Definition: cairo_gal.h:318
bool isFillEnabled
Is filling of graphic objects enabled ?
Enable/disable filling.
Definition: cairo_gal.h:310
#define max(a, b)
Definition: auxiliary.h:86
virtual void DrawGroup(int aGroupNumber) override
Draw the stored group.
Definition: cairo_gal.cpp:694
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
double r
Red component.
Definition: color4d.h:291
Set the fill path.
Definition: cairo_gal.h:316
Save the transformation matrix.
Definition: cairo_gal.h:321
#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::DrawLine ( const VECTOR2D aStartPoint,
const VECTOR2D aEndPoint 
)
overridevirtual

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

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

Referenced by IsVisible().

178 {
179  cairo_move_to( currentContext, aStartPoint.x, aStartPoint.y );
180  cairo_line_to( currentContext, aEndPoint.x, aEndPoint.y );
181  flushPath();
182  isElementAdded = true;
183 }
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:340
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
void CAIRO_GAL::drawPoly ( const std::deque< VECTOR2D > &  aPointList)
private

Drawing polygons & polylines is the same in cairo, so here is the common code.

Definition at line 1146 of file cairo_gal.cpp.

References currentContext, flushPath(), and isElementAdded.

Referenced by DrawPolygon(), and DrawPolyline().

1147 {
1148  // Iterate over the point list and draw the segments
1149  std::deque<VECTOR2D>::const_iterator it = aPointList.begin();
1150 
1151  cairo_move_to( currentContext, it->x, it->y );
1152 
1153  for( ++it; it != aPointList.end(); ++it )
1154  {
1155  cairo_line_to( currentContext, it->x, it->y );
1156  }
1157 
1158  flushPath();
1159  isElementAdded = true;
1160 }
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:340
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
void CAIRO_GAL::drawPoly ( const VECTOR2D  aPointList[],
int  aListSize 
)
private

Definition at line 1163 of file cairo_gal.cpp.

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

1164 {
1165  // Iterate over the point list and draw the segments
1166  const VECTOR2D* ptr = aPointList;
1167 
1168  cairo_move_to( currentContext, ptr->x, ptr->y );
1169 
1170  for( int i = 0; i < aListSize; ++i )
1171  {
1172  ++ptr;
1173  cairo_line_to( currentContext, ptr->x, ptr->y );
1174  }
1175 
1176  flushPath();
1177  isElementAdded = true;
1178 }
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:340
size_t i
Definition: json11.cpp:597
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
void CAIRO_GAL::drawPoly ( const SHAPE_LINE_CHAIN aLineChain)
private

Definition at line 1181 of file cairo_gal.cpp.

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

1182 {
1183  if( aLineChain.PointCount() < 2 )
1184  return;
1185 
1186  auto numPoints = aLineChain.PointCount();
1187 
1188  if( aLineChain.IsClosed() )
1189  numPoints += 1;
1190 
1191  const VECTOR2I start = aLineChain.CPoint( 0 );
1192  cairo_move_to( currentContext, start.x, start.y );
1193 
1194  for( int i = 1; i < numPoints; ++i )
1195  {
1196  const VECTOR2I& p = aLineChain.CPoint( i );
1197  cairo_line_to( currentContext, p.x, p.y );
1198  }
1199 
1200  flushPath();
1201  isElementAdded = true;
1202 }
int PointCount() const
Function PointCount()
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:340
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:348
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
virtual void KIGFX::CAIRO_GAL::DrawPolygon ( const std::deque< VECTOR2D > &  aPointList)
inlineoverridevirtual

Draw a polygon.

Parameters
aPointListis the list of the polygon points.

Reimplemented from KIGFX::GAL.

Definition at line 132 of file cairo_gal.h.

References drawPoly().

Referenced by DrawPolygon().

132 { 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:1146
virtual void KIGFX::CAIRO_GAL::DrawPolygon ( const VECTOR2D  aPointList[],
int  aListSize 
)
inlineoverridevirtual
void CAIRO_GAL::DrawPolygon ( const SHAPE_POLY_SET aPolySet)
overridevirtual

Reimplemented from KIGFX::GAL.

Definition at line 340 of file cairo_gal.cpp.

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

341 {
342  for( int i = 0; i < aPolySet.OutlineCount(); ++i )
343  drawPoly( aPolySet.COutline( i ) );
344 }
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:1146
int OutlineCount() const
Returns the number of outlines in the set
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
size_t i
Definition: json11.cpp:597
virtual void KIGFX::CAIRO_GAL::DrawPolyline ( const std::deque< VECTOR2D > &  aPointList)
inlineoverridevirtual

Draw a polyline.

Parameters
aPointListis a list of 2D-Vectors containing the polyline points.

Reimplemented from KIGFX::GAL.

Definition at line 127 of file cairo_gal.h.

References drawPoly().

127 { 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:1146
virtual void KIGFX::CAIRO_GAL::DrawPolyline ( const VECTOR2D  aPointList[],
int  aListSize 
)
inlineoverridevirtual

Reimplemented from KIGFX::GAL.

Definition at line 128 of file cairo_gal.h.

References drawPoly().

128 { 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:1146
virtual void KIGFX::CAIRO_GAL::DrawPolyline ( const SHAPE_LINE_CHAIN aLineChain)
inlineoverridevirtual

Reimplemented from KIGFX::GAL.

Definition at line 129 of file cairo_gal.h.

References drawPoly().

129 { 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:1146
void CAIRO_GAL::DrawRectangle ( const VECTOR2D aStartPoint,
const VECTOR2D aEndPoint 
)
overridevirtual

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

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

Referenced by IsVisible().

323 {
324  // Calculate the diagonal points
325  VECTOR2D diagonalPointA( aEndPoint.x, aStartPoint.y );
326  VECTOR2D diagonalPointB( aStartPoint.x, aEndPoint.y );
327 
328  // The path is composed from 4 segments
329  cairo_move_to( currentContext, aStartPoint.x, aStartPoint.y );
330  cairo_line_to( currentContext, diagonalPointA.x, diagonalPointA.y );
331  cairo_line_to( currentContext, aEndPoint.x, aEndPoint.y );
332  cairo_line_to( currentContext, diagonalPointB.x, diagonalPointB.y );
333  cairo_close_path( currentContext );
334  flushPath();
335 
336  isElementAdded = true;
337 }
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:340
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
void CAIRO_GAL::DrawSegment ( const VECTOR2D aStartPoint,
const VECTOR2D aEndPoint,
double  aWidth 
)
overridevirtual

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

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

Referenced by IsVisible().

188 {
189  if( isFillEnabled )
190  {
191  // Filled tracks mode
192  SetLineWidth( aWidth );
193 
194  cairo_move_to( currentContext, (double) aStartPoint.x, (double) aStartPoint.y );
195  cairo_line_to( currentContext, (double) aEndPoint.x, (double) aEndPoint.y );
196  cairo_set_source_rgba( currentContext, fillColor.r, fillColor.g, fillColor.b, fillColor.a );
197  cairo_stroke( currentContext );
198  }
199  else
200  {
201  // Outline mode for tracks
202  VECTOR2D startEndVector = aEndPoint - aStartPoint;
203  double lineAngle = atan2( startEndVector.y, startEndVector.x );
204  double lineLength = startEndVector.EuclideanNorm();
205 
206  cairo_save( currentContext );
207 
208  cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
209 
210  cairo_translate( currentContext, aStartPoint.x, aStartPoint.y );
211  cairo_rotate( currentContext, lineAngle );
212 
213  cairo_arc( currentContext, 0.0, 0.0, aWidth / 2.0, M_PI / 2.0, 3.0 * M_PI / 2.0 );
214  cairo_arc( currentContext, lineLength, 0.0, aWidth / 2.0, -M_PI / 2.0, M_PI / 2.0 );
215 
216  cairo_move_to( currentContext, 0.0, aWidth / 2.0 );
217  cairo_line_to( currentContext, lineLength, aWidth / 2.0 );
218 
219  cairo_move_to( currentContext, 0.0, -aWidth / 2.0 );
220  cairo_line_to( currentContext, lineLength, -aWidth / 2.0 );
221 
222  cairo_restore( currentContext );
223  flushPath();
224  }
225 
226  isElementAdded = true;
227 }
double g
Green component.
Definition: color4d.h:292
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:293
double a
Alpha component.
Definition: color4d.h:294
T EuclideanNorm() const
Destructor.
Definition: vector2d.h:292
COLOR4D strokeColor
The color of the outlines.
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:340
virtual void SetLineWidth(double aLineWidth) override
Set the line width.
Definition: cairo_gal.cpp:528
bool isFillEnabled
Is filling of graphic objects enabled ?
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
double r
Red component.
Definition: color4d.h:291
void CAIRO_GAL::EnableDepthTest ( bool  aEnabled = false)
overridevirtual

Reimplemented from KIGFX::GAL.

Definition at line 1216 of file cairo_gal.cpp.

Referenced by SetPaintListener().

1217 {
1218 
1219 }
void CAIRO_GAL::EndDrawing ( )
overridevirtual

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

Reimplemented from KIGFX::GAL.

Definition at line 141 of file cairo_gal.cpp.

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

Referenced by IsVisible().

142 {
143  // Force remaining objects to be drawn
144  Flush();
145 
146  // Merge buffers on the screen
147  compositor->DrawBuffer( mainBuffer );
148  compositor->DrawBuffer( overlayBuffer );
149 
150  // Now translate the raw context data from the format stored
151  // by cairo into a format understood by wxImage.
152  pixman_image_t* dstImg = pixman_image_create_bits(PIXMAN_r8g8b8,
153  screenSize.x, screenSize.y, (uint32_t*)wxOutput, wxBufferWidth * 3 );
154  pixman_image_t* srcImg = pixman_image_create_bits(PIXMAN_a8b8g8r8,
155  screenSize.x, screenSize.y, (uint32_t*)bitmapBuffer, wxBufferWidth * 4 );
156 
157  pixman_image_composite (PIXMAN_OP_SRC, srcImg, NULL, dstImg,
158  0, 0, 0, 0, 0, 0, screenSize.x, screenSize.y );
159 
160  // Free allocated memory
161  pixman_image_unref( srcImg );
162  pixman_image_unref( dstImg );
163 
164  wxImage img( wxBufferWidth, screenSize.y, (unsigned char*) wxOutput, true );
165  wxBitmap bmp( img );
166  wxMemoryDC mdc( bmp );
167  wxClientDC clientDC( this );
168 
169  // Now it is the time to blit the mouse cursor
170  blitCursor( mdc );
171  clientDC.Blit( 0, 0, screenSize.x, screenSize.y, &mdc, 0, 0, wxCOPY );
172 
173  deinitSurface();
174 }
void deinitSurface()
Destroy Cairo surfaces when are not needed anymore.
Definition: cairo_gal.cpp:1119
virtual void Flush() override
Force all remaining objects to be drawn.
Definition: cairo_gal.cpp:447
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:293
unsigned char * wxOutput
wxImage comaptible buffer
Definition: cairo_gal.h:302
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:291
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:351
VECTOR2I screenSize
Screen size in screen coordinates.
virtual void blitCursor(wxMemoryDC &clientDC)
Blits cursor into the current screen.
Definition: cairo_gal.cpp:1034
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:292
void CAIRO_GAL::EndGroup ( )
overridevirtual

End the group.

Reimplemented from KIGFX::GAL.

Definition at line 685 of file cairo_gal.cpp.

References deinitSurface(), isGrouping, and storePath().

Referenced by DrawPolygon().

686 {
687  storePath();
688  isGrouping = false;
689 
690  deinitSurface();
691 }
void deinitSurface()
Destroy Cairo surfaces when are not needed anymore.
Definition: cairo_gal.cpp:1119
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:339
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:972
virtual void KIGFX::GAL::EndUpdate ( )
inlinevirtualinherited
void CAIRO_GAL::Flush ( )
overridevirtual

Force all remaining objects to be drawn.

Reimplemented from KIGFX::GAL.

Definition at line 447 of file cairo_gal.cpp.

References storePath().

Referenced by DrawPolygon(), and EndDrawing().

448 {
449  storePath();
450 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:972
void CAIRO_GAL::flushPath ( )
private

Definition at line 950 of file cairo_gal.cpp.

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

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

951 {
952  if( isFillEnabled )
953  {
954  cairo_set_source_rgba( currentContext,
956 
957  if( isStrokeEnabled )
958  cairo_fill_preserve( currentContext );
959  else
960  cairo_fill( currentContext );
961  }
962 
963  if( isStrokeEnabled )
964  {
965  cairo_set_source_rgba( currentContext,
967  cairo_stroke( currentContext );
968  }
969 }
double g
Green component.
Definition: color4d.h:292
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:293
double a
Alpha component.
Definition: color4d.h:294
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:348
double r
Red component.
Definition: color4d.h:291
const COLOR4D& KIGFX::GAL::GetClearColor ( ) const
inlineinherited

Definition at line 214 of file graphics_abstraction_layer.h.

References KIGFX::GAL::m_clearColor.

215  {
216  return m_clearColor;
217  }
COLOR4D GAL::getCursorColor ( ) const
protectedinherited

Gets the actual cursor color to draw.

Definition at line 421 of file graphics_abstraction_layer.cpp.

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

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

422 {
423  auto color = cursorColor;
424 
425  // dim the cursor if it's only on because it was forced
426  // (this helps to provide a hint for active tools)
427  if( !isCursorEnabled )
428  {
429  color.a = color.a * 0.5;
430  }
431 
432  return color;
433 }
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 264 of file graphics_abstraction_layer.h.

References KIGFX::GAL::fillColor.

Referenced by DrawArc().

265  {
266  return fillColor;
267  }
COLOR4D fillColor
The fill color.
double KIGFX::GAL::GetGridLineWidth ( ) const
inlineinherited

Get the grid line width.

Returns
the grid line width

Definition at line 902 of file graphics_abstraction_layer.h.

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

903  {
904  return gridLineWidth;
905  }
double 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 399 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(), KIGFX::WX_VIEW_CONTROLS::GetRawCursorPosition(), and SCH_BASE_FRAME::HandleBlockBegin().

400 {
401 #if 0
402  // This old code expects a non zero grid size, which can be wrong here.
403  return VECTOR2D( KiROUND( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x,
404  KiROUND( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y );
405 #else
406  // if grid size == 0.0 there is no grid, so use aPoint as grid reference position
407  double cx = gridSize.x > 0.0 ? KiROUND( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x
408  : aPoint.x;
409  double cy = gridSize.y > 0.0 ? KiROUND( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y
410  : aPoint.y;
411 
412  return VECTOR2D( cx, cy );
413 #endif
414 }
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 854 of file graphics_abstraction_layer.h.

References KIGFX::GAL::gridSize.

Referenced by SCH_DRAW_PANEL::SwitchBackend(), and SCH_BASE_FRAME::SyncView().

855  {
856  return gridSize;
857  }
VECTOR2D gridSize
The grid size.
EDA_TEXT_HJUSTIFY_T KIGFX::GAL::GetHorizontalJustify ( ) const
inlineinherited

Returns current text horizontal justification setting.

Definition at line 486 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().

487  {
489  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
EDA_TEXT_HJUSTIFY_T m_horizontalJustify
Horizontal justification.
double 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 681 of file graphics_abstraction_layer.h.

References KIGFX::GAL::lookAtPoint.

682  {
683  return lookAtPoint;
684  }
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 730 of file graphics_abstraction_layer.h.

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

731  {
732  return depthRange.y;
733  }
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 722 of file graphics_abstraction_layer.h.

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

723  {
724  return depthRange.x;
725  }
VECTOR2D depthRange
Range of the depth.
unsigned int CAIRO_GAL::getNewGroupNumber ( )
private

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

References groupCounter, groups, and max.

Referenced by BeginGroup().

1206 {
1207  wxASSERT_MSG( groups.size() < std::numeric_limits<unsigned int>::max(),
1208  wxT( "There are no free slots to store a group" ) );
1209 
1210  while( groups.find( groupCounter ) != groups.end() )
1211  groupCounter++;
1212 
1213  return groupCounter++;
1214 }
unsigned int groupCounter
Counter used for generating keys for groups.
Definition: cairo_gal.h:343
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:342
#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 381 of file graphics_abstraction_layer.h.

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

382  {
384  }
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.
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 622 of file graphics_abstraction_layer.h.

References KIGFX::GAL::screenWorldMatrix.

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

623  {
624  return screenWorldMatrix;
625  }
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 284 of file graphics_abstraction_layer.h.

References KIGFX::GAL::strokeColor.

Referenced by DrawArc().

285  {
286  return strokeColor;
287  }
COLOR4D strokeColor
The color of the outlines.
const STROKE_FONT& KIGFX::GAL::GetStrokeFont ( ) const
inlineinherited

Definition at line 326 of file graphics_abstraction_layer.h.

References KIGFX::GAL::strokeFont.

Referenced by EDA_TEXT::GetTextBox().

327  {
328  return strokeFont;
329  }
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 897 of file cairo_gal.cpp.

References currentTarget.

Referenced by DrawPolygon().

898 {
899  return currentTarget;
900 }
RENDER_TARGET currentTarget
Current rendering target.
Definition: cairo_gal.h:294
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 168 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().

169 {
170  // Compute the X and Y size of a given text.
171  // Because computeTextLineSize expects a one line text,
172  // aText is expected to be only one line text.
173  return strokeFont.computeTextLineSize( aText );
174 }
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 504 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().

505  {
507  }
EDA_TEXT_VJUSTIFY_T m_verticalJustify
Vertical justification.
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
double KIGFX::GAL::GetWorldScale ( ) const
inlineinherited
const MATRIX3x3D& KIGFX::GAL::GetWorldScreenMatrix ( ) const
inlineinherited

Get the world <-> screen transformation matrix.

Returns
the transformation matrix.

Definition at line 612 of file graphics_abstraction_layer.h.

References KIGFX::GAL::worldScreenMatrix.

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

613  {
614  return worldScreenMatrix;
615  }
MATRIX3x3D worldScreenMatrix
World transformation.
double KIGFX::GAL::GetZoomFactor ( ) const
inlineinherited
void CAIRO_GAL::initSurface ( )
private

Prepare Cairo surfaces for drawing.

Definition at line 1075 of file cairo_gal.cpp.

References backgroundColor, bitmapBuffer, cairoWorldScreenMatrix, ClearScreen(), KIGFX::GAL::ComputeWorldScreenMatrix(), context, currentContext, GAL_FORMAT, isElementAdded, isInitialized, KIGFX::GAL::lineWidth, KIGFX::GAL::m_clearColor, MATRIX3x3< T >::m_data, KIGFX::GAL::screenSize, stride, surface, KIGFX::GAL::worldScreenMatrix, wxBufferWidth, and VECTOR2< T >::y.

Referenced by BeginDrawing(), and BeginGroup().

1076 {
1077  if( isInitialized )
1078  return;
1079 
1080  // Create the Cairo surface
1081  surface = cairo_image_surface_create_for_data( (unsigned char*) bitmapBuffer, GAL_FORMAT,
1083  context = cairo_create( surface );
1084 #ifdef __WXDEBUG__
1085  cairo_status_t status = cairo_status( context );
1086  wxASSERT_MSG( status == CAIRO_STATUS_SUCCESS, wxT( "Cairo context creation error" ) );
1087 #endif /* __WXDEBUG__ */
1089 
1090  cairo_set_antialias( context, CAIRO_ANTIALIAS_NONE );
1091 
1093  // Clear the screen
1094  ClearScreen( );
1095 
1096  // Compute the world <-> screen transformations
1098 
1099  cairo_matrix_init( &cairoWorldScreenMatrix, worldScreenMatrix.m_data[0][0],
1102  worldScreenMatrix.m_data[1][2] );
1103 
1104  cairo_set_matrix( context, &cairoWorldScreenMatrix );
1105 
1106  // Start drawing with a new path
1107  cairo_new_path( context );
1108  isElementAdded = true;
1109 
1110  cairo_set_line_join( context, CAIRO_LINE_JOIN_ROUND );
1111  cairo_set_line_cap( context, CAIRO_LINE_CAP_ROUND );
1112 
1113  lineWidth = 0;
1114 
1115  isInitialized = true;
1116 }
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:354
virtual void ComputeWorldScreenMatrix()
Compute the world <-> screen transformation matrix.
T m_data[3][3]
Definition: matrix3x3.h:64
double lineWidth
The line width.
virtual void ClearScreen() override
Clear the screen.
Definition: cairo_gal.cpp:453
cairo_surface_t * surface
Cairo surface.
Definition: cairo_gal.h:350
COLOR4D backgroundColor
Background color.
Definition: cairo_gal.h:355
cairo_t * context
Cairo image.
Definition: cairo_gal.h:349
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:340
MATRIX3x3D worldScreenMatrix
World transformation.
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:351
static const cairo_format_t GAL_FORMAT
Format used to store pixels.
Definition: cairo_gal.h:414
int stride
Stride value for Cairo.
Definition: cairo_gal.h:353
cairo_matrix_t cairoWorldScreenMatrix
Cairo world to screen transformation matrix.
Definition: cairo_gal.h:347
VECTOR2I screenSize
Screen size in screen coordinates.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
bool KIGFX::GAL::IsCursorEnabled ( ) const
inlineinherited

Returns information about cursor visibility.

Returns
True if cursor is visible.

Definition at line 955 of file graphics_abstraction_layer.h.

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

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

956  {
958  }
bool isCursorEnabled
Is the cursor enabled?
bool forceDisplayCursor
Always show cursor.
bool KIGFX::GAL::IsFontBold ( ) const
inlineinherited

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

Definition at line 432 of file graphics_abstraction_layer.h.

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

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

433  {
434  return textProperties.m_bold;
435  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
bool KIGFX::GAL::IsFontItalic ( ) const
inlineinherited

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

Definition at line 450 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().

451  {
452  return textProperties.m_italic;
453  }
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 69 of file graphics_abstraction_layer.h.

Referenced by SCH_DRAW_PANEL::onPaint(), and EDA_DRAW_PANEL_GAL::onRefreshTimer().

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

Returns true if text should displayed mirrored.

Definition at line 468 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().

469  {
470  return textProperties.m_mirrored;
471  }
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 91 of file cairo_gal.h.

References BeginDrawing(), DrawArc(), DrawArcSegment(), DrawCircle(), DrawLine(), DrawRectangle(), DrawSegment(), and EndDrawing().

92  {
93  return IsShownOnScreen() && !GetClientRect().IsEmpty();
94  }
virtual void KIGFX::GAL::lockContext ( )
inlineprotectedvirtualinherited

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1063 of file graphics_abstraction_layer.h.

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

Handler for observer settings changes.

Implements KIGFX::GAL_DISPLAY_OPTIONS_OBSERVER.

Definition at line 88 of file graphics_abstraction_layer.cpp.

References KIGFX::GAL::updatedGalDisplayOptions().

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

Paint event handler.

Parameters
aEventis the paint event.

Definition at line 1020 of file cairo_gal.cpp.

References PostPaint().

Referenced by CAIRO_GAL().

1021 {
1022  PostPaint();
1023 }
void PostPaint()
Function PostPaint posts an event to m_paint_listener.
Definition: cairo_gal.h:262
void KIGFX::GAL::PopDepth ( )
inlineinherited

Restores previously stored drawing depth for the depth stack.

Definition at line 997 of file graphics_abstraction_layer.h.

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

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

998  {
999  layerDepth = depthStack.top();
1000  depthStack.pop();
1001  }
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 262 of file cairo_gal.h.

References paintListener.

Referenced by onPaint().

263  {
264  if( paintListener )
265  {
266  wxPaintEvent redrawEvent;
267  wxPostEvent( paintListener, redrawEvent );
268  }
269  }
wxEvtHandler * paintListener
Paint listener.
Definition: cairo_gal.h:300
void KIGFX::GAL::PushDepth ( )
inlineinherited

Stores current drawing depth on the depth stack.

Definition at line 989 of file graphics_abstraction_layer.h.

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

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

990  {
991  depthStack.push( layerDepth );
992  }
double layerDepth
The actual layer depth.
std::stack< double > depthStack
Stored depth values.
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 153 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().

154 {
155  // Tiny but non-zero - this will always need setting
156  // there is no built-in default
157  SetGlyphSize( { 1.0, 1.0 } );
158 
161 
162  SetFontBold( false );
163  SetFontItalic( false );
164  SetTextMirrored( false );
165 }
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::GAL.

Definition at line 419 of file cairo_gal.cpp.

References allocateBitmaps(), compositor, deleteBitmaps(), KIGFX::GAL::screenSize, and validCompositor.

Referenced by DrawPolygon().

420 {
421  screenSize = VECTOR2I( aWidth, aHeight );
422 
423  // Recreate the bitmaps
424  deleteBitmaps();
425  allocateBitmaps();
426 
427  if( validCompositor )
428  compositor->Resize( aWidth, aHeight );
429 
430  validCompositor = false;
431 
432  SetSize( wxSize( aWidth, aHeight ) );
433 }
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:295
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:291
VECTOR2I screenSize
Screen size in screen coordinates.
void deleteBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1067
void allocateBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:1052
void CAIRO_GAL::Restore ( )
overridevirtual

Restore the context.

Reimplemented from KIGFX::GAL.

Definition at line 650 of file cairo_gal.cpp.

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

Referenced by DrawPolygon().

651 {
652  storePath();
653 
654  if( isGrouping )
655  {
656  GROUP_ELEMENT groupElement;
657  groupElement.command = CMD_RESTORE;
658  currentGroup->push_back( groupElement );
659  }
660  else
661  {
662  cairo_restore( currentContext );
663  }
664 }
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:344
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:339
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:972
Restore the transformation matrix.
Definition: cairo_gal.h:322
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
void CAIRO_GAL::RestoreScreen ( )
overridevirtual

Restore the screen contents.

Reimplemented from KIGFX::GAL.

Definition at line 854 of file cairo_gal.cpp.

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

Referenced by DrawPolygon().

855 {
856  int offset = 0;
857 
858  for( int j = 0; j < screenSize.y; j++ )
859  {
860  for( int i = 0; i < stride; i++ )
861  {
862  bitmapBuffer[offset + i] = bitmapBufferBackup[offset + i];
863  offset += stride;
864  }
865  }
866 }
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:351
int stride
Stride value for Cairo.
Definition: cairo_gal.h:353
unsigned int * bitmapBufferBackup
Backup storage of the cairo image.
Definition: cairo_gal.h:352
size_t i
Definition: json11.cpp:597
VECTOR2I screenSize
Screen size in screen coordinates.
void CAIRO_GAL::Rotate ( double  aAngle)
overridevirtual

Rotate the context.

Parameters
aAngleis the rotation angle in radians.

Reimplemented from KIGFX::GAL.

Definition at line 577 of file cairo_gal.cpp.

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

Referenced by DrawPolygon().

578 {
579  storePath();
580 
581  if( isGrouping )
582  {
583  GROUP_ELEMENT groupElement;
584  groupElement.command = CMD_ROTATE;
585  groupElement.argument.dblArg[0] = aAngle;
586  currentGroup->push_back( groupElement );
587  }
588  else
589  {
590  cairo_rotate( currentContext, aAngle );
591  }
592 }
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:344
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:339
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:972
Rotate the context.
Definition: cairo_gal.h:318
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
void CAIRO_GAL::Save ( )
overridevirtual

Save the context.

Reimplemented from KIGFX::GAL.

Definition at line 633 of file cairo_gal.cpp.

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

Referenced by DrawPolygon().

634 {
635  storePath();
636 
637  if( isGrouping )
638  {
639  GROUP_ELEMENT groupElement;
640  groupElement.command = CMD_SAVE;
641  currentGroup->push_back( groupElement );
642  }
643  else
644  {
645  cairo_save( currentContext );
646  }
647 }
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:344
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:339
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:972
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
Save the transformation matrix.
Definition: cairo_gal.h:321
void CAIRO_GAL::SaveScreen ( )
overridevirtual

Save the screen contents.

Reimplemented from KIGFX::GAL.

Definition at line 838 of file cairo_gal.cpp.

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

Referenced by DrawPolygon().

839 {
840  // Copy the current bitmap to the backup buffer
841  int offset = 0;
842 
843  for( int j = 0; j < screenSize.y; j++ )
844  {
845  for( int i = 0; i < stride; i++ )
846  {
847  bitmapBufferBackup[offset + i] = bitmapBuffer[offset + i];
848  offset += stride;
849  }
850  }
851 }
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:351
int stride
Stride value for Cairo.
Definition: cairo_gal.h:353
unsigned int * bitmapBufferBackup
Backup storage of the cairo image.
Definition: cairo_gal.h:352
size_t i
Definition: json11.cpp:597
VECTOR2I screenSize
Screen size in screen coordinates.
void CAIRO_GAL::Scale ( const VECTOR2D aScale)
overridevirtual

Scale the context.

Parameters
aScaleis the scale factor for the x- and y-axis.

Reimplemented from KIGFX::GAL.

Definition at line 614 of file cairo_gal.cpp.

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

Referenced by DrawPolygon().

615 {
616  storePath();
617 
618  if( isGrouping )
619  {
620  GROUP_ELEMENT groupElement;
621  groupElement.command = CMD_SCALE;
622  groupElement.argument.dblArg[0] = aScale.x;
623  groupElement.argument.dblArg[1] = aScale.y;
624  currentGroup->push_back( groupElement );
625  }
626  else
627  {
628  cairo_scale( currentContext, aScale.x, aScale.y );
629  }
630 }
Scale the context.
Definition: cairo_gal.h:320
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:344
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:339
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:972
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
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 874 of file graphics_abstraction_layer.h.

References KIGFX::GAL::axesColor.

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

875  {
876  axesColor = aAxesColor;
877  }
COLOR4D axesColor
Color of the axes.
void KIGFX::GAL::SetAxesEnabled ( bool  aAxesEnabled)
inlineinherited

Enables drawing the axes.

Definition at line 882 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().

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

Definition at line 209 of file graphics_abstraction_layer.h.

References KIGFX::GAL::m_clearColor.

Referenced by EDA_DRAW_PANEL_GAL::onPaint().

210  {
211  m_clearColor = aColor;
212  }
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 892 of file graphics_abstraction_layer.h.

References KIGFX::GAL::gridTick.

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

893  {
894  gridTick = aInterval;
895  }
int gridTick
Every tick line gets the double width.
void CAIRO_GAL::setCompositor ( )
private

Prepare the compositor.

Definition at line 1132 of file cairo_gal.cpp.

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

Referenced by BeginDrawing().

1133 {
1134  // Recreate the compositor with the new Cairo context
1135  compositor.reset( new CAIRO_COMPOSITOR( &currentContext ) );
1136  compositor->Resize( screenSize.x, screenSize.y );
1137 
1138  // Prepare buffers
1139  mainBuffer = compositor->CreateBuffer();
1140  overlayBuffer = compositor->CreateBuffer();
1141 
1142  validCompositor = true;
1143 }
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:293
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:295
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:291
VECTOR2I screenSize
Screen size in screen coordinates.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:292
void KIGFX::GAL::SetCursorColor ( const COLOR4D aCursorColor)
inlineinherited

Set the cursor color.

Parameters
aCursorColoris the color of the cursor.

Definition at line 965 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().

966  {
967  cursorColor = aCursorColor;
968  }
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 946 of file graphics_abstraction_layer.h.

References KIGFX::GAL::isCursorEnabled.

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

947  {
948  isCursorEnabled = aCursorEnabled;
949  }
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 714 of file graphics_abstraction_layer.h.

References KIGFX::GAL::depthRange.

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

715  {
716  depthRange = aDepthRange;
717  }
VECTOR2D depthRange
Range of the depth.
void CAIRO_GAL::SetFillColor ( const COLOR4D aColor)
overridevirtual

Set the fill color.

Parameters
aColoris the color for filling.

Reimplemented from KIGFX::GAL.

Definition at line 510 of file cairo_gal.cpp.

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

Referenced by DrawPolygon().

511 {
512  storePath();
513  fillColor = aColor;
514 
515  if( isGrouping )
516  {
517  GROUP_ELEMENT groupElement;
518  groupElement.command = CMD_SET_FILLCOLOR;
519  groupElement.argument.dblArg[0] = fillColor.r;
520  groupElement.argument.dblArg[1] = fillColor.g;
521  groupElement.argument.dblArg[2] = fillColor.b;
522  groupElement.argument.dblArg[3] = fillColor.a;
523  currentGroup->push_back( groupElement );
524  }
525 }
double g
Green component.
Definition: color4d.h:292
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:293
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:344
double a
Alpha component.
Definition: color4d.h:294
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:339
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:972
double r
Red component.
Definition: color4d.h:291
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 751 of file graphics_abstraction_layer.h.

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

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

752  {
753  globalFlipX = xAxis;
754  globalFlipY = yAxis;
755  }
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 424 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().

425  {
426  textProperties.m_bold = aBold;
427  }
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 442 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().

443  {
444  textProperties.m_italic = aItalic;
445  }
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 406 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().

407  {
408  textProperties.m_glyphSize = aGlyphSize;
409  }
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 864 of file graphics_abstraction_layer.h.

References KIGFX::GAL::gridColor.

Referenced by CAIRO_GAL(), 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().

865  {
866  gridColor = aGridColor;
867  }
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 825 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().

826  {
827  gridOrigin = aGridOrigin;
828 
829  if( gridSize.x == 0.0 || gridSize.y == 0.0 )
830  gridOffset = VECTOR2D(0.0, 0.0);
831  else
832  gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
833  (long) gridOrigin.y % (long) gridSize.y );
834  }
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 841 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(), SCH_DRAW_PANEL::SwitchBackend(), COMMON_TOOLS::updateGrid(), and PCBNEW_CONTROL::updateGrid().

842  {
843  gridSize = aGridSize;
844 
845  gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
846  (long) gridOrigin.y % (long) gridSize.y );
847  }
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 815 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 SCH_DRAW_PANEL::SwitchBackend().

816  {
817  gridVisibility = aVisibility;
818  }
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 478 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().

479  {
480  textProperties.m_horizontalJustify = aHorizontalJustify;
481  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
EDA_TEXT_HJUSTIFY_T m_horizontalJustify
Horizontal justification.
void CAIRO_GAL::SetIsFill ( bool  aIsFillEnabled)
overridevirtual

Enable/disable fill.

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

Reimplemented from KIGFX::GAL.

Definition at line 462 of file cairo_gal.cpp.

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

Referenced by DrawPolygon().

463 {
464  storePath();
465  isFillEnabled = aIsFillEnabled;
466 
467  if( isGrouping )
468  {
469  GROUP_ELEMENT groupElement;
470  groupElement.command = CMD_SET_FILL;
471  groupElement.argument.boolArg = aIsFillEnabled;
472  currentGroup->push_back( groupElement );
473  }
474 }
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:344
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:339
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:972
bool isFillEnabled
Is filling of graphic objects enabled ?
Enable/disable filling.
Definition: cairo_gal.h:310
void CAIRO_GAL::SetIsStroke ( bool  aIsStrokeEnabled)
overridevirtual

Enable/disable stroked outlines.

Parameters
aIsStrokeEnabledis true, if the outline of an object should be stroked.

Reimplemented from KIGFX::GAL.

Definition at line 477 of file cairo_gal.cpp.

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

Referenced by DrawPolygon().

478 {
479  storePath();
480  isStrokeEnabled = aIsStrokeEnabled;
481 
482  if( isGrouping )
483  {
484  GROUP_ELEMENT groupElement;
485  groupElement.command = CMD_SET_STROKE;
486  groupElement.argument.boolArg = aIsStrokeEnabled;
487  currentGroup->push_back( groupElement );
488  }
489 }
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:344
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:339
bool isStrokeEnabled
Are the outlines stroked ?
Enable/disable stroking.
Definition: cairo_gal.h:311
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:972
void CAIRO_GAL::SetLayerDepth ( double  aLayerDepth)
overridevirtual

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

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

Referenced by DrawPolygon().

553 {
554  super::SetLayerDepth( aLayerDepth );
555 
556  if( isInitialized )
557  storePath();
558 }
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:354
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:972
void CAIRO_GAL::SetLineWidth ( double  aLineWidth)
overridevirtual

Set the line width.

Parameters
aLineWidthis the line width.

Reimplemented from KIGFX::GAL.

Definition at line 528 of file cairo_gal.cpp.

References KIGFX::CAIRO_GAL::GROUP_ELEMENT::argument, CMD_SET_LINE_WIDTH, KIGFX::CAIRO_GAL::GROUP_ELEMENT::command, currentContext, currentGroup, KIGFX::CAIRO_GAL::GROUP_ELEMENT::dblArg, isGrouping, KIGFX::GAL::lineWidth, max, min, and storePath().

Referenced by DrawArc(), DrawArcSegment(), DrawPolygon(), and DrawSegment().

529 {
530  storePath();
531 
532  lineWidth = aLineWidth;
533 
534  if( isGrouping )
535  {
536  GROUP_ELEMENT groupElement;
537  groupElement.command = CMD_SET_LINE_WIDTH;
538  groupElement.argument.dblArg[0] = aLineWidth;
539  currentGroup->push_back( groupElement );
540  }
541  else
542  {
543  // Make lines appear at least 1 pixel wide, no matter of zoom
544  double x = 1.0, y = 1.0;
545  cairo_device_to_user_distance( currentContext, &x, &y );
546  double minWidth = std::min( fabs( x ), fabs( y ) );
547  cairo_set_line_width( currentContext, std::max( aLineWidth, minWidth ) );
548  }
549 }
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:344
double lineWidth
The line width.
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:339
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:972
#define max(a, b)
Definition: auxiliary.h:86
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
#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 671 of file graphics_abstraction_layer.h.

References KIGFX::GAL::lookAtPoint.

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

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

Definition at line 271 of file cairo_gal.h.

References mouseListener.

272  {
273  mouseListener = aMouseListener;
274  }
wxEvtHandler * mouseListener
Mouse listener.
Definition: cairo_gal.h:299
void CAIRO_GAL::SetNegativeDrawMode ( bool  aSetting)
overridevirtual

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

References currentContext.

Referenced by DrawPolygon().

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

Definition at line 276 of file cairo_gal.h.

References drawGridLine(), EnableDepthTest(), and paintListener.

277  {
278  paintListener = aPaintListener;
279  }
wxEvtHandler * paintListener
Paint listener.
Definition: cairo_gal.h:300
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 659 of file graphics_abstraction_layer.h.

References KIGFX::GAL::screenDPI.

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

660  {
661  screenDPI = aScreenDPI;
662  }
double screenDPI
The dots per inch of the screen.
void CAIRO_GAL::SetStrokeColor ( const COLOR4D aColor)
overridevirtual

Set the stroke color.

Parameters
aColoris the color for stroking the outline.

Reimplemented from KIGFX::GAL.

Definition at line 492 of file cairo_gal.cpp.

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

Referenced by DrawArc(), and DrawPolygon().

493 {
494  storePath();
495  strokeColor = aColor;
496 
497  if( isGrouping )
498  {
499  GROUP_ELEMENT groupElement;
500  groupElement.command = CMD_SET_STROKECOLOR;
501  groupElement.argument.dblArg[0] = strokeColor.r;
502  groupElement.argument.dblArg[1] = strokeColor.g;
503  groupElement.argument.dblArg[2] = strokeColor.b;
504  groupElement.argument.dblArg[3] = strokeColor.a;
505  currentGroup->push_back( groupElement );
506  }
507 }
double g
Green component.
Definition: color4d.h:292
double b
Blue component.
Definition: color4d.h:293
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:344
double a
Alpha component.
Definition: color4d.h:294
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:339
COLOR4D strokeColor
The color of the outlines.
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:972
double r
Red component.
Definition: color4d.h:291
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 869 of file cairo_gal.cpp.

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

Referenced by CAIRO_GAL(), and DrawPolygon().

870 {
871  // If the compositor is not set, that means that there is a recaching process going on
872  // and we do not need the compositor now
873  if( !validCompositor )
874  return;
875 
876  // Cairo grouping prevents display of overlapping items on the same layer in the lighter color
877  if( isInitialized )
878  storePath();
879 
880  switch( aTarget )
881  {
882  default:
883  case TARGET_CACHED:
884  case TARGET_NONCACHED:
885  compositor->SetBuffer( mainBuffer );
886  break;
887 
888  case TARGET_OVERLAY:
889  compositor->SetBuffer( overlayBuffer );
890  break;
891  }
892 
893  currentTarget = aTarget;
894 }
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:354
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:293
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:295
Auxiliary rendering target (noncached)
Definition: definitions.h:42
RENDER_TARGET currentTarget
Current rendering target.
Definition: cairo_gal.h:294
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:291
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:972
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:292
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 142 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().

143 {
144  SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
147  SetFontBold( aText->IsBold() );
148  SetFontItalic( aText->IsItalic() );
149  SetTextMirrored( aText->IsMirrored() );
150 }
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 460 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().

461  {
462  textProperties.m_mirrored = aMirrored;
463  }
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 496 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().

497  {
498  textProperties.m_verticalJustify = aVerticalJustify;
499  }
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 632 of file graphics_abstraction_layer.h.

References KIGFX::GAL::worldScreenMatrix.

633  {
634  worldScreenMatrix = aMatrix;
635  }
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 646 of file graphics_abstraction_layer.h.

References KIGFX::GAL::worldUnitLength.

Referenced by KIGFX::GAL::GAL(), SCH_DRAW_PANEL::SCH_DRAW_PANEL(), SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL(), SCH_DRAW_PANEL::SwitchBackend(), and PCB_DRAW_PANEL_GAL::SwitchBackend().

647  {
648  worldUnitLength = aWorldUnitLength;
649  }
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 691 of file graphics_abstraction_layer.h.

References KIGFX::GAL::zoomFactor.

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

692  {
693  zoomFactor = aZoomFactor;
694  }
double zoomFactor
The zoom factor.
bool CAIRO_GAL::Show ( bool  aShow)
overridevirtual

Shows/hides the GAL canvas.

Reimplemented from KIGFX::GAL.

Definition at line 436 of file cairo_gal.cpp.

Referenced by DrawPolygon().

437 {
438  bool s = wxWindow::Show( aShow );
439 
440  if( aShow )
441  wxWindow::Raise();
442 
443  return s;
444 }
void CAIRO_GAL::skipMouseEvent ( wxMouseEvent &  aEvent)
private

Mouse event handler, forwards the event to the child.

Parameters
aEventis the mouse event to be forwarded.

Definition at line 1026 of file cairo_gal.cpp.

References mouseListener.

Referenced by CAIRO_GAL().

1027 {
1028  // Post the mouse event to the event listener registered in constructor, if any
1029  if( mouseListener )
1030  wxPostEvent( mouseListener, aEvent );
1031 }
wxEvtHandler * mouseListener
Mouse listener.
Definition: cairo_gal.h:299
void CAIRO_GAL::storePath ( )
private

Store the actual path.

Definition at line 972 of file cairo_gal.cpp.

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

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

973 {
974  if( isElementAdded )
975  {
976  isElementAdded = false;
977 
978  if( !isGrouping )
979  {
980  if( isFillEnabled )
981  {
982  cairo_set_source_rgb( currentContext, fillColor.r, fillColor.g, fillColor.b );
983  cairo_fill_preserve( currentContext );
984  }
985 
986  if( isStrokeEnabled )
987  {
988  cairo_set_source_rgb( currentContext, strokeColor.r, strokeColor.g,
989  strokeColor.b );
990  cairo_stroke_preserve( currentContext );
991  }
992  }
993  else
994  {
995  // Copy the actual path, append it to the global path list
996  // then check, if the path needs to be stroked/filled and
997  // add this command to the group list;
998  if( isStrokeEnabled )
999  {
1000  GROUP_ELEMENT groupElement;
1001  groupElement.cairoPath = cairo_copy_path( currentContext );
1002  groupElement.command = CMD_STROKE_PATH;
1003  currentGroup->push_back( groupElement );
1004  }
1005 
1006  if( isFillEnabled )
1007  {
1008  GROUP_ELEMENT groupElement;
1009  groupElement.cairoPath = cairo_copy_path( currentContext );
1010  groupElement.command = CMD_FILL_PATH;
1011  currentGroup->push_back( groupElement );
1012  }
1013  }
1014 
1015  cairo_new_path( currentContext );
1016  }
1017 }
double g
Green component.
Definition: color4d.h:292
COLOR4D fillColor
The fill color.
Set the stroke path.
Definition: cairo_gal.h:315
double b
Blue component.
Definition: color4d.h:293
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:344
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:339
bool isStrokeEnabled
Are the outlines stroked ?
COLOR4D strokeColor
The color of the outlines.
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:340
bool isFillEnabled
Is filling of graphic objects enabled ?
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
double r
Red component.
Definition: color4d.h:291
Set the fill path.
Definition: cairo_gal.h:316
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 338 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().

340  {
341  strokeFont.Draw( aText, aPosition, aRotationAngle );
342  }
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 936 of file graphics_abstraction_layer.h.

References KIGFX::GAL::worldScreenMatrix.

Referenced by blitCursor().

937  {
938  return VECTOR2D( worldScreenMatrix * aPoint );
939  }
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 925 of file graphics_abstraction_layer.h.

References KIGFX::GAL::screenWorldMatrix.

926  {
927  return VECTOR2D( screenWorldMatrix * aPoint );
928  }
MATRIX3x3D screenWorldMatrix
Screen transformation.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
void CAIRO_GAL::Transform ( const MATRIX3x3D aTransformation)
overridevirtual

Transform the context.

Parameters
aTransformationis the ransformation matrix.

Reimplemented from KIGFX::GAL.

Definition at line 561 of file cairo_gal.cpp.

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

Referenced by DrawPolygon().

562 {
563  cairo_matrix_t cairoTransformation;
564 
565  cairo_matrix_init( &cairoTransformation,
566  aTransformation.m_data[0][0],
567  aTransformation.m_data[1][0],
568  aTransformation.m_data[0][1],
569  aTransformation.m_data[1][1],
570  aTransformation.m_data[0][2],
571  aTransformation.m_data[1][2] );
572 
573  cairo_transform( currentContext, &cairoTransformation );
574 }
T m_data[3][3]
Definition: matrix3x3.h:64
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
void CAIRO_GAL::Translate ( const VECTOR2D aTranslation)
overridevirtual

Translate the context.

Parameters
aTranslationis the translation vector.

Reimplemented from KIGFX::GAL.

Definition at line 595 of file cairo_gal.cpp.

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

Referenced by DrawPolygon().

596 {
597  storePath();
598 
599  if( isGrouping )
600  {
601  GROUP_ELEMENT groupElement;
602  groupElement.command = CMD_TRANSLATE;
603  groupElement.argument.dblArg[0] = aTranslation.x;
604  groupElement.argument.dblArg[1] = aTranslation.y;
605  currentGroup->push_back( groupElement );
606  }
607  else
608  {
609  cairo_translate( currentContext, aTranslation.x, aTranslation.y );
610  }
611 }
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:344
Translate the context.
Definition: cairo_gal.h:319
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:339
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:972
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:348
virtual void KIGFX::GAL::unlockContext ( )
inlineprotectedvirtualinherited

Reimplemented in KIGFX::OPENGL_GAL.

Definition at line 1065 of file graphics_abstraction_layer.h.

1065 {}
bool CAIRO_GAL::updatedGalDisplayOptions ( const GAL_DISPLAY_OPTIONS aOptions)
overrideprivatevirtual

Cairo-specific update handlers

Reimplemented from KIGFX::GAL.

Definition at line 115 of file cairo_gal.cpp.

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

116 {
117  bool refresh = false;
118 
119  if( super::updatedGalDisplayOptions( aOptions ) )
120  {
121  Refresh();
122  refresh = true;
123  }
124 
125  return refresh;
126 }
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 1046 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
private

Background color.

Definition at line 355 of file cairo_gal.h.

Referenced by ClearScreen(), and initSurface().

unsigned int* KIGFX::CAIRO_GAL::bitmapBuffer
private

Storage of the cairo image.

Definition at line 351 of file cairo_gal.h.

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

unsigned int* KIGFX::CAIRO_GAL::bitmapBufferBackup
private

Backup storage of the cairo image.

Definition at line 352 of file cairo_gal.h.

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

unsigned int KIGFX::CAIRO_GAL::bufferSize
private

Size of buffers cairoOutput, bitmapBuffers.

Definition at line 301 of file cairo_gal.h.

Referenced by allocateBitmaps().

cairo_matrix_t KIGFX::CAIRO_GAL::cairoWorldScreenMatrix
private

Cairo world to screen transformation matrix.

Definition at line 347 of file cairo_gal.h.

Referenced by CAIRO_GAL(), and initSurface().

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

Object for layers compositing.

Definition at line 291 of file cairo_gal.h.

Referenced by BeginDrawing(), ClearTarget(), EndDrawing(), ResizeScreen(), setCompositor(), and SetTarget().

cairo_t* KIGFX::CAIRO_GAL::context
private

Cairo image.

Definition at line 349 of file cairo_gal.h.

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

GROUP* KIGFX::CAIRO_GAL::currentGroup
private
RENDER_TARGET KIGFX::CAIRO_GAL::currentTarget
private

Current rendering target.

Definition at line 294 of file cairo_gal.h.

Referenced by GetTarget(), and SetTarget().

COLOR4D KIGFX::GAL::cursorColor
protectedinherited

Cursor color.

Definition at line 1056 of file graphics_abstraction_layer.h.

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

VECTOR2D KIGFX::GAL::cursorPosition
protectedinherited

Current cursor position (world coordinates)

Definition at line 1058 of file graphics_abstraction_layer.h.

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

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

Stored depth values.

Definition at line 1012 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 1057 of file graphics_abstraction_layer.h.

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

const cairo_format_t KIGFX::CAIRO_GAL::GAL_FORMAT = CAIRO_FORMAT_RGB24
staticprivate

Format used to store pixels.

Definition at line 414 of file cairo_gal.h.

Referenced by allocateBitmaps(), and initSurface().

bool KIGFX::GAL::globalFlipX
protectedinherited
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 1093 of file graphics_abstraction_layer.h.

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

COLOR4D KIGFX::GAL::gridColor
protectedinherited

Color of the grid.

Definition at line 1045 of file graphics_abstraction_layer.h.

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

double 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 1050 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 1044 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 1048 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 1040 of file graphics_abstraction_layer.h.

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

unsigned int KIGFX::CAIRO_GAL::groupCounter
private

Counter used for generating keys for groups.

Definition at line 343 of file cairo_gal.h.

Referenced by CAIRO_GAL(), and getNewGroupNumber().

std::map<int, GROUP> KIGFX::CAIRO_GAL::groups
private

List of graphic groups.

Definition at line 342 of file cairo_gal.h.

Referenced by BeginGroup(), ChangeGroupColor(), ClearCache(), DeleteGroup(), DrawGroup(), and getNewGroupNumber().

bool KIGFX::GAL::isCursorEnabled
protectedinherited
bool KIGFX::CAIRO_GAL::isElementAdded
private
bool KIGFX::CAIRO_GAL::isGrouping
private
bool KIGFX::CAIRO_GAL::isInitialized
private

Are Cairo image & surface ready to use.

Definition at line 354 of file cairo_gal.h.

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

const float KIGFX::CAIRO_GAL::LAYER_ALPHA
staticprivate

Opacity of a single layer

Definition at line 417 of file cairo_gal.h.

VECTOR2D KIGFX::GAL::lookAtPoint
protectedinherited

Point to be looked at in world space.

Definition at line 1017 of file graphics_abstraction_layer.h.

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

COLOR4D KIGFX::GAL::m_clearColor
protectedinherited
unsigned int KIGFX::CAIRO_GAL::mainBuffer
private

Handle to the main buffer.

Definition at line 292 of file cairo_gal.h.

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

const int KIGFX::CAIRO_GAL::MAX_CAIRO_ARGUMENTS = 4
staticprivate

Maximum number of arguments for one command.

Definition at line 305 of file cairo_gal.h.

const int GAL::MAX_DEPTH = 1023
staticprotectedinherited

Definition at line 1090 of file graphics_abstraction_layer.h.

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

const double GAL::METRIC_UNIT_LENGTH = 1e9
staticinherited

Definition at line 1003 of file graphics_abstraction_layer.h.

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

const int GAL::MIN_DEPTH = -1024
staticprotectedinherited

Possible depth range.

Definition at line 1086 of file graphics_abstraction_layer.h.

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

wxEvtHandler* KIGFX::CAIRO_GAL::mouseListener
private

Mouse listener.

Definition at line 299 of file cairo_gal.h.

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

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

Definition at line 1010 of file graphics_abstraction_layer.h.

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

unsigned int KIGFX::CAIRO_GAL::overlayBuffer
private

Handle to the overlay buffer.

Definition at line 293 of file cairo_gal.h.

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

wxEvtHandler* KIGFX::CAIRO_GAL::paintListener
private

Paint listener.

Definition at line 300 of file cairo_gal.h.

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

wxWindow* KIGFX::CAIRO_GAL::parentWindow
private

Parent window.

Definition at line 298 of file cairo_gal.h.

Referenced by CAIRO_GAL().

double KIGFX::GAL::screenDPI
protectedinherited

The dots per inch of the screen.

Definition at line 1016 of file graphics_abstraction_layer.h.

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

MATRIX3x3D KIGFX::GAL::screenWorldMatrix
protectedinherited
int KIGFX::CAIRO_GAL::stride
private

Stride value for Cairo.

Definition at line 353 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 1061 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::surface
private

Cairo surface.

Definition at line 350 of file cairo_gal.h.

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

bool KIGFX::CAIRO_GAL::validCompositor
private

Compositor initialization flag.

Definition at line 295 of file cairo_gal.h.

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

double KIGFX::GAL::worldScale
protectedinherited
double KIGFX::GAL::worldUnitLength
protectedinherited

The unit length of the world coordinates [inch].

Definition at line 1015 of file graphics_abstraction_layer.h.

Referenced by DrawBitmap(), KIGFX::OPENGL_GAL::DrawBitmap(), and KIGFX::GAL::SetWorldUnitLength().

int KIGFX::CAIRO_GAL::wxBufferWidth
private

Definition at line 357 of file cairo_gal.h.

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

unsigned char* KIGFX::CAIRO_GAL::wxOutput
private

wxImage comaptible buffer

Definition at line 302 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: