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-2021 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/cursors.h>
38 #include <gal/definitions.h>
39 #include <gal/stroke_font.h>
41 #include <newstroke_font.h>
42 
43 class SHAPE_LINE_CHAIN;
44 class SHAPE_POLY_SET;
45 class BITMAP_BASE;
46 
47 namespace KIGFX
48 {
49 
61 {
62  // These friend declarations allow us to hide routines that should not be called. The
63  // corresponding RAII objects must be used instead.
64  friend class GAL_CONTEXT_LOCKER;
65  friend class GAL_UPDATE_CONTEXT;
66  friend class GAL_DRAWING_CONTEXT;
67 
68 public:
69  // Constructor / Destructor
70  GAL( GAL_DISPLAY_OPTIONS& aOptions );
71  virtual ~GAL();
72 
74  virtual bool IsInitialized() const { return true; }
75 
77  virtual bool IsVisible() const { return true; }
78 
80  virtual bool IsCairoEngine() { return false; }
81 
83  virtual bool IsOpenGlEngine() { return false; }
84 
85  // ---------------
86  // Drawing methods
87  // ---------------
88 
97  virtual void DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) {};
98 
108  virtual void DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint,
109  double aWidth ) {};
110 
116  virtual void DrawPolyline( const std::deque<VECTOR2D>& aPointList ) {};
117  virtual void DrawPolyline( const VECTOR2D aPointList[], int aListSize ) {};
118  virtual void DrawPolyline( const SHAPE_LINE_CHAIN& aLineChain ) {};
119 
126  virtual void DrawCircle( const VECTOR2D& aCenterPoint, double aRadius ) {};
127 
136  virtual void DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle,
137  double aEndAngle ) {};
138 
155  virtual void DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle,
156  double aEndAngle, double aWidth ) {};
157 
164  virtual void DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) {};
165 
171  virtual void DrawPolygon( const std::deque<VECTOR2D>& aPointList ) {};
172  virtual void DrawPolygon( const VECTOR2D aPointList[], int aListSize ) {};
173  virtual void DrawPolygon( const SHAPE_POLY_SET& aPolySet, bool aStrokeTriangulation = false ) {};
174  virtual void DrawPolygon( const SHAPE_LINE_CHAIN& aPolySet ) {};
175 
187  virtual void DrawCurve( const VECTOR2D& startPoint, const VECTOR2D& controlPointA,
188  const VECTOR2D& controlPointB, const VECTOR2D& endPoint,
189  double aFilterValue = 0.0 ) {};
190 
194  virtual void DrawBitmap( const BITMAP_BASE& aBitmap ) {};
195 
196  // --------------
197  // Screen methods
198  // --------------
199 
201  virtual void ResizeScreen( int aWidth, int aHeight ) {};
202 
204  virtual bool Show( bool aShow ) { return true; };
205 
208  {
209  return m_screenSize;
210  }
211 
213  virtual void Flush() {};
214 
215  void SetClearColor( const COLOR4D& aColor )
216  {
217  m_clearColor = aColor;
218  }
219 
220  const COLOR4D& GetClearColor( ) const
221  {
222  return m_clearColor;
223  }
224 
230  virtual void ClearScreen() {};
231 
232  // -----------------
233  // Attribute setting
234  // -----------------
235 
241  virtual void SetIsFill( bool aIsFillEnabled )
242  {
243  m_isFillEnabled = aIsFillEnabled;
244  }
245 
251  virtual void SetIsStroke( bool aIsStrokeEnabled )
252  {
253  m_isStrokeEnabled = aIsStrokeEnabled;
254  }
255 
261  virtual void SetFillColor( const COLOR4D& aColor )
262  {
263  m_fillColor = aColor;
264  }
265 
271  inline const COLOR4D& GetFillColor() const
272  {
273  return m_fillColor;
274  }
275 
281  virtual void SetStrokeColor( const COLOR4D& aColor )
282  {
283  m_strokeColor = aColor;
284  }
285 
291  inline const COLOR4D& GetStrokeColor() const
292  {
293  return m_strokeColor;
294  }
295 
301  virtual void SetLineWidth( float aLineWidth )
302  {
303  m_lineWidth = aLineWidth;
304  }
305 
311  inline float GetLineWidth() const
312  {
313  return m_lineWidth;
314  }
315 
321  virtual void SetLayerDepth( double aLayerDepth )
322  {
323  assert( aLayerDepth <= m_depthRange.y );
324  assert( aLayerDepth >= m_depthRange.x );
325 
326  m_layerDepth = aLayerDepth;
327  }
328 
329  // ----
330  // Text
331  // ----
332 
333  const STROKE_FONT& GetStrokeFont() const
334  {
335  return m_strokeFont;
336  }
337 
345  virtual void StrokeText( const wxString& aText, const VECTOR2D& aPosition,
346  double aRotationAngle )
347  {
348  m_strokeFont.Draw( aText, aPosition, aRotationAngle );
349  }
350 
359  virtual void BitmapText( const wxString& aText, const VECTOR2D& aPosition,
360  double aRotationAngle )
361  {
362  // Fallback: use stroke font
363 
364  // Handle flipped view
365  if( m_globalFlipX )
367 
368  // Bitmap font is slightly smaller and slightly heavier than the stroke font so we
369  // compensate a bit before stroking
370  float saveLineWidth = m_lineWidth;
371  VECTOR2D saveGlyphSize = textProperties.m_glyphSize;
372  {
373  m_lineWidth *= 1.2f;
375 
376  StrokeText( aText, aPosition, aRotationAngle );
377  }
378  m_lineWidth = saveLineWidth;
379  textProperties.m_glyphSize = saveGlyphSize;
380 
381  if( m_globalFlipX )
383  }
384 
391  VECTOR2D GetTextLineSize( const UTF8& aText ) const;
392 
398  virtual void SetTextAttributes( const EDA_TEXT* aText );
399 
406  void ResetTextAttributes();
407 
413  inline void SetGlyphSize( const VECTOR2D& aSize ) { textProperties.m_glyphSize = aSize; }
414  const VECTOR2D& GetGlyphSize() const { return textProperties.m_glyphSize; }
415 
421  inline void SetFontBold( bool aBold ) { textProperties.m_bold = aBold; }
422  inline bool IsFontBold() const { return textProperties.m_bold; }
423 
429  inline void SetFontItalic( bool aItalic ) { textProperties.m_italic = aItalic; }
430  inline bool IsFontItalic() const { return textProperties.m_italic; }
431 
432  inline void SetFontUnderlined( bool aUnderlined ) { textProperties.m_underlined = aUnderlined; }
433  inline bool IsFontUnderlined() const { return textProperties.m_underlined; }
434 
440  inline void SetTextMirrored( bool aMirrored ) { textProperties.m_mirrored = aMirrored; }
441  inline bool IsTextMirrored() const { return textProperties.m_mirrored; }
442 
448  inline void SetHorizontalJustify( const EDA_TEXT_HJUSTIFY_T aHorizontalJustify )
449  {
450  textProperties.m_horizontalJustify = aHorizontalJustify;
451  }
452 
457  {
459  }
460 
466  inline void SetVerticalJustify( const EDA_TEXT_VJUSTIFY_T aVerticalJustify )
467  {
468  textProperties.m_verticalJustify = aVerticalJustify;
469  }
470 
475  {
477  }
478 
479 
480  // --------------
481  // Transformation
482  // --------------
483 
489  virtual void Transform( const MATRIX3x3D& aTransformation ) {};
490 
496  virtual void Rotate( double aAngle ) {};
497 
503  virtual void Translate( const VECTOR2D& aTranslation ) {};
504 
510  virtual void Scale( const VECTOR2D& aScale ) {};
511 
513  virtual void Save() {};
514 
516  virtual void Restore() {};
517 
518  // --------------------------------------------
519  // Group methods
520  // ---------------------------------------------
521 
530  virtual int BeginGroup() { return 0; };
531 
533  virtual void EndGroup() {};
534 
540  virtual void DrawGroup( int aGroupNumber ) {};
541 
548  virtual void ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor ) {};
549 
556  virtual void ChangeGroupDepth( int aGroupNumber, int aDepth ) {};
557 
563  virtual void DeleteGroup( int aGroupNumber ) {};
564 
568  virtual void ClearCache() {};
569 
570  // --------------------------------------------------------
571  // Handling the world <-> screen transformation
572  // --------------------------------------------------------
573 
575  virtual void ComputeWorldScreenMatrix();
576 
583  {
584  return m_worldScreenMatrix;
585  }
586 
593  {
594  return m_screenWorldMatrix;
595  }
596 
602  inline void SetWorldScreenMatrix( const MATRIX3x3D& aMatrix )
603  {
604  m_worldScreenMatrix = aMatrix;
605  }
606 
611 
621  inline void SetWorldUnitLength( double aWorldUnitLength )
622  {
623  m_worldUnitLength = aWorldUnitLength;
624  }
625 
626  inline void SetScreenSize( const VECTOR2I& aSize )
627  {
628  m_screenSize = aSize;
629  }
630 
639  inline void SetScreenDPI( double aScreenDPI )
640  {
641  m_screenDPI = aScreenDPI;
642  }
643 
651  inline void SetLookAtPoint( const VECTOR2D& aPoint )
652  {
653  m_lookAtPoint = aPoint;
654  }
655 
661  inline const VECTOR2D& GetLookAtPoint() const
662  {
663  return m_lookAtPoint;
664  }
665 
671  inline void SetZoomFactor( double aZoomFactor )
672  {
673  m_zoomFactor = aZoomFactor;
674  }
675 
681  inline double GetZoomFactor() const
682  {
683  return m_zoomFactor;
684  }
685 
691  void SetRotation( double aRotation )
692  {
693  m_rotation = aRotation;
694  }
695 
701  double GetRotation() const
702  {
703  return m_rotation;
704  }
705 
714  inline void SetDepthRange( const VECTOR2D& aDepthRange )
715  {
716  m_depthRange = aDepthRange;
717  }
718 
722  inline double GetMinDepth() const
723  {
724  return m_depthRange.x;
725  }
726 
730  inline double GetMaxDepth() const
731  {
732  return m_depthRange.y;
733  }
734 
740  inline double GetWorldScale() const
741  {
742  return m_worldScale;
743  }
744 
751  inline void SetFlip( bool xAxis, bool yAxis )
752  {
753  m_globalFlipX = xAxis;
754  m_globalFlipY = yAxis;
755  }
756 
760  bool IsFlippedX() const
761  {
762  return m_globalFlipX;
763  }
764 
768  bool IsFlippedY() const
769  {
770  return m_globalFlipY;
771  }
772 
773  // ---------------------------
774  // Buffer manipulation methods
775  // ---------------------------
776 
782  virtual void SetTarget( RENDER_TARGET aTarget ) {};
783 
789  virtual RENDER_TARGET GetTarget() const { return TARGET_CACHED; };
790 
796  virtual void ClearTarget( RENDER_TARGET aTarget ) {};
797 
803  virtual bool HasTarget( RENDER_TARGET aTarget )
804  {
805  return true;
806  };
807 
819  virtual void SetNegativeDrawMode( bool aSetting ) {};
820 
821  // -------------
822  // Grid methods
823  // -------------
824 
830  void SetGridVisibility( bool aVisibility ) { m_gridVisibility = aVisibility; }
831 
832  bool GetGridVisibility() const { return m_gridVisibility; }
833 
834  bool GetGridSnapping() const
835  {
838  }
839 
845  inline void SetGridOrigin( const VECTOR2D& aGridOrigin )
846  {
847  m_gridOrigin = aGridOrigin;
848 
849  if( m_gridSize.x == 0.0 || m_gridSize.y == 0.0 )
850  {
851  m_gridOffset = VECTOR2D( 0.0, 0.0);
852  }
853  else
854  {
855  m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x,
856  (long) m_gridOrigin.y % (long) m_gridSize.y );
857  }
858  }
859 
860  inline const VECTOR2D& GetGridOrigin() const
861  {
862  return m_gridOrigin;
863  }
864 
870  inline void SetGridSize( const VECTOR2D& aGridSize )
871  {
872  m_gridSize = aGridSize;
873 
874  // Avoid stupid grid size values: a grid size should be >= 1 in internal units
875  m_gridSize.x = std::max( 1.0, m_gridSize.x );
876  m_gridSize.y = std::max( 1.0, m_gridSize.y );
877 
878  m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x,
879  (long) m_gridOrigin.y % (long) m_gridSize.y );
880  }
881 
887  inline const VECTOR2D& GetGridSize() const
888  {
889  return m_gridSize;
890  }
891 
897  inline void SetGridColor( const COLOR4D& aGridColor )
898  {
899  m_gridColor = aGridColor;
900  }
901 
907  inline void SetAxesColor( const COLOR4D& aAxesColor )
908  {
909  m_axesColor = aAxesColor;
910  }
911 
915  inline void SetAxesEnabled( bool aAxesEnabled )
916  {
917  m_axesEnabled = aAxesEnabled;
918  }
919 
925  inline void SetCoarseGrid( int aInterval )
926  {
927  m_gridTick = aInterval;
928  }
929 
935  inline float GetGridLineWidth() const
936  {
937  return m_gridLineWidth;
938  }
939 
941  virtual void DrawGrid() {};
942 
949  VECTOR2D GetGridPoint( const VECTOR2D& aPoint ) const;
950 
957  inline VECTOR2D ToWorld( const VECTOR2D& aPoint ) const
958  {
959  return VECTOR2D( m_screenWorldMatrix * aPoint );
960  }
961 
968  inline VECTOR2D ToScreen( const VECTOR2D& aPoint ) const
969  {
970  return VECTOR2D( m_worldScreenMatrix * aPoint );
971  }
972 
979  virtual bool SetNativeCursorStyle( KICURSOR aCursor );
980 
986  inline void SetCursorEnabled( bool aCursorEnabled )
987  {
988  m_isCursorEnabled = aCursorEnabled;
989  }
990 
996  bool IsCursorEnabled() const
997  {
999  }
1000 
1006  inline void SetCursorColor( const COLOR4D& aCursorColor )
1007  {
1008  m_cursorColor = aCursorColor;
1009  }
1010 
1016  virtual void DrawCursor( const VECTOR2D& aCursorPosition ) {};
1017 
1022  inline void AdvanceDepth()
1023  {
1024  m_layerDepth -= 0.05;
1025  }
1026 
1030  inline void PushDepth()
1031  {
1032  m_depthStack.push( m_layerDepth );
1033  }
1034 
1038  inline void PopDepth()
1039  {
1040  m_layerDepth = m_depthStack.top();
1041  m_depthStack.pop();
1042  }
1043 
1044  virtual void EnableDepthTest( bool aEnabled = false ) {};
1045 
1050  virtual bool IsContextLocked()
1051  {
1052  return false;
1053  }
1054 
1055 protected:
1057  virtual void lockContext( int aClientCookie ) {}
1058 
1059  virtual void unlockContext( int aClientCookie ) {}
1060 
1063  virtual void beginUpdate() {}
1064 
1066  virtual void endUpdate() {}
1067 
1070  virtual void beginDrawing() {};
1071 
1074  virtual void endDrawing() {};
1075 
1077  inline void computeWorldScale()
1078  {
1080  }
1081 
1087  double computeMinGridSpacing() const;
1088 
1090  static const int MIN_DEPTH;
1091  static const int MAX_DEPTH;
1092 
1094  static const int GRID_DEPTH;
1095 
1099  COLOR4D getCursorColor() const;
1100 
1101  // ---------------
1102  // Settings observer interface
1103  // ---------------
1107  void OnGalDisplayOptionsChanged( const GAL_DISPLAY_OPTIONS& aOptions ) override;
1108 
1117  virtual bool updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions );
1118 
1121 
1122  std::stack<double> m_depthStack;
1124 
1126  double m_screenDPI;
1128 
1129  double m_zoomFactor;
1130  double m_rotation;
1133  double m_worldScale;
1134 
1137 
1138  float m_lineWidth;
1139 
1142 
1146 
1147  double m_layerDepth;
1149 
1150  // Grid settings
1162 
1164  // Cursor settings
1170 
1172 
1175 
1176 private:
1178  {
1182  bool m_bold;
1183  bool m_italic;
1186  } textProperties;
1187 };
1188 
1189 
1191 {
1192 public:
1194  m_gal( aGal )
1195  {
1196  m_cookie = rand();
1198  }
1199 
1201  {
1203  }
1204 
1205 protected:
1208 };
1209 
1210 
1212 {
1213 public:
1215  GAL_CONTEXT_LOCKER( aGal )
1216  {
1217  m_gal->beginUpdate();
1218  }
1219 
1221  {
1222  m_gal->endUpdate();
1223  }
1224 };
1225 
1226 
1228 {
1229 public:
1231  GAL_CONTEXT_LOCKER( aGal )
1232  {
1233  m_gal->beginDrawing();
1234  }
1235 
1237  {
1238  m_gal->endDrawing();
1239  }
1240 };
1241 
1242 
1243 }; // namespace KIGFX
1244 
1245 #endif /* GRAPHICSABSTRACTIONLAYER_H_ */
const STROKE_FONT & GetStrokeFont() const
static const int GRID_DEPTH
Depth level on which the grid is drawn.
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
Return the minimum depth in the currently used range (the top).
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
float GetLineWidth() const
Get the line width.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
void SetClearColor(const COLOR4D &aColor)
bool m_isFillEnabled
Is filling of graphic objects enabled ?
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:61
GRID_STYLE
GRID_STYLE: Type definition of the grid style.
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:191
virtual void DeleteGroup(int aGroupNumber)
Delete the group from the memory.
double GetMaxDepth() const
Return the maximum depth in the currently used range (the bottom).
bool m_axesEnabled
Should the axes be drawn.
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draw a text using a bitmap font.
double m_zoomFactor
The zoom factor.
bool IsTextMirrored() const
double computeMinGridSpacing() const
compute minimum grid spacing from the grid settings
STROKE_FONT m_strokeFont
Instance of object that stores information about how to draw texts.
MATRIX3x3D m_screenWorldMatrix
Screen transformation.
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).
VECTOR2D ToScreen(const VECTOR2D &aPoint) const
Compute the point position in screen coordinates from given world coordinates.
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle)
Draw an arc.
EDA_TEXT_VJUSTIFY_T m_verticalJustify
Vertical justification.
VECTOR2D m_gridSize
The grid size.
void SetFontBold(bool aBold)
Set bold property of current font.
void SetFlip(bool xAxis, bool yAxis)
Sets flipping of the screen.
virtual void DrawBitmap(const BITMAP_BASE &aBitmap)
Draw a bitmap image.
virtual void DrawPolygon(const SHAPE_POLY_SET &aPolySet, bool aStrokeTriangulation=false)
VECTOR2D m_lookAtPoint
Point to be looked at in world space.
virtual bool HasTarget(RENDER_TARGET aTarget)
Return true if the target exists.
KICURSOR
Definition: cursors.h:33
virtual void endUpdate()
Disable item update mode.
virtual void Transform(const MATRIX3x3D &aTransformation)
Transform the context.
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
Return 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)
int m_gridTick
Every tick line gets the double width.
float m_gridLineWidth
Line width of the grid.
MATRIX3x3D m_worldScreenMatrix
World transformation.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void EndGroup()
End the group.
double m_layerDepth
The actual layer depth.
virtual void Rotate(double aAngle)
Rotate the context.
COLOR4D m_gridColor
Color of the grid.
This class handle bitmap images in KiCad.
Definition: bitmap_base.h:51
double m_worldScale
The scale factor world->screen.
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.
std::stack< double > m_depthStack
Stored depth values.
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)
Change the color used to draw the group.
static const int MIN_DEPTH
Possible depth range.
double m_screenDPI
The dots per inch of the screen.
virtual RENDER_TARGET GetTarget() const
Get the currently used target for rendering.
const VECTOR2I & GetScreenPixelSize() const
Return GAL canvas size in pixels.
VECTOR2D m_cursorPosition
Current cursor position (world coordinates)
GAL_DISPLAY_OPTIONS & m_options
GAL(GAL_DISPLAY_OPTIONS &aOptions)
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
bool GetGridSnapping() const
GRID_SNAPPING m_gridSnapping
Thickness to render grid lines/dots.
bool m_globalFlipX
Flag for X axis flipping.
bool IsFontUnderlined() const
bool m_isStrokeEnabled
Are the outlines stroked ?
COLOR4D m_strokeColor
The color of the outlines.
const COLOR4D & GetStrokeColor() const
Get the stroke color.
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
void OnGalDisplayOptionsChanged(const GAL_DISPLAY_OPTIONS &aOptions) override
Handler for observer settings changes.
void ResetTextAttributes()
Reset text attributes to default styling.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
float GetGridLineWidth() const
Get the grid line width.
void PopDepth()
Restore previously stored drawing depth for the depth stack.
int m_gridMinSpacing
Minimum screen size of the grid (pixels) below which the grid is not drawn.
bool m_gridVisibility
Should the grid be shown.
Represent a set of closed polygons.
bool m_isCursorEnabled
Is the cursor enabled?
virtual void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draw a vector type text using preloaded Newstroke font.
virtual int BeginGroup()
Begin a group.
virtual void beginUpdate()
Enable item update mode.
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
virtual void ClearTarget(RENDER_TARGET aTarget)
Clear the target for rendering.
virtual void unlockContext(int aClientCookie)
void SetScreenSize(const VECTOR2I &aSize)
virtual void DrawGrid()
virtual bool IsCairoEngine()
Return true if the GAL engine is a Cairo based type.
virtual void DrawCursor(const VECTOR2D &aCursorPosition)
Draw the cursor.
double GetZoomFactor() const
Get the zoom factor.
virtual bool IsOpenGlEngine()
Return true if the GAL engine is a OpenGL based type.
bool IsFlippedY() const
Return true if flip flag for the Y axis is set.
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
void SetFontItalic(bool aItalic)
Set italic property of current font.
virtual void DrawPolyline(const SHAPE_LINE_CHAIN &aLineChain)
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
virtual void ResizeScreen(int aWidth, int aHeight)
Resize 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
Get the actual cursor color to draw.
COLOR4D m_cursorColor
Cursor color.
void SetGlyphSize(const VECTOR2D &aSize)
Set the font glyph size.
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
virtual bool SetNativeCursorStyle(KICURSOR aCursor)
Set the cursor in the native panel.
virtual bool Show(bool aShow)
Show/hide the GAL canvas.
void Draw(const UTF8 &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draw a string.
const VECTOR2D & GetGridSize() const
Return the grid size.
void computeWorldScale()
Compute the scaling factor for the world->screen matrix.
GRID_STYLE m_gridStyle
Grid display style.
virtual void ClearScreen()
Clear the screen.
VECTOR2D ToWorld(const VECTOR2D &aPoint) const
Compute the point position in world coordinates from given screen coordinates.
void SetTextMirrored(bool aMirrored)
Set a mirrored property of text.
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)
COLOR4D m_fillColor
The fill color.
void SetCoarseGrid(int aInterval)
Draw every tick line wider.
double m_rotation
Rotation transformation (radians)
VECTOR2D m_depthRange
Range of the depth.
void PushDepth()
Store current drawing depth on the depth stack.
COLOR4D m_axesColor
Color of the axes.
bool m_forceDisplayCursor
Always show cursor.
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 m_globalFlipY
Flag for Y axis flipping.
EDA_TEXT_VJUSTIFY_T GetVerticalJustify() const
Returns current text vertical justification setting.
Represent a polyline (an zero-thickness chain of connected line segments).
VECTOR2D m_gridOffset
The grid offset to compensate cursor position.
virtual bool IsVisible() const
Return 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)
Change the depth (Z-axis position) of the group.
BOX2D GetVisibleWorldExtents() const
void SetGridVisibility(bool aVisibility)
Set the visibility setting of the grid.
bool m_fullscreenCursor
Shape of the cursor (fullscreen or small cross)
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.
VECTOR2D m_gridOrigin
The grid origin.
virtual void lockContext(int aClientCookie)
Use GAL_CONTEXT_LOCKER RAII object.
double m_worldUnitLength
The unit length of the world coordinates [inch].
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
Return information about cursor visibility.
void AdvanceDepth()
Change 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.
VECTOR2I m_screenSize
Screen size in screen coordinates.
virtual void SetNegativeDrawMode(bool aSetting)
Set negative draw mode in the renderer.
virtual void DrawPolygon(const VECTOR2D aPointList[], int aListSize)
Implement a stroke font drawing.
Definition: stroke_font.h:54
KICURSOR m_currentNativeCursor
Current cursor.
float m_lineWidth
The line width.
virtual void ClearCache()
Delete all data created during caching of graphic items.
virtual bool IsInitialized() const
Return 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)
Set the target for rendering.
Abstract interface for drawing on a 2D-surface.
static const int MAX_DEPTH
virtual void EnableDepthTest(bool aEnabled=false)
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103