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 
50 {
53 };
54 
66 {
67  // These friend declarations allow us to hide routines that should not be called. The
68  // corresponding RAII objects must be used instead.
69  friend class GAL_CONTEXT_LOCKER;
70  friend class GAL_UPDATE_CONTEXT;
71  friend class GAL_DRAWING_CONTEXT;
72 
73 public:
74  // Constructor / Destructor
75  GAL( GAL_DISPLAY_OPTIONS& aOptions );
76  virtual ~GAL();
77 
79  virtual bool IsInitialized() const { return true; }
80 
82  virtual bool IsVisible() const { return true; }
83 
85  virtual bool IsCairoEngine() { return false; }
86 
88  virtual bool IsOpenGlEngine() { return false; }
89 
90  // ---------------
91  // Drawing methods
92  // ---------------
93 
102  virtual void DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) {};
103 
113  virtual void DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint, double aWidth ) {};
114 
120  virtual void DrawPolyline( const std::deque<VECTOR2D>& aPointList ) {};
121  virtual void DrawPolyline( const VECTOR2D aPointList[], int aListSize ) {};
122  virtual void DrawPolyline( const SHAPE_LINE_CHAIN& aLineChain ) {};
123 
130  virtual void DrawCircle( const VECTOR2D& aCenterPoint, double aRadius ) {};
131 
140  virtual void
141  DrawArc( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle, double aEndAngle ) {};
142 
159  virtual void
160  DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius, double aStartAngle,
161  double aEndAngle, double aWidth ) {};
162 
169  virtual void DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) {};
170 
176  virtual void DrawPolygon( const std::deque<VECTOR2D>& aPointList ) {};
177  virtual void DrawPolygon( const VECTOR2D aPointList[], int aListSize ) {};
178  virtual void DrawPolygon( const SHAPE_POLY_SET& aPolySet ) {};
179  virtual void DrawPolygon( const SHAPE_LINE_CHAIN& aPolySet ) {};
180 
192  virtual void DrawCurve( const VECTOR2D& startPoint, const VECTOR2D& controlPointA,
193  const VECTOR2D& controlPointB, const VECTOR2D& endPoint,
194  double aFilterValue = 0.0 ) {};
195 
199  virtual void DrawBitmap( const BITMAP_BASE& aBitmap ) {};
200 
201  // --------------
202  // Screen methods
203  // --------------
204 
206  virtual void ResizeScreen( int aWidth, int aHeight ) {};
207 
209  virtual bool Show( bool aShow ) { return true; };
210 
213  {
214  return screenSize;
215  }
216 
218  virtual void Flush() {};
219 
220  void SetClearColor( const COLOR4D& aColor )
221  {
222  m_clearColor = aColor;
223  }
224 
225  const COLOR4D& GetClearColor( ) const
226  {
227  return m_clearColor;
228  }
229 
234  virtual void ClearScreen() {};
235 
236  // -----------------
237  // Attribute setting
238  // -----------------
239 
245  virtual void SetIsFill( bool aIsFillEnabled )
246  {
247  isFillEnabled = aIsFillEnabled;
248  }
249 
255  virtual void SetIsStroke( bool aIsStrokeEnabled )
256  {
257  isStrokeEnabled = aIsStrokeEnabled;
258  }
259 
265  virtual void SetFillColor( const COLOR4D& aColor )
266  {
267  fillColor = aColor;
268  }
269 
275  inline const COLOR4D& GetFillColor() const
276  {
277  return fillColor;
278  }
279 
285  virtual void SetStrokeColor( const COLOR4D& aColor )
286  {
287  strokeColor = aColor;
288  }
289 
295  inline const COLOR4D& GetStrokeColor() const
296  {
297  return strokeColor;
298  }
299 
305  virtual void SetLineWidth( float aLineWidth )
306  {
307  lineWidth = aLineWidth;
308  }
309 
315  inline float GetLineWidth() const
316  {
317  return lineWidth;
318  }
319 
325  virtual void SetLayerDepth( double aLayerDepth )
326  {
327  assert( aLayerDepth <= depthRange.y );
328  assert( aLayerDepth >= depthRange.x );
329 
330  layerDepth = aLayerDepth;
331  }
332 
333  // ----
334  // Text
335  // ----
336 
337  const STROKE_FONT& GetStrokeFont() const
338  {
339  return strokeFont;
340  }
341 
350  virtual void StrokeText( const wxString& aText, const VECTOR2D& aPosition,
351  double aRotationAngle, int aMarkupFlags = 0 )
352  {
353  strokeFont.Draw( aText, aPosition, aRotationAngle, aMarkupFlags );
354  }
355 
364  virtual void BitmapText( const wxString& aText, const VECTOR2D& aPosition,
365  double aRotationAngle )
366  {
367  // Fallback: use stroke font
368 
369  // Handle flipped view
370  if( globalFlipX )
372 
373  StrokeText( aText, aPosition, aRotationAngle );
374 
375  if( globalFlipX )
377  }
378 
387  VECTOR2D GetTextLineSize( const UTF8& aText, int aMarkupFlags = 0 ) const;
388 
395  {
397  }
398 
404  virtual void SetTextAttributes( const EDA_TEXT* aText );
405 
412  void ResetTextAttributes();
413 
419  inline void SetGlyphSize( const VECTOR2D aGlyphSize )
420  {
421  textProperties.m_glyphSize = aGlyphSize;
422  }
423 
427  const VECTOR2D& GetGlyphSize() const
428  {
430  }
431 
437  inline void SetFontBold( const bool aBold )
438  {
439  textProperties.m_bold = aBold;
440  }
441 
445  inline bool IsFontBold() const
446  {
447  return textProperties.m_bold;
448  }
449 
455  inline void SetFontItalic( const bool aItalic )
456  {
457  textProperties.m_italic = aItalic;
458  }
459 
463  inline bool IsFontItalic() const
464  {
465  return textProperties.m_italic;
466  }
467 
473  inline void SetTextMirrored( const bool aMirrored )
474  {
475  textProperties.m_mirrored = aMirrored;
476  }
477 
481  inline bool IsTextMirrored() const
482  {
483  return textProperties.m_mirrored;
484  }
485 
491  inline void SetHorizontalJustify( const EDA_TEXT_HJUSTIFY_T aHorizontalJustify )
492  {
493  textProperties.m_horizontalJustify = aHorizontalJustify;
494  }
495 
500  {
502  }
503 
509  inline void SetVerticalJustify( const EDA_TEXT_VJUSTIFY_T aVerticalJustify )
510  {
511  textProperties.m_verticalJustify = aVerticalJustify;
512  }
513 
518  {
520  }
521 
522 
523  // --------------
524  // Transformation
525  // --------------
526 
532  virtual void Transform( const MATRIX3x3D& aTransformation ) {};
533 
539  virtual void Rotate( double aAngle ) {};
540 
546  virtual void Translate( const VECTOR2D& aTranslation ) {};
547 
553  virtual void Scale( const VECTOR2D& aScale ) {};
554 
556  virtual void Save() {};
557 
559  virtual void Restore() {};
560 
561  // --------------------------------------------
562  // Group methods
563  // ---------------------------------------------
564 
573  virtual int BeginGroup() { return 0; };
574 
576  virtual void EndGroup() {};
577 
583  virtual void DrawGroup( int aGroupNumber ) {};
584 
591  virtual void ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor ) {};
592 
599  virtual void ChangeGroupDepth( int aGroupNumber, int aDepth ) {};
600 
606  virtual void DeleteGroup( int aGroupNumber ) {};
607 
611  virtual void ClearCache() {};
612 
613  // --------------------------------------------------------
614  // Handling the world <-> screen transformation
615  // --------------------------------------------------------
616 
618  virtual void ComputeWorldScreenMatrix();
619 
626  {
627  return worldScreenMatrix;
628  }
629 
636  {
637  return screenWorldMatrix;
638  }
639 
645  inline void SetWorldScreenMatrix( const MATRIX3x3D& aMatrix )
646  {
647  worldScreenMatrix = aMatrix;
648  }
649 
659  inline void SetWorldUnitLength( double aWorldUnitLength )
660  {
661  worldUnitLength = aWorldUnitLength;
662  }
663 
664  inline void SetScreenSize( const VECTOR2I& aSize )
665  {
666  screenSize = aSize;
667  }
668 
677  inline void SetScreenDPI( double aScreenDPI )
678  {
679  screenDPI = aScreenDPI;
680  }
681 
689  inline void SetLookAtPoint( const VECTOR2D& aPoint )
690  {
691  lookAtPoint = aPoint;
692  }
693 
699  inline const VECTOR2D& GetLookAtPoint() const
700  {
701  return lookAtPoint;
702  }
703 
709  inline void SetZoomFactor( double aZoomFactor )
710  {
711  zoomFactor = aZoomFactor;
712  }
713 
719  inline double GetZoomFactor() const
720  {
721  return zoomFactor;
722  }
723 
729  void SetRotation( double aRotation )
730  {
731  rotation = aRotation;
732  }
733 
739  double GetRotation() const
740  {
741  return rotation;
742  }
743 
752  inline void SetDepthRange( const VECTOR2D& aDepthRange )
753  {
754  depthRange = aDepthRange;
755  }
756 
760  inline double GetMinDepth() const
761  {
762  return depthRange.x;
763  }
764 
768  inline double GetMaxDepth() const
769  {
770  return depthRange.y;
771  }
772 
778  inline double GetWorldScale() const
779  {
780  return worldScale;
781  }
782 
789  inline void SetFlip( bool xAxis, bool yAxis )
790  {
791  globalFlipX = xAxis;
792  globalFlipY = yAxis;
793  }
794 
798  bool IsFlippedX() const
799  {
800  return globalFlipX;
801  }
802 
806  bool IsFlippedY() const
807  {
808  return globalFlipY;
809  }
810 
811  // ---------------------------
812  // Buffer manipulation methods
813  // ---------------------------
814 
820  virtual void SetTarget( RENDER_TARGET aTarget ) {};
821 
827  virtual RENDER_TARGET GetTarget() const { return TARGET_CACHED; };
828 
834  virtual void ClearTarget( RENDER_TARGET aTarget ) {};
835 
847  virtual void SetNegativeDrawMode( bool aSetting ) {};
848 
849  // -------------
850  // Grid methods
851  // -------------
852 
858  inline void SetGridVisibility( bool aVisibility )
859  {
860  gridVisibility = aVisibility;
861  }
862 
868  inline void SetGridOrigin( const VECTOR2D& aGridOrigin )
869  {
870  gridOrigin = aGridOrigin;
871 
872  if( gridSize.x == 0.0 || gridSize.y == 0.0 )
873  gridOffset = VECTOR2D(0.0, 0.0);
874  else
875  gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
876  (long) gridOrigin.y % (long) gridSize.y );
877  }
878 
884  inline void SetGridSize( const VECTOR2D& aGridSize )
885  {
886  gridSize = aGridSize;
887 
888  gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x,
889  (long) gridOrigin.y % (long) gridSize.y );
890  }
891 
897  inline const VECTOR2D& GetGridSize() const
898  {
899  return gridSize;
900  }
901 
907  inline void SetGridColor( const COLOR4D& aGridColor )
908  {
909  gridColor = aGridColor;
910  }
911 
917  inline void SetAxesColor( const COLOR4D& aAxesColor )
918  {
919  axesColor = aAxesColor;
920  }
921 
925  inline void SetAxesEnabled( bool aAxesEnabled )
926  {
927  axesEnabled = aAxesEnabled;
928  }
929 
935  inline void SetCoarseGrid( int aInterval )
936  {
937  gridTick = aInterval;
938  }
939 
945  inline float GetGridLineWidth() const
946  {
947  return gridLineWidth;
948  }
949 
951  virtual void DrawGrid() {};
952 
960  VECTOR2D GetGridPoint( const VECTOR2D& aPoint ) const;
961 
968  inline VECTOR2D ToWorld( const VECTOR2D& aPoint ) const
969  {
970  return VECTOR2D( screenWorldMatrix * aPoint );
971  }
972 
979  inline VECTOR2D ToScreen( const VECTOR2D& aPoint ) const
980  {
981  return VECTOR2D( worldScreenMatrix * aPoint );
982  }
983 
989  inline void SetCursorEnabled( bool aCursorEnabled )
990  {
991  isCursorEnabled = aCursorEnabled;
992  }
993 
998  bool IsCursorEnabled() const
999  {
1001  }
1002 
1008  inline void SetCursorColor( const COLOR4D& aCursorColor )
1009  {
1010  cursorColor = aCursorColor;
1011  }
1012 
1018  virtual void DrawCursor( const VECTOR2D& aCursorPosition ) {};
1019 
1024  inline void AdvanceDepth()
1025  {
1026  layerDepth -= 0.05;
1027  }
1028 
1032  inline void PushDepth()
1033  {
1034  depthStack.push( layerDepth );
1035  }
1036 
1040  inline void PopDepth()
1041  {
1042  layerDepth = depthStack.top();
1043  depthStack.pop();
1044  }
1045 
1046  virtual void EnableDepthTest( bool aEnabled = false ) {};
1047 
1048 protected:
1049 
1052 
1053  std::stack<double> depthStack;
1055 
1057  double screenDPI;
1059 
1060  double zoomFactor;
1061  double rotation;
1064  double worldScale;
1065 
1068 
1069  float lineWidth;
1070 
1073 
1077 
1078  double layerDepth;
1080 
1081  // Grid settings
1090  int gridTick;
1093 
1095  // Cursor settings
1101 
1104 
1106  virtual void lockContext( int aClientCookie ) {}
1107 
1108  virtual void unlockContext( int aClientCookie ) {}
1109 
1112  virtual void beginUpdate() {}
1113 
1115  virtual void endUpdate() {}
1116 
1119  virtual void beginDrawing() {};
1120 
1123  virtual void endDrawing() {};
1124 
1126  inline void computeWorldScale()
1127  {
1129  }
1130 
1136  double computeMinGridSpacing() const;
1137 
1139  static const int MIN_DEPTH;
1140  static const int MAX_DEPTH;
1141 
1143  static const int GRID_DEPTH;
1144 
1148  COLOR4D getCursorColor() const;
1149 
1150  // ---------------
1151  // Settings observer interface
1152  // ---------------
1156  void OnGalDisplayOptionsChanged( const GAL_DISPLAY_OPTIONS& aOptions ) override;
1157 
1167  virtual bool updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions );
1168 
1169 private:
1171  {
1175  bool m_bold;
1176  bool m_italic;
1178  } textProperties;
1179 };
1180 
1181 
1183 {
1184 public:
1186  m_gal( aGal )
1187  {
1188  m_cookie = rand();
1190  }
1191 
1193  {
1195  }
1196 
1197 protected:
1200 };
1201 
1202 
1204 {
1205 public:
1207  GAL_CONTEXT_LOCKER( aGal )
1208  {
1209  m_gal->beginUpdate();
1210  }
1211 
1213  {
1214  m_gal->endUpdate();
1215  }
1216 };
1217 
1218 
1220 {
1221 public:
1223  GAL_CONTEXT_LOCKER( aGal )
1224  {
1225  m_gal->beginDrawing();
1226  }
1227 
1229  {
1230  m_gal->endDrawing();
1231  }
1232 };
1233 
1234 
1235 }; // namespace KIGFX
1236 
1237 #endif /* GRAPHICSABSTRACTIONLAYER_H_ */
const STROKE_FONT & GetStrokeFont() const
static const int GRID_DEPTH
Depth level on which the grid is drawn.
int gridTick
Every tick line gets the double width.
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
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.
double GetMinDepth() const
Returns the minimum depth in the currently used range (the top).
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
double zoomFactor
The zoom factor.
STROKE_FONT strokeFont
Instance of object that stores information about how to draw texts.
float GetLineWidth() const
Get the line width.
VECTOR2D cursorPosition
Current cursor position (world coordinates)
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
void SetClearColor(const COLOR4D &aColor)
bool axesEnabled
Should the axes be drawn.
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:44
GRID_STYLE
GRID_STYLE: Type definition of the grid style.
VECTOR2D gridOffset
The grid offset to compensate cursor position.
double layerDepth
The actual layer depth.
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:58
virtual void DeleteGroup(int aGroupNumber)
Delete the group from the memory.
double GetMaxDepth() const
Returns the maximum depth in the currently used range (the bottom).
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draws a text using a bitmap font.
bool IsTextMirrored() const
Returns true if text should displayed mirrored.
double computeMinGridSpacing() const
compute minimum grid spacing from the grid settings
bool isCursorEnabled
Is the cursor enabled?
void SetCursorEnabled(bool aCursorEnabled)
Enable/disable cursor.
const COLOR4D & GetFillColor() const
Get the fill color.
bool IsFlippedX() const
Return true if flip flag for the X axis is set.
virtual void SetTextAttributes(const EDA_TEXT *aText)
Loads attributes of the given text (bold/italic/underline/mirrored and so on).
int gridMinSpacing
Minimum screen size of the grid (pixels) below which the grid is not drawn.
VECTOR2D ToScreen(const VECTOR2D &aPoint) const
Compute the point position in screen coordinates from given world coordinates.
GRID_STYLE gridStyle
Grid display style.
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle)
Draw an arc.
GAL_DISPLAY_OPTIONS & options
double rotation
Rotation transformation (radians)
EDA_TEXT_VJUSTIFY_T m_verticalJustify
Vertical justification.
virtual void DrawPolygon(const SHAPE_POLY_SET &aPolySet)
void SetFlip(bool xAxis, bool yAxis)
Sets flipping of the screen.
virtual void DrawBitmap(const BITMAP_BASE &aBitmap)
Draw a bitmap image.
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 void ComputeWorldScreenMatrix()
Compute the world <-> screen transformation matrix.
EDA_TEXT_HJUSTIFY_T GetHorizontalJustify() const
Returns current text horizontal justification setting.
void SetScreenDPI(double aScreenDPI)
Set the dots per inch of the screen.
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)
VECTOR2D lookAtPoint
Point to be looked at in world space.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void EndGroup()
End the group.
virtual void Rotate(double aAngle)
Rotate the context.
This class handle bitmap images in KiCad.
Definition: bitmap_base.h:51
const VECTOR2D & GetGlyphSize() const
VECTOR2D GetGridPoint(const VECTOR2D &aPoint) const
Function GetGridPoint() For a given point it returns the nearest point belonging to the grid in world...
bool IsFontBold() const
Returns true if current font has 'bold' attribute enabled.
Class EDA_TEXT is a mix-in class (via multiple inheritance) that handles texts such as labels,...
Definition: eda_text.h:109
virtual void ChangeGroupColor(int aGroupNumber, const COLOR4D &aNewColor)
Changes the color used to draw the group.
static const int MIN_DEPTH
Possible depth range.
virtual RENDER_TARGET GetTarget() const
Gets the currently used target for rendering.
const VECTOR2I & GetScreenPixelSize() const
Returns GAL canvas size in pixels.
GAL(GAL_DISPLAY_OPTIONS &aOptions)
void SetFontBold(const bool aBold)
Set bold property of current font.
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
const COLOR4D & GetStrokeColor() const
Get the stroke color.
COLOR4D cursorColor
Cursor color.
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
bool fullscreenCursor
Shape of the cursor (fullscreen or small cross)
void OnGalDisplayOptionsChanged(const GAL_DISPLAY_OPTIONS &aOptions) override
Handler for observer settings changes.
void ResetTextAttributes()
Reset text attributes to default styling.
bool isStrokeEnabled
Are the outlines stroked ?
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
float GetGridLineWidth() const
Get the grid line width.
void PopDepth()
Restores previously stored drawing depth for the depth stack.
Class SHAPE_POLY_SET.
COLOR4D axesColor
Color of the axes.
virtual int BeginGroup()
Begin a group.
virtual void beginUpdate()
Enables item update mode.
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
virtual void ClearTarget(RENDER_TARGET aTarget)
Clears the target for rendering.
virtual void unlockContext(int aClientCookie)
void SetScreenSize(const VECTOR2I &aSize)
COLOR4D strokeColor
The color of the outlines.
float gridLineWidth
Line width of the grid.
virtual void DrawGrid()
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 void StrokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle, int aMarkupFlags=0)
Draws a vector type text using preloaded Newstroke font.
double GetZoomFactor() const
Get the zoom factor.
virtual bool IsOpenGlEngine()
Returns true if the GAL engine is a opengl based type.
bool IsFlippedY() const
Return true if flip flag for the Y axis is set.
VECTOR2D gridOrigin
The grid origin.
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
struct KIGFX::GAL::TEXT_PROPERTIES textProperties
void SetCursorColor(const COLOR4D &aCursorColor)
Set the cursor color.
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
const COLOR4D & GetClearColor() const
MATRIX3x3D worldScreenMatrix
World transformation.
virtual void DrawPolyline(const SHAPE_LINE_CHAIN &aLineChain)
void SetAxesEnabled(bool aAxesEnabled)
Enables drawing the axes.
virtual void ResizeScreen(int aWidth, int aHeight)
Resizes the canvas.
void SetGridSize(const VECTOR2D &aGridSize)
Set the grid size.
virtual void DrawPolygon(const SHAPE_LINE_CHAIN &aPolySet)
void SetWorldUnitLength(double aWorldUnitLength)
Set the unit length.
COLOR4D getCursorColor() const
Gets the actual cursor color to draw.
virtual void Flush()
Force all remaining objects to be drawn.
virtual bool updatedGalDisplayOptions(const GAL_DISPLAY_OPTIONS &aOptions)
Function updatedGalDisplayOptions.
virtual void Scale(const VECTOR2D &aScale)
Scale the context.
bool IsFontItalic() const
Returns true if current font has 'italic' attribute enabled.
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:51
float lineWidth
The line width.
bool isFillEnabled
Is filling of graphic objects enabled ?
virtual bool Show(bool aShow)
Shows/hides the GAL canvas.
const VECTOR2D & GetGridSize() const
Returns the grid size.
void computeWorldScale()
Compute the scaling factor for the world->screen matrix.
virtual void ClearScreen()
Clear the screen.
VECTOR2D ToWorld(const VECTOR2D &aPoint) const
Compute the point position in world coordinates from given screen coordinates.
double computeOverbarVerticalPosition() const
Compute the vertical position of an overbar, sometimes used in texts.
const VECTOR2D & GetLookAtPoint() const
Get the look at point.
void SetWorldScreenMatrix(const MATRIX3x3D &aMatrix)
Set the world <-> screen transformation matrix.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void DrawPolyline(const VECTOR2D aPointList[], int aListSize)
void SetCoarseGrid(int aInterval)
Draw every tick line wider.
void 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:48
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
void SetRotation(double aRotation)
Set the rotation angle.
bool globalFlipY
Flag for Y axis flipping.
EDA_TEXT_VJUSTIFY_T GetVerticalJustify() const
Returns current text vertical justification setting.
Class SHAPE_LINE_CHAIN.
double worldScale
The scale factor world->screen.
VECTOR2D gridSize
The grid size.
void Draw(const UTF8 &aText, const VECTOR2D &aPosition, double aRotationAngle, int markupFlags)
Draw a string.
VECTOR2I screenSize
Screen size in screen coordinates.
virtual bool IsVisible() const
Returns true if the GAL canvas is visible on the screen.
void SetZoomFactor(double aZoomFactor)
Set the zoom factor of the scene.
virtual void ChangeGroupDepth(int aGroupNumber, int aDepth)
Changes the depth (Z-axis position) of the group.
void SetGridVisibility(bool aVisibility)
Sets the visibility setting of the grid.
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.
void SetLookAtPoint(const VECTOR2D &aPoint)
Set the Point in world space to look at.
virtual void lockContext(int aClientCookie)
Private: use GAL_CONTEXT_LOCKER RAII object.
virtual void Save()
Save the context.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
RENDER_TARGET
RENDER_TARGET: Possible rendering targets.
Definition: definitions.h:46
const MATRIX3x3D & GetWorldScreenMatrix() const
Get the world <-> screen transformation matrix.
VECTOR2D m_glyphSize
Size of the glyphs.
double GetRotation() const
Get the rotation angle.
double GetWorldScale() const
Get the world scale.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
virtual void DrawCurve(const VECTOR2D &startPoint, const VECTOR2D &controlPointA, const VECTOR2D &controlPointB, const VECTOR2D &endPoint, double aFilterValue=0.0)
Draw a cubic bezier spline.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
void SetDepthRange(const VECTOR2D &aDepthRange)
Set the range of the layer depth.
bool IsCursorEnabled() const
Returns information about cursor visibility.
void AdvanceDepth()
Changes the current depth to deeper, so it is possible to draw objects right beneath other.
virtual void beginDrawing()
Begin the drawing, needs to be called for every new frame.
virtual void SetNegativeDrawMode(bool aSetting)
Sets negative draw mode in the renderer.
virtual void DrawPolygon(const VECTOR2D aPointList[], int aListSize)
Class STROKE_FONT implements stroke font drawing.
Definition: stroke_font.h:53
bool forceDisplayCursor
Always show cursor.
virtual void ClearCache()
Delete all data created during caching of graphic items.
double GetOverbarVerticalPosition() const
Compute the vertical position of an overbar, sometimes used in texts.
virtual bool IsInitialized() const
Returns the initalization status for the canvas.
virtual void endDrawing()
End the drawing, needs to be called for every new frame.
EDA_TEXT_HJUSTIFY_T m_horizontalJustify
Horizontal justification.
virtual void SetTarget(RENDER_TARGET aTarget)
Sets the target for rendering.
Class GAL is the abstract interface for drawing on a 2D-surface.
double screenDPI
The dots per inch of the screen.
VECTOR2D GetTextLineSize(const UTF8 &aText, int aMarkupFlags=0) const
Compute the X and Y size of a given text.
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