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-2017 Kicad Developers, see change_log.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, double aWidth ) {};
108 
114  virtual void DrawPolyline( const std::deque<VECTOR2D>& aPointList ) {};
115  virtual void DrawPolyline( const VECTOR2D aPointList[], int aListSize ) {};
116  virtual void DrawPolyline( const SHAPE_LINE_CHAIN& aLineChain ) {};
117 
124  virtual void DrawCircle( const VECTOR2D& aCenterPoint, double aRadius ) {};
125 
134  virtual void
135  DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle, double aEndAngle ) {};
136 
151  virtual void
152  DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle,
153  double aEndAngle, double aWidth ) {};
154 
161  virtual void DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) {};
162 
168  virtual void DrawPolygon( const std::deque<VECTOR2D>& aPointList ) {};
169  virtual void DrawPolygon( const VECTOR2D aPointList[], int aListSize ) {};
170  virtual void DrawPolygon( const SHAPE_POLY_SET& aPolySet ) {};
171  virtual void DrawPolygon( const SHAPE_LINE_CHAIN& aPolySet ) {};
172 
181  virtual void DrawCurve( const VECTOR2D& startPoint, const VECTOR2D& controlPointA,
182  const VECTOR2D& controlPointB, const VECTOR2D& endPoint ) {};
183 
187  virtual void DrawBitmap( const BITMAP_BASE& aBitmap ) {};
188 
189  // --------------
190  // Screen methods
191  // --------------
192 
194  virtual void ResizeScreen( int aWidth, int aHeight ) {};
195 
197  virtual bool Show( bool aShow ) { return true; };
198 
201  {
202  return screenSize;
203  }
204 
206  virtual void Flush() {};
207 
208  void SetClearColor( const COLOR4D& aColor )
209  {
210  m_clearColor = aColor;
211  }
212 
213  const COLOR4D& GetClearColor( ) const
214  {
215  return m_clearColor;
216  }
217 
222  virtual void ClearScreen() {};
223 
224  // -----------------
225  // Attribute setting
226  // -----------------
227 
233  virtual void SetIsFill( bool aIsFillEnabled )
234  {
235  isFillEnabled = aIsFillEnabled;
236  }
237 
243  virtual void SetIsStroke( bool aIsStrokeEnabled )
244  {
245  isStrokeEnabled = aIsStrokeEnabled;
246  }
247 
253  virtual void SetFillColor( const COLOR4D& aColor )
254  {
255  fillColor = aColor;
256  }
257 
263  inline const COLOR4D& GetFillColor() const
264  {
265  return fillColor;
266  }
267 
273  virtual void SetStrokeColor( const COLOR4D& aColor )
274  {
275  strokeColor = aColor;
276  }
277 
283  inline const COLOR4D& GetStrokeColor() const
284  {
285  return strokeColor;
286  }
287 
293  virtual void SetLineWidth( float aLineWidth )
294  {
295  lineWidth = aLineWidth;
296  }
297 
303  inline float GetLineWidth() const
304  {
305  return lineWidth;
306  }
307 
313  virtual void SetLayerDepth( double aLayerDepth )
314  {
315  assert( aLayerDepth <= depthRange.y );
316  assert( aLayerDepth >= depthRange.x );
317 
318  layerDepth = aLayerDepth;
319  }
320 
321  // ----
322  // Text
323  // ----
324 
325  const STROKE_FONT& GetStrokeFont() const
326  {
327  return strokeFont;
328  }
329 
337  virtual void StrokeText( const wxString& aText, const VECTOR2D& aPosition,
338  double aRotationAngle )
339  {
340  strokeFont.Draw( aText, aPosition, aRotationAngle );
341  }
342 
351  virtual void BitmapText( const wxString& aText, const VECTOR2D& aPosition,
352  double aRotationAngle )
353  {
354  // Fallback: use stroke font
355 
356  // Handle flipped view
357  if( globalFlipX )
359 
360  StrokeText( aText, aPosition, aRotationAngle );
361 
362  if( globalFlipX )
364  }
365 
373  VECTOR2D GetTextLineSize( const UTF8& aText ) const;
374 
381  {
383  }
384 
390  virtual void SetTextAttributes( const EDA_TEXT* aText );
391 
398  void ResetTextAttributes();
399 
405  inline void SetGlyphSize( const VECTOR2D aGlyphSize )
406  {
407  textProperties.m_glyphSize = aGlyphSize;
408  }
409 
413  const VECTOR2D& GetGlyphSize() const
414  {
416  }
417 
423  inline void SetFontBold( const bool aBold )
424  {
425  textProperties.m_bold = aBold;
426  }
427 
431  inline bool IsFontBold() const
432  {
433  return textProperties.m_bold;
434  }
435 
441  inline void SetFontItalic( const bool aItalic )
442  {
443  textProperties.m_italic = aItalic;
444  }
445 
449  inline bool IsFontItalic() const
450  {
451  return textProperties.m_italic;
452  }
453 
459  inline void SetTextMirrored( const bool aMirrored )
460  {
461  textProperties.m_mirrored = aMirrored;
462  }
463 
467  inline bool IsTextMirrored() const
468  {
469  return textProperties.m_mirrored;
470  }
471 
477  inline void SetHorizontalJustify( const EDA_TEXT_HJUSTIFY_T aHorizontalJustify )
478  {
479  textProperties.m_horizontalJustify = aHorizontalJustify;
480  }
481 
486  {
488  }
489 
495  inline void SetVerticalJustify( const EDA_TEXT_VJUSTIFY_T aVerticalJustify )
496  {
497  textProperties.m_verticalJustify = aVerticalJustify;
498  }
499 
504  {
506  }
507 
508 
509  // --------------
510  // Transformation
511  // --------------
512 
518  virtual void Transform( const MATRIX3x3D& aTransformation ) {};
519 
525  virtual void Rotate( double aAngle ) {};
526 
532  virtual void Translate( const VECTOR2D& aTranslation ) {};
533 
539  virtual void Scale( const VECTOR2D& aScale ) {};
540 
542  virtual void Save() {};
543 
545  virtual void Restore() {};
546 
547  // --------------------------------------------
548  // Group methods
549  // ---------------------------------------------
550 
559  virtual int BeginGroup() { return 0; };
560 
562  virtual void EndGroup() {};
563 
569  virtual void DrawGroup( int aGroupNumber ) {};
570 
577  virtual void ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor ) {};
578 
585  virtual void ChangeGroupDepth( int aGroupNumber, int aDepth ) {};
586 
592  virtual void DeleteGroup( int aGroupNumber ) {};
593 
597  virtual void ClearCache() {};
598 
599  // --------------------------------------------------------
600  // Handling the world <-> screen transformation
601  // --------------------------------------------------------
602 
604  virtual void ComputeWorldScreenMatrix();
605 
612  {
613  return worldScreenMatrix;
614  }
615 
622  {
623  return screenWorldMatrix;
624  }
625 
631  inline void SetWorldScreenMatrix( const MATRIX3x3D& aMatrix )
632  {
633  worldScreenMatrix = aMatrix;
634  }
635 
645  inline void SetWorldUnitLength( double aWorldUnitLength )
646  {
647  worldUnitLength = aWorldUnitLength;
648  }
649 
650  inline void SetScreenSize( const VECTOR2I& aSize )
651  {
652  screenSize = aSize;
653  }
654 
663  inline void SetScreenDPI( double aScreenDPI )
664  {
665  screenDPI = aScreenDPI;
666  }
667 
675  inline void SetLookAtPoint( const VECTOR2D& aPoint )
676  {
677  lookAtPoint = aPoint;
678  }
679 
685  inline const VECTOR2D& GetLookAtPoint() const
686  {
687  return lookAtPoint;
688  }
689 
695  inline void SetZoomFactor( double aZoomFactor )
696  {
697  zoomFactor = aZoomFactor;
698  }
699 
705  inline double GetZoomFactor() const
706  {
707  return zoomFactor;
708  }
709 
715  void SetRotation( double aRotation )
716  {
717  rotation = aRotation;
718  }
719 
725  double GetRotation() const
726  {
727  return rotation;
728  }
729 
738  inline void SetDepthRange( const VECTOR2D& aDepthRange )
739  {
740  depthRange = aDepthRange;
741  }
742 
746  inline double GetMinDepth() const
747  {
748  return depthRange.x;
749  }
750 
754  inline double GetMaxDepth() const
755  {
756  return depthRange.y;
757  }
758 
764  inline double GetWorldScale() const
765  {
766  return worldScale;
767  }
768 
775  inline void SetFlip( bool xAxis, bool yAxis )
776  {
777  globalFlipX = xAxis;
778  globalFlipY = yAxis;
779  }
780 
784  bool IsFlippedX() const
785  {
786  return globalFlipX;
787  }
788 
792  bool IsFlippedY() const
793  {
794  return globalFlipY;
795  }
796 
797  // ---------------------------
798  // Buffer manipulation methods
799  // ---------------------------
800 
804  virtual void SaveScreen() {};
805 
809  virtual void RestoreScreen() {};
810 
816  virtual void SetTarget( RENDER_TARGET aTarget ) {};
817 
823  virtual RENDER_TARGET GetTarget() const { return TARGET_CACHED; };
824 
830  virtual void ClearTarget( RENDER_TARGET aTarget ) {};
831 
843  virtual void SetNegativeDrawMode( bool aSetting ) {};
844 
845  // -------------
846  // Grid methods
847  // -------------
848 
854  inline void SetGridVisibility( bool aVisibility )
855  {
856  gridVisibility = aVisibility;
857  }
858 
864  inline void SetGridOrigin( const VECTOR2D& aGridOrigin )
865  {
866  gridOrigin = aGridOrigin;
867 
868  if( gridSize.x == 0.0 || gridSize.y == 0.0 )
869  gridOffset = VECTOR2D(0.0, 0.0);
870  else
871  gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
872  (long) gridOrigin.y % (long) gridSize.y );
873  }
874 
880  inline void SetGridSize( const VECTOR2D& aGridSize )
881  {
882  gridSize = aGridSize;
883 
884  gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
885  (long) gridOrigin.y % (long) gridSize.y );
886  }
887 
893  inline const VECTOR2D& GetGridSize() const
894  {
895  return gridSize;
896  }
897 
903  inline void SetGridColor( const COLOR4D& aGridColor )
904  {
905  gridColor = aGridColor;
906  }
907 
913  inline void SetAxesColor( const COLOR4D& aAxesColor )
914  {
915  axesColor = aAxesColor;
916  }
917 
921  inline void SetAxesEnabled( bool aAxesEnabled )
922  {
923  axesEnabled = aAxesEnabled;
924  }
925 
931  inline void SetCoarseGrid( int aInterval )
932  {
933  gridTick = aInterval;
934  }
935 
941  inline float GetGridLineWidth() const
942  {
943  return gridLineWidth;
944  }
945 
947  virtual void DrawGrid();
948 
956  VECTOR2D GetGridPoint( const VECTOR2D& aPoint ) const;
957 
964  inline VECTOR2D ToWorld( const VECTOR2D& aPoint ) const
965  {
966  return VECTOR2D( screenWorldMatrix * aPoint );
967  }
968 
975  inline VECTOR2D ToScreen( const VECTOR2D& aPoint ) const
976  {
977  return VECTOR2D( worldScreenMatrix * aPoint );
978  }
979 
985  inline void SetCursorEnabled( bool aCursorEnabled )
986  {
987  isCursorEnabled = aCursorEnabled;
988  }
989 
994  bool IsCursorEnabled() const
995  {
997  }
998 
1004  inline void SetCursorColor( const COLOR4D& aCursorColor )
1005  {
1006  cursorColor = aCursorColor;
1007  }
1008 
1014  virtual void DrawCursor( const VECTOR2D& aCursorPosition ) {};
1015 
1020  inline void AdvanceDepth()
1021  {
1022  layerDepth -= 0.05;
1023  }
1024 
1028  inline void PushDepth()
1029  {
1030  depthStack.push( layerDepth );
1031  }
1032 
1036  inline void PopDepth()
1037  {
1038  layerDepth = depthStack.top();
1039  depthStack.pop();
1040  }
1041 
1042  virtual void EnableDepthTest( bool aEnabled = false ) {};
1043 
1044 protected:
1045 
1048 
1049  std::stack<double> depthStack;
1051 
1053  double screenDPI;
1055 
1056  double zoomFactor;
1057  double rotation;
1060  double worldScale;
1061 
1064 
1065  float lineWidth;
1066 
1069 
1073 
1074  double layerDepth;
1076 
1077  // Grid settings
1086  int gridTick;
1089 
1091  // Cursor settings
1097 
1100 
1102  virtual void lockContext( int aClientCookie ) {}
1103 
1104  virtual void unlockContext( int aClientCookie ) {}
1105 
1108  virtual void beginUpdate() {}
1109 
1111  virtual void endUpdate() {}
1112 
1115  virtual void beginDrawing() {};
1116 
1119  virtual void endDrawing() {};
1120 
1122  inline void computeWorldScale()
1123  {
1124  worldScale = screenDPI * worldUnitLength * zoomFactor;
1125  }
1126 
1132  double computeMinGridSpacing() const;
1133 
1140  virtual void drawGridLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) {};
1141 
1143  static const int MIN_DEPTH;
1144  static const int MAX_DEPTH;
1145 
1147  static const int GRID_DEPTH;
1148 
1152  COLOR4D getCursorColor() const;
1153 
1154  // ---------------
1155  // Settings observer interface
1156  // ---------------
1160  void OnGalDisplayOptionsChanged( const GAL_DISPLAY_OPTIONS& aOptions ) override;
1161 
1171  virtual bool updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions );
1172 
1173 private:
1175  {
1179  bool m_bold;
1180  bool m_italic;
1182  } textProperties;
1183 };
1184 
1185 
1187 {
1188 public:
1190  m_gal( aGal )
1191  {
1192  m_cookie = rand();
1193  m_gal->lockContext( m_cookie );
1194  }
1195 
1197  {
1198  m_gal->unlockContext( m_cookie );
1199  }
1200 
1201 protected:
1204 };
1205 
1206 
1208 {
1209 public:
1211  GAL_CONTEXT_LOCKER( aGal )
1212  {
1213  m_gal->beginUpdate();
1214  }
1215 
1217  {
1218  m_gal->endUpdate();
1219  }
1220 };
1221 
1222 
1224 {
1225 public:
1227  GAL_CONTEXT_LOCKER( aGal )
1228  {
1229  m_gal->beginDrawing();
1230  }
1231 
1233  {
1234  m_gal->endDrawing();
1235  }
1236 };
1237 
1238 
1239 }; // namespace KIGFX
1240 
1241 #endif /* GRAPHICSABSTRACTIONLAYER_H_ */
double computeMinGridSpacing() const
compute minimum grid spacing from the grid settings
static const int GRID_DEPTH
Depth level on which the grid is drawn.
bool IsCursorEnabled() const
Returns information about cursor visibility.
int gridTick
Every tick line gets the double width.
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
Class UTF8 is an 8 bit string that is assuredly encoded in UTF8, and supplies special conversion supp...
Definition: utf8.h:73
virtual void DrawGroup(int aGroupNumber)
Draw the stored group.
void SetFontItalic(const bool aItalic)
Set italic property of current font.
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
EDA_TEXT_HJUSTIFY_T GetHorizontalJustify() const
Returns current text horizontal justification setting.
double zoomFactor
The zoom factor.
STROKE_FONT strokeFont
Instance of object that stores information about how to draw texts.
VECTOR2D cursorPosition
Current cursor position (world coordinates)
const COLOR4D & GetStrokeColor() const
Get the stroke color.
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:62
EDA_TEXT_VJUSTIFY_T GetVerticalJustify() const
Returns current text vertical justification setting.
GRID_STYLE
GRID_STYLE: Type definition of the grid style.
VECTOR2D gridOffset
The grid offset to compensate cursor position.
double computeOverbarVerticalPosition() const
Compute the vertical position of an overbar, sometimes used in texts.
double layerDepth
The actual layer depth.
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:57
virtual void DeleteGroup(int aGroupNumber)
Delete the group from the memory.
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a text using a bitmap font.
double GetWorldScale() const
Get the world scale.
bool isCursorEnabled
Is the cursor enabled?
void SetCursorEnabled(bool aCursorEnabled)
Enable/disable cursor.
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.
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.
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
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.
double GetRotation() const
Get the rotation angle.
virtual bool IsVisible() const
Returns true if the GAL canvas is visible on the screen.
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.
virtual bool IsInitialized() const
Returns the initalization status for the canvas.
virtual void ComputeWorldScreenMatrix()
Compute the world <-> screen transformation matrix.
void SetScreenDPI(double aScreenDPI)
Set the dots per inch of the screen.
const VECTOR2D & GetLookAtPoint() const
Get the look at point.
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)
virtual void drawGridLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a grid line (usually a simplified line function).
const MATRIX3x3D & GetWorldScreenMatrix() const
Get the world <-> screen transformation matrix.
VECTOR2D lookAtPoint
Point to be looked at in world space.
VECTOR2D ToScreen(const VECTOR2D &aPoint) const
Compute the point position in screen coordinates from given world coordinates.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void EndGroup()
End the group.
virtual void Rotate(double aAngle)
Rotate the context.
virtual void DrawCurve(const VECTOR2D &startPoint, const VECTOR2D &controlPointA, const VECTOR2D &controlPointB, const VECTOR2D &endPoint)
Draw a cubic bezier spline.
This class handle bitmap images in KiCad.
Definition: bitmap_base.h:46
Class EDA_TEXT is a mix-in class (via multiple inheritance) that handles texts such as labels...
Definition: eda_text.h:127
virtual void ChangeGroupColor(int aGroupNumber, const COLOR4D &aNewColor)
Changes the color used to draw the group.
static const int MIN_DEPTH
Possible depth range.
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.
virtual void SaveScreen()
Save the screen contents.
bool IsFlippedY() const
Return true if flip flag for the Y axis is set.
COLOR4D cursorColor
Cursor color.
bool IsFontBold() const
Returns true if current font has &#39;bold&#39; attribute enabled.
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:586
COLOR4D getCursorColor() const
Gets the actual cursor color to draw.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
void PopDepth()
Restores previously stored drawing depth for the depth stack.
float GetGridLineWidth() const
Get the grid line width.
Class SHAPE_POLY_SET.
bool IsFlippedX() const
Return true if flip flag for the X axis is 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.
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.
virtual bool IsOpenGlEngine()
Returns true if the GAL engine is a opengl based type.
const VECTOR2D & GetGlyphSize() const
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.
MATRIX3x3D worldScreenMatrix
World transformation.
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.
const COLOR4D & GetFillColor() const
Get the fill color.
const COLOR4D & GetClearColor() const
virtual void Flush()
Force all remaining objects to be drawn.
virtual bool updatedGalDisplayOptions(const GAL_DISPLAY_OPTIONS &aOptions)
Function updatedGalDisplayOptions.
virtual void DrawGrid()
>
virtual void Scale(const VECTOR2D &aScale)
Scale the context.
const VECTOR2D & GetGridSize() const
Returns the grid size.
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:69
float lineWidth
The line width.
bool isFillEnabled
Is filling of graphic objects enabled ?
virtual bool Show(bool aShow)
Shows/hides the GAL canvas.
const VECTOR2I & GetScreenPixelSize() const
Returns GAL canvas size in pixels.
void Draw(const UTF8 &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draw a string.
void computeWorldScale()
Compute the scaling factor for the world->screen matrix.
virtual void ClearScreen()
Clear the screen.
VECTOR2D GetGridPoint(const VECTOR2D &aPoint) const
Function GetGridPoint() For a given point it returns the nearest point belonging to the grid in world...
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.
virtual void RestoreScreen()
Restore the screen contents.
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.
Main rendering target (cached)
Definition: definitions.h:41
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.
Class SHAPE_LINE_CHAIN.
double worldScale
The scale factor world->screen.
double GetOverbarVerticalPosition() const
Compute the vertical position of an overbar, sometimes used in texts.
VECTOR2D gridSize
The grid size.
VECTOR2I screenSize
Screen size in screen coordinates.
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.
double GetZoomFactor() const
Get the zoom factor.
void SetGridVisibility(bool aVisibility)
Sets the visibility setting of the grid.
bool IsFontItalic() const
Returns true if current font has &#39;italic&#39; attribute enabled.
void SetGlyphSize(const VECTOR2D aGlyphSize)
Set the font glyph size.
virtual void DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth)
Draw an arc segment.
double GetMinDepth() const
Returns the minimum depth in the currently used range (the top).
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.
const STROKE_FONT & GetStrokeFont() const
virtual void Save()
Save the context.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
RENDER_TARGET
RENDER_TARGET: Possible rendering targets.
Definition: definitions.h:39
virtual RENDER_TARGET GetTarget() const
Gets the currently used target for rendering.
float GetLineWidth() const
Get the line width.
bool IsTextMirrored() const
Returns true if text should displayed mirrored.
VECTOR2D m_glyphSize
Size of the glyphs.
double GetMaxDepth() const
Returns the maximum depth in the currently used range (the bottom).
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
VECTOR2D GetTextLineSize(const UTF8 &aText) const
Compute the X and Y size of a given text.
void SetDepthRange(const VECTOR2D &aDepthRange)
Set the range of the layer depth.
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 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
VECTOR2D ToWorld(const VECTOR2D &aPoint) const
Compute the point position in world coordinates from given screen coordinates.
bool forceDisplayCursor
Always show cursor.
virtual void ClearCache()
Delete all data created during caching of graphic items.
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)
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39