KiCad PCB EDA Suite
graphics_abstraction_layer.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KICAD, a free EDA CAD application.
3  *
4  * Copyright (C) 2012 Torsten Hueter, torstenhtr <at> gmx.de
5  * Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * Graphics Abstraction Layer (GAL) - base class
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
27 #ifndef GRAPHICSABSTRACTIONLAYER_H_
28 #define GRAPHICSABSTRACTIONLAYER_H_
29 
30 #include <deque>
31 #include <stack>
32 #include <limits>
33 
34 #include <math/matrix3x3.h>
35 
36 #include <gal/color4d.h>
37 #include <gal/definitions.h>
38 #include <gal/stroke_font.h>
40 #include <newstroke_font.h>
41 
42 class SHAPE_LINE_CHAIN;
43 class SHAPE_POLY_SET;
44 class BITMAP_BASE;
45 
46 namespace KIGFX
47 {
48 
60 {
61  // These friend declarations allow us to hide routines that should not be called. The
62  // corresponding RAII objects must be used instead.
63  friend class GAL_CONTEXT_LOCKER;
64  friend class GAL_UPDATE_CONTEXT;
65  friend class GAL_DRAWING_CONTEXT;
66 
67 public:
68  // Constructor / Destructor
69  GAL( GAL_DISPLAY_OPTIONS& aOptions );
70  virtual ~GAL();
71 
73  virtual bool IsInitialized() const { return true; }
74 
76  virtual bool IsVisible() const { return true; }
77 
79  virtual bool IsCairoEngine() { return false; }
80 
82  virtual bool IsOpenGlEngine() { return false; }
83 
84  // ---------------
85  // Drawing methods
86  // ---------------
87 
96  virtual void DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) {};
97 
107  virtual void DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint,
108  double aWidth ) {};
109 
115  virtual void DrawPolyline( const std::deque<VECTOR2D>& aPointList ) {};
116  virtual void DrawPolyline( const VECTOR2D aPointList[], int aListSize ) {};
117  virtual void DrawPolyline( const SHAPE_LINE_CHAIN& aLineChain ) {};
118 
125  virtual void DrawCircle( const VECTOR2D& aCenterPoint, double aRadius ) {};
126 
135  virtual void
136  DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle,
137  double aEndAngle ) {};
138 
155  virtual void
156  DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle,
157  double aEndAngle, double aWidth ) {};
158 
165  virtual void DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) {};
166 
172  virtual void DrawPolygon( const std::deque<VECTOR2D>& aPointList ) {};
173  virtual void DrawPolygon( const VECTOR2D aPointList[], int aListSize ) {};
174  virtual void DrawPolygon( const SHAPE_POLY_SET& aPolySet ) {};
175  virtual void DrawPolygon( const SHAPE_LINE_CHAIN& aPolySet ) {};
176 
188  virtual void DrawCurve( const VECTOR2D& startPoint, const VECTOR2D& controlPointA,
189  const VECTOR2D& controlPointB, const VECTOR2D& endPoint,
190  double aFilterValue = 0.0 ) {};
191 
195  virtual void DrawBitmap( const BITMAP_BASE& aBitmap ) {};
196 
197  // --------------
198  // Screen methods
199  // --------------
200 
202  virtual void ResizeScreen( int aWidth, int aHeight ) {};
203 
205  virtual bool Show( bool aShow ) { return true; };
206 
209  {
210  return screenSize;
211  }
212 
214  virtual void Flush() {};
215 
216  void SetClearColor( const COLOR4D& aColor )
217  {
218  m_clearColor = aColor;
219  }
220 
221  const COLOR4D& GetClearColor( ) const
222  {
223  return m_clearColor;
224  }
225 
231  virtual void ClearScreen() {};
232 
233  // -----------------
234  // Attribute setting
235  // -----------------
236 
242  virtual void SetIsFill( bool aIsFillEnabled )
243  {
244  isFillEnabled = aIsFillEnabled;
245  }
246 
252  virtual void SetIsStroke( bool aIsStrokeEnabled )
253  {
254  isStrokeEnabled = aIsStrokeEnabled;
255  }
256 
262  virtual void SetFillColor( const COLOR4D& aColor )
263  {
264  fillColor = aColor;
265  }
266 
272  inline const COLOR4D& GetFillColor() const
273  {
274  return fillColor;
275  }
276 
282  virtual void SetStrokeColor( const COLOR4D& aColor )
283  {
284  strokeColor = aColor;
285  }
286 
292  inline const COLOR4D& GetStrokeColor() const
293  {
294  return strokeColor;
295  }
296 
302  virtual void SetLineWidth( float aLineWidth )
303  {
304  lineWidth = aLineWidth;
305  }
306 
312  inline float GetLineWidth() const
313  {
314  return lineWidth;
315  }
316 
322  virtual void SetLayerDepth( double aLayerDepth )
323  {
324  assert( aLayerDepth <= depthRange.y );
325  assert( aLayerDepth >= depthRange.x );
326 
327  layerDepth = aLayerDepth;
328  }
329 
330  // ----
331  // Text
332  // ----
333 
334  const STROKE_FONT& GetStrokeFont() const
335  {
336  return strokeFont;
337  }
338 
346  virtual void StrokeText( const wxString& aText, const VECTOR2D& aPosition,
347  double aRotationAngle )
348  {
349  strokeFont.Draw( aText, aPosition, aRotationAngle );
350  }
351 
360  virtual void BitmapText( const wxString& aText, const VECTOR2D& aPosition,
361  double aRotationAngle )
362  {
363  // Fallback: use stroke font
364 
365  // Handle flipped view
366  if( globalFlipX )
368 
369  StrokeText( aText, aPosition, aRotationAngle );
370 
371  if( globalFlipX )
373  }
374 
382  VECTOR2D GetTextLineSize( const UTF8& aText ) const;
383 
389  virtual void SetTextAttributes( const EDA_TEXT* aText );
390 
397  void ResetTextAttributes();
398 
404  inline void SetGlyphSize( const VECTOR2D aSize ) { textProperties.m_glyphSize = aSize; }
405  const VECTOR2D& GetGlyphSize() const { return textProperties.m_glyphSize; }
406 
412  inline void SetFontBold( const bool aBold ) { textProperties.m_bold = aBold; }
413  inline bool IsFontBold() const { return textProperties.m_bold; }
414 
420  inline void SetFontItalic( bool aItalic ) { textProperties.m_italic = aItalic; }
421  inline bool IsFontItalic() const { return textProperties.m_italic; }
422 
423  inline void SetFontUnderlined( bool aUnderlined ) { textProperties.m_underlined = aUnderlined; }
424  inline bool IsFontUnderlined() const { return textProperties.m_underlined; }
425 
431  inline void SetTextMirrored( const bool aMirrored ) { textProperties.m_mirrored = aMirrored; }
432  inline bool IsTextMirrored() const { return textProperties.m_mirrored; }
433 
439  inline void SetHorizontalJustify( const EDA_TEXT_HJUSTIFY_T aHorizontalJustify )
440  {
441  textProperties.m_horizontalJustify = aHorizontalJustify;
442  }
443 
448  {
450  }
451 
457  inline void SetVerticalJustify( const EDA_TEXT_VJUSTIFY_T aVerticalJustify )
458  {
459  textProperties.m_verticalJustify = aVerticalJustify;
460  }
461 
466  {
468  }
469 
470 
471  // --------------
472  // Transformation
473  // --------------
474 
480  virtual void Transform( const MATRIX3x3D& aTransformation ) {};
481 
487  virtual void Rotate( double aAngle ) {};
488 
494  virtual void Translate( const VECTOR2D& aTranslation ) {};
495 
501  virtual void Scale( const VECTOR2D& aScale ) {};
502 
504  virtual void Save() {};
505 
507  virtual void Restore() {};
508 
509  // --------------------------------------------
510  // Group methods
511  // ---------------------------------------------
512 
521  virtual int BeginGroup() { return 0; };
522 
524  virtual void EndGroup() {};
525 
531  virtual void DrawGroup( int aGroupNumber ) {};
532 
539  virtual void ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor ) {};
540 
547  virtual void ChangeGroupDepth( int aGroupNumber, int aDepth ) {};
548 
554  virtual void DeleteGroup( int aGroupNumber ) {};
555 
559  virtual void ClearCache() {};
560 
561  // --------------------------------------------------------
562  // Handling the world <-> screen transformation
563  // --------------------------------------------------------
564 
566  virtual void ComputeWorldScreenMatrix();
567 
574  {
575  return worldScreenMatrix;
576  }
577 
584  {
585  return screenWorldMatrix;
586  }
587 
593  inline void SetWorldScreenMatrix( const MATRIX3x3D& aMatrix )
594  {
595  worldScreenMatrix = aMatrix;
596  }
597 
607  inline void SetWorldUnitLength( double aWorldUnitLength )
608  {
609  worldUnitLength = aWorldUnitLength;
610  }
611 
612  inline void SetScreenSize( const VECTOR2I& aSize )
613  {
614  screenSize = aSize;
615  }
616 
625  inline void SetScreenDPI( double aScreenDPI )
626  {
627  screenDPI = aScreenDPI;
628  }
629 
637  inline void SetLookAtPoint( const VECTOR2D& aPoint )
638  {
639  lookAtPoint = aPoint;
640  }
641 
647  inline const VECTOR2D& GetLookAtPoint() const
648  {
649  return lookAtPoint;
650  }
651 
657  inline void SetZoomFactor( double aZoomFactor )
658  {
659  zoomFactor = aZoomFactor;
660  }
661 
667  inline double GetZoomFactor() const
668  {
669  return zoomFactor;
670  }
671 
677  void SetRotation( double aRotation )
678  {
679  rotation = aRotation;
680  }
681 
687  double GetRotation() const
688  {
689  return rotation;
690  }
691 
700  inline void SetDepthRange( const VECTOR2D& aDepthRange )
701  {
702  depthRange = aDepthRange;
703  }
704 
708  inline double GetMinDepth() const
709  {
710  return depthRange.x;
711  }
712 
716  inline double GetMaxDepth() const
717  {
718  return depthRange.y;
719  }
720 
726  inline double GetWorldScale() const
727  {
728  return worldScale;
729  }
730 
737  inline void SetFlip( bool xAxis, bool yAxis )
738  {
739  globalFlipX = xAxis;
740  globalFlipY = yAxis;
741  }
742 
746  bool IsFlippedX() const
747  {
748  return globalFlipX;
749  }
750 
754  bool IsFlippedY() const
755  {
756  return globalFlipY;
757  }
758 
759  // ---------------------------
760  // Buffer manipulation methods
761  // ---------------------------
762 
768  virtual void SetTarget( RENDER_TARGET aTarget ) {};
769 
775  virtual RENDER_TARGET GetTarget() const { return TARGET_CACHED; };
776 
782  virtual void ClearTarget( RENDER_TARGET aTarget ) {};
783 
789  virtual bool HasTarget( RENDER_TARGET aTarget )
790  {
791  return true;
792  };
793 
805  virtual void SetNegativeDrawMode( bool aSetting ) {};
806 
807  // -------------
808  // Grid methods
809  // -------------
810 
816  void SetGridVisibility( bool aVisibility ) { gridVisibility = aVisibility; }
817 
818  bool GetGridVisibility() const { return gridVisibility; }
819 
820  bool GetGridSnapping() const
821  {
824  }
830  inline void SetGridOrigin( const VECTOR2D& aGridOrigin )
831  {
832  gridOrigin = aGridOrigin;
833 
834  if( gridSize.x == 0.0 || gridSize.y == 0.0 )
835  gridOffset = VECTOR2D(0.0, 0.0);
836  else
837  gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
838  (long) gridOrigin.y % (long) gridSize.y );
839  }
840 
841  inline const VECTOR2D& GetGridOrigin() const
842  {
843  return gridOrigin;
844  }
845 
851  inline void SetGridSize( const VECTOR2D& aGridSize )
852  {
853  gridSize = aGridSize;
854 
855  // Avoid stupid grid size values: a grid size should be >= 1 in internal units
856  gridSize.x = std::max( 1.0, gridSize.x );
857  gridSize.y = std::max( 1.0, gridSize.y );
858 
859  gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
860  (long) gridOrigin.y % (long) gridSize.y );
861  }
862 
868  inline const VECTOR2D& GetGridSize() const
869  {
870  return gridSize;
871  }
872 
878  inline void SetGridColor( const COLOR4D& aGridColor )
879  {
880  gridColor = aGridColor;
881  }
882 
888  inline void SetAxesColor( const COLOR4D& aAxesColor )
889  {
890  axesColor = aAxesColor;
891  }
892 
896  inline void SetAxesEnabled( bool aAxesEnabled )
897  {
898  axesEnabled = aAxesEnabled;
899  }
900 
906  inline void SetCoarseGrid( int aInterval )
907  {
908  gridTick = aInterval;
909  }
910 
916  inline float GetGridLineWidth() const
917  {
918  return gridLineWidth;
919  }
920 
922  virtual void DrawGrid() {};
923 
930  VECTOR2D GetGridPoint( const VECTOR2D& aPoint ) const;
931 
938  inline VECTOR2D ToWorld( const VECTOR2D& aPoint ) const
939  {
940  return VECTOR2D( screenWorldMatrix * aPoint );
941  }
942 
949  inline VECTOR2D ToScreen( const VECTOR2D& aPoint ) const
950  {
951  return VECTOR2D( worldScreenMatrix * aPoint );
952  }
953 
959  inline void SetCursorEnabled( bool aCursorEnabled )
960  {
961  isCursorEnabled = aCursorEnabled;
962  }
963 
969  bool IsCursorEnabled() const
970  {
972  }
973 
979  inline void SetCursorColor( const COLOR4D& aCursorColor )
980  {
981  cursorColor = aCursorColor;
982  }
983 
989  virtual void DrawCursor( const VECTOR2D& aCursorPosition ) {};
990 
995  inline void AdvanceDepth()
996  {
997  layerDepth -= 0.05;
998  }
999 
1003  inline void PushDepth()
1004  {
1005  depthStack.push( layerDepth );
1006  }
1007 
1011  inline void PopDepth()
1012  {
1013  layerDepth = depthStack.top();
1014  depthStack.pop();
1015  }
1016 
1017  virtual void EnableDepthTest( bool aEnabled = false ) {};
1018 
1023  virtual bool IsContextLocked()
1024  {
1025  return false;
1026  }
1027 
1028 protected:
1030  virtual void lockContext( int aClientCookie ) {}
1031 
1032  virtual void unlockContext( int aClientCookie ) {}
1033 
1036  virtual void beginUpdate() {}
1037 
1039  virtual void endUpdate() {}
1040 
1043  virtual void beginDrawing() {};
1044 
1047  virtual void endDrawing() {};
1048 
1050  inline void computeWorldScale()
1051  {
1053  }
1054 
1060  double computeMinGridSpacing() const;
1061 
1063  static const int MIN_DEPTH;
1064  static const int MAX_DEPTH;
1065 
1067  static const int GRID_DEPTH;
1068 
1072  COLOR4D getCursorColor() const;
1073 
1074  // ---------------
1075  // Settings observer interface
1076  // ---------------
1080  void OnGalDisplayOptionsChanged( const GAL_DISPLAY_OPTIONS& aOptions ) override;
1081 
1090  virtual bool updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions );
1091 
1094 
1095  std::stack<double> depthStack;
1097 
1099  double screenDPI;
1101 
1102  double zoomFactor;
1103  double rotation;
1106  double worldScale;
1107 
1110 
1111  float lineWidth;
1112 
1115 
1119 
1120  double layerDepth;
1122 
1123  // Grid settings
1132  int gridTick;
1135 
1137  // Cursor settings
1143 
1146 
1147 private:
1149  {
1153  bool m_bold;
1154  bool m_italic;
1157  } textProperties;
1158 };
1159 
1160 
1162 {
1163 public:
1165  m_gal( aGal )
1166  {
1167  m_cookie = rand();
1169  }
1170 
1172  {
1174  }
1175 
1176 protected:
1179 };
1180 
1181 
1183 {
1184 public:
1186  GAL_CONTEXT_LOCKER( aGal )
1187  {
1188  m_gal->beginUpdate();
1189  }
1190 
1192  {
1193  m_gal->endUpdate();
1194  }
1195 };
1196 
1197 
1199 {
1200 public:
1202  GAL_CONTEXT_LOCKER( aGal )
1203  {
1204  m_gal->beginDrawing();
1205  }
1206 
1208  {
1209  m_gal->endDrawing();
1210  }
1211 };
1212 
1213 
1214 }; // namespace KIGFX
1215 
1216 #endif /* GRAPHICSABSTRACTIONLAYER_H_ */
const STROKE_FONT & GetStrokeFont() const
static const int GRID_DEPTH
Depth level on which the grid is drawn.
int gridTick
Every tick line gets the double width.
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
Definition: utf8.h:70
virtual void DrawGroup(int aGroupNumber)
Draw the stored group.
double GetMinDepth() const
Returns the minimum depth in the currently used range (the top).
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
double zoomFactor
The zoom factor.
STROKE_FONT strokeFont
Instance of object that stores information about how to draw texts.
float GetLineWidth() const
Get the line width.
VECTOR2D cursorPosition
Current cursor position (world coordinates)
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
void SetClearColor(const COLOR4D &aColor)
bool axesEnabled
Should the axes be drawn.
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:61
GRID_STYLE
GRID_STYLE: Type definition of the grid style.
VECTOR2D gridOffset
The grid offset to compensate cursor position.
double layerDepth
The actual layer depth.
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:175
virtual void DeleteGroup(int aGroupNumber)
Delete the group from the memory.
double GetMaxDepth() const
Returns the maximum depth in the currently used range (the bottom).
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a text using a bitmap font.
bool IsTextMirrored() const
double computeMinGridSpacing() const
compute minimum grid spacing from the grid settings
bool isCursorEnabled
Is the cursor enabled?
void SetCursorEnabled(bool aCursorEnabled)
Enable/disable cursor.
const COLOR4D & GetFillColor() const
Get the fill color.
bool IsFlippedX() const
Return true if flip flag for the X axis is set.
virtual void SetTextAttributes(const EDA_TEXT *aText)
Loads attributes of the given text (bold/italic/underline/mirrored and so on).
int gridMinSpacing
Minimum screen size of the grid (pixels) below which the grid is not drawn.
VECTOR2D ToScreen(const VECTOR2D &aPoint) const
Compute the point position in screen coordinates from given world coordinates.
GRID_STYLE gridStyle
Grid display style.
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle)
Draw an arc.
GAL_DISPLAY_OPTIONS & options
double rotation
Rotation transformation (radians)
EDA_TEXT_VJUSTIFY_T m_verticalJustify
Vertical justification.
virtual void DrawPolygon(const SHAPE_POLY_SET &aPolySet)
void SetFlip(bool xAxis, bool yAxis)
Sets flipping of the screen.
virtual void DrawBitmap(const BITMAP_BASE &aBitmap)
Draw a bitmap image.
virtual bool HasTarget(RENDER_TARGET aTarget)
Returns true if the target exists.
COLOR4D fillColor
The fill color.
VECTOR2D depthRange
Range of the depth.
virtual void endUpdate()
Disables item update mode.
virtual void Transform(const MATRIX3x3D &aTransformation)
Transform the context.
MATRIX3x3D screenWorldMatrix
Screen transformation.
bool globalFlipX
Flag for X axis flipping.
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
void SetGridOrigin(const VECTOR2D &aGridOrigin)
Set the origin point for the grid.
VECTOR2D GetTextLineSize(const UTF8 &aText) const
Compute the X and Y size of a given text.
virtual void ComputeWorldScreenMatrix()
Compute the world <-> screen transformation matrix.
EDA_TEXT_HJUSTIFY_T GetHorizontalJustify() const
Returns current text horizontal justification setting.
void SetScreenDPI(double aScreenDPI)
Set the dots per inch of the screen.
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)
VECTOR2D lookAtPoint
Point to be looked at in world space.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void EndGroup()
End the group.
virtual void Rotate(double aAngle)
Rotate the context.
This class handle bitmap images in KiCad.
Definition: bitmap_base.h:51
const VECTOR2D & GetGlyphSize() const
VECTOR2D GetGridPoint(const VECTOR2D &aPoint) const
For a given point it returns the nearest point belonging to the grid in world coordinates.
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:119
virtual void ChangeGroupColor(int aGroupNumber, const COLOR4D &aNewColor)
Changes the color used to draw the group.
static const int MIN_DEPTH
Possible depth range.
virtual RENDER_TARGET GetTarget() const
Gets the currently used target for rendering.
const VECTOR2I & GetScreenPixelSize() const
Returns GAL canvas size in pixels.
GAL(GAL_DISPLAY_OPTIONS &aOptions)
void SetFontBold(const bool aBold)
Set bold property of current font.
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
bool GetGridSnapping() const
GRID_SNAPPING m_gridSnapping
Snapping options for the grid
bool IsFontUnderlined() const
const COLOR4D & GetStrokeColor() const
Get the stroke color.
COLOR4D cursorColor
Cursor color.
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
bool fullscreenCursor
Shape of the cursor (fullscreen or small cross)
void OnGalDisplayOptionsChanged(const GAL_DISPLAY_OPTIONS &aOptions) override
Handler for observer settings changes.
void ResetTextAttributes()
Reset text attributes to default styling.
bool isStrokeEnabled
Are the outlines stroked ?
VECTOR2< double > VECTOR2D
Definition: vector2d.h:629
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
float GetGridLineWidth() const
Get the grid line width.
void PopDepth()
Restores previously stored drawing depth for the depth stack.
SHAPE_POLY_SET.
COLOR4D axesColor
Color of the axes.
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a vector type text using preloaded Newstroke font.
virtual int BeginGroup()
Begin a group.
virtual void beginUpdate()
Enables item update mode.
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
virtual void ClearTarget(RENDER_TARGET aTarget)
Clears the target for rendering.
virtual void unlockContext(int aClientCookie)
void SetScreenSize(const VECTOR2I &aSize)
COLOR4D strokeColor
The color of the outlines.
float gridLineWidth
Line width of the grid.
virtual void DrawGrid()
Draw the grid
std::stack< double > depthStack
Stored depth values.
virtual bool IsCairoEngine()
Returns true if the GAL engine is a cairo based type.
double worldUnitLength
The unit length of the world coordinates [inch].
virtual void DrawCursor(const VECTOR2D &aCursorPosition)
Draw the cursor.
double GetZoomFactor() const
Get the zoom factor.
virtual bool IsOpenGlEngine()
Returns true if the GAL engine is a OpenGL based type.
bool IsFlippedY() const
Return true if flip flag for the Y axis is set.
VECTOR2D gridOrigin
The grid origin.
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
void SetCursorColor(const COLOR4D &aCursorColor)
Set the cursor color.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
const COLOR4D & GetClearColor() const
MATRIX3x3D worldScreenMatrix
World transformation.
void SetFontItalic(bool aItalic)
Set italic property of current font.
virtual void DrawPolyline(const SHAPE_LINE_CHAIN &aLineChain)
void SetAxesEnabled(bool aAxesEnabled)
Enables drawing the axes.
virtual void ResizeScreen(int aWidth, int aHeight)
Resizes the canvas.
void SetGridSize(const VECTOR2D &aGridSize)
Set the grid size.
virtual void DrawPolygon(const SHAPE_LINE_CHAIN &aPolySet)
void SetWorldUnitLength(double aWorldUnitLength)
Set the unit length.
COLOR4D getCursorColor() const
Gets the actual cursor color to draw.
virtual void Flush()
Force all remaining objects to be drawn.
virtual bool updatedGalDisplayOptions(const GAL_DISPLAY_OPTIONS &aOptions)
Handle updating display options.
virtual void Scale(const VECTOR2D &aScale)
Scale the context.
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:68
float lineWidth
The line width.
bool isFillEnabled
Is filling of graphic objects enabled ?
virtual bool Show(bool aShow)
Shows/hides the GAL canvas.
void Draw(const UTF8 &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draw a string.
const VECTOR2D & GetGridSize() const
Returns the grid size.
void computeWorldScale()
Compute the scaling factor for the world->screen matrix.
virtual void ClearScreen()
Clear the screen.
VECTOR2D ToWorld(const VECTOR2D &aPoint) const
Compute the point position in world coordinates from given screen coordinates.
const VECTOR2D & GetLookAtPoint() const
Get the look at point.
void SetWorldScreenMatrix(const MATRIX3x3D &aMatrix)
Set the world <-> screen transformation matrix.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void DrawPolyline(const VECTOR2D aPointList[], int aListSize)
void SetCoarseGrid(int aInterval)
Draw every tick line wider.
void SetGlyphSize(const VECTOR2D aSize)
Set the font glyph size.
void PushDepth()
Stores current drawing depth on the depth stack.
COLOR4D gridColor
Color of the grid.
bool gridVisibility
Should the grid be shown.
virtual void Restore()
Restore the context.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
void SetFontUnderlined(bool aUnderlined)
Main rendering target (cached)
Definition: definitions.h:48
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
void SetRotation(double aRotation)
Set the rotation angle.
bool globalFlipY
Flag for Y axis flipping.
EDA_TEXT_VJUSTIFY_T GetVerticalJustify() const
Returns current text vertical justification setting.
SHAPE_LINE_CHAIN.
double worldScale
The scale factor world->screen.
VECTOR2D gridSize
The grid size.
VECTOR2I screenSize
Screen size in screen coordinates.
virtual bool IsVisible() const
Returns true if the GAL canvas is visible on the screen.
void SetZoomFactor(double aZoomFactor)
Set the zoom factor of the scene.
virtual void ChangeGroupDepth(int aGroupNumber, int aDepth)
Changes the depth (Z-axis position) of the group.
void SetGridVisibility(bool aVisibility)
Sets the visibility setting of the grid.
const VECTOR2D & GetGridOrigin() const
virtual void DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth)
Draw an arc segment.
void SetLookAtPoint(const VECTOR2D &aPoint)
Set the Point in world space to look at.
virtual void lockContext(int aClientCookie)
Private: use GAL_CONTEXT_LOCKER RAII object.
virtual void Save()
Save the context.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
bool GetGridVisibility() const
RENDER_TARGET
RENDER_TARGET: Possible rendering targets.
Definition: definitions.h:46
const MATRIX3x3D & GetWorldScreenMatrix() const
Get the world <-> screen transformation matrix.
VECTOR2D m_glyphSize
Size of the glyphs.
double GetRotation() const
Get the rotation angle.
double GetWorldScale() const
Get the world scale.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void DrawCurve(const VECTOR2D &startPoint, const VECTOR2D &controlPointA, const VECTOR2D &controlPointB, const VECTOR2D &endPoint, double aFilterValue=0.0)
Draw a cubic bezier spline.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
void SetDepthRange(const VECTOR2D &aDepthRange)
Set the range of the layer depth.
bool IsCursorEnabled() const
Returns information about cursor visibility.
void AdvanceDepth()
Changes the current depth to deeper, so it is possible to draw objects right beneath other.
virtual void beginDrawing()
Begin the drawing, needs to be called for every new frame.
virtual bool IsContextLocked()
Checks the state of the context lock.
virtual void SetNegativeDrawMode(bool aSetting)
Sets negative draw mode in the renderer.
virtual void DrawPolygon(const VECTOR2D aPointList[], int aListSize)
Class STROKE_FONT implements stroke font drawing.
Definition: stroke_font.h:53
bool forceDisplayCursor
Always show cursor.
virtual void ClearCache()
Delete all data created during caching of graphic items.
virtual bool IsInitialized() const
Returns the initialization status for the canvas.
virtual void endDrawing()
End the drawing, needs to be called for every new frame.
EDA_TEXT_HJUSTIFY_T m_horizontalJustify
Horizontal justification.
virtual void SetTarget(RENDER_TARGET aTarget)
Sets the target for rendering.
Class GAL is the abstract interface for drawing on a 2D-surface.
double screenDPI
The dots per inch of the screen.
static const int MAX_DEPTH
virtual void EnableDepthTest(bool aEnabled=false)
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98