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 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 (const COLOR4D &aColor) 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 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 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...
 
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...
 
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...
 
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 332 of file cairo_gal.h.

typedef GAL KIGFX::CAIRO_GAL::super
private

Super class definition.

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

300  {
301  CMD_SET_FILL,
307  CMD_FILL_PATH,
308  //CMD_TRANSFORM, ///< Transform the actual context
309  CMD_ROTATE,
310  CMD_TRANSLATE,
311  CMD_SCALE,
312  CMD_SAVE,
313  CMD_RESTORE,
315  };
Scale the context.
Definition: cairo_gal.h:311
Set the stroke path.
Definition: cairo_gal.h:306
Translate the context.
Definition: cairo_gal.h:310
Enable/disable stroking.
Definition: cairo_gal.h:302
Restore the transformation matrix.
Definition: cairo_gal.h:313
Rotate the context.
Definition: cairo_gal.h:309
Enable/disable filling.
Definition: cairo_gal.h:301
Set the fill path.
Definition: cairo_gal.h:307
Save the transformation matrix.
Definition: cairo_gal.h:312

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

47  :
48  GAL( aDisplayOptions ),
49  wxWindow( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxEXPAND, aName )
50 {
51  parentWindow = aParent;
52  mouseListener = aMouseListener;
53  paintListener = aPaintListener;
54 
55  // Initialise grouping
56  isGrouping = false;
57  isElementAdded = false;
58  groupCounter = 0;
59  currentGroup = nullptr;
60 
61  // Initialise compositing state
62  mainBuffer = 0;
63  overlayBuffer = 0;
64  validCompositor = false;
66 
67  // Initialise Cairo state
68  cairo_matrix_init_identity( &cairoWorldScreenMatrix );
69  currentContext = nullptr;
70  context = nullptr;
71  surface = nullptr;
72  isInitialized = false;
73 
74  // Connecting the event handlers
75  Connect( wxEVT_PAINT, wxPaintEventHandler( CAIRO_GAL::onPaint ) );
76 
77  // Mouse events are skipped to the parent
78  Connect( wxEVT_MOTION, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
79  Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
80  Connect( wxEVT_LEFT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
81  Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
82  Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
83  Connect( wxEVT_MIDDLE_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
84  Connect( wxEVT_MIDDLE_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
85  Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
86  Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
87  Connect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
88  Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
89 #if defined _WIN32 || defined _WIN64
90  Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
91 #endif
92 
93  SetSize( aParent->GetSize() );
94  screenSize = VECTOR2I( aParent->GetSize() );
95 
96  // Grid color settings are different in Cairo and OpenGL
97  SetGridColor( COLOR4D( 0.1, 0.1, 0.1, 0.8 ) );
99 
100  // Allocate memory for pixel storage
101  allocateBitmaps();
102 }
unsigned int groupCounter
Counter used for generating keys for groups.
Definition: cairo_gal.h:334
Definition: colors.h:57
void onPaint(wxPaintEvent &aEvent)
Paint event handler.
Definition: cairo_gal.cpp:945
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:345
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:284
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:286
Auxiliary rendering target (noncached)
Definition: definitions.h:42
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:335
GAL(GAL_DISPLAY_OPTIONS &aOptions)
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:330
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
cairo_surface_t * surface
Cairo surface.
Definition: cairo_gal.h:341
cairo_t * context
Cairo image.
Definition: cairo_gal.h:340
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:331
wxEvtHandler * paintListener
Paint listener.
Definition: cairo_gal.h:291
virtual void SetTarget(RENDER_TARGET aTarget) override
Sets the target for rendering.
Definition: cairo_gal.cpp:800
void skipMouseEvent(wxMouseEvent &aEvent)
Mouse event handler, forwards the event to the child.
Definition: cairo_gal.cpp:951
cairo_matrix_t cairoWorldScreenMatrix
Cairo world to screen transformation matrix.
Definition: cairo_gal.h:338
VECTOR2I screenSize
Screen size in screen coordinates.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
wxEvtHandler * mouseListener
Mouse listener.
Definition: cairo_gal.h:290
void allocateBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:977
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:283
wxWindow * parentWindow
Parent window.
Definition: cairo_gal.h:289
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 105 of file cairo_gal.cpp.

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

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

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

References KIGFX::GAL::layerDepth.

941  {
942  layerDepth -= 0.05;
943  }
double layerDepth
The actual layer depth.
void CAIRO_GAL::allocateBitmaps ( )
private

Allocate the bitmaps for drawing.

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

978 {
980  while( ( ( wxBufferWidth * 3 ) % 4 ) != 0 ) wxBufferWidth++;
981 
982  // Create buffer, use the system independent Cairo context backend
983  stride = cairo_format_stride_for_width( GAL_FORMAT, wxBufferWidth );
985 
986  bitmapBuffer = new unsigned int[bufferSize];
987  bitmapBufferBackup = new unsigned int[bufferSize];
988  wxOutput = new unsigned char[wxBufferWidth * 3 * screenSize.y];
989 }
unsigned char * wxOutput
wxImage comaptible buffer
Definition: cairo_gal.h:293
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:342
static const cairo_format_t GAL_FORMAT
Format used to store pixels.
Definition: cairo_gal.h:405
int stride
Stride value for Cairo.
Definition: cairo_gal.h:344
unsigned int * bitmapBufferBackup
Backup storage of the cairo image.
Definition: cairo_gal.h:343
VECTOR2I screenSize
Screen size in screen coordinates.
unsigned int bufferSize
Size of buffers cairoOutput, bitmapBuffers.
Definition: cairo_gal.h:292
void CAIRO_GAL::BeginDrawing ( )
overridevirtual

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

Reimplemented from KIGFX::GAL.

Definition at line 128 of file cairo_gal.cpp.

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

129 {
130  initSurface();
131 
132  if( !validCompositor )
133  setCompositor();
134 
135  compositor->SetMainContext( context );
136  compositor->SetBuffer( mainBuffer );
137 }
void initSurface()
Prepare Cairo surfaces for drawing.
Definition: cairo_gal.cpp:1000
void setCompositor()
Prepare the compositor.
Definition: cairo_gal.cpp:1056
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:286
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:282
cairo_t * context
Cairo image.
Definition: cairo_gal.h:340
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:283
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 598 of file cairo_gal.cpp.

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

599 {
600  initSurface();
601 
602  // If the grouping is started: the actual path is stored in the group, when
603  // a attribute was changed or when grouping stops with the end group method.
604  storePath();
605 
606  GROUP group;
607  int groupNumber = getNewGroupNumber();
608  groups.insert( std::make_pair( groupNumber, group ) );
609  currentGroup = &groups[groupNumber];
610  isGrouping = true;
611 
612  return groupNumber;
613 }
void initSurface()
Prepare Cairo surfaces for drawing.
Definition: cairo_gal.cpp:1000
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:335
unsigned int getNewGroupNumber()
Returns a valid key that can be used as a new group number.
Definition: cairo_gal.cpp:1129
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:330
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:333
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:897
std::deque< GROUP_ELEMENT > GROUP
A graphic group type definition.
Definition: cairo_gal.h:332
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 324 of file graphics_abstraction_layer.h.

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

Referenced by KIGFX::PCB_PAINTER::draw(), KIGFX::PREVIEW::DrawTextNextToCursor(), and drawTicksAlongLine().

326  {
327  // Fallback: use stroke font
328 
329  // Handle flipped view
330  if( globalFlipX )
332 
333  StrokeText( aText, aPosition, aRotationAngle );
334 
335  if( globalFlipX )
337  }
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 959 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().

960 {
961  if( !IsCursorEnabled() )
962  return;
963 
964  auto p = ToScreen( cursorPosition );
965 
966  const auto cColor = getCursorColor();
967  const int cursorSize = fullscreenCursor ? 8000 : 80;
968 
969  wxColour color( cColor.r * cColor.a * 255, cColor.g * cColor.a * 255,
970  cColor.b * cColor.a * 255, 255 );
971  clientDC.SetPen( wxPen( color ) );
972  clientDC.DrawLine( p.x - cursorSize / 2, p.y, p.x + cursorSize / 2, p.y );
973  clientDC.DrawLine( p.x, p.y - cursorSize / 2, p.x, p.y + cursorSize / 2 );
974 }
bool IsCursorEnabled() const
Returns information about cursor visibility.
VECTOR2D cursorPosition
Current cursor position (world coordinates)
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 715 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().

716 {
717  storePath();
718 
719  for( GROUP::iterator it = groups[aGroupNumber].begin();
720  it != groups[aGroupNumber].end(); ++it )
721  {
722  if( it->command == CMD_SET_FILLCOLOR || it->command == CMD_SET_STROKECOLOR )
723  {
724  it->argument.dblArg[0] = aNewColor.r;
725  it->argument.dblArg[1] = aNewColor.g;
726  it->argument.dblArg[2] = aNewColor.b;
727  it->argument.dblArg[3] = aNewColor.a;
728  }
729  }
730 }
double g
Green component.
Definition: color4d.h:287
double b
Blue component.
Definition: color4d.h:288
double a
Alpha component.
Definition: color4d.h:289
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:333
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:897
double r
Red component.
Definition: color4d.h:286
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 733 of file cairo_gal.cpp.

734 {
735  // Cairo does not have any possibilities to change the depth coordinate of stored items,
736  // it depends only on the order of drawing
737 }
void CAIRO_GAL::ClearCache ( )
overridevirtual

Delete all data created during caching of graphic items.

Reimplemented from KIGFX::GAL.

Definition at line 760 of file cairo_gal.cpp.

References DeleteGroup(), and groups.

Referenced by ~CAIRO_GAL().

761 {
762  for( int i = groups.size() - 1; i >= 0; --i )
763  {
764  DeleteGroup( i );
765  }
766 }
virtual void DeleteGroup(int aGroupNumber) override
Delete the group from the memory.
Definition: cairo_gal.cpp:740
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:333
void CAIRO_GAL::ClearScreen ( const COLOR4D aColor)
overridevirtual

Clear the screen.

Parameters
aColoris the color used for clearing.

Reimplemented from KIGFX::GAL.

Definition at line 384 of file cairo_gal.cpp.

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

Referenced by initSurface().

385 {
386  backgroundColor = aColor;
387  cairo_set_source_rgb( currentContext, aColor.r, aColor.g, aColor.b );
388  cairo_rectangle( currentContext, 0.0, 0.0, screenSize.x, screenSize.y );
389  cairo_fill( currentContext );
390 }
double g
Green component.
Definition: color4d.h:287
double b
Blue component.
Definition: color4d.h:288
COLOR4D backgroundColor
Background color.
Definition: cairo_gal.h:346
VECTOR2I screenSize
Screen size in screen coordinates.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
double r
Red component.
Definition: color4d.h:286
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 834 of file cairo_gal.cpp.

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

835 {
836  // Save the current state
837  unsigned int currentBuffer = compositor->GetBuffer();
838 
839  switch( aTarget )
840  {
841  // Cached and noncached items are rendered to the same buffer
842  default:
843  case TARGET_CACHED:
844  case TARGET_NONCACHED:
845  compositor->SetBuffer( mainBuffer );
846  break;
847 
848  case TARGET_OVERLAY:
849  compositor->SetBuffer( overlayBuffer );
850  break;
851  }
852 
853  compositor->ClearBuffer();
854 
855  // Restore the previous state
856  compositor->SetBuffer( currentBuffer );
857 }
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:284
Auxiliary rendering target (noncached)
Definition: definitions.h:42
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:282
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:283
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::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 1020 of file graphics_abstraction_layer.h.

References KIGFX::GAL::zoomFactor.

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

1021  {
1023  }
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(), 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:589
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 1043 of file cairo_gal.cpp.

References context, isInitialized, and surface.

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

1044 {
1045  if( !isInitialized )
1046  return;
1047 
1048  // Destroy Cairo objects
1049  cairo_destroy( context );
1050  cairo_surface_destroy( surface );
1051 
1052  isInitialized = false;
1053 }
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:345
cairo_surface_t * surface
Cairo surface.
Definition: cairo_gal.h:341
cairo_t * context
Cairo image.
Definition: cairo_gal.h:340
void CAIRO_GAL::deleteBitmaps ( )
private

Allocate the bitmaps for drawing.

Definition at line 992 of file cairo_gal.cpp.

References bitmapBuffer, bitmapBufferBackup, and wxOutput.

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

993 {
994  delete[] bitmapBuffer;
995  delete[] bitmapBufferBackup;
996  delete[] wxOutput;
997 }
unsigned char * wxOutput
wxImage comaptible buffer
Definition: cairo_gal.h:293
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:342
unsigned int * bitmapBufferBackup
Backup storage of the cairo image.
Definition: cairo_gal.h:343
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 740 of file cairo_gal.cpp.

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

Referenced by ClearCache().

741 {
742  storePath();
743 
744  // Delete the Cairo paths
745  std::deque<GROUP_ELEMENT>::iterator it, end;
746 
747  for( it = groups[aGroupNumber].begin(), end = groups[aGroupNumber].end(); it != end; ++it )
748  {
749  if( it->command == CMD_FILL_PATH || it->command == CMD_STROKE_PATH )
750  {
751  cairo_path_destroy( it->cairoPath );
752  }
753  }
754 
755  // Delete the group
756  groups.erase( aGroupNumber );
757 }
Set the stroke path.
Definition: cairo_gal.h:306
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:333
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:897
Set the fill path.
Definition: cairo_gal.h:307
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 238 of file cairo_gal.cpp.

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

240 {
241  SWAP( aStartAngle, >, aEndAngle );
242 
243  cairo_new_sub_path( currentContext );
244  cairo_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, aStartAngle, aEndAngle );
245 
246  if( isFillEnabled )
247  {
248  VECTOR2D startPoint( cos( aStartAngle ) * aRadius + aCenterPoint.x,
249  sin( aStartAngle ) * aRadius + aCenterPoint.y );
250  VECTOR2D endPoint( cos( aEndAngle ) * aRadius + aCenterPoint.x,
251  sin( aEndAngle ) * aRadius + aCenterPoint.y );
252 
253  cairo_move_to( currentContext, aCenterPoint.x, aCenterPoint.y );
254  cairo_line_to( currentContext, startPoint.x, startPoint.y );
255  cairo_line_to( currentContext, endPoint.x, endPoint.y );
256  cairo_close_path( currentContext );
257  }
258 
259  flushPath();
260 
261  isElementAdded = true;
262 }
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:331
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:339
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 265 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.

267 {
268  SWAP( aStartAngle, >, aEndAngle );
269 
270  if( isFillEnabled )
271  {
272  // Filled segments mode
273  SetLineWidth( aWidth );
274  cairo_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, aStartAngle, aEndAngle );
275  cairo_set_source_rgba( currentContext, fillColor.r, fillColor.g, fillColor.b, fillColor.a );
276  cairo_stroke( currentContext );
277  }
278  else
279  {
280  double width = aWidth / 2.0;
281  VECTOR2D startPoint( cos( aStartAngle ) * aRadius,
282  sin( aStartAngle ) * aRadius );
283  VECTOR2D endPoint( cos( aEndAngle ) * aRadius,
284  sin( aEndAngle ) * aRadius );
285 
286  cairo_save( currentContext );
287 
288  cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
289 
290  cairo_translate( currentContext, aCenterPoint.x, aCenterPoint.y );
291 
292  cairo_new_sub_path( currentContext );
293  cairo_arc( currentContext, 0, 0, aRadius - width, aStartAngle, aEndAngle );
294 
295  cairo_new_sub_path( currentContext );
296  cairo_arc( currentContext, 0, 0, aRadius + width, aStartAngle, aEndAngle );
297 
298  cairo_new_sub_path( currentContext );
299  cairo_arc_negative( currentContext, startPoint.x, startPoint.y, width, aStartAngle, aStartAngle + M_PI );
300 
301  cairo_new_sub_path( currentContext );
302  cairo_arc( currentContext, endPoint.x, endPoint.y, width, aEndAngle, aEndAngle + M_PI );
303 
304  cairo_restore( currentContext );
305  flushPath();
306  }
307 
308  isElementAdded = true;
309 }
double g
Green component.
Definition: color4d.h:287
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:288
double a
Alpha component.
Definition: color4d.h:289
COLOR4D strokeColor
The color of the outlines.
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:331
virtual void SetLineWidth(double aLineWidth) override
Set the line width.
Definition: cairo_gal.cpp:459
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:339
double r
Red component.
Definition: color4d.h:286
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 229 of file cairo_gal.cpp.

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

230 {
231  cairo_new_sub_path( currentContext );
232  cairo_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, 0.0, 2 * M_PI );
233  flushPath();
234  isElementAdded = true;
235 }
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:331
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
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 860 of file cairo_gal.cpp.

References KIGFX::GAL::cursorPosition.

861 {
862  cursorPosition = aCursorPosition;
863 }
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 337 of file cairo_gal.cpp.

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

339 {
340  cairo_move_to( currentContext, aStartPoint.x, aStartPoint.y );
341  cairo_curve_to( currentContext, aControlPointA.x, aControlPointA.y, aControlPointB.x,
342  aControlPointB.y, aEndPoint.x, aEndPoint.y );
343  cairo_line_to( currentContext, aEndPoint.x, aEndPoint.y );
344 
345  flushPath();
346  isElementAdded = true;
347 }
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:331
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
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, 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 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  // Draw the grid behind all other layers
273  SetLayerDepth( depthRange.y * 0.75 );
274 
276  {
277  SetIsFill( false );
278  SetIsStroke( true );
280 
281  // Now draw the grid, every coarse grid line gets the double width
282 
283  // Vertical lines
284  for( int j = gridStartY-1; j <= gridEndY; j++ )
285  {
286  const double y = j * gridSize.y + gridOrigin.y;
287 
288  if( axesEnabled && y == 0 )
289  continue;
290 
291  if( j % gridTick == 0 && gridScreenSizeDense > gridThreshold )
292  SetLineWidth( doubleMarker );
293  else
294  SetLineWidth( marker );
295 
296  if( ( j % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
297  || gridScreenSizeDense > gridThreshold )
298  {
299  drawGridLine( VECTOR2D( gridStartX * gridSize.x + gridOrigin.x, y ),
300  VECTOR2D( gridEndX * gridSize.x + gridOrigin.x, y ) );
301  }
302  }
303 
304  // Horizontal lines
305  for( int i = gridStartX-1; i <= gridEndX; i++ )
306  {
307  const double x = i * gridSize.x + gridOrigin.x;
308 
309  if( axesEnabled && x == 0 )
310  continue;
311 
312  if( i % gridTick == 0 && gridScreenSizeDense > gridThreshold )
313  SetLineWidth( doubleMarker );
314  else
315  SetLineWidth( marker );
316 
317  if( ( i % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
318  || gridScreenSizeDense > gridThreshold )
319  {
320  drawGridLine( VECTOR2D( x, gridStartY * gridSize.y + gridOrigin.y ),
321  VECTOR2D( x, gridEndY * gridSize.y + gridOrigin.y ) );
322  }
323  }
324  }
325  else if( gridStyle == GRID_STYLE::SMALL_CROSS )
326  {
327  SetIsFill( false );
328  SetIsStroke( true );
330 
331  SetLineWidth( marker );
332  double lineLen = GetLineWidth() * 2;
333 
334  // Vertical positions:
335  for( int j = gridStartY-1; j <= gridEndY; j++ )
336  {
337  if( ( j % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
338  || gridScreenSizeDense > gridThreshold )
339  {
340  int posY = j * gridSize.y + gridOrigin.y;
341 
342  // Horizontal positions:
343  for( int i = gridStartX-1; i <= gridEndX; i++ )
344  {
345  if( ( i % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
346  || gridScreenSizeDense > gridThreshold )
347  {
348  int posX = i * gridSize.x + gridOrigin.x;
349 
350  drawGridLine( VECTOR2D( posX - lineLen, posY ),
351  VECTOR2D( posX + lineLen, posY ) );
352 
353  drawGridLine( VECTOR2D( posX, posY - lineLen ),
354  VECTOR2D( posX, posY + lineLen ) );
355  }
356  }
357  }
358  }
359  }
360  else // Dotted grid
361  {
362  bool tickX, tickY;
363  SetIsFill( true );
364  SetIsStroke( false );
366 
367  for( int j = gridStartY-1; j <= gridEndY; j++ )
368  {
369  if( j % gridTick == 0 && gridScreenSizeDense > gridThreshold )
370  tickY = true;
371  else
372  tickY = false;
373 
374  for( int i = gridStartX-1; i <= gridEndX; i++ )
375  {
376  if( i % gridTick == 0 && gridScreenSizeDense > gridThreshold )
377  tickX = true;
378  else
379  tickX = false;
380 
381  if( tickX || tickY || gridScreenSizeDense > gridThreshold )
382  {
383  double radius = ( ( tickX && tickY ) ? doubleMarker : marker ) / 2.0;
384  DrawRectangle( VECTOR2D( i * gridSize.x - radius + gridOrigin.x,
385  j * gridSize.y - radius + gridOrigin.y ),
386  VECTOR2D( i * gridSize.x + radius + gridOrigin.x,
387  j * gridSize.y + radius + gridOrigin.y ) );
388  }
389  }
390  }
391  }
392 }
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)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
GRID_STYLE gridStyle
Grid display style.
Class VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:65
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:589
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.
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 866 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.

867 {
868  cairo_move_to( currentContext, aStartPoint.x, aStartPoint.y );
869  cairo_line_to( currentContext, aEndPoint.x, aEndPoint.y );
870  cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
871  cairo_stroke( currentContext );
872 }
double g
Green component.
Definition: color4d.h:287
double b
Blue component.
Definition: color4d.h:288
double a
Alpha component.
Definition: color4d.h:289
COLOR4D strokeColor
The color of the outlines.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
double r
Red component.
Definition: color4d.h:286
void CAIRO_GAL::DrawGroup ( int  aGroupNumber)
overridevirtual

Draw the stored group.

Parameters
aGroupNumberis the group number.

Reimplemented from KIGFX::GAL.

Definition at line 625 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.

626 {
627  // This method implements a small Virtual Machine - all stored commands
628  // are executed; nested calling is also possible
629 
630  storePath();
631 
632  for( GROUP::iterator it = groups[aGroupNumber].begin();
633  it != groups[aGroupNumber].end(); ++it )
634  {
635  switch( it->command )
636  {
637  case CMD_SET_FILL:
638  isFillEnabled = it->argument.boolArg;
639  break;
640 
641  case CMD_SET_STROKE:
642  isStrokeEnabled = it->argument.boolArg;
643  break;
644 
645  case CMD_SET_FILLCOLOR:
646  fillColor = COLOR4D( it->argument.dblArg[0], it->argument.dblArg[1], it->argument.dblArg[2],
647  it->argument.dblArg[3] );
648  break;
649 
650  case CMD_SET_STROKECOLOR:
651  strokeColor = COLOR4D( it->argument.dblArg[0], it->argument.dblArg[1], it->argument.dblArg[2],
652  it->argument.dblArg[3] );
653  break;
654 
655  case CMD_SET_LINE_WIDTH:
656  {
657  // Make lines appear at least 1 pixel wide, no matter of zoom
658  double x = 1.0, y = 1.0;
659  cairo_device_to_user_distance( currentContext, &x, &y );
660  double minWidth = std::min( fabs( x ), fabs( y ) );
661  cairo_set_line_width( currentContext, std::max( it->argument.dblArg[0], minWidth ) );
662  }
663  break;
664 
665 
666  case CMD_STROKE_PATH:
667  cairo_set_source_rgb( currentContext, strokeColor.r, strokeColor.g, strokeColor.b );
668  cairo_append_path( currentContext, it->cairoPath );
669  cairo_stroke( currentContext );
670  break;
671 
672  case CMD_FILL_PATH:
673  cairo_set_source_rgb( currentContext, fillColor.r, fillColor.g, fillColor.b );
674  cairo_append_path( currentContext, it->cairoPath );
675  cairo_fill( currentContext );
676  break;
677 
678  /*
679  case CMD_TRANSFORM:
680  cairo_matrix_t matrix;
681  cairo_matrix_init( &matrix, it->argument.dblArg[0], it->argument.dblArg[1], it->argument.dblArg[2],
682  it->argument.dblArg[3], it->argument.dblArg[4], it->argument.dblArg[5] );
683  cairo_transform( currentContext, &matrix );
684  break;
685  */
686 
687  case CMD_ROTATE:
688  cairo_rotate( currentContext, it->argument.dblArg[0] );
689  break;
690 
691  case CMD_TRANSLATE:
692  cairo_translate( currentContext, it->argument.dblArg[0], it->argument.dblArg[1] );
693  break;
694 
695  case CMD_SCALE:
696  cairo_scale( currentContext, it->argument.dblArg[0], it->argument.dblArg[1] );
697  break;
698 
699  case CMD_SAVE:
700  cairo_save( currentContext );
701  break;
702 
703  case CMD_RESTORE:
704  cairo_restore( currentContext );
705  break;
706 
707  case CMD_CALL_GROUP:
708  DrawGroup( it->argument.intArg );
709  break;
710  }
711  }
712 }
Scale the context.
Definition: cairo_gal.h:311
double g
Green component.
Definition: color4d.h:287
COLOR4D fillColor
The fill color.
Set the stroke path.
Definition: cairo_gal.h:306
double b
Blue component.
Definition: color4d.h:288
Translate the context.
Definition: cairo_gal.h:310
bool isStrokeEnabled
Are the outlines stroked ?
Enable/disable stroking.
Definition: cairo_gal.h:302
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:333
COLOR4D strokeColor
The color of the outlines.
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:897
Restore the transformation matrix.
Definition: cairo_gal.h:313
Rotate the context.
Definition: cairo_gal.h:309
bool isFillEnabled
Is filling of graphic objects enabled ?
Enable/disable filling.
Definition: cairo_gal.h:301
#define max(a, b)
Definition: auxiliary.h:86
virtual void DrawGroup(int aGroupNumber) override
Draw the stored group.
Definition: cairo_gal.cpp:625
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
double r
Red component.
Definition: color4d.h:286
Set the fill path.
Definition: cairo_gal.h:307
Save the transformation matrix.
Definition: cairo_gal.h:312
#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 176 of file cairo_gal.cpp.

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

177 {
178  cairo_move_to( currentContext, aStartPoint.x, aStartPoint.y );
179  cairo_line_to( currentContext, aEndPoint.x, aEndPoint.y );
180  flushPath();
181  isElementAdded = true;
182 }
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:331
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
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 1070 of file cairo_gal.cpp.

References currentContext, flushPath(), and isElementAdded.

Referenced by DrawPolygon(), and DrawPolyline().

1071 {
1072  // Iterate over the point list and draw the segments
1073  std::deque<VECTOR2D>::const_iterator it = aPointList.begin();
1074 
1075  cairo_move_to( currentContext, it->x, it->y );
1076 
1077  for( ++it; it != aPointList.end(); ++it )
1078  {
1079  cairo_line_to( currentContext, it->x, it->y );
1080  }
1081 
1082  flushPath();
1083  isElementAdded = true;
1084 }
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:331
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
void CAIRO_GAL::drawPoly ( const VECTOR2D  aPointList[],
int  aListSize 
)
private

Definition at line 1087 of file cairo_gal.cpp.

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

1088 {
1089  // Iterate over the point list and draw the segments
1090  const VECTOR2D* ptr = aPointList;
1091 
1092  cairo_move_to( currentContext, ptr->x, ptr->y );
1093 
1094  for( int i = 0; i < aListSize; ++i )
1095  {
1096  ++ptr;
1097  cairo_line_to( currentContext, ptr->x, ptr->y );
1098  }
1099 
1100  flushPath();
1101  isElementAdded = true;
1102 }
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:331
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
void CAIRO_GAL::drawPoly ( const SHAPE_LINE_CHAIN aLineChain)
private

Definition at line 1105 of file cairo_gal.cpp.

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

1106 {
1107  if( aLineChain.PointCount() < 2 )
1108  return;
1109 
1110  auto numPoints = aLineChain.PointCount();
1111 
1112  if( aLineChain.IsClosed() )
1113  numPoints += 1;
1114 
1115  const VECTOR2I start = aLineChain.CPoint( 0 );
1116  cairo_move_to( currentContext, start.x, start.y );
1117 
1118  for( int i = 1; i < numPoints; ++i )
1119  {
1120  const VECTOR2I& p = aLineChain.CPoint( i );
1121  cairo_line_to( currentContext, p.x, p.y );
1122  }
1123 
1124  flushPath();
1125  isElementAdded = true;
1126 }
int PointCount() const
Function PointCount()
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:331
bool IsClosed() const
Function IsClosed()
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
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 131 of file cairo_gal.h.

References drawPoly().

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

Reimplemented from KIGFX::GAL.

Definition at line 132 of file cairo_gal.h.

References drawPoly().

132 { 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:1070
void CAIRO_GAL::DrawPolygon ( const SHAPE_POLY_SET aPolySet)
overridevirtual

Reimplemented from KIGFX::GAL.

Definition at line 330 of file cairo_gal.cpp.

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

331 {
332  for( int i = 0; i < aPolySet.OutlineCount(); ++i )
333  drawPoly( aPolySet.COutline( i ) );
334 }
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:1070
int OutlineCount() const
Returns the number of outlines in the set
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
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 126 of file cairo_gal.h.

References drawPoly().

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

Reimplemented from KIGFX::GAL.

Definition at line 127 of file cairo_gal.h.

References drawPoly().

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

Reimplemented from KIGFX::GAL.

Definition at line 128 of file cairo_gal.h.

References drawPoly().

128 { 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:1070
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 312 of file cairo_gal.cpp.

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

313 {
314  // Calculate the diagonal points
315  VECTOR2D diagonalPointA( aEndPoint.x, aStartPoint.y );
316  VECTOR2D diagonalPointB( aStartPoint.x, aEndPoint.y );
317 
318  // The path is composed from 4 segments
319  cairo_move_to( currentContext, aStartPoint.x, aStartPoint.y );
320  cairo_line_to( currentContext, diagonalPointA.x, diagonalPointA.y );
321  cairo_line_to( currentContext, aEndPoint.x, aEndPoint.y );
322  cairo_line_to( currentContext, diagonalPointB.x, diagonalPointB.y );
323  cairo_close_path( currentContext );
324  flushPath();
325 
326  isElementAdded = true;
327 }
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:331
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
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 185 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.

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

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

Reimplemented from KIGFX::GAL.

Definition at line 140 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.

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

End the group.

Reimplemented from KIGFX::GAL.

Definition at line 616 of file cairo_gal.cpp.

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

617 {
618  storePath();
619  isGrouping = false;
620 
621  deinitSurface();
622 }
void deinitSurface()
Destroy Cairo surfaces when are not needed anymore.
Definition: cairo_gal.cpp:1043
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:330
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:897
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 378 of file cairo_gal.cpp.

References storePath().

Referenced by EndDrawing().

379 {
380  storePath();
381 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:897
void CAIRO_GAL::flushPath ( )
private

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

876 {
877  if( isFillEnabled )
878  {
879  cairo_set_source_rgba( currentContext,
881 
882  if( isStrokeEnabled )
883  cairo_fill_preserve( currentContext );
884  else
885  cairo_fill( currentContext );
886  }
887 
888  if( isStrokeEnabled )
889  {
890  cairo_set_source_rgba( currentContext,
892  cairo_stroke( currentContext );
893  }
894 }
double g
Green component.
Definition: color4d.h:287
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:288
double a
Alpha component.
Definition: color4d.h:289
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:339
double r
Red component.
Definition: color4d.h:286
COLOR4D GAL::getCursorColor ( ) const
protectedinherited

Gets the actual cursor color to draw.

Definition at line 406 of file graphics_abstraction_layer.cpp.

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

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

407 {
408  auto color = cursorColor;
409 
410  // dim the cursor if it's only on because it was forced
411  // (this helps to provide a hint for active tools)
412  if( !isCursorEnabled )
413  {
414  color.a = color.a * 0.5;
415  }
416 
417  return color;
418 }
bool isCursorEnabled
Is the cursor enabled?
COLOR4D cursorColor
Cursor color.
double KIGFX::GAL::GetGridLineWidth ( ) const
inlineinherited

Get the grid line width.

Returns
the grid line width

Definition at line 861 of file graphics_abstraction_layer.h.

References KIGFX::GAL::gridLineWidth.

862  {
863  return gridLineWidth;
864  }
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 395 of file graphics_abstraction_layer.cpp.

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

Referenced by KIGFX::WX_VIEW_CONTROLS::GetCursorPosition(), and EDIT_POINTS_FACTORY::Make().

396 {
397  return VECTOR2D( KiROUND( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x,
398  KiROUND( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y );
399 }
VECTOR2D gridOffset
The grid offset to compensate cursor position.
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589
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 813 of file graphics_abstraction_layer.h.

References KIGFX::GAL::gridSize.

814  {
815  return gridSize;
816  }
VECTOR2D gridSize
The grid size.
EDA_TEXT_HJUSTIFY_T KIGFX::GAL::GetHorizontalJustify ( ) const
inlineinherited

Returns current text horizontal justification setting.

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

459  {
461  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
EDA_TEXT_HJUSTIFY_T m_horizontalJustify
Horizontal justification.
double KIGFX::GAL::GetLineWidth ( void  ) const
inlineinherited
const VECTOR2D& KIGFX::GAL::GetLookAtPoint ( ) const
inlineinherited

Get the look at point.

Returns
the look at point.

Definition at line 653 of file graphics_abstraction_layer.h.

References KIGFX::GAL::lookAtPoint.

654  {
655  return lookAtPoint;
656  }
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 702 of file graphics_abstraction_layer.h.

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

703  {
704  return depthRange.y;
705  }
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 694 of file graphics_abstraction_layer.h.

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

695  {
696  return depthRange.x;
697  }
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 1129 of file cairo_gal.cpp.

References groupCounter, groups, and max.

Referenced by BeginGroup().

1130 {
1131  wxASSERT_MSG( groups.size() < std::numeric_limits<unsigned int>::max(),
1132  wxT( "There are no free slots to store a group" ) );
1133 
1134  while( groups.find( groupCounter ) != groups.end() )
1135  groupCounter++;
1136 
1137  return groupCounter++;
1138 }
unsigned int groupCounter
Counter used for generating keys for groups.
Definition: cairo_gal.h:334
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:333
#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 353 of file graphics_abstraction_layer.h.

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

354  {
356  }
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 594 of file graphics_abstraction_layer.h.

References KIGFX::GAL::screenWorldMatrix.

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

595  {
596  return screenWorldMatrix;
597  }
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 256 of file graphics_abstraction_layer.h.

References KIGFX::GAL::strokeColor.

257  {
258  return strokeColor;
259  }
COLOR4D strokeColor
The color of the outlines.
const STROKE_FONT& KIGFX::GAL::GetStrokeFont ( ) const
inlineinherited

Definition at line 298 of file graphics_abstraction_layer.h.

References KIGFX::GAL::strokeFont.

Referenced by EDA_TEXT::GetTextBox().

299  {
300  return strokeFont;
301  }
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 828 of file cairo_gal.cpp.

References currentTarget.

829 {
830  return currentTarget;
831 }
RENDER_TARGET currentTarget
Current rendering target.
Definition: cairo_gal.h:285
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 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 476 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().

477  {
479  }
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 584 of file graphics_abstraction_layer.h.

References KIGFX::GAL::worldScreenMatrix.

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

585  {
586  return worldScreenMatrix;
587  }
MATRIX3x3D worldScreenMatrix
World transformation.
double KIGFX::GAL::GetZoomFactor ( ) const
inlineinherited

Get the zoom factor.

Returns
the zoom factor.

Definition at line 673 of file graphics_abstraction_layer.h.

References KIGFX::GAL::zoomFactor.

Referenced by EDA_DRAW_PANEL_GAL::GetLegacyZoom(), EDA_DRAW_FRAME::GetZoomLevelIndicator(), EDA_DRAW_FRAME::UseGalCanvas(), and COMMON_TOOLS::ZoomPreset().

674  {
675  return zoomFactor;
676  }
double zoomFactor
The zoom factor.
void CAIRO_GAL::initSurface ( )
private

Prepare Cairo surfaces for drawing.

Definition at line 1000 of file cairo_gal.cpp.

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

Referenced by BeginDrawing(), and BeginGroup().

1001 {
1002  if( isInitialized )
1003  return;
1004 
1005  // Create the Cairo surface
1006  surface = cairo_image_surface_create_for_data( (unsigned char*) bitmapBuffer, GAL_FORMAT,
1008  context = cairo_create( surface );
1009 #ifdef __WXDEBUG__
1010  cairo_status_t status = cairo_status( context );
1011  wxASSERT_MSG( status == CAIRO_STATUS_SUCCESS, wxT( "Cairo context creation error" ) );
1012 #endif /* __WXDEBUG__ */
1014 
1015  cairo_set_antialias( context, CAIRO_ANTIALIAS_NONE );
1016 
1017  // Clear the screen
1019 
1020  // Compute the world <-> screen transformations
1022 
1023  cairo_matrix_init( &cairoWorldScreenMatrix, worldScreenMatrix.m_data[0][0],
1026  worldScreenMatrix.m_data[1][2] );
1027 
1028  cairo_set_matrix( context, &cairoWorldScreenMatrix );
1029 
1030  // Start drawing with a new path
1031  cairo_new_path( context );
1032  isElementAdded = true;
1033 
1034  cairo_set_line_join( context, CAIRO_LINE_JOIN_ROUND );
1035  cairo_set_line_cap( context, CAIRO_LINE_CAP_ROUND );
1036 
1037  lineWidth = 0;
1038 
1039  isInitialized = true;
1040 }
virtual void ClearScreen(const COLOR4D &aColor) override
Clear the screen.
Definition: cairo_gal.cpp:384
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:345
virtual void ComputeWorldScreenMatrix()
Compute the world <-> screen transformation matrix.
T m_data[3][3]
Definition: matrix3x3.h:64
double lineWidth
The line width.
cairo_surface_t * surface
Cairo surface.
Definition: cairo_gal.h:341
COLOR4D backgroundColor
Background color.
Definition: cairo_gal.h:346
cairo_t * context
Cairo image.
Definition: cairo_gal.h:340
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:331
MATRIX3x3D worldScreenMatrix
World transformation.
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:342
static const cairo_format_t GAL_FORMAT
Format used to store pixels.
Definition: cairo_gal.h:405
int stride
Stride value for Cairo.
Definition: cairo_gal.h:344
cairo_matrix_t cairoWorldScreenMatrix
Cairo world to screen transformation matrix.
Definition: cairo_gal.h:338
VECTOR2I screenSize
Screen size in screen coordinates.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
bool KIGFX::GAL::IsCursorEnabled ( ) const
inlineinherited

Returns information about cursor visibility.

Returns
True if cursor is visible.

Definition at line 914 of file graphics_abstraction_layer.h.

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

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

915  {
917  }
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 404 of file graphics_abstraction_layer.h.

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

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

405  {
406  return textProperties.m_bold;
407  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
bool KIGFX::GAL::IsFontItalic ( ) const
inlineinherited

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

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

423  {
424  return textProperties.m_italic;
425  }
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 66 of file graphics_abstraction_layer.h.

Referenced by EDA_DRAW_PANEL_GAL::onRefreshTimer().

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

Returns true if text should displayed mirrored.

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

441  {
442  return textProperties.m_mirrored;
443  }
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.

91  {
92  return IsShownOnScreen();
93  }
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 945 of file cairo_gal.cpp.

References PostPaint().

Referenced by CAIRO_GAL().

946 {
947  PostPaint();
948 }
void PostPaint()
Function PostPaint posts an event to m_paint_listener.
Definition: cairo_gal.h:255
void KIGFX::GAL::PopDepth ( )
inlineinherited

Restores previously stored drawing depth for the depth stack.

Definition at line 956 of file graphics_abstraction_layer.h.

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

957  {
958  layerDepth = depthStack.top();
959  depthStack.pop();
960  }
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 255 of file cairo_gal.h.

References paintListener.

Referenced by onPaint().

256  {
257  if( paintListener )
258  {
259  wxPaintEvent redrawEvent;
260  wxPostEvent( paintListener, redrawEvent );
261  }
262  }
wxEvtHandler * paintListener
Paint listener.
Definition: cairo_gal.h:291
void KIGFX::GAL::PushDepth ( )
inlineinherited

Stores current drawing depth on the depth stack.

Definition at line 948 of file graphics_abstraction_layer.h.

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

949  {
950  depthStack.push( layerDepth );
951  }
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(), and KIGFX::GAL::GAL().

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

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

351 {
352  screenSize = VECTOR2I( aWidth, aHeight );
353 
354  // Recreate the bitmaps
355  deleteBitmaps();
356  allocateBitmaps();
357 
358  if( validCompositor )
359  compositor->Resize( aWidth, aHeight );
360 
361  validCompositor = false;
362 
363  SetSize( wxSize( aWidth, aHeight ) );
364 }
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:286
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:282
VECTOR2I screenSize
Screen size in screen coordinates.
void deleteBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:992
void allocateBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:977
void CAIRO_GAL::Restore ( )
overridevirtual

Restore the context.

Reimplemented from KIGFX::GAL.

Definition at line 581 of file cairo_gal.cpp.

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

582 {
583  storePath();
584 
585  if( isGrouping )
586  {
587  GROUP_ELEMENT groupElement;
588  groupElement.command = CMD_RESTORE;
589  currentGroup->push_back( groupElement );
590  }
591  else
592  {
593  cairo_restore( currentContext );
594  }
595 }
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:335
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:330
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:897
Restore the transformation matrix.
Definition: cairo_gal.h:313
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
void CAIRO_GAL::RestoreScreen ( )
overridevirtual

Restore the screen contents.

Reimplemented from KIGFX::GAL.

Definition at line 785 of file cairo_gal.cpp.

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

786 {
787  int offset = 0;
788 
789  for( int j = 0; j < screenSize.y; j++ )
790  {
791  for( int i = 0; i < stride; i++ )
792  {
793  bitmapBuffer[offset + i] = bitmapBufferBackup[offset + i];
794  offset += stride;
795  }
796  }
797 }
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:342
int stride
Stride value for Cairo.
Definition: cairo_gal.h:344
unsigned int * bitmapBufferBackup
Backup storage of the cairo image.
Definition: cairo_gal.h:343
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 508 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().

509 {
510  storePath();
511 
512  if( isGrouping )
513  {
514  GROUP_ELEMENT groupElement;
515  groupElement.command = CMD_ROTATE;
516  groupElement.argument.dblArg[0] = aAngle;
517  currentGroup->push_back( groupElement );
518  }
519  else
520  {
521  cairo_rotate( currentContext, aAngle );
522  }
523 }
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:335
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:330
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:897
Rotate the context.
Definition: cairo_gal.h:309
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
void CAIRO_GAL::Save ( )
overridevirtual

Save the context.

Reimplemented from KIGFX::GAL.

Definition at line 564 of file cairo_gal.cpp.

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

565 {
566  storePath();
567 
568  if( isGrouping )
569  {
570  GROUP_ELEMENT groupElement;
571  groupElement.command = CMD_SAVE;
572  currentGroup->push_back( groupElement );
573  }
574  else
575  {
576  cairo_save( currentContext );
577  }
578 }
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:335
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:330
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:897
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
Save the transformation matrix.
Definition: cairo_gal.h:312
void CAIRO_GAL::SaveScreen ( )
overridevirtual

Save the screen contents.

Reimplemented from KIGFX::GAL.

Definition at line 769 of file cairo_gal.cpp.

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

770 {
771  // Copy the current bitmap to the backup buffer
772  int offset = 0;
773 
774  for( int j = 0; j < screenSize.y; j++ )
775  {
776  for( int i = 0; i < stride; i++ )
777  {
778  bitmapBufferBackup[offset + i] = bitmapBuffer[offset + i];
779  offset += stride;
780  }
781  }
782 }
unsigned int * bitmapBuffer
Storage of the cairo image.
Definition: cairo_gal.h:342
int stride
Stride value for Cairo.
Definition: cairo_gal.h:344
unsigned int * bitmapBufferBackup
Backup storage of the cairo image.
Definition: cairo_gal.h:343
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 545 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.

546 {
547  storePath();
548 
549  if( isGrouping )
550  {
551  GROUP_ELEMENT groupElement;
552  groupElement.command = CMD_SCALE;
553  groupElement.argument.dblArg[0] = aScale.x;
554  groupElement.argument.dblArg[1] = aScale.y;
555  currentGroup->push_back( groupElement );
556  }
557  else
558  {
559  cairo_scale( currentContext, aScale.x, aScale.y );
560  }
561 }
Scale the context.
Definition: cairo_gal.h:311
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:335
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:330
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:897
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
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 833 of file graphics_abstraction_layer.h.

References KIGFX::GAL::axesColor.

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

834  {
835  axesColor = aAxesColor;
836  }
COLOR4D axesColor
Color of the axes.
void KIGFX::GAL::SetAxesEnabled ( bool  aAxesEnabled)
inlineinherited

Enables drawing the axes.

Definition at line 841 of file graphics_abstraction_layer.h.

References KIGFX::GAL::axesEnabled.

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

842  {
843  axesEnabled = aAxesEnabled;
844  }
bool axesEnabled
Should the axes be drawn.
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 851 of file graphics_abstraction_layer.h.

References KIGFX::GAL::gridTick.

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

852  {
853  gridTick = aInterval;
854  }
int gridTick
Every tick line gets the double width.
void CAIRO_GAL::setCompositor ( )
private

Prepare the compositor.

Definition at line 1056 of file cairo_gal.cpp.

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

Referenced by BeginDrawing().

1057 {
1058  // Recreate the compositor with the new Cairo context
1059  compositor.reset( new CAIRO_COMPOSITOR( &currentContext ) );
1060  compositor->Resize( screenSize.x, screenSize.y );
1061 
1062  // Prepare buffers
1063  mainBuffer = compositor->CreateBuffer();
1064  overlayBuffer = compositor->CreateBuffer();
1065 
1066  validCompositor = true;
1067 }
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:284
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:286
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:282
VECTOR2I screenSize
Screen size in screen coordinates.
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
unsigned int mainBuffer
Handle to the main buffer.
Definition: cairo_gal.h:283
void KIGFX::GAL::SetCursorColor ( const COLOR4D aCursorColor)
inlineinherited

Set the cursor color.

Parameters
aCursorColoris the color of the cursor.

Definition at line 924 of file graphics_abstraction_layer.h.

References KIGFX::GAL::cursorColor.

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

925  {
926  cursorColor = aCursorColor;
927  }
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 905 of file graphics_abstraction_layer.h.

References KIGFX::GAL::isCursorEnabled.

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

906  {
907  isCursorEnabled = aCursorEnabled;
908  }
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 686 of file graphics_abstraction_layer.h.

References KIGFX::GAL::depthRange.

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

687  {
688  depthRange = aDepthRange;
689  }
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 441 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().

442 {
443  storePath();
444  fillColor = aColor;
445 
446  if( isGrouping )
447  {
448  GROUP_ELEMENT groupElement;
449  groupElement.command = CMD_SET_FILLCOLOR;
450  groupElement.argument.dblArg[0] = fillColor.r;
451  groupElement.argument.dblArg[1] = fillColor.g;
452  groupElement.argument.dblArg[2] = fillColor.b;
453  groupElement.argument.dblArg[3] = fillColor.a;
454  currentGroup->push_back( groupElement );
455  }
456 }
double g
Green component.
Definition: color4d.h:287
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:288
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:335
double a
Alpha component.
Definition: color4d.h:289
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:330
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:897
double r
Red component.
Definition: color4d.h:286
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 723 of file graphics_abstraction_layer.h.

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

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

724  {
725  globalFlipX = xAxis;
726  globalFlipY = yAxis;
727  }
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 396 of file graphics_abstraction_layer.h.

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

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

397  {
398  textProperties.m_bold = aBold;
399  }
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 414 of file graphics_abstraction_layer.h.

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

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

415  {
416  textProperties.m_italic = aItalic;
417  }
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 378 of file graphics_abstraction_layer.h.

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

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

379  {
380  textProperties.m_glyphSize = aGlyphSize;
381  }
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 823 of file graphics_abstraction_layer.h.

References KIGFX::GAL::gridColor.

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

824  {
825  gridColor = aGridColor;
826  }
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 784 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 PCB_BASE_EDIT_FRAME::SetBoard(), setOrigin(), and EDA_DRAW_FRAME::UseGalCanvas().

785  {
786  gridOrigin = aGridOrigin;
787 
788  if( gridSize.x == 0.0 || gridSize.y == 0.0 )
789  gridOffset = VECTOR2D(0.0, 0.0);
790  else
791  gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
792  (long) gridOrigin.y % (long) gridSize.y );
793  }
VECTOR2D gridOffset
The grid offset to compensate cursor position.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589
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 800 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 COMMON_TOOLS::updateGrid(), PCBNEW_CONTROL::updateGrid(), and EDA_DRAW_FRAME::UseGalCanvas().

801  {
802  gridSize = aGridSize;
803 
804  gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
805  (long) gridOrigin.y % (long) gridSize.y );
806  }
VECTOR2D gridOffset
The grid offset to compensate cursor position.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589
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 774 of file graphics_abstraction_layer.h.

References KIGFX::GAL::gridVisibility.

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

775  {
776  gridVisibility = aVisibility;
777  }
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 450 of file graphics_abstraction_layer.h.

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

Referenced by KIGFX::PCB_PAINTER::draw(), KIGFX::PREVIEW::DrawTextNextToCursor(), drawTicksAlongLine(), KIGFX::GAL::ResetTextAttributes(), and KIGFX::GAL::SetTextAttributes().

451  {
452  textProperties.m_horizontalJustify = aHorizontalJustify;
453  }
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 393 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().

394 {
395  storePath();
396  isFillEnabled = aIsFillEnabled;
397 
398  if( isGrouping )
399  {
400  GROUP_ELEMENT groupElement;
401  groupElement.command = CMD_SET_FILL;
402  groupElement.argument.boolArg = aIsFillEnabled;
403  currentGroup->push_back( groupElement );
404  }
405 }
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:335
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:330
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:897
bool isFillEnabled
Is filling of graphic objects enabled ?
Enable/disable filling.
Definition: cairo_gal.h:301
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 408 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().

409 {
410  storePath();
411  isStrokeEnabled = aIsStrokeEnabled;
412 
413  if( isGrouping )
414  {
415  GROUP_ELEMENT groupElement;
416  groupElement.command = CMD_SET_STROKE;
417  groupElement.argument.boolArg = aIsStrokeEnabled;
418  currentGroup->push_back( groupElement );
419  }
420 }
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:335
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:330
bool isStrokeEnabled
Are the outlines stroked ?
Enable/disable stroking.
Definition: cairo_gal.h:302
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:897
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 483 of file cairo_gal.cpp.

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

484 {
485  super::SetLayerDepth( aLayerDepth );
486 
487  if( isInitialized )
488  storePath();
489 }
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:345
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:897
void CAIRO_GAL::SetLineWidth ( double  aLineWidth)
overridevirtual

Set the line width.

Parameters
aLineWidthis the line width.

Reimplemented from KIGFX::GAL.

Definition at line 459 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 DrawArcSegment(), and DrawSegment().

460 {
461  storePath();
462 
463  lineWidth = aLineWidth;
464 
465  if( isGrouping )
466  {
467  GROUP_ELEMENT groupElement;
468  groupElement.command = CMD_SET_LINE_WIDTH;
469  groupElement.argument.dblArg[0] = aLineWidth;
470  currentGroup->push_back( groupElement );
471  }
472  else
473  {
474  // Make lines appear at least 1 pixel wide, no matter of zoom
475  double x = 1.0, y = 1.0;
476  cairo_device_to_user_distance( currentContext, &x, &y );
477  double minWidth = std::min( fabs( x ), fabs( y ) );
478  cairo_set_line_width( currentContext, std::max( aLineWidth, minWidth ) );
479  }
480 }
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:335
double lineWidth
The line width.
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:330
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:897
#define max(a, b)
Definition: auxiliary.h:86
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
#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 643 of file graphics_abstraction_layer.h.

References KIGFX::GAL::lookAtPoint.

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

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

Definition at line 264 of file cairo_gal.h.

References mouseListener.

265  {
266  mouseListener = aMouseListener;
267  }
wxEvtHandler * mouseListener
Mouse listener.
Definition: cairo_gal.h:290
void KIGFX::CAIRO_GAL::SetPaintListener ( wxEvtHandler *  aPaintListener)
inline

Definition at line 269 of file cairo_gal.h.

References paintListener.

270  {
271  paintListener = aPaintListener;
272  }
wxEvtHandler * paintListener
Paint listener.
Definition: cairo_gal.h:291
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 631 of file graphics_abstraction_layer.h.

References KIGFX::GAL::screenDPI.

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

632  {
633  screenDPI = aScreenDPI;
634  }
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 423 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.

424 {
425  storePath();
426  strokeColor = aColor;
427 
428  if( isGrouping )
429  {
430  GROUP_ELEMENT groupElement;
431  groupElement.command = CMD_SET_STROKECOLOR;
432  groupElement.argument.dblArg[0] = strokeColor.r;
433  groupElement.argument.dblArg[1] = strokeColor.g;
434  groupElement.argument.dblArg[2] = strokeColor.b;
435  groupElement.argument.dblArg[3] = strokeColor.a;
436  currentGroup->push_back( groupElement );
437  }
438 }
double g
Green component.
Definition: color4d.h:287
double b
Blue component.
Definition: color4d.h:288
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:335
double a
Alpha component.
Definition: color4d.h:289
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:330
COLOR4D strokeColor
The color of the outlines.
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:897
double r
Red component.
Definition: color4d.h:286
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 800 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().

801 {
802  // If the compositor is not set, that means that there is a recaching process going on
803  // and we do not need the compositor now
804  if( !validCompositor )
805  return;
806 
807  // Cairo grouping prevents display of overlapping items on the same layer in the lighter color
808  if( isInitialized )
809  storePath();
810 
811  switch( aTarget )
812  {
813  default:
814  case TARGET_CACHED:
815  case TARGET_NONCACHED:
816  compositor->SetBuffer( mainBuffer );
817  break;
818 
819  case TARGET_OVERLAY:
820  compositor->SetBuffer( overlayBuffer );
821  break;
822  }
823 
824  currentTarget = aTarget;
825 }
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:345
unsigned int overlayBuffer
Handle to the overlay buffer.
Definition: cairo_gal.h:284
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:286
Auxiliary rendering target (noncached)
Definition: definitions.h:42
RENDER_TARGET currentTarget
Current rendering target.
Definition: cairo_gal.h:285
std::shared_ptr< CAIRO_COMPOSITOR > compositor
Object for layers compositing.
Definition: cairo_gal.h:282
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:897
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:283
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::WORKSHEET_VIEWITEM::draw(), KIGFX::PCB_PAINTER::draw(), and DrawGraphicText().

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:170
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:190
bool IsBold() const
Definition: eda_text.h:173
void SetFontBold(const bool aBold)
Set bold property of current font.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589
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:191
bool IsMirrored() const
Definition: eda_text.h:179
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
const wxSize & GetTextSize() const
Definition: eda_text.h:215
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 432 of file graphics_abstraction_layer.h.

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

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

433  {
434  textProperties.m_mirrored = aMirrored;
435  }
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 468 of file graphics_abstraction_layer.h.

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

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

469  {
470  textProperties.m_verticalJustify = aVerticalJustify;
471  }
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 604 of file graphics_abstraction_layer.h.

References KIGFX::GAL::worldScreenMatrix.

605  {
606  worldScreenMatrix = aMatrix;
607  }
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 618 of file graphics_abstraction_layer.h.

References KIGFX::GAL::worldUnitLength.

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

619  {
620  worldUnitLength = aWorldUnitLength;
621  }
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 663 of file graphics_abstraction_layer.h.

References KIGFX::GAL::zoomFactor.

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

664  {
665  zoomFactor = aZoomFactor;
666  }
double zoomFactor
The zoom factor.
bool CAIRO_GAL::Show ( bool  aShow)
overridevirtual

Shows/hides the GAL canvas.

Reimplemented from KIGFX::GAL.

Definition at line 367 of file cairo_gal.cpp.

368 {
369  bool s = wxWindow::Show( aShow );
370 
371  if( aShow )
372  wxWindow::Raise();
373 
374  return s;
375 }
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 951 of file cairo_gal.cpp.

References mouseListener.

Referenced by CAIRO_GAL().

952 {
953  // Post the mouse event to the event listener registered in constructor, if any
954  if( mouseListener )
955  wxPostEvent( mouseListener, aEvent );
956 }
wxEvtHandler * mouseListener
Mouse listener.
Definition: cairo_gal.h:290
void CAIRO_GAL::storePath ( )
private

Store the actual path.

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

898 {
899  if( isElementAdded )
900  {
901  isElementAdded = false;
902 
903  if( !isGrouping )
904  {
905  if( isFillEnabled )
906  {
907  cairo_set_source_rgb( currentContext, fillColor.r, fillColor.g, fillColor.b );
908  cairo_fill_preserve( currentContext );
909  }
910 
911  if( isStrokeEnabled )
912  {
913  cairo_set_source_rgb( currentContext, strokeColor.r, strokeColor.g,
914  strokeColor.b );
915  cairo_stroke_preserve( currentContext );
916  }
917  }
918  else
919  {
920  // Copy the actual path, append it to the global path list
921  // then check, if the path needs to be stroked/filled and
922  // add this command to the group list;
923  if( isStrokeEnabled )
924  {
925  GROUP_ELEMENT groupElement;
926  groupElement.cairoPath = cairo_copy_path( currentContext );
927  groupElement.command = CMD_STROKE_PATH;
928  currentGroup->push_back( groupElement );
929  }
930 
931  if( isFillEnabled )
932  {
933  GROUP_ELEMENT groupElement;
934  groupElement.cairoPath = cairo_copy_path( currentContext );
935  groupElement.command = CMD_FILL_PATH;
936  currentGroup->push_back( groupElement );
937  }
938  }
939 
940  cairo_new_path( currentContext );
941  }
942 }
double g
Green component.
Definition: color4d.h:287
COLOR4D fillColor
The fill color.
Set the stroke path.
Definition: cairo_gal.h:306
double b
Blue component.
Definition: color4d.h:288
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:335
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:330
bool isStrokeEnabled
Are the outlines stroked ?
COLOR4D strokeColor
The color of the outlines.
bool isElementAdded
Was an graphic element added ?
Definition: cairo_gal.h:331
bool isFillEnabled
Is filling of graphic objects enabled ?
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
double r
Red component.
Definition: color4d.h:286
Set the fill path.
Definition: cairo_gal.h:307
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 310 of file graphics_abstraction_layer.h.

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

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

312  {
313  strokeFont.Draw( aText, aPosition, aRotationAngle );
314  }
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 895 of file graphics_abstraction_layer.h.

References KIGFX::GAL::worldScreenMatrix.

Referenced by blitCursor().

896  {
897  return VECTOR2D( worldScreenMatrix * aPoint );
898  }
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589
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 884 of file graphics_abstraction_layer.h.

References KIGFX::GAL::screenWorldMatrix.

885  {
886  return VECTOR2D( screenWorldMatrix * aPoint );
887  }
MATRIX3x3D screenWorldMatrix
Screen transformation.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589
void CAIRO_GAL::Transform ( const MATRIX3x3D aTransformation)
overridevirtual

Transform the context.

Parameters
aTransformationis the ransformation matrix.

Reimplemented from KIGFX::GAL.

Definition at line 492 of file cairo_gal.cpp.

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

493 {
494  cairo_matrix_t cairoTransformation;
495 
496  cairo_matrix_init( &cairoTransformation,
497  aTransformation.m_data[0][0],
498  aTransformation.m_data[1][0],
499  aTransformation.m_data[0][1],
500  aTransformation.m_data[1][1],
501  aTransformation.m_data[0][2],
502  aTransformation.m_data[1][2] );
503 
504  cairo_transform( currentContext, &cairoTransformation );
505 }
T m_data[3][3]
Definition: matrix3x3.h:64
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
void CAIRO_GAL::Translate ( const VECTOR2D aTranslation)
overridevirtual

Translate the context.

Parameters
aTranslationis the translation vector.

Reimplemented from KIGFX::GAL.

Definition at line 526 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.

527 {
528  storePath();
529 
530  if( isGrouping )
531  {
532  GROUP_ELEMENT groupElement;
533  groupElement.command = CMD_TRANSLATE;
534  groupElement.argument.dblArg[0] = aTranslation.x;
535  groupElement.argument.dblArg[1] = aTranslation.y;
536  currentGroup->push_back( groupElement );
537  }
538  else
539  {
540  cairo_translate( currentContext, aTranslation.x, aTranslation.y );
541  }
542 }
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:335
Translate the context.
Definition: cairo_gal.h:310
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:330
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:897
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
bool CAIRO_GAL::updatedGalDisplayOptions ( const GAL_DISPLAY_OPTIONS aOptions)
overrideprivatevirtual

Cairo-specific update handlers

Reimplemented from KIGFX::GAL.

Definition at line 114 of file cairo_gal.cpp.

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

115 {
116  bool refresh = false;
117 
118  if( super::updatedGalDisplayOptions( aOptions ) )
119  {
120  Refresh();
121  refresh = true;
122  }
123 
124  return refresh;
125 }
void Refresh()
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 1002 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 346 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 342 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 343 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 292 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 338 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 282 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 340 of file cairo_gal.h.

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

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

Current rendering target.

Definition at line 285 of file cairo_gal.h.

Referenced by GetTarget(), and SetTarget().

COLOR4D KIGFX::GAL::cursorColor
protectedinherited

Cursor color.

Definition at line 1012 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 1014 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 969 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 1013 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 405 of file cairo_gal.h.

Referenced by allocateBitmaps(), and initSurface().

bool KIGFX::GAL::globalFlipX
protectedinherited
bool KIGFX::GAL::globalFlipY
protectedinherited

Flag for Y axis flipping.

Definition at line 982 of file graphics_abstraction_layer.h.

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

const int GAL::GRID_DEPTH = MAX_DEPTH - 1
staticprotectedinherited

Depth level on which the grid is drawn.

Definition at line 1045 of file graphics_abstraction_layer.h.

COLOR4D KIGFX::GAL::gridColor
protectedinherited

Color of the grid.

Definition at line 1001 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 1006 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 1000 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 1004 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 996 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 334 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 333 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

Was an graphic element added ?

Definition at line 331 of file cairo_gal.h.

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

bool KIGFX::CAIRO_GAL::isGrouping
private
bool KIGFX::CAIRO_GAL::isInitialized
private

Are Cairo image & surface ready to use.

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

VECTOR2D KIGFX::GAL::lookAtPoint
protectedinherited

Point to be looked at in world space.

Definition at line 974 of file graphics_abstraction_layer.h.

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

unsigned int KIGFX::CAIRO_GAL::mainBuffer
private

Handle to the main buffer.

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

const int GAL::MAX_DEPTH = 1023
staticprotectedinherited

Definition at line 1042 of file graphics_abstraction_layer.h.

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

const double GAL::METRIC_UNIT_LENGTH = 1e9
staticinherited

Definition at line 962 of file graphics_abstraction_layer.h.

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

const int GAL::MIN_DEPTH = -1024
staticprotectedinherited

Possible depth range.

Definition at line 1038 of file graphics_abstraction_layer.h.

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

wxEvtHandler* KIGFX::CAIRO_GAL::mouseListener
private

Mouse listener.

Definition at line 290 of file cairo_gal.h.

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

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

Definition at line 967 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 284 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 291 of file cairo_gal.h.

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

wxWindow* KIGFX::CAIRO_GAL::parentWindow
private

Parent window.

Definition at line 289 of file cairo_gal.h.

Referenced by CAIRO_GAL().

double KIGFX::GAL::screenDPI
protectedinherited

The dots per inch of the screen.

Definition at line 973 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 344 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 1017 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 341 of file cairo_gal.h.

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

bool KIGFX::CAIRO_GAL::validCompositor
private

Compositor initialization flag.

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

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

int KIGFX::CAIRO_GAL::wxBufferWidth
private

Definition at line 348 of file cairo_gal.h.

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

unsigned char* KIGFX::CAIRO_GAL::wxOutput
private

wxImage comaptible buffer

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