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 
157  virtual void DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle,
158  double aEndAngle, double aWidth, double aMaxError ) {};
159 
166  virtual void DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) {};
167 
173  virtual void DrawPolygon( const std::deque<VECTOR2D>& aPointList ) {};
174  virtual void DrawPolygon( const VECTOR2D aPointList[], int aListSize ) {};
175  virtual void DrawPolygon( const SHAPE_POLY_SET& aPolySet, bool aStrokeTriangulation = false ) {};
176  virtual void DrawPolygon( const SHAPE_LINE_CHAIN& aPolySet ) {};
177 
189  virtual void DrawCurve( const VECTOR2D& startPoint, const VECTOR2D& controlPointA,
190  const VECTOR2D& controlPointB, const VECTOR2D& endPoint,
191  double aFilterValue = 0.0 ) {};
192 
196  virtual void DrawBitmap( const BITMAP_BASE& aBitmap ) {};
197 
198  // --------------
199  // Screen methods
200  // --------------
201 
203  virtual void ResizeScreen( int aWidth, int aHeight ) {};
204 
206  virtual bool Show( bool aShow ) { return true; };
207 
210  {
211  return m_screenSize;
212  }
213 
215  virtual void Flush() {};
216 
217  void SetClearColor( const COLOR4D& aColor )
218  {
219  m_clearColor = aColor;
220  }
221 
222  const COLOR4D& GetClearColor( ) const
223  {
224  return m_clearColor;
225  }
226 
232  virtual void ClearScreen() {};
233 
234  // -----------------
235  // Attribute setting
236  // -----------------
237 
243  virtual void SetIsFill( bool aIsFillEnabled )
244  {
245  m_isFillEnabled = aIsFillEnabled;
246  }
247 
253  virtual void SetIsStroke( bool aIsStrokeEnabled )
254  {
255  m_isStrokeEnabled = aIsStrokeEnabled;
256  }
257 
263  virtual void SetFillColor( const COLOR4D& aColor )
264  {
265  m_fillColor = aColor;
266  }
267 
273  inline const COLOR4D& GetFillColor() const
274  {
275  return m_fillColor;
276  }
277 
283  virtual void SetStrokeColor( const COLOR4D& aColor )
284  {
285  m_strokeColor = aColor;
286  }
287 
293  inline const COLOR4D& GetStrokeColor() const
294  {
295  return m_strokeColor;
296  }
297 
303  virtual void SetLineWidth( float aLineWidth )
304  {
305  m_lineWidth = aLineWidth;
306  }
307 
313  inline float GetLineWidth() const
314  {
315  return m_lineWidth;
316  }
317 
323  virtual void SetLayerDepth( double aLayerDepth )
324  {
325  assert( aLayerDepth <= m_depthRange.y );
326  assert( aLayerDepth >= m_depthRange.x );
327 
328  m_layerDepth = aLayerDepth;
329  }
330 
331  // ----
332  // Text
333  // ----
334 
335  const STROKE_FONT& GetStrokeFont() const
336  {
337  return m_strokeFont;
338  }
339 
347  virtual void StrokeText( const wxString& aText, const VECTOR2D& aPosition,
348  double aRotationAngle )
349  {
350  m_strokeFont.Draw( aText, aPosition, aRotationAngle );
351  }
352 
361  virtual void BitmapText( const wxString& aText, const VECTOR2D& aPosition,
362  double aRotationAngle )
363  {
364  // Fallback: use stroke font
365 
366  // Handle flipped view
367  if( m_globalFlipX )
369 
370  // Bitmap font is slightly smaller and slightly heavier than the stroke font so we
371  // compensate a bit before stroking
372  float saveLineWidth = m_lineWidth;
373  VECTOR2D saveGlyphSize = textProperties.m_glyphSize;
374  {
375  m_lineWidth *= 1.2f;
377 
378  StrokeText( aText, aPosition, aRotationAngle );
379  }
380  m_lineWidth = saveLineWidth;
381  textProperties.m_glyphSize = saveGlyphSize;
382 
383  if( m_globalFlipX )
385  }
386 
393  VECTOR2D GetTextLineSize( const UTF8& aText ) const;
394 
400  virtual void SetTextAttributes( const EDA_TEXT* aText );
401 
408  void ResetTextAttributes();
409 
415  inline void SetGlyphSize( const VECTOR2D& aSize ) { textProperties.m_glyphSize = aSize; }
416  const VECTOR2D& GetGlyphSize() const { return textProperties.m_glyphSize; }
417 
423  inline void SetFontBold( bool aBold ) { textProperties.m_bold = aBold; }
424  inline bool IsFontBold() const { return textProperties.m_bold; }
425 
431  inline void SetFontItalic( bool aItalic ) { textProperties.m_italic = aItalic; }
432  inline bool IsFontItalic() const { return textProperties.m_italic; }
433 
434  inline void SetFontUnderlined( bool aUnderlined ) { textProperties.m_underlined = aUnderlined; }
435  inline bool IsFontUnderlined() const { return textProperties.m_underlined; }
436 
442  inline void SetTextMirrored( bool aMirrored ) { textProperties.m_mirrored = aMirrored; }
443  inline bool IsTextMirrored() const { return textProperties.m_mirrored; }
444 
450  inline void SetHorizontalJustify( const EDA_TEXT_HJUSTIFY_T aHorizontalJustify )
451  {
452  textProperties.m_horizontalJustify = aHorizontalJustify;
453  }
454 
459  {
461  }
462 
468  inline void SetVerticalJustify( const EDA_TEXT_VJUSTIFY_T aVerticalJustify )
469  {
470  textProperties.m_verticalJustify = aVerticalJustify;
471  }
472 
477  {
479  }
480 
481 
482  // --------------
483  // Transformation
484  // --------------
485 
491  virtual void Transform( const MATRIX3x3D& aTransformation ) {};
492 
498  virtual void Rotate( double aAngle ) {};
499 
505  virtual void Translate( const VECTOR2D& aTranslation ) {};
506 
512  virtual void Scale( const VECTOR2D& aScale ) {};
513 
515  virtual void Save() {};
516 
518  virtual void Restore() {};
519 
520  // --------------------------------------------
521  // Group methods
522  // ---------------------------------------------
523 
532  virtual int BeginGroup() { return 0; };
533 
535  virtual void EndGroup() {};
536 
542  virtual void DrawGroup( int aGroupNumber ) {};
543 
550  virtual void ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor ) {};
551 
558  virtual void ChangeGroupDepth( int aGroupNumber, int aDepth ) {};
559 
565  virtual void DeleteGroup( int aGroupNumber ) {};
566 
570  virtual void ClearCache() {};
571 
572  // --------------------------------------------------------
573  // Handling the world <-> screen transformation
574  // --------------------------------------------------------
575 
577  virtual void ComputeWorldScreenMatrix();
578 
585  {
586  return m_worldScreenMatrix;
587  }
588 
595  {
596  return m_screenWorldMatrix;
597  }
598 
604  inline void SetWorldScreenMatrix( const MATRIX3x3D& aMatrix )
605  {
606  m_worldScreenMatrix = aMatrix;
607  }
608 
613 
623  inline void SetWorldUnitLength( double aWorldUnitLength )
624  {
625  m_worldUnitLength = aWorldUnitLength;
626  }
627 
628  inline void SetScreenSize( const VECTOR2I& aSize )
629  {
630  m_screenSize = aSize;
631  }
632 
641  inline void SetScreenDPI( double aScreenDPI )
642  {
643  m_screenDPI = aScreenDPI;
644  }
645 
653  inline void SetLookAtPoint( const VECTOR2D& aPoint )
654  {
655  m_lookAtPoint = aPoint;
656  }
657 
663  inline const VECTOR2D& GetLookAtPoint() const
664  {
665  return m_lookAtPoint;
666  }
667 
673  inline void SetZoomFactor( double aZoomFactor )
674  {
675  m_zoomFactor = aZoomFactor;
676  }
677 
683  inline double GetZoomFactor() const
684  {
685  return m_zoomFactor;
686  }
687 
693  void SetRotation( double aRotation )
694  {
695  m_rotation = aRotation;
696  }
697 
703  double GetRotation() const
704  {
705  return m_rotation;
706  }
707 
716  inline void SetDepthRange( const VECTOR2D& aDepthRange )
717  {
718  m_depthRange = aDepthRange;
719  }
720 
724  inline double GetMinDepth() const
725  {
726  return m_depthRange.x;
727  }
728 
732  inline double GetMaxDepth() const
733  {
734  return m_depthRange.y;
735  }
736 
742  inline double GetWorldScale() const
743  {
744  return m_worldScale;
745  }
746 
753  inline void SetFlip( bool xAxis, bool yAxis )
754  {
755  m_globalFlipX = xAxis;
756  m_globalFlipY = yAxis;
757  }
758 
762  bool IsFlippedX() const
763  {
764  return m_globalFlipX;
765  }
766 
770  bool IsFlippedY() const
771  {
772  return m_globalFlipY;
773  }
774 
775  // ---------------------------
776  // Buffer manipulation methods
777  // ---------------------------
778 
784  virtual void SetTarget( RENDER_TARGET aTarget ) {};
785 
791  virtual RENDER_TARGET GetTarget() const { return TARGET_CACHED; };
792 
798  virtual void ClearTarget( RENDER_TARGET aTarget ) {};
799 
805  virtual bool HasTarget( RENDER_TARGET aTarget )
806  {
807  return true;
808  };
809 
821  virtual void SetNegativeDrawMode( bool aSetting ) {};
822 
830  virtual void StartDiffLayer() {};
831 
837  virtual void EndDiffLayer() {};
838 
847  virtual void StartNegativesLayer(){};
848 
853  virtual void EndNegativesLayer(){};
854 
855  // -------------
856  // Grid methods
857  // -------------
858 
864  void SetGridVisibility( bool aVisibility ) { m_gridVisibility = aVisibility; }
865 
866  bool GetGridVisibility() const { return m_gridVisibility; }
867 
868  bool GetGridSnapping() const
869  {
872  }
873 
879  inline void SetGridOrigin( const VECTOR2D& aGridOrigin )
880  {
881  m_gridOrigin = aGridOrigin;
882 
883  if( m_gridSize.x == 0.0 || m_gridSize.y == 0.0 )
884  {
885  m_gridOffset = VECTOR2D( 0.0, 0.0);
886  }
887  else
888  {
889  m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x,
890  (long) m_gridOrigin.y % (long) m_gridSize.y );
891  }
892  }
893 
894  inline const VECTOR2D& GetGridOrigin() const
895  {
896  return m_gridOrigin;
897  }
898 
904  inline void SetGridSize( const VECTOR2D& aGridSize )
905  {
906  m_gridSize = aGridSize;
907 
908  // Avoid stupid grid size values: a grid size should be >= 1 in internal units
909  m_gridSize.x = std::max( 1.0, m_gridSize.x );
910  m_gridSize.y = std::max( 1.0, m_gridSize.y );
911 
912  m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x,
913  (long) m_gridOrigin.y % (long) m_gridSize.y );
914  }
915 
921  inline const VECTOR2D& GetGridSize() const
922  {
923  return m_gridSize;
924  }
925 
931  inline void SetGridColor( const COLOR4D& aGridColor )
932  {
933  m_gridColor = aGridColor;
934  }
935 
941  inline void SetAxesColor( const COLOR4D& aAxesColor )
942  {
943  m_axesColor = aAxesColor;
944  }
945 
949  inline void SetAxesEnabled( bool aAxesEnabled )
950  {
951  m_axesEnabled = aAxesEnabled;
952  }
953 
959  inline void SetCoarseGrid( int aInterval )
960  {
961  m_gridTick = aInterval;
962  }
963 
969  inline float GetGridLineWidth() const
970  {
971  return m_gridLineWidth;
972  }
973 
975  virtual void DrawGrid() {};
976 
983  VECTOR2D GetGridPoint( const VECTOR2D& aPoint ) const;
984 
991  inline VECTOR2D ToWorld( const VECTOR2D& aPoint ) const
992  {
993  return VECTOR2D( m_screenWorldMatrix * aPoint );
994  }
995 
1002  inline VECTOR2D ToScreen( const VECTOR2D& aPoint ) const
1003  {
1004  return VECTOR2D( m_worldScreenMatrix * aPoint );
1005  }
1006 
1013  virtual bool SetNativeCursorStyle( KICURSOR aCursor );
1014 
1020  inline void SetCursorEnabled( bool aCursorEnabled )
1021  {
1022  m_isCursorEnabled = aCursorEnabled;
1023  }
1024 
1030  bool IsCursorEnabled() const
1031  {
1033  }
1034 
1040  inline void SetCursorColor( const COLOR4D& aCursorColor )
1041  {
1042  m_cursorColor = aCursorColor;
1043  }
1044 
1050  virtual void DrawCursor( const VECTOR2D& aCursorPosition ) {};
1051 
1056  inline void AdvanceDepth()
1057  {
1058  m_layerDepth -= 0.05;
1059  }
1060 
1064  inline void PushDepth()
1065  {
1066  m_depthStack.push( m_layerDepth );
1067  }
1068 
1072  inline void PopDepth()
1073  {
1074  m_layerDepth = m_depthStack.top();
1075  m_depthStack.pop();
1076  }
1077 
1078  virtual void EnableDepthTest( bool aEnabled = false ) {};
1079 
1084  virtual bool IsContextLocked()
1085  {
1086  return false;
1087  }
1088 
1089 protected:
1091  virtual void lockContext( int aClientCookie ) {}
1092 
1093  virtual void unlockContext( int aClientCookie ) {}
1094 
1097  virtual void beginUpdate() {}
1098 
1100  virtual void endUpdate() {}
1101 
1104  virtual void beginDrawing() {};
1105 
1108  virtual void endDrawing() {};
1109 
1111  inline void computeWorldScale()
1112  {
1114  }
1115 
1121  double computeMinGridSpacing() const;
1122 
1124  static const int MIN_DEPTH;
1125  static const int MAX_DEPTH;
1126 
1128  static const int GRID_DEPTH;
1129 
1133  COLOR4D getCursorColor() const;
1134 
1135  // ---------------
1136  // Settings observer interface
1137  // ---------------
1141  void OnGalDisplayOptionsChanged( const GAL_DISPLAY_OPTIONS& aOptions ) override;
1142 
1151  virtual bool updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions );
1152 
1155 
1156  std::stack<double> m_depthStack;
1158 
1160  double m_screenDPI;
1162 
1163  double m_zoomFactor;
1164  double m_rotation;
1167  double m_worldScale;
1168 
1171 
1172  float m_lineWidth;
1173 
1176 
1180 
1181  double m_layerDepth;
1183 
1184  // Grid settings
1196 
1198  // Cursor settings
1204 
1206 
1209 
1210 private:
1212  {
1216  bool m_bold;
1217  bool m_italic;
1220  } textProperties;
1221 };
1222 
1223 
1225 {
1226 public:
1228  m_gal( aGal )
1229  {
1230  m_cookie = rand();
1232  }
1233 
1235  {
1237  }
1238 
1239 protected:
1242 };
1243 
1244 
1246 {
1247 public:
1249  GAL_CONTEXT_LOCKER( aGal )
1250  {
1251  m_gal->beginUpdate();
1252  }
1253 
1255  {
1256  m_gal->endUpdate();
1257  }
1258 };
1259 
1260 
1262 {
1263 public:
1265  GAL_CONTEXT_LOCKER( aGal )
1266  {
1267  m_gal->beginDrawing();
1268  }
1269 
1271  {
1272  m_gal->endDrawing();
1273  }
1274 };
1275 
1276 
1277 }; // namespace KIGFX
1278 
1279 #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:236
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 EndDiffLayer()
Ends rendering of a differential layer.
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.
virtual void StartNegativesLayer()
Begins rendering in a new layer that will be copied to the main layer in EndNegativesLayer().
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.
virtual void StartDiffLayer()
Begins rendering of a differential layer.
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 EndNegativesLayer()
Ends rendering of a negatives layer and draws it to the main layer.
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.
virtual void DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth, double aMaxError)
Draw an arc segment.
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