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
137  DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle,
138  double aEndAngle ) {};
139 
156  virtual void
157  DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle,
158  double aEndAngle, double aWidth ) {};
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 ) {};
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( const 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( const 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 
823  // -------------
824  // Grid methods
825  // -------------
826 
832  void SetGridVisibility( bool aVisibility ) { m_gridVisibility = aVisibility; }
833 
834  bool GetGridVisibility() const { return m_gridVisibility; }
835 
836  bool GetGridSnapping() const
837  {
840  }
846  inline void SetGridOrigin( const VECTOR2D& aGridOrigin )
847  {
848  m_gridOrigin = aGridOrigin;
849 
850  if( m_gridSize.x == 0.0 || m_gridSize.y == 0.0 )
851  {
852  m_gridOffset = VECTOR2D( 0.0, 0.0);
853  }
854  else
855  {
856  m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x,
857  (long) m_gridOrigin.y % (long) m_gridSize.y );
858  }
859  }
860 
861  inline const VECTOR2D& GetGridOrigin() const
862  {
863  return m_gridOrigin;
864  }
865 
871  inline void SetGridSize( const VECTOR2D& aGridSize )
872  {
873  m_gridSize = aGridSize;
874 
875  // Avoid stupid grid size values: a grid size should be >= 1 in internal units
876  m_gridSize.x = std::max( 1.0, m_gridSize.x );
877  m_gridSize.y = std::max( 1.0, m_gridSize.y );
878 
879  m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x,
880  (long) m_gridOrigin.y % (long) m_gridSize.y );
881  }
882 
888  inline const VECTOR2D& GetGridSize() const
889  {
890  return m_gridSize;
891  }
892 
898  inline void SetGridColor( const COLOR4D& aGridColor )
899  {
900  m_gridColor = aGridColor;
901  }
902 
908  inline void SetAxesColor( const COLOR4D& aAxesColor )
909  {
910  m_axesColor = aAxesColor;
911  }
912 
916  inline void SetAxesEnabled( bool aAxesEnabled )
917  {
918  m_axesEnabled = aAxesEnabled;
919  }
920 
926  inline void SetCoarseGrid( int aInterval )
927  {
928  m_gridTick = aInterval;
929  }
930 
936  inline float GetGridLineWidth() const
937  {
938  return m_gridLineWidth;
939  }
940 
942  virtual void DrawGrid() {};
943 
950  VECTOR2D GetGridPoint( const VECTOR2D& aPoint ) const;
951 
958  inline VECTOR2D ToWorld( const VECTOR2D& aPoint ) const
959  {
960  return VECTOR2D( m_screenWorldMatrix * aPoint );
961  }
962 
969  inline VECTOR2D ToScreen( const VECTOR2D& aPoint ) const
970  {
971  return VECTOR2D( m_worldScreenMatrix * aPoint );
972  }
973 
980  virtual bool SetNativeCursorStyle( KICURSOR aCursor );
981 
987  inline void SetCursorEnabled( bool aCursorEnabled )
988  {
989  m_isCursorEnabled = aCursorEnabled;
990  }
991 
997  bool IsCursorEnabled() const
998  {
1000  }
1001 
1007  inline void SetCursorColor( const COLOR4D& aCursorColor )
1008  {
1009  m_cursorColor = aCursorColor;
1010  }
1011 
1017  virtual void DrawCursor( const VECTOR2D& aCursorPosition ) {};
1018 
1023  inline void AdvanceDepth()
1024  {
1025  m_layerDepth -= 0.05;
1026  }
1027 
1031  inline void PushDepth()
1032  {
1033  m_depthStack.push( m_layerDepth );
1034  }
1035 
1039  inline void PopDepth()
1040  {
1041  m_layerDepth = m_depthStack.top();
1042  m_depthStack.pop();
1043  }
1044 
1045  virtual void EnableDepthTest( bool aEnabled = false ) {};
1046 
1051  virtual bool IsContextLocked()
1052  {
1053  return false;
1054  }
1055 
1056 protected:
1058  virtual void lockContext( int aClientCookie ) {}
1059 
1060  virtual void unlockContext( int aClientCookie ) {}
1061 
1064  virtual void beginUpdate() {}
1065 
1067  virtual void endUpdate() {}
1068 
1071  virtual void beginDrawing() {};
1072 
1075  virtual void endDrawing() {};
1076 
1078  inline void computeWorldScale()
1079  {
1081  }
1082 
1088  double computeMinGridSpacing() const;
1089 
1091  static const int MIN_DEPTH;
1092  static const int MAX_DEPTH;
1093 
1095  static const int GRID_DEPTH;
1096 
1100  COLOR4D getCursorColor() const;
1101 
1102  // ---------------
1103  // Settings observer interface
1104  // ---------------
1108  void OnGalDisplayOptionsChanged( const GAL_DISPLAY_OPTIONS& aOptions ) override;
1109 
1118  virtual bool updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions );
1119 
1122 
1123  std::stack<double> m_depthStack;
1125 
1127  double m_screenDPI;
1129 
1130  double m_zoomFactor;
1131  double m_rotation;
1134  double m_worldScale;
1135 
1138 
1139  float m_lineWidth;
1140 
1143 
1147 
1148  double m_layerDepth;
1150 
1151  // Grid settings
1163 
1165  // Cursor settings
1171 
1173 
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:175
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.
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.
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 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
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.
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
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.
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.
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)
void SetGlyphSize(const VECTOR2D aSize)
Set the font glyph size.
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.
SHAPE_LINE_CHAIN.
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:98