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 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, groupCounter, isGrouping, isInitialized, mouseListener, onPaint(), paintListener, parentWindow, KIGFX::GAL::screenSize, KIGFX::GAL::SetAxesColor(), KIGFX::GAL::SetGridColor(), skipMouseEvent(), 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  // Initialize the flags
56  isGrouping = false;
57  isInitialized = false;
58  validCompositor = false;
59  groupCounter = 0;
60 
61  // Connecting the event handlers
62  Connect( wxEVT_PAINT, wxPaintEventHandler( CAIRO_GAL::onPaint ) );
63 
64  // Mouse events are skipped to the parent
65  Connect( wxEVT_MOTION, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
66  Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
67  Connect( wxEVT_LEFT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
68  Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
69  Connect( wxEVT_MIDDLE_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
70  Connect( wxEVT_MIDDLE_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
71  Connect( wxEVT_MIDDLE_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
72  Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
73  Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
74  Connect( wxEVT_RIGHT_DCLICK, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
75  Connect( wxEVT_MOUSEWHEEL, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
76 #if defined _WIN32 || defined _WIN64
77  Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( CAIRO_GAL::skipMouseEvent ) );
78 #endif
79 
80  SetSize( aParent->GetSize() );
81  screenSize = VECTOR2I( aParent->GetSize() );
82 
83  // Grid color settings are different in Cairo and OpenGL
84  SetGridColor( COLOR4D( 0.1, 0.1, 0.1, 0.8 ) );
86 
87  // Allocate memory for pixel storage
89 }
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:930
bool isInitialized
Are Cairo image & surface ready to use.
Definition: cairo_gal.h:345
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590
bool validCompositor
Compositor initialization flag.
Definition: cairo_gal.h:286
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.
wxEvtHandler * paintListener
Paint listener.
Definition: cairo_gal.h:291
void skipMouseEvent(wxMouseEvent &aEvent)
Mouse event handler, forwards the event to the child.
Definition: cairo_gal.cpp:936
VECTOR2I screenSize
Screen size in screen coordinates.
wxEvtHandler * mouseListener
Mouse listener.
Definition: cairo_gal.h:290
void allocateBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:962
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 92 of file cairo_gal.cpp.

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

93 {
94  deinitSurface();
95  deleteBitmaps();
96 
97  ClearCache();
98 }
void deinitSurface()
Destroy Cairo surfaces when are not needed anymore.
Definition: cairo_gal.cpp:1028
virtual void ClearCache() override
Delete all data created during caching of graphic items.
Definition: cairo_gal.cpp:745
void deleteBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:977

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

References KIGFX::GAL::layerDepth.

932  {
933  layerDepth -= 0.05;
934  }
double layerDepth
The actual layer depth.
void CAIRO_GAL::allocateBitmaps ( )
private

Allocate the bitmaps for drawing.

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

963 {
965  while( ( ( wxBufferWidth * 3 ) % 4 ) != 0 ) wxBufferWidth++;
966 
967  // Create buffer, use the system independent Cairo context backend
968  stride = cairo_format_stride_for_width( GAL_FORMAT, wxBufferWidth );
970 
971  bitmapBuffer = new unsigned int[bufferSize];
972  bitmapBufferBackup = new unsigned int[bufferSize];
973  wxOutput = new unsigned char[wxBufferWidth * 3 * screenSize.y];
974 }
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 115 of file cairo_gal.cpp.

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

116 {
117  initSurface();
118 
119  if( !validCompositor )
120  setCompositor();
121 
122  compositor->SetMainContext( context );
123  compositor->SetBuffer( mainBuffer );
124 }
void initSurface()
Prepare Cairo surfaces for drawing.
Definition: cairo_gal.cpp:985
void setCompositor()
Prepare the compositor.
Definition: cairo_gal.cpp:1041
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 583 of file cairo_gal.cpp.

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

584 {
585  initSurface();
586 
587  // If the grouping is started: the actual path is stored in the group, when
588  // a attribute was changed or when grouping stops with the end group method.
589  storePath();
590 
591  GROUP group;
592  int groupNumber = getNewGroupNumber();
593  groups.insert( std::make_pair( groupNumber, group ) );
594  currentGroup = &groups[groupNumber];
595  isGrouping = true;
596 
597  return groupNumber;
598 }
void initSurface()
Prepare Cairo surfaces for drawing.
Definition: cairo_gal.cpp:985
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:1114
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:882
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 323 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().

325  {
326  // Fallback: use stroke font
327 
328  // Handle flipped view
329  if( globalFlipX )
331 
332  StrokeText( aText, aPosition, aRotationAngle );
333 
334  if( globalFlipX )
336  }
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 944 of file cairo_gal.cpp.

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

Referenced by EndDrawing().

945 {
946  if( !IsCursorEnabled() )
947  return;
948 
949  auto p = ToScreen( cursorPosition );
950 
951  const auto cColor = getCursorColor();
952  const int cursorSize = fullscreenCursor ? 8000 : 80;
953 
954  wxColour color( cColor.r * cColor.a * 255, cColor.g * cColor.a * 255,
955  cColor.b * cColor.a * 255, 255 );
956  clientDC.SetPen( wxPen( color ) );
957  clientDC.DrawLine( p.x - cursorSize / 2, p.y, p.x + cursorSize / 2, p.y );
958  clientDC.DrawLine( p.x, p.y - cursorSize / 2, p.x, p.y + cursorSize / 2 );
959 }
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 700 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().

701 {
702  storePath();
703 
704  for( GROUP::iterator it = groups[aGroupNumber].begin();
705  it != groups[aGroupNumber].end(); ++it )
706  {
707  if( it->command == CMD_SET_FILLCOLOR || it->command == CMD_SET_STROKECOLOR )
708  {
709  it->argument.dblArg[0] = aNewColor.r;
710  it->argument.dblArg[1] = aNewColor.g;
711  it->argument.dblArg[2] = aNewColor.b;
712  it->argument.dblArg[3] = aNewColor.a;
713  }
714  }
715 }
double g
Green component.
Definition: color4d.h:282
double b
Blue component.
Definition: color4d.h:283
double a
Alpha component.
Definition: color4d.h:284
std::map< int, GROUP > groups
List of graphic groups.
Definition: cairo_gal.h:333
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:882
double r
Red component.
Definition: color4d.h:281
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 718 of file cairo_gal.cpp.

719 {
720  // Cairo does not have any possibilities to change the depth coordinate of stored items,
721  // it depends only on the order of drawing
722 }
void CAIRO_GAL::ClearCache ( )
overridevirtual

Delete all data created during caching of graphic items.

Reimplemented from KIGFX::GAL.

Definition at line 745 of file cairo_gal.cpp.

References DeleteGroup(), and groups.

Referenced by ~CAIRO_GAL().

746 {
747  for( int i = groups.size() - 1; i >= 0; --i )
748  {
749  DeleteGroup( i );
750  }
751 }
virtual void DeleteGroup(int aGroupNumber) override
Delete the group from the memory.
Definition: cairo_gal.cpp:725
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 369 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().

370 {
371  backgroundColor = aColor;
372  cairo_set_source_rgb( currentContext, aColor.r, aColor.g, aColor.b );
373  cairo_rectangle( currentContext, 0.0, 0.0, screenSize.x, screenSize.y );
374  cairo_fill( currentContext );
375 }
double g
Green component.
Definition: color4d.h:282
double b
Blue component.
Definition: color4d.h:283
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:281
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 819 of file cairo_gal.cpp.

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

820 {
821  // Save the current state
822  unsigned int currentBuffer = compositor->GetBuffer();
823 
824  switch( aTarget )
825  {
826  // Cached and noncached items are rendered to the same buffer
827  default:
828  case TARGET_CACHED:
829  case TARGET_NONCACHED:
830  compositor->SetBuffer( mainBuffer );
831  break;
832 
833  case TARGET_OVERLAY:
834  compositor->SetBuffer( overlayBuffer );
835  break;
836  }
837 
838  compositor->ClearBuffer();
839 
840  // Restore the previous state
841  compositor->SetBuffer( currentBuffer );
842 }
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 186 of file graphics_abstraction_layer.cpp.

References KIGFX::GAL::gridMinSpacing.

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

187 {
188  // just return the current value. This could be cleverer and take
189  // into account other settings in future
190  return gridMinSpacing;
191 }
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 1011 of file graphics_abstraction_layer.h.

References KIGFX::GAL::zoomFactor.

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

1012  {
1014  }
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 158 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().

159 {
161 
163 
164  MATRIX3x3D translation;
165  translation.SetIdentity();
166  translation.SetTranslation( 0.5 * VECTOR2D( screenSize ) );
167 
169  scale.SetIdentity();
170  scale.SetScale( VECTOR2D( worldScale, worldScale ) );
171 
172  MATRIX3x3D flip;
173 
174  flip.SetIdentity();
175  flip.SetScale( VECTOR2D( globalFlipX ? -1.0 : 1.0, globalFlipY ? -1.0 : 1.0 ) );
176 
177  MATRIX3x3D lookat;
178  lookat.SetIdentity();
179  lookat.SetTranslation( -lookAtPoint );
180 
181  worldScreenMatrix = translation * flip * scale * lookat * worldScreenMatrix;
182  screenWorldMatrix = worldScreenMatrix.Inverse();
183 }
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 1028 of file cairo_gal.cpp.

References context, isInitialized, and surface.

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

1029 {
1030  if( !isInitialized )
1031  return;
1032 
1033  // Destroy Cairo objects
1034  cairo_destroy( context );
1035  cairo_surface_destroy( surface );
1036 
1037  isInitialized = false;
1038 }
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 977 of file cairo_gal.cpp.

References bitmapBuffer, bitmapBufferBackup, and wxOutput.

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

978 {
979  delete[] bitmapBuffer;
980  delete[] bitmapBufferBackup;
981  delete[] wxOutput;
982 }
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 725 of file cairo_gal.cpp.

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

Referenced by ClearCache().

726 {
727  storePath();
728 
729  // Delete the Cairo paths
730  std::deque<GROUP_ELEMENT>::iterator it, end;
731 
732  for( it = groups[aGroupNumber].begin(), end = groups[aGroupNumber].end(); it != end; ++it )
733  {
734  if( it->command == CMD_FILL_PATH || it->command == CMD_STROKE_PATH )
735  {
736  cairo_path_destroy( it->cairoPath );
737  }
738  }
739 
740  // Delete the group
741  groups.erase( aGroupNumber );
742 }
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:882
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 225 of file cairo_gal.cpp.

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

227 {
228  SWAP( aStartAngle, >, aEndAngle );
229 
230  cairo_new_sub_path( currentContext );
231  cairo_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, aStartAngle, aEndAngle );
232 
233  if( isFillEnabled )
234  {
235  VECTOR2D startPoint( cos( aStartAngle ) * aRadius + aCenterPoint.x,
236  sin( aStartAngle ) * aRadius + aCenterPoint.y );
237  VECTOR2D endPoint( cos( aEndAngle ) * aRadius + aCenterPoint.x,
238  sin( aEndAngle ) * aRadius + aCenterPoint.y );
239 
240  cairo_move_to( currentContext, aCenterPoint.x, aCenterPoint.y );
241  cairo_line_to( currentContext, startPoint.x, startPoint.y );
242  cairo_line_to( currentContext, endPoint.x, endPoint.y );
243  cairo_close_path( currentContext );
244  }
245 
246  flushPath();
247 
248  isElementAdded = true;
249 }
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.

Reimplemented from KIGFX::GAL.

Definition at line 252 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, KIGFX::GAL::strokeColor, SWAP, VECTOR2< T >::x, and VECTOR2< T >::y.

254 {
255  SWAP( aStartAngle, >, aEndAngle );
256 
257  if( isFillEnabled )
258  {
259  cairo_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, aStartAngle, aEndAngle );
260  cairo_set_source_rgba( currentContext, fillColor.r, fillColor.g, fillColor.b, fillColor.a );
261  cairo_stroke( currentContext );
262  }
263  else
264  {
265  double width = aWidth / 2.0;
266  VECTOR2D startPoint( cos( aStartAngle ) * aRadius,
267  sin( aStartAngle ) * aRadius );
268  VECTOR2D endPoint( cos( aEndAngle ) * aRadius,
269  sin( aEndAngle ) * aRadius );
270 
271  cairo_save( currentContext );
272 
273  cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
274 
275  cairo_translate( currentContext, aCenterPoint.x, aCenterPoint.y );
276 
277  cairo_new_sub_path( currentContext );
278  cairo_arc( currentContext, 0, 0, aRadius - width, aStartAngle, aEndAngle );
279 
280  cairo_new_sub_path( currentContext );
281  cairo_arc( currentContext, 0, 0, aRadius + width, aStartAngle, aEndAngle );
282 
283  cairo_new_sub_path( currentContext );
284  cairo_arc_negative( currentContext, startPoint.x, startPoint.y, width, aStartAngle, aStartAngle + M_PI );
285 
286  cairo_new_sub_path( currentContext );
287  cairo_arc( currentContext, endPoint.x, endPoint.y, width, aEndAngle, aEndAngle + M_PI );
288 
289  cairo_restore( currentContext );
290  flushPath();
291  }
292 
293  isElementAdded = true;
294 }
double g
Green component.
Definition: color4d.h:282
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:283
double a
Alpha component.
Definition: color4d.h:284
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 ?
#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:281
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 216 of file cairo_gal.cpp.

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

217 {
218  cairo_new_sub_path( currentContext );
219  cairo_arc( currentContext, aCenterPoint.x, aCenterPoint.y, aRadius, 0.0, 2 * M_PI );
220  flushPath();
221  isElementAdded = true;
222 }
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 845 of file cairo_gal.cpp.

References KIGFX::GAL::cursorPosition.

846 {
847  cursorPosition = aCursorPosition;
848 }
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 322 of file cairo_gal.cpp.

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

324 {
325  cairo_move_to( currentContext, aStartPoint.x, aStartPoint.y );
326  cairo_curve_to( currentContext, aControlPointA.x, aControlPointA.y, aControlPointB.x,
327  aControlPointB.y, aEndPoint.x, aEndPoint.y );
328  cairo_line_to( currentContext, aEndPoint.x, aEndPoint.y );
329 
330  flushPath();
331  isElementAdded = true;
332 }
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 194 of file graphics_abstraction_layer.cpp.

References abs, 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().

195 {
197 
198  // Draw the grid
199  // For the drawing the start points, end points and increments have
200  // to be calculated in world coordinates
201  VECTOR2D worldStartPoint = screenWorldMatrix * VECTOR2D( 0.0, 0.0 );
202  VECTOR2D worldEndPoint = screenWorldMatrix * VECTOR2D( screenSize );
203 
204  const double gridThreshold = computeMinGridSpacing();
205 
206  int gridScreenSizeDense = KiROUND( gridSize.x * worldScale );
207  int gridScreenSizeCoarse = KiROUND( gridSize.x * static_cast<double>( gridTick ) * worldScale );
208 
209  // Compute the line marker or point radius of the grid
210  // Note: generic grids can't handle sub-pixel lines without
211  // either losing fine/course distinction or having some dots
212  // fail to render
213  double marker = std::max( 1.0, gridLineWidth ) / worldScale;
214  double doubleMarker = 2.0 * marker;
215 
216  // Draw axes if desired
217  if( axesEnabled )
218  {
219  SetIsFill( false );
220  SetIsStroke( true );
222  SetLineWidth( marker );
223 
224  drawGridLine( VECTOR2D( worldStartPoint.x, 0 ),
225  VECTOR2D( worldEndPoint.x, 0 ) );
226 
227  drawGridLine( VECTOR2D( 0, worldStartPoint.y ),
228  VECTOR2D( 0, worldEndPoint.y ) );
229  }
230 
231  if( !gridVisibility )
232  return;
233 
234  // Check if the grid would not be too dense
235  if( std::max( gridScreenSizeDense, gridScreenSizeCoarse ) <= gridThreshold )
236  return;
237 
238  // Compute grid variables
239  int gridStartX = KiROUND( worldStartPoint.x / gridSize.x );
240  int gridEndX = KiROUND( worldEndPoint.x / gridSize.x );
241  int gridStartY = KiROUND( worldStartPoint.y / gridSize.y );
242  int gridEndY = KiROUND( worldEndPoint.y / gridSize.y );
243 
244  // Correct the index, else some lines are not correctly painted
245  gridStartY -= std::abs( gridOrigin.y / gridSize.y ) + 1;
246  gridEndY -= std::abs( gridOrigin.y / gridSize.y ) - 1;
247 
248  gridStartX -= std::abs( gridOrigin.x / gridSize.x ) + 1;
249  gridEndX -= std::abs( gridOrigin.x / gridSize.x ) - 1;
250 
251  int dirX = gridEndX >= gridStartX ? 1 : -1;
252  int dirY = gridEndY >= gridStartY ? 1 : -1;
253 
254  // Draw the grid behind all other layers
255  SetLayerDepth( depthRange.y * 0.75 );
256 
258  {
259  SetIsFill( false );
260  SetIsStroke( true );
262 
263  // Now draw the grid, every coarse grid line gets the double width
264 
265  // Vertical lines
266  for( int j = gridStartY; j != gridEndY; j += dirY )
267  {
268  const double y = j * gridSize.y + gridOrigin.y;
269 
270  if( axesEnabled && y == 0 )
271  continue;
272 
273  if( j % gridTick == 0 && gridScreenSizeDense > gridThreshold )
274  SetLineWidth( doubleMarker );
275  else
276  SetLineWidth( marker );
277 
278  if( ( j % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
279  || gridScreenSizeDense > gridThreshold )
280  {
281  drawGridLine( VECTOR2D( gridStartX * gridSize.x + gridOrigin.x, y ),
282  VECTOR2D( gridEndX * gridSize.x + gridOrigin.x, y ) );
283  }
284  }
285 
286  // Horizontal lines
287  for( int i = gridStartX; i != gridEndX; i += dirX )
288  {
289  const double x = i * gridSize.x + gridOrigin.x;
290 
291  if( axesEnabled && x == 0 )
292  continue;
293 
294  if( i % gridTick == 0 && gridScreenSizeDense > gridThreshold )
295  SetLineWidth( doubleMarker );
296  else
297  SetLineWidth( marker );
298 
299  if( ( i % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
300  || gridScreenSizeDense > gridThreshold )
301  {
302  drawGridLine( VECTOR2D( x, gridStartY * gridSize.y + gridOrigin.y ),
303  VECTOR2D( x, gridEndY * gridSize.y + gridOrigin.y ) );
304  }
305  }
306  }
307  else if( gridStyle == GRID_STYLE::SMALL_CROSS )
308  {
309  SetIsFill( false );
310  SetIsStroke( true );
312 
313  SetLineWidth( marker );
314  double lineLen = GetLineWidth() * 2;
315 
316  // Vertical positions:
317  for( int j = gridStartY; j != gridEndY; j += dirY )
318  {
319  if( ( j % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
320  || gridScreenSizeDense > gridThreshold )
321  {
322  int posY = j * gridSize.y + gridOrigin.y;
323 
324  // Horizontal positions:
325  for( int i = gridStartX; i != gridEndX; i += dirX )
326  {
327  if( ( i % gridTick == 0 && gridScreenSizeCoarse > gridThreshold )
328  || gridScreenSizeDense > gridThreshold )
329  {
330  int posX = i * gridSize.x + gridOrigin.x;
331 
332  drawGridLine( VECTOR2D( posX - lineLen, posY ),
333  VECTOR2D( posX + lineLen, posY ) );
334 
335  drawGridLine( VECTOR2D( posX, posY - lineLen ),
336  VECTOR2D( posX, posY + lineLen ) );
337  }
338  }
339  }
340  }
341  }
342  else // Dotted grid
343  {
344  bool tickX, tickY;
345  SetIsFill( true );
346  SetIsStroke( false );
348 
349  for( int j = gridStartY; j != gridEndY; j += dirY )
350  {
351  if( j % gridTick == 0 && gridScreenSizeDense > gridThreshold )
352  tickY = true;
353  else
354  tickY = false;
355 
356  for( int i = gridStartX; i != gridEndX; i += dirX )
357  {
358  if( i % gridTick == 0 && gridScreenSizeDense > gridThreshold )
359  tickX = true;
360  else
361  tickX = false;
362 
363  if( tickX || tickY || gridScreenSizeDense > gridThreshold )
364  {
365  double radius = ( ( tickX && tickY ) ? doubleMarker : marker ) / 2.0;
366  DrawRectangle( VECTOR2D( i * gridSize.x - radius + gridOrigin.x,
367  j * gridSize.y - radius + gridOrigin.y ),
368  VECTOR2D( i * gridSize.x + radius + gridOrigin.x,
369  j * gridSize.y + radius + gridOrigin.y ) );
370  }
371  }
372  }
373  }
374 }
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.
#define abs(a)
Definition: auxiliary.h:84
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 851 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.

852 {
853  cairo_move_to( currentContext, aStartPoint.x, aStartPoint.y );
854  cairo_line_to( currentContext, aEndPoint.x, aEndPoint.y );
855  cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
856  cairo_stroke( currentContext );
857 }
double g
Green component.
Definition: color4d.h:282
double b
Blue component.
Definition: color4d.h:283
double a
Alpha component.
Definition: color4d.h:284
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:281
void CAIRO_GAL::DrawGroup ( int  aGroupNumber)
overridevirtual

Draw the stored group.

Parameters
aGroupNumberis the group number.

Reimplemented from KIGFX::GAL.

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

611 {
612  // This method implements a small Virtual Machine - all stored commands
613  // are executed; nested calling is also possible
614 
615  storePath();
616 
617  for( GROUP::iterator it = groups[aGroupNumber].begin();
618  it != groups[aGroupNumber].end(); ++it )
619  {
620  switch( it->command )
621  {
622  case CMD_SET_FILL:
623  isFillEnabled = it->argument.boolArg;
624  break;
625 
626  case CMD_SET_STROKE:
627  isStrokeEnabled = it->argument.boolArg;
628  break;
629 
630  case CMD_SET_FILLCOLOR:
631  fillColor = COLOR4D( it->argument.dblArg[0], it->argument.dblArg[1], it->argument.dblArg[2],
632  it->argument.dblArg[3] );
633  break;
634 
635  case CMD_SET_STROKECOLOR:
636  strokeColor = COLOR4D( it->argument.dblArg[0], it->argument.dblArg[1], it->argument.dblArg[2],
637  it->argument.dblArg[3] );
638  break;
639 
640  case CMD_SET_LINE_WIDTH:
641  {
642  // Make lines appear at least 1 pixel wide, no matter of zoom
643  double x = 1.0, y = 1.0;
644  cairo_device_to_user_distance( currentContext, &x, &y );
645  double minWidth = std::min( fabs( x ), fabs( y ) );
646  cairo_set_line_width( currentContext, std::max( it->argument.dblArg[0], minWidth ) );
647  }
648  break;
649 
650 
651  case CMD_STROKE_PATH:
652  cairo_set_source_rgb( currentContext, strokeColor.r, strokeColor.g, strokeColor.b );
653  cairo_append_path( currentContext, it->cairoPath );
654  cairo_stroke( currentContext );
655  break;
656 
657  case CMD_FILL_PATH:
658  cairo_set_source_rgb( currentContext, fillColor.r, fillColor.g, fillColor.b );
659  cairo_append_path( currentContext, it->cairoPath );
660  cairo_fill( currentContext );
661  break;
662 
663  /*
664  case CMD_TRANSFORM:
665  cairo_matrix_t matrix;
666  cairo_matrix_init( &matrix, it->argument.dblArg[0], it->argument.dblArg[1], it->argument.dblArg[2],
667  it->argument.dblArg[3], it->argument.dblArg[4], it->argument.dblArg[5] );
668  cairo_transform( currentContext, &matrix );
669  break;
670  */
671 
672  case CMD_ROTATE:
673  cairo_rotate( currentContext, it->argument.dblArg[0] );
674  break;
675 
676  case CMD_TRANSLATE:
677  cairo_translate( currentContext, it->argument.dblArg[0], it->argument.dblArg[1] );
678  break;
679 
680  case CMD_SCALE:
681  cairo_scale( currentContext, it->argument.dblArg[0], it->argument.dblArg[1] );
682  break;
683 
684  case CMD_SAVE:
685  cairo_save( currentContext );
686  break;
687 
688  case CMD_RESTORE:
689  cairo_restore( currentContext );
690  break;
691 
692  case CMD_CALL_GROUP:
693  DrawGroup( it->argument.intArg );
694  break;
695  }
696  }
697 }
Scale the context.
Definition: cairo_gal.h:311
double g
Green component.
Definition: color4d.h:282
COLOR4D fillColor
The fill color.
Set the stroke path.
Definition: cairo_gal.h:306
double b
Blue component.
Definition: color4d.h:283
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:882
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:610
cairo_t * currentContext
Currently used Cairo context for drawing.
Definition: cairo_gal.h:339
double r
Red component.
Definition: color4d.h:281
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 163 of file cairo_gal.cpp.

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

164 {
165  cairo_move_to( currentContext, aStartPoint.x, aStartPoint.y );
166  cairo_line_to( currentContext, aEndPoint.x, aEndPoint.y );
167  flushPath();
168  isElementAdded = true;
169 }
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 1055 of file cairo_gal.cpp.

References currentContext, flushPath(), and isElementAdded.

Referenced by DrawPolygon(), and DrawPolyline().

1056 {
1057  // Iterate over the point list and draw the segments
1058  std::deque<VECTOR2D>::const_iterator it = aPointList.begin();
1059 
1060  cairo_move_to( currentContext, it->x, it->y );
1061 
1062  for( ++it; it != aPointList.end(); ++it )
1063  {
1064  cairo_line_to( currentContext, it->x, it->y );
1065  }
1066 
1067  flushPath();
1068  isElementAdded = true;
1069 }
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 1072 of file cairo_gal.cpp.

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

1073 {
1074  // Iterate over the point list and draw the segments
1075  const VECTOR2D* ptr = aPointList;
1076 
1077  cairo_move_to( currentContext, ptr->x, ptr->y );
1078 
1079  for( int i = 0; i < aListSize; ++i )
1080  {
1081  ++ptr;
1082  cairo_line_to( currentContext, ptr->x, ptr->y );
1083  }
1084 
1085  flushPath();
1086  isElementAdded = true;
1087 }
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 1090 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.

1091 {
1092  if( aLineChain.PointCount() < 2 )
1093  return;
1094 
1095  auto numPoints = aLineChain.PointCount();
1096 
1097  if( aLineChain.IsClosed() )
1098  numPoints += 1;
1099 
1100  const VECTOR2I start = aLineChain.CPoint( 0 );
1101  cairo_move_to( currentContext, start.x, start.y );
1102 
1103  for( int i = 1; i < numPoints; ++i )
1104  {
1105  const VECTOR2I& p = aLineChain.CPoint( i );
1106  cairo_line_to( currentContext, p.x, p.y );
1107  }
1108 
1109  flushPath();
1110  isElementAdded = true;
1111 }
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:1055
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:1055
void CAIRO_GAL::DrawPolygon ( const SHAPE_POLY_SET aPolySet)
overridevirtual

Reimplemented from KIGFX::GAL.

Definition at line 315 of file cairo_gal.cpp.

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

316 {
317  for( int i = 0; i < aPolySet.OutlineCount(); ++i )
318  drawPoly( aPolySet.COutline( i ) );
319 }
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:1055
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:1055
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:1055
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:1055
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 297 of file cairo_gal.cpp.

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

298 {
299  // Calculate the diagonal points
300  VECTOR2D diagonalPointA( aEndPoint.x, aStartPoint.y );
301  VECTOR2D diagonalPointB( aStartPoint.x, aEndPoint.y );
302 
303  // The path is composed from 4 segments
304  cairo_move_to( currentContext, aStartPoint.x, aStartPoint.y );
305  cairo_line_to( currentContext, diagonalPointA.x, diagonalPointA.y );
306  cairo_line_to( currentContext, aEndPoint.x, aEndPoint.y );
307  cairo_line_to( currentContext, diagonalPointB.x, diagonalPointB.y );
308  cairo_close_path( currentContext );
309  flushPath();
310 
311  isElementAdded = true;
312 }
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 172 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.

174 {
175  if( isFillEnabled )
176  {
177  // Filled tracks mode
178  SetLineWidth( aWidth );
179 
180  cairo_move_to( currentContext, (double) aStartPoint.x, (double) aStartPoint.y );
181  cairo_line_to( currentContext, (double) aEndPoint.x, (double) aEndPoint.y );
182  cairo_set_source_rgba( currentContext, fillColor.r, fillColor.g, fillColor.b, fillColor.a );
183  cairo_stroke( currentContext );
184  }
185  else
186  {
187  // Outline mode for tracks
188  VECTOR2D startEndVector = aEndPoint - aStartPoint;
189  double lineAngle = atan2( startEndVector.y, startEndVector.x );
190  double lineLength = startEndVector.EuclideanNorm();
191 
192  cairo_save( currentContext );
193 
194  cairo_set_source_rgba( currentContext, strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
195 
196  cairo_translate( currentContext, aStartPoint.x, aStartPoint.y );
197  cairo_rotate( currentContext, lineAngle );
198 
199  cairo_arc( currentContext, 0.0, 0.0, aWidth / 2.0, M_PI / 2.0, 3.0 * M_PI / 2.0 );
200  cairo_arc( currentContext, lineLength, 0.0, aWidth / 2.0, -M_PI / 2.0, M_PI / 2.0 );
201 
202  cairo_move_to( currentContext, 0.0, aWidth / 2.0 );
203  cairo_line_to( currentContext, lineLength, aWidth / 2.0 );
204 
205  cairo_move_to( currentContext, 0.0, -aWidth / 2.0 );
206  cairo_line_to( currentContext, lineLength, -aWidth / 2.0 );
207 
208  cairo_restore( currentContext );
209  flushPath();
210  }
211 
212  isElementAdded = true;
213 }
double g
Green component.
Definition: color4d.h:282
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:283
double a
Alpha component.
Definition: color4d.h:284
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:444
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:281
void CAIRO_GAL::EndDrawing ( )
overridevirtual

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

Reimplemented from KIGFX::GAL.

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

128 {
129  // Force remaining objects to be drawn
130  Flush();
131 
132  // Merge buffers on the screen
133  compositor->DrawBuffer( mainBuffer );
134  compositor->DrawBuffer( overlayBuffer );
135 
136  // Now translate the raw context data from the format stored
137  // by cairo into a format understood by wxImage.
138  pixman_image_t* dstImg = pixman_image_create_bits(PIXMAN_r8g8b8,
139  screenSize.x, screenSize.y, (uint32_t*)wxOutput, wxBufferWidth * 3 );
140  pixman_image_t* srcImg = pixman_image_create_bits(PIXMAN_a8b8g8r8,
141  screenSize.x, screenSize.y, (uint32_t*)bitmapBuffer, wxBufferWidth * 4 );
142 
143  pixman_image_composite (PIXMAN_OP_SRC, srcImg, NULL, dstImg,
144  0, 0, 0, 0, 0, 0, screenSize.x, screenSize.y );
145 
146  // Free allocated memory
147  pixman_image_unref( srcImg );
148  pixman_image_unref( dstImg );
149 
150  wxImage img( wxBufferWidth, screenSize.y, (unsigned char*) wxOutput, true );
151  wxBitmap bmp( img );
152  wxMemoryDC mdc( bmp );
153  wxClientDC clientDC( this );
154 
155  // Now it is the time to blit the mouse cursor
156  blitCursor( mdc );
157  clientDC.Blit( 0, 0, screenSize.x, screenSize.y, &mdc, 0, 0, wxCOPY );
158 
159  deinitSurface();
160 }
void deinitSurface()
Destroy Cairo surfaces when are not needed anymore.
Definition: cairo_gal.cpp:1028
virtual void Flush() override
Force all remaining objects to be drawn.
Definition: cairo_gal.cpp:363
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:944
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 601 of file cairo_gal.cpp.

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

602 {
603  storePath();
604  isGrouping = false;
605 
606  deinitSurface();
607 }
void deinitSurface()
Destroy Cairo surfaces when are not needed anymore.
Definition: cairo_gal.cpp:1028
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:330
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:882
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 363 of file cairo_gal.cpp.

References storePath().

Referenced by EndDrawing().

364 {
365  storePath();
366 }
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:882
void CAIRO_GAL::flushPath ( )
private

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

861 {
862  if( isFillEnabled )
863  {
864  cairo_set_source_rgba( currentContext,
866 
867  if( isStrokeEnabled )
868  cairo_fill_preserve( currentContext );
869  else
870  cairo_fill( currentContext );
871  }
872 
873  if( isStrokeEnabled )
874  {
875  cairo_set_source_rgba( currentContext,
877  cairo_stroke( currentContext );
878  }
879 }
double g
Green component.
Definition: color4d.h:282
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:283
double a
Alpha component.
Definition: color4d.h:284
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:281
COLOR4D GAL::getCursorColor ( ) const
protectedinherited

Gets the actual cursor color to draw.

Definition at line 388 of file graphics_abstraction_layer.cpp.

References KIGFX::COLOR4D::a, KIGFX::GAL::cursorColor, and KIGFX::GAL::isCursorEnabled.

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

389 {
390  auto color = cursorColor;
391 
392  // dim the cursor if it's only on because it was forced
393  // (this helps to provide a hint for active tools)
394  if( !isCursorEnabled )
395  {
396  color.a = color.a * 0.5;
397  }
398 
399  return color;
400 }
bool isCursorEnabled
Is the cursor enabled?
double a
Alpha component.
Definition: color4d.h:284
COLOR4D cursorColor
Cursor color.
double KIGFX::GAL::GetGridLineWidth ( ) const
inlineinherited

Get the grid line width.

Returns
the grid line width

Definition at line 852 of file graphics_abstraction_layer.h.

References KIGFX::GAL::gridLineWidth.

853  {
854  return gridLineWidth;
855  }
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 377 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().

378 {
379  return VECTOR2D( KiROUND( ( aPoint.x - gridOffset.x ) / gridSize.x ) * gridSize.x + gridOffset.x,
380  KiROUND( ( aPoint.y - gridOffset.y ) / gridSize.y ) * gridSize.y + gridOffset.y );
381 }
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 804 of file graphics_abstraction_layer.h.

References KIGFX::GAL::gridSize.

805  {
806  return gridSize;
807  }
VECTOR2D gridSize
The grid size.
EDA_TEXT_HJUSTIFY_T KIGFX::GAL::GetHorizontalJustify ( ) const
inlineinherited

Returns current text horizontal justification setting.

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

450  {
452  }
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 644 of file graphics_abstraction_layer.h.

References KIGFX::GAL::lookAtPoint.

645  {
646  return lookAtPoint;
647  }
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 693 of file graphics_abstraction_layer.h.

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

694  {
695  return depthRange.y;
696  }
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 685 of file graphics_abstraction_layer.h.

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

686  {
687  return depthRange.x;
688  }
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 1114 of file cairo_gal.cpp.

References groupCounter, groups, and max.

Referenced by BeginGroup().

1115 {
1116  wxASSERT_MSG( groups.size() < std::numeric_limits<unsigned int>::max(),
1117  wxT( "There are no free slots to store a group" ) );
1118 
1119  while( groups.find( groupCounter ) != groups.end() )
1120  groupCounter++;
1121 
1122  return groupCounter++;
1123 }
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 352 of file graphics_abstraction_layer.h.

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

353  {
355  }
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 585 of file graphics_abstraction_layer.h.

References KIGFX::GAL::screenWorldMatrix.

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

586  {
587  return screenWorldMatrix;
588  }
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 255 of file graphics_abstraction_layer.h.

References KIGFX::GAL::strokeColor.

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

Definition at line 297 of file graphics_abstraction_layer.h.

References KIGFX::GAL::strokeFont.

Referenced by EDA_TEXT::GetTextBox().

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

References currentTarget.

814 {
815  return currentTarget;
816 }
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 149 of file graphics_abstraction_layer.cpp.

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

Referenced by GraphicTextWidth(), and EDA_TEXT::LenSize().

150 {
151  // Compute the X and Y size of a given text.
152  // Because computeTextLineSize expects a one line text,
153  // aText is expected to be only one line text.
154  return strokeFont.computeTextLineSize( aText );
155 }
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 467 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().

468  {
470  }
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 575 of file graphics_abstraction_layer.h.

References KIGFX::GAL::worldScreenMatrix.

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

576  {
577  return worldScreenMatrix;
578  }
MATRIX3x3D worldScreenMatrix
World transformation.
double KIGFX::GAL::GetZoomFactor ( ) const
inlineinherited

Get the zoom factor.

Returns
the zoom factor.

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

665  {
666  return zoomFactor;
667  }
double zoomFactor
The zoom factor.
void CAIRO_GAL::initSurface ( )
private

Prepare Cairo surfaces for drawing.

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

986 {
987  if( isInitialized )
988  return;
989 
990  // Create the Cairo surface
991  surface = cairo_image_surface_create_for_data( (unsigned char*) bitmapBuffer, GAL_FORMAT,
993  context = cairo_create( surface );
994 #ifdef __WXDEBUG__
995  cairo_status_t status = cairo_status( context );
996  wxASSERT_MSG( status == CAIRO_STATUS_SUCCESS, wxT( "Cairo context creation error" ) );
997 #endif /* __WXDEBUG__ */
999 
1000  cairo_set_antialias( context, CAIRO_ANTIALIAS_NONE );
1001 
1002  // Clear the screen
1004 
1005  // Compute the world <-> screen transformations
1007 
1008  cairo_matrix_init( &cairoWorldScreenMatrix, worldScreenMatrix.m_data[0][0],
1011  worldScreenMatrix.m_data[1][2] );
1012 
1013  cairo_set_matrix( context, &cairoWorldScreenMatrix );
1014 
1015  // Start drawing with a new path
1016  cairo_new_path( context );
1017  isElementAdded = true;
1018 
1019  cairo_set_line_join( context, CAIRO_LINE_JOIN_ROUND );
1020  cairo_set_line_cap( context, CAIRO_LINE_CAP_ROUND );
1021 
1022  lineWidth = 0;
1023 
1024  isInitialized = true;
1025 }
virtual void ClearScreen(const COLOR4D &aColor) override
Clear the screen.
Definition: cairo_gal.cpp:369
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 905 of file graphics_abstraction_layer.h.

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

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

906  {
908  }
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 395 of file graphics_abstraction_layer.h.

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

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

396  {
397  return textProperties.m_bold;
398  }
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
bool KIGFX::GAL::IsFontItalic ( ) const
inlineinherited

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

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

414  {
415  return textProperties.m_italic;
416  }
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 431 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().

432  {
433  return textProperties.m_mirrored;
434  }
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 84 of file graphics_abstraction_layer.cpp.

References KIGFX::GAL::updatedGalDisplayOptions().

85 {
86  // defer to the child class first
87  updatedGalDisplayOptions( aOptions );
88 
89  // there is no refresh to do at this level
90 }
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 930 of file cairo_gal.cpp.

References PostPaint().

Referenced by CAIRO_GAL().

931 {
932  PostPaint();
933 }
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 947 of file graphics_abstraction_layer.h.

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

948  {
949  layerDepth = depthStack.top();
950  depthStack.pop();
951  }
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 939 of file graphics_abstraction_layer.h.

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

940  {
941  depthStack.push( layerDepth );
942  }
double layerDepth
The actual layer depth.
std::stack< double > depthStack
Stored depth values.
void CAIRO_GAL::ResizeScreen ( int  aWidth,
int  aHeight 
)
overridevirtual

Resizes the canvas.

Reimplemented from KIGFX::GAL.

Definition at line 335 of file cairo_gal.cpp.

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

336 {
337  screenSize = VECTOR2I( aWidth, aHeight );
338 
339  // Recreate the bitmaps
340  deleteBitmaps();
341  allocateBitmaps();
342 
343  if( validCompositor )
344  compositor->Resize( aWidth, aHeight );
345 
346  validCompositor = false;
347 
348  SetSize( wxSize( aWidth, aHeight ) );
349 }
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:977
void allocateBitmaps()
Allocate the bitmaps for drawing.
Definition: cairo_gal.cpp:962
void CAIRO_GAL::Restore ( )
overridevirtual

Restore the context.

Reimplemented from KIGFX::GAL.

Definition at line 566 of file cairo_gal.cpp.

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

567 {
568  storePath();
569 
570  if( isGrouping )
571  {
572  GROUP_ELEMENT groupElement;
573  groupElement.command = CMD_RESTORE;
574  currentGroup->push_back( groupElement );
575  }
576  else
577  {
578  cairo_restore( currentContext );
579  }
580 }
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:882
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 770 of file cairo_gal.cpp.

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

771 {
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  bitmapBuffer[offset + i] = bitmapBufferBackup[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::Rotate ( double  aAngle)
overridevirtual

Rotate the context.

Parameters
aAngleis the rotation angle in radians.

Reimplemented from KIGFX::GAL.

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

494 {
495  storePath();
496 
497  if( isGrouping )
498  {
499  GROUP_ELEMENT groupElement;
500  groupElement.command = CMD_ROTATE;
501  groupElement.argument.dblArg[0] = aAngle;
502  currentGroup->push_back( groupElement );
503  }
504  else
505  {
506  cairo_rotate( currentContext, aAngle );
507  }
508 }
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:882
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 549 of file cairo_gal.cpp.

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

550 {
551  storePath();
552 
553  if( isGrouping )
554  {
555  GROUP_ELEMENT groupElement;
556  groupElement.command = CMD_SAVE;
557  currentGroup->push_back( groupElement );
558  }
559  else
560  {
561  cairo_save( currentContext );
562  }
563 }
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:882
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 754 of file cairo_gal.cpp.

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

755 {
756  // Copy the current bitmap to the backup buffer
757  int offset = 0;
758 
759  for( int j = 0; j < screenSize.y; j++ )
760  {
761  for( int i = 0; i < stride; i++ )
762  {
763  bitmapBufferBackup[offset + i] = bitmapBuffer[offset + i];
764  offset += stride;
765  }
766  }
767 }
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 530 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.

531 {
532  storePath();
533 
534  if( isGrouping )
535  {
536  GROUP_ELEMENT groupElement;
537  groupElement.command = CMD_SCALE;
538  groupElement.argument.dblArg[0] = aScale.x;
539  groupElement.argument.dblArg[1] = aScale.y;
540  currentGroup->push_back( groupElement );
541  }
542  else
543  {
544  cairo_scale( currentContext, aScale.x, aScale.y );
545  }
546 }
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:882
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 824 of file graphics_abstraction_layer.h.

References KIGFX::GAL::axesColor.

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

825  {
826  axesColor = aAxesColor;
827  }
COLOR4D axesColor
Color of the axes.
void KIGFX::GAL::SetAxesEnabled ( bool  aAxesEnabled)
inlineinherited

Enables drawing the axes.

Definition at line 832 of file graphics_abstraction_layer.h.

References KIGFX::GAL::axesEnabled.

833  {
834  axesEnabled = aAxesEnabled;
835  }
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 842 of file graphics_abstraction_layer.h.

References KIGFX::GAL::gridTick.

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

843  {
844  gridTick = aInterval;
845  }
int gridTick
Every tick line gets the double width.
void CAIRO_GAL::setCompositor ( )
private

Prepare the compositor.

Definition at line 1041 of file cairo_gal.cpp.

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

Referenced by BeginDrawing().

1042 {
1043  // Recreate the compositor with the new Cairo context
1044  compositor.reset( new CAIRO_COMPOSITOR( &currentContext ) );
1045  compositor->Resize( screenSize.x, screenSize.y );
1046 
1047  // Prepare buffers
1048  mainBuffer = compositor->CreateBuffer();
1049  overlayBuffer = compositor->CreateBuffer();
1050 
1051  validCompositor = true;
1052 }
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 915 of file graphics_abstraction_layer.h.

References KIGFX::GAL::cursorColor.

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

916  {
917  cursorColor = aCursorColor;
918  }
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 896 of file graphics_abstraction_layer.h.

References KIGFX::GAL::isCursorEnabled.

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

897  {
898  isCursorEnabled = aCursorEnabled;
899  }
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 677 of file graphics_abstraction_layer.h.

References KIGFX::GAL::depthRange.

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

678  {
679  depthRange = aDepthRange;
680  }
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 426 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().

427 {
428  storePath();
429  fillColor = aColor;
430 
431  if( isGrouping )
432  {
433  GROUP_ELEMENT groupElement;
434  groupElement.command = CMD_SET_FILLCOLOR;
435  groupElement.argument.dblArg[0] = fillColor.r;
436  groupElement.argument.dblArg[1] = fillColor.g;
437  groupElement.argument.dblArg[2] = fillColor.b;
438  groupElement.argument.dblArg[3] = fillColor.a;
439  currentGroup->push_back( groupElement );
440  }
441 }
double g
Green component.
Definition: color4d.h:282
COLOR4D fillColor
The fill color.
double b
Blue component.
Definition: color4d.h:283
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:335
double a
Alpha component.
Definition: color4d.h:284
bool isGrouping
Is grouping enabled ?
Definition: cairo_gal.h:330
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:882
double r
Red component.
Definition: color4d.h:281
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 714 of file graphics_abstraction_layer.h.

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

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

715  {
716  globalFlipX = xAxis;
717  globalFlipY = yAxis;
718  }
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 387 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(), and KIGFX::GAL::SetTextAttributes().

388  {
389  textProperties.m_bold = aBold;
390  }
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 405 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(), and KIGFX::GAL::SetTextAttributes().

406  {
407  textProperties.m_italic = aItalic;
408  }
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 369 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::PREVIEW::SetConstantGlyphHeight(), and KIGFX::GAL::SetTextAttributes().

370  {
371  textProperties.m_glyphSize = aGlyphSize;
372  }
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 814 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().

815  {
816  gridColor = aGridColor;
817  }
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 775 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().

776  {
777  gridOrigin = aGridOrigin;
778 
779  if( gridSize.x == 0.0 || gridSize.y == 0.0 )
780  gridOffset = VECTOR2D(0.0, 0.0);
781  else
782  gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
783  (long) gridOrigin.y % (long) gridSize.y );
784  }
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 791 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().

792  {
793  gridSize = aGridSize;
794 
795  gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
796  (long) gridOrigin.y % (long) gridSize.y );
797  }
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 765 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().

766  {
767  gridVisibility = aVisibility;
768  }
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 441 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(), and KIGFX::GAL::SetTextAttributes().

442  {
443  textProperties.m_horizontalJustify = aHorizontalJustify;
444  }
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 378 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().

379 {
380  storePath();
381  isFillEnabled = aIsFillEnabled;
382 
383  if( isGrouping )
384  {
385  GROUP_ELEMENT groupElement;
386  groupElement.command = CMD_SET_FILL;
387  groupElement.argument.boolArg = aIsFillEnabled;
388  currentGroup->push_back( groupElement );
389  }
390 }
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:882
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 393 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().

394 {
395  storePath();
396  isStrokeEnabled = aIsStrokeEnabled;
397 
398  if( isGrouping )
399  {
400  GROUP_ELEMENT groupElement;
401  groupElement.command = CMD_SET_STROKE;
402  groupElement.argument.boolArg = aIsStrokeEnabled;
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
bool isStrokeEnabled
Are the outlines stroked ?
Enable/disable stroking.
Definition: cairo_gal.h:302
void storePath()
Store the actual path.
Definition: cairo_gal.cpp:882
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 468 of file cairo_gal.cpp.

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

469 {
470  super::SetLayerDepth( aLayerDepth );
471 
472  if( isInitialized )
473  storePath();
474 }
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:882
void CAIRO_GAL::SetLineWidth ( double  aLineWidth)
overridevirtual

Set the line width.

Parameters
aLineWidthis the line width.

Reimplemented from KIGFX::GAL.

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

445 {
446  storePath();
447 
448  lineWidth = aLineWidth;
449 
450  if( isGrouping )
451  {
452  GROUP_ELEMENT groupElement;
453  groupElement.command = CMD_SET_LINE_WIDTH;
454  groupElement.argument.dblArg[0] = aLineWidth;
455  currentGroup->push_back( groupElement );
456  }
457  else
458  {
459  // Make lines appear at least 1 pixel wide, no matter of zoom
460  double x = 1.0, y = 1.0;
461  cairo_device_to_user_distance( currentContext, &x, &y );
462  double minWidth = std::min( fabs( x ), fabs( y ) );
463  cairo_set_line_width( currentContext, std::max( aLineWidth, minWidth ) );
464  }
465 }
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:882
#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 634 of file graphics_abstraction_layer.h.

References KIGFX::GAL::lookAtPoint.

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

635  {
636  lookAtPoint = aPoint;
637  }
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 622 of file graphics_abstraction_layer.h.

References KIGFX::GAL::screenDPI.

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

623  {
624  screenDPI = aScreenDPI;
625  }
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 408 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.

409 {
410  storePath();
411  strokeColor = aColor;
412 
413  if( isGrouping )
414  {
415  GROUP_ELEMENT groupElement;
416  groupElement.command = CMD_SET_STROKECOLOR;
417  groupElement.argument.dblArg[0] = strokeColor.r;
418  groupElement.argument.dblArg[1] = strokeColor.g;
419  groupElement.argument.dblArg[2] = strokeColor.b;
420  groupElement.argument.dblArg[3] = strokeColor.a;
421  currentGroup->push_back( groupElement );
422  }
423 }
double g
Green component.
Definition: color4d.h:282
double b
Blue component.
Definition: color4d.h:283
GROUP * currentGroup
Currently used group.
Definition: cairo_gal.h:335
double a
Alpha component.
Definition: color4d.h:284
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:882
double r
Red component.
Definition: color4d.h:281
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 785 of file cairo_gal.cpp.

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

786 {
787  // If the compositor is not set, that means that there is a recaching process going on
788  // and we do not need the compositor now
789  if( !validCompositor )
790  return;
791 
792  // Cairo grouping prevents display of overlapping items on the same layer in the lighter color
793  if( isInitialized )
794  storePath();
795 
796  switch( aTarget )
797  {
798  default:
799  case TARGET_CACHED:
800  case TARGET_NONCACHED:
801  compositor->SetBuffer( mainBuffer );
802  break;
803 
804  case TARGET_OVERLAY:
805  compositor->SetBuffer( overlayBuffer );
806  break;
807  }
808 
809  currentTarget = aTarget;
810 }
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:882
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 138 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().

139 {
140  SetGlyphSize( VECTOR2D( aText->GetTextSize() ) );
143  SetFontBold( aText->IsBold() );
144  SetFontItalic( aText->IsItalic() );
145  SetTextMirrored( aText->IsMirrored() );
146 }
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 423 of file graphics_abstraction_layer.h.

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

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

424  {
425  textProperties.m_mirrored = aMirrored;
426  }
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 459 of file graphics_abstraction_layer.h.

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

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

460  {
461  textProperties.m_verticalJustify = aVerticalJustify;
462  }
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 595 of file graphics_abstraction_layer.h.

References KIGFX::GAL::worldScreenMatrix.

596  {
597  worldScreenMatrix = aMatrix;
598  }
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 609 of file graphics_abstraction_layer.h.

References KIGFX::GAL::worldUnitLength.

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

610  {
611  worldUnitLength = aWorldUnitLength;
612  }
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 654 of file graphics_abstraction_layer.h.

References KIGFX::GAL::zoomFactor.

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

655  {
656  zoomFactor = aZoomFactor;
657  }
double zoomFactor
The zoom factor.
bool CAIRO_GAL::Show ( bool  aShow)
overridevirtual

Shows/hides the GAL canvas.

Reimplemented from KIGFX::GAL.

Definition at line 352 of file cairo_gal.cpp.

353 {
354  bool s = wxWindow::Show( aShow );
355 
356  if( aShow )
357  wxWindow::Raise();
358 
359  return s;
360 }
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 936 of file cairo_gal.cpp.

References mouseListener.

Referenced by CAIRO_GAL().

937 {
938  // Post the mouse event to the event listener registered in constructor, if any
939  if( mouseListener )
940  wxPostEvent( mouseListener, aEvent );
941 }
wxEvtHandler * mouseListener
Mouse listener.
Definition: cairo_gal.h:290
void CAIRO_GAL::storePath ( )
private

Store the actual path.

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

883 {
884  if( isElementAdded )
885  {
886  isElementAdded = false;
887 
888  if( !isGrouping )
889  {
890  if( isFillEnabled )
891  {
892  cairo_set_source_rgb( currentContext, fillColor.r, fillColor.g, fillColor.b );
893  cairo_fill_preserve( currentContext );
894  }
895 
896  if( isStrokeEnabled )
897  {
898  cairo_set_source_rgb( currentContext, strokeColor.r, strokeColor.g,
899  strokeColor.b );
900  cairo_stroke_preserve( currentContext );
901  }
902  }
903  else
904  {
905  // Copy the actual path, append it to the global path list
906  // then check, if the path needs to be stroked/filled and
907  // add this command to the group list;
908  if( isStrokeEnabled )
909  {
910  GROUP_ELEMENT groupElement;
911  groupElement.cairoPath = cairo_copy_path( currentContext );
912  groupElement.command = CMD_STROKE_PATH;
913  currentGroup->push_back( groupElement );
914  }
915 
916  if( isFillEnabled )
917  {
918  GROUP_ELEMENT groupElement;
919  groupElement.cairoPath = cairo_copy_path( currentContext );
920  groupElement.command = CMD_FILL_PATH;
921  currentGroup->push_back( groupElement );
922  }
923  }
924 
925  cairo_new_path( currentContext );
926  }
927 }
double g
Green component.
Definition: color4d.h:282
COLOR4D fillColor
The fill color.
Set the stroke path.
Definition: cairo_gal.h:306
double b
Blue component.
Definition: color4d.h:283
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:281
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 309 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().

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

References KIGFX::GAL::worldScreenMatrix.

Referenced by blitCursor().

887  {
888  return VECTOR2D( worldScreenMatrix * aPoint );
889  }
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 875 of file graphics_abstraction_layer.h.

References KIGFX::GAL::screenWorldMatrix.

876  {
877  return VECTOR2D( screenWorldMatrix * aPoint );
878  }
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 477 of file cairo_gal.cpp.

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

478 {
479  cairo_matrix_t cairoTransformation;
480 
481  cairo_matrix_init( &cairoTransformation,
482  aTransformation.m_data[0][0],
483  aTransformation.m_data[1][0],
484  aTransformation.m_data[0][1],
485  aTransformation.m_data[1][1],
486  aTransformation.m_data[0][2],
487  aTransformation.m_data[1][2] );
488 
489  cairo_transform( currentContext, &cairoTransformation );
490 }
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 511 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.

512 {
513  storePath();
514 
515  if( isGrouping )
516  {
517  GROUP_ELEMENT groupElement;
518  groupElement.command = CMD_TRANSLATE;
519  groupElement.argument.dblArg[0] = aTranslation.x;
520  groupElement.argument.dblArg[1] = aTranslation.y;
521  currentGroup->push_back( groupElement );
522  }
523  else
524  {
525  cairo_translate( currentContext, aTranslation.x, aTranslation.y );
526  }
527 }
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:882
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 101 of file cairo_gal.cpp.

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

102 {
103  bool refresh = false;
104 
105  if( super::updatedGalDisplayOptions( aOptions ) )
106  {
107  Refresh();
108  refresh = true;
109  }
110 
111  return refresh;
112 }
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 993 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 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(), 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 1003 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 1005 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 960 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 1004 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 973 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 1036 of file graphics_abstraction_layer.h.

COLOR4D KIGFX::GAL::gridColor
protectedinherited

Color of the grid.

Definition at line 992 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 997 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 991 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 995 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 987 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 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 965 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(), 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 1033 of file graphics_abstraction_layer.h.

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

const double GAL::METRIC_UNIT_LENGTH = 1e9
staticinherited

Definition at line 953 of file graphics_abstraction_layer.h.

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

const int GAL::MIN_DEPTH = -1024
staticprotectedinherited

Possible depth range.

Definition at line 1029 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 958 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 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 964 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 1008 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 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 963 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: