KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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/gal.h>
37#include <gal/color4d.h>
38#include <gal/cursors.h>
39#include <gal/definitions.h>
41#include <font/stroke_font.h>
42#include <geometry/eda_angle.h>
43#include <pgm_base.h>
45
47class SHAPE_POLY_SET;
48class BITMAP_BASE;
49
50namespace KIGFX
51{
62class GAL_API GAL : GAL_DISPLAY_OPTIONS_OBSERVER
63{
64 // These friend declarations allow us to hide routines that should not be called. The
65 // corresponding RAII objects must be used instead.
66 friend class GAL_CONTEXT_LOCKER;
67 friend class GAL_UPDATE_CONTEXT;
68 friend class GAL_DRAWING_CONTEXT;
69
70public:
71 // Constructor / Destructor
72 GAL( GAL_DISPLAY_OPTIONS& aOptions );
73 virtual ~GAL();
74
76 virtual bool IsInitialized() const { return true; }
77
79 virtual bool IsVisible() const { return true; }
80
82 virtual bool IsCairoEngine() { return false; }
83
85 virtual bool IsOpenGlEngine() { return false; }
86
87 // ---------------
88 // Drawing methods
89 // ---------------
90
99 virtual void DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) {};
100
110 virtual void DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint,
111 double aWidth ){};
112
119 virtual void DrawSegmentChain( const std::vector<VECTOR2D>& aPointList, double aWidth ){};
120 virtual void DrawSegmentChain( const SHAPE_LINE_CHAIN& aLineChain, double aWidth ){};
121
127 virtual void DrawPolyline( const std::deque<VECTOR2D>& aPointList ) {};
128 virtual void DrawPolyline( const std::vector<VECTOR2D>& aPointList ) {};
129 virtual void DrawPolyline( const VECTOR2D aPointList[], int aListSize ) {};
130 virtual void DrawPolyline( const SHAPE_LINE_CHAIN& aLineChain ) {};
131
137 virtual void DrawPolylines( const std::vector<std::vector<VECTOR2D>>& aPointLists ){};
138
145 virtual void DrawCircle( const VECTOR2D& aCenterPoint, double aRadius ) {};
146
154 virtual void DrawHoleWall( const VECTOR2D& aCenterPoint, double aHoleRadius,
155 double aWallWidth ) {};
156
165 virtual void DrawArc( const VECTOR2D& aCenterPoint, double aRadius,
166 const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aAngle ){};
167
188 virtual void DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius,
189 const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aAngle,
190 double aWidth, double aMaxError ){};
191
198 virtual void DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) {};
199
200 void DrawRectangle( const BOX2I& aRect )
201 {
202 DrawRectangle( aRect.GetOrigin(), aRect.GetEnd() );
203 }
204
208 virtual void DrawGlyph( const KIFONT::GLYPH& aGlyph, int aNth = 0, int aTotal = 1 ) {};
209
213 virtual void DrawGlyphs( const std::vector<std::unique_ptr<KIFONT::GLYPH>>& aGlyphs )
214 {
215 for( size_t i = 0; i < aGlyphs.size(); i++ )
216 DrawGlyph( *aGlyphs[i], i, aGlyphs.size() );
217 }
218
219
225 virtual void DrawPolygon( const std::deque<VECTOR2D>& aPointList ) {};
226 virtual void DrawPolygon( const VECTOR2D aPointList[], int aListSize ) {};
227 virtual void DrawPolygon( const SHAPE_POLY_SET& aPolySet,
228 bool aStrokeTriangulation = false ) {};
229 virtual void DrawPolygon( const SHAPE_LINE_CHAIN& aPolySet ) {};
230
242 virtual void DrawCurve( const VECTOR2D& startPoint, const VECTOR2D& controlPointA,
243 const VECTOR2D& controlPointB, const VECTOR2D& endPoint,
244 double aFilterValue = 0.0 ) {};
245
249 virtual void DrawBitmap( const BITMAP_BASE& aBitmap, double alphaBlend = 1.0 ) {};
250
251 // --------------
252 // Screen methods
253 // --------------
254
256 virtual void ResizeScreen( int aWidth, int aHeight ) {};
257
259 virtual bool Show( bool aShow ) { return true; };
260
263 {
264 return m_screenSize;
265 }
266
268 virtual int GetSwapInterval() const { return 0; };
269
271 virtual void Flush() {};
272
273 void SetClearColor( const COLOR4D& aColor )
274 {
275 m_clearColor = aColor;
276 }
277
278 const COLOR4D& GetClearColor( ) const
279 {
280 return m_clearColor;
281 }
282
288 virtual void ClearScreen() {};
289
290 // -----------------
291 // Attribute setting
292 // -----------------
293
299 virtual void SetIsFill( bool aIsFillEnabled )
300 {
301 m_isFillEnabled = aIsFillEnabled;
302 }
303
309 inline bool GetIsFill() const
310 {
311 return m_isFillEnabled;
312 }
313
319 virtual void SetIsStroke( bool aIsStrokeEnabled )
320 {
321 m_isStrokeEnabled = aIsStrokeEnabled;
322 }
323
329 inline bool GetIsStroke() const
330 {
331 return m_isStrokeEnabled;
332 }
333
339 virtual void SetFillColor( const COLOR4D& aColor )
340 {
341 m_fillColor = aColor;
342 }
343
349 inline const COLOR4D& GetFillColor() const
350 {
351 return m_fillColor;
352 }
353
359 virtual void SetStrokeColor( const COLOR4D& aColor )
360 {
361 m_strokeColor = aColor;
362 }
363
369 inline const COLOR4D& GetStrokeColor() const
370 {
371 return m_strokeColor;
372 }
373
379 virtual void SetLineWidth( float aLineWidth )
380 {
381 m_lineWidth = aLineWidth;
382 }
383
389 virtual void SetMinLineWidth( float aLineWidth )
390 {
391 m_minLineWidth = aLineWidth;
392 }
393
399 inline float GetLineWidth() const
400 {
401 return m_lineWidth;
402 }
403
409 inline float GetMinLineWidth() const
410 {
411 return m_minLineWidth;
412 }
413
422 virtual void SetLayerDepth( double aLayerDepth )
423 {
424 wxCHECK_MSG( aLayerDepth <= m_depthRange.y, /*void*/,
425 wxT( "SetLayerDepth: below minimum" ) );
426 wxCHECK_MSG( aLayerDepth >= m_depthRange.x, /*void*/,
427 wxT( "SetLayerDepth: above maximum" ) );
428
429 m_layerDepth = aLayerDepth;
430 }
431
439 inline void AdvanceDepth()
440 {
442 }
443
444 // ----
445 // Text
446 // ----
447
456 virtual void BitmapText( const wxString& aText, const VECTOR2I& aPosition,
457 const EDA_ANGLE& aAngle );
458
465 void ResetTextAttributes();
466
467 void SetGlyphSize( const VECTOR2I aSize ) { m_attributes.m_Size = aSize; }
468 const VECTOR2I& GetGlyphSize() const { return m_attributes.m_Size; }
469
470 inline void SetFontBold( const bool aBold ) { m_attributes.m_Bold = aBold; }
471 inline bool IsFontBold() const { return m_attributes.m_Bold; }
472
473 inline void SetFontItalic( bool aItalic ) { m_attributes.m_Italic = aItalic; }
474 inline bool IsFontItalic() const { return m_attributes.m_Italic; }
475
476 inline void SetFontUnderlined( bool aUnderlined ) { m_attributes.m_Underlined = aUnderlined; }
477 inline bool IsFontUnderlined() const { return m_attributes.m_Underlined; }
478
479 void SetTextMirrored( const bool aMirrored ) { m_attributes.m_Mirrored = aMirrored; }
480 bool IsTextMirrored() const { return m_attributes.m_Mirrored; }
481
482 void SetHorizontalJustify( const GR_TEXT_H_ALIGN_T aHorizontalJustify )
483 {
484 m_attributes.m_Halign = aHorizontalJustify;
485 }
486
488
489 void SetVerticalJustify( const GR_TEXT_V_ALIGN_T aVerticalJustify )
490 {
491 m_attributes.m_Valign = aVerticalJustify;
492 }
493
495
496
497 // --------------
498 // Transformation
499 // --------------
500
506 virtual void Transform( const MATRIX3x3D& aTransformation ) {};
507
513 virtual void Rotate( double aAngle ) {};
514
520 virtual void Translate( const VECTOR2D& aTranslation ) {};
521
527 virtual void Scale( const VECTOR2D& aScale ) {};
528
530 virtual void Save() {};
531
533 virtual void Restore() {};
534
535 // --------------------------------------------
536 // Group methods
537 // ---------------------------------------------
538
547 virtual int BeginGroup() { return 0; };
548
550 virtual void EndGroup() {};
551
557 virtual void DrawGroup( int aGroupNumber ) {};
558
565 virtual void ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor ) {};
566
573 virtual void ChangeGroupDepth( int aGroupNumber, int aDepth ) {};
574
580 virtual void DeleteGroup( int aGroupNumber ) {};
581
585 virtual void ClearCache() {};
586
587 // --------------------------------------------------------
588 // Handling the world <-> screen transformation
589 // --------------------------------------------------------
590
592 virtual void ComputeWorldScreenMatrix();
593
600 {
601 return m_worldScreenMatrix;
602 }
603
610 {
611 return m_screenWorldMatrix;
612 }
613
619 inline void SetWorldScreenMatrix( const MATRIX3x3D& aMatrix )
620 {
621 m_worldScreenMatrix = aMatrix;
622 }
623
627 BOX2D GetVisibleWorldExtents() const;
628
636 void SetWorldUnitLength( double aWorldUnitLength ) { m_worldUnitLength = aWorldUnitLength; }
637
638 void SetScreenSize( const VECTOR2I& aSize ) { m_screenSize = aSize; }
639
646 void SetScreenDPI( double aScreenDPI ) { m_screenDPI = aScreenDPI; }
647 double GetScreenDPI() const { return m_screenDPI; }
648
654 void SetLookAtPoint( const VECTOR2D& aPoint ) { m_lookAtPoint = aPoint; }
655 const VECTOR2D& GetLookAtPoint() const { return m_lookAtPoint; }
656
657 void SetZoomFactor( double aZoomFactor ) { m_zoomFactor = aZoomFactor; }
658 double GetZoomFactor() const { return m_zoomFactor; }
659
663 void SetRotation( double aRotation ) { m_rotation = aRotation; }
664 double GetRotation() const { return m_rotation; }
665
674 void SetDepthRange( const VECTOR2D& aDepthRange ) { m_depthRange = aDepthRange; }
675 double GetMinDepth() const { return m_depthRange.x; }
676 double GetMaxDepth() const { return m_depthRange.y; }
677
683 double GetWorldScale() const { return m_worldScale; }
684
691 inline void SetFlip( bool xAxis, bool yAxis )
692 {
693 m_globalFlipX = xAxis;
694 m_globalFlipY = yAxis;
695 }
696
697 bool IsFlippedX() const { return m_globalFlipX; }
698 bool IsFlippedY() const { return m_globalFlipY; }
699
700 // ---------------------------
701 // Buffer manipulation methods
702 // ---------------------------
703
709 virtual void SetTarget( RENDER_TARGET aTarget ) {};
710
716 virtual RENDER_TARGET GetTarget() const { return TARGET_CACHED; };
717
723 virtual void ClearTarget( RENDER_TARGET aTarget ) {};
724
730 virtual bool HasTarget( RENDER_TARGET aTarget )
731 {
732 return true;
733 };
734
746 virtual void SetNegativeDrawMode( bool aSetting ) {};
747
755 virtual void StartDiffLayer() {};
756
762 virtual void EndDiffLayer() {};
763
772 virtual void StartNegativesLayer(){};
773
778 virtual void EndNegativesLayer(){};
779
780 // -------------
781 // Grid methods
782 // -------------
783
789 void SetGridVisibility( bool aVisibility ) { m_gridVisibility = aVisibility; }
790
791 bool GetGridVisibility() const { return m_gridVisibility; }
792
793 bool GetGridSnapping() const
794 {
795 return m_options.m_gridSnapping == KIGFX::GRID_SNAPPING::ALWAYS ||
797 }
798
804 inline void SetGridOrigin( const VECTOR2D& aGridOrigin )
805 {
806 m_gridOrigin = aGridOrigin;
807
808 if( m_gridSize.x == 0.0 || m_gridSize.y == 0.0 )
809 {
810 m_gridOffset = VECTOR2D( 0.0, 0.0);
811 }
812 else
813 {
814 m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x,
815 (long) m_gridOrigin.y % (long) m_gridSize.y );
816 }
817 }
818
819 inline const VECTOR2D& GetGridOrigin() const
820 {
821 return m_gridOrigin;
822 }
823
829 inline void SetGridSize( const VECTOR2D& aGridSize )
830 {
831 m_gridSize = aGridSize;
832
833 // Avoid stupid grid size values: a grid size should be >= 1 in internal units
834 m_gridSize.x = std::max( 1.0, m_gridSize.x );
835 m_gridSize.y = std::max( 1.0, m_gridSize.y );
836
837 m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x,
838 (long) m_gridOrigin.y % (long) m_gridSize.y );
839 }
840
846 inline const VECTOR2D& GetGridSize() const
847 {
848 return m_gridSize;
849 }
850
857 {
858 VECTOR2D gridScreenSize( m_gridSize );
859 gridScreenSize.x = std::max( 100.0, gridScreenSize.x );
860 gridScreenSize.y = std::max( 100.0, gridScreenSize.y );
861
862 double gridThreshold = computeMinGridSpacing() / m_worldScale;
863
865 gridThreshold *= 2.0;
866
867 // If we cannot display the grid density, scale down by a tick size and
868 // try again. Eventually, we get some representation of the grid
869 while( std::min( gridScreenSize.x, gridScreenSize.y ) <= gridThreshold )
870 {
871 gridScreenSize = gridScreenSize * static_cast<double>( m_gridTick );
872 }
873
874 return gridScreenSize;
875 }
876
882 inline void SetGridColor( const COLOR4D& aGridColor )
883 {
884 m_gridColor = aGridColor;
885 }
886
892 inline void SetAxesColor( const COLOR4D& aAxesColor )
893 {
894 m_axesColor = aAxesColor;
895 }
896
900 inline void SetAxesEnabled( bool aAxesEnabled )
901 {
902 m_axesEnabled = aAxesEnabled;
903 }
904
910 inline void SetCoarseGrid( int aInterval )
911 {
912 m_gridTick = aInterval;
913 }
914
920 inline float GetGridLineWidth() const
921 {
922 return m_gridLineWidth;
923 }
924
926 virtual void DrawGrid() {};
927
934 VECTOR2D GetGridPoint( const VECTOR2D& aPoint ) const;
935
942 inline VECTOR2D ToWorld( const VECTOR2D& aPoint ) const
943 {
944 return VECTOR2D( m_screenWorldMatrix * aPoint );
945 }
946
953 inline VECTOR2D ToScreen( const VECTOR2D& aPoint ) const
954 {
955 return VECTOR2D( m_worldScreenMatrix * aPoint );
956 }
957
964 virtual bool SetNativeCursorStyle( KICURSOR aCursor, bool aHiDPI );
965
971 inline void SetCursorEnabled( bool aCursorEnabled )
972 {
973 m_isCursorEnabled = aCursorEnabled;
974 }
975
981 bool IsCursorEnabled() const
982 {
984 }
985
991 inline void SetCursorColor( const COLOR4D& aCursorColor )
992 {
993 m_cursorColor = aCursorColor;
994 }
995
1001 virtual void DrawCursor( const VECTOR2D& aCursorPosition ) {};
1002
1003 virtual void EnableDepthTest( bool aEnabled = false ) {};
1004
1009 virtual bool IsContextLocked()
1010 {
1011 return false;
1012 }
1013
1014
1016 virtual void LockContext( int aClientCookie ) {}
1017
1018 virtual void UnlockContext( int aClientCookie ) {}
1019
1024
1027 virtual void BeginDrawing() {};
1028
1031 virtual void EndDrawing() {};
1032protected:
1033
1036 virtual void beginUpdate() {}
1037
1039 virtual void endUpdate() {}
1040
1041
1042
1044 inline void computeWorldScale()
1045 {
1047
1048 if( Pgm().GetCommonSettings() )
1050 }
1051
1057 double computeMinGridSpacing() const;
1058
1060 static const int MIN_DEPTH;
1061 static const int MAX_DEPTH;
1062
1064 static const int GRID_DEPTH;
1065
1069 COLOR4D getCursorColor() const;
1070
1071 // ---------------
1072 // Settings observer interface
1073 // ---------------
1077 void OnGalDisplayOptionsChanged( const GAL_DISPLAY_OPTIONS& aOptions ) override;
1078
1087 virtual bool updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions );
1088
1092 template <typename T>
1093 void normalize( T &a, T &b )
1094 {
1095 if( a > b )
1096 {
1097 T tmp = a;
1098 a = b;
1099 b = tmp;
1100 }
1101 }
1102
1105
1106 std::stack<double> m_depthStack;
1108
1112
1114 double m_rotation;
1118
1121
1124
1127
1131
1134
1135 // Grid settings
1148
1149 // Cursor settings
1155
1157
1158private:
1159
1160 inline double getLayerDepth() const
1161 {
1162 return m_layerDepth;
1163 }
1164
1166
1167 friend class GAL_SCOPED_ATTRS;
1168};
1169
1170
1172{
1173public:
1175 m_gal( aGal )
1176 {
1177 m_cookie = rand();
1178 m_gal->LockContext( m_cookie );
1179 }
1180
1182 {
1183 m_gal->UnlockContext( m_cookie );
1184 }
1185
1186protected:
1189};
1190
1191
1193{
1194public:
1196 GAL_CONTEXT_LOCKER( aGal )
1197 {
1198 m_gal->beginUpdate();
1199 }
1200
1202 {
1203 m_gal->endUpdate();
1204 }
1205};
1206
1207
1209{
1210public:
1212 GAL_CONTEXT_LOCKER( aGal )
1213 {
1214 m_gal->BeginDrawing();
1215 }
1216
1217 ~GAL_DRAWING_CONTEXT() noexcept( false )
1218 {
1219 m_gal->EndDrawing();
1220 }
1221};
1222
1223
1228{
1229public:
1231 {
1238
1239 // It is not clear to me that GAL needs to save text attributes.
1240 // Only BitmapText uses it, and maybe that should be passed in
1241 // explicitly (like for Draw) - every caller of BitmapText sets
1242 // the text attributes anyway.
1243 // TEXT_ATTRS = 64,
1244
1245 // Convenience flags
1249
1251 };
1252
1258 GAL_SCOPED_ATTRS( KIGFX::GAL& aGal, int aFlags )
1259 : m_gal( aGal ), m_flags( aFlags )
1260 {
1261 // Save what we need to restore later.
1262 // These are all so cheap to copy, it's likely not worth if'ing
1263 m_strokeWidth = aGal.GetLineWidth();
1265 m_isStroke = aGal.GetIsStroke();
1266 m_fillColor = aGal.GetFillColor();
1267 m_isFill = aGal.GetIsFill();
1268 m_layerDepth = aGal.getLayerDepth();
1269 }
1270
1272 {
1273 // Restore the attributes that were saved
1274 // based on the flags that were set.
1275
1276 if( m_flags & STROKE_WIDTH )
1277 m_gal.SetLineWidth( m_strokeWidth );
1278
1279 if( m_flags & STROKE_COLOR )
1280 m_gal.SetStrokeColor( m_strokeColor );
1281
1282 if( m_flags & IS_STROKE )
1283 m_gal.SetIsStroke( m_isStroke );
1284
1285 if( m_flags & FILL_COLOR )
1286 m_gal.SetFillColor( m_fillColor );
1287
1288 if( m_flags & IS_FILL )
1289 m_gal.SetIsFill( m_isFill );
1290
1291 if( m_flags & LAYER_DEPTH )
1292 m_gal.SetLayerDepth( m_layerDepth );
1293 }
1294
1295private:
1298
1302
1305
1307};
1308
1309
1310}; // namespace KIGFX
1311
1312#endif /* GRAPHICSABSTRACTIONLAYER_H_ */
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
BOX2< VECTOR2D > BOX2D
Definition box2.h:923
This class handle bitmap images in KiCad.
Definition bitmap_base.h:49
constexpr const Vec GetEnd() const
Definition box2.h:212
constexpr const Vec & GetOrigin() const
Definition box2.h:210
APPEARANCE m_Appearance
GAL(GAL_DISPLAY_OPTIONS &aOptions)
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:104
GAL_SCOPED_ATTRS(KIGFX::GAL &aGal, int aFlags)
Instantiate a GAL_SCOPED_ATTRS object, saving the current attributes of the GAL.
Abstract interface for drawing on a 2D-surface.
const VECTOR2D & GetGridOrigin() const
virtual void ResizeScreen(int aWidth, int aHeight)
Resize the canvas.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
float GetGridLineWidth() const
Get the grid line width.
virtual bool Show(bool aShow)
Show/hide the GAL canvas.
virtual void SetLayerDepth(double aLayerDepth)
Set the depth of the layer (position on the z-axis)
double GetScreenDPI() const
const MATRIX3x3D & GetWorldScreenMatrix() const
Get the world <-> screen transformation matrix.
bool IsCursorEnabled() const
Return information about cursor visibility.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
friend class GAL_DRAWING_CONTEXT
friend class GAL_CONTEXT_LOCKER
virtual void EndDrawing()
End the drawing, needs to be called for every new frame.
virtual void StartDiffLayer()
Begins rendering of a differential layer.
bool m_isCursorEnabled
Is the cursor enabled?
virtual void DrawGlyph(const KIFONT::GLYPH &aGlyph, int aNth=0, int aTotal=1)
Draw a polygon representing a font glyph.
virtual void EndDiffLayer()
Ends rendering of a differential layer.
virtual void Rotate(double aAngle)
Rotate the context.
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
MATRIX3x3D m_worldScreenMatrix
World transformation.
VECTOR2D GetVisibleGridSize() const
Return the visible grid size in x and y directions.
double m_layerDepth
The actual layer depth.
void SetVerticalJustify(const GR_TEXT_V_ALIGN_T aVerticalJustify)
bool GetIsFill() const
Get the fill status.
void AdvanceDepth()
Change the current depth to deeper, so it is possible to draw objects right beneath other.
const COLOR4D & GetFillColor() const
Get the fill color.
void SetFontBold(const bool aBold)
MATRIX3x3D m_screenWorldMatrix
Screen transformation.
void SetFontUnderlined(bool aUnderlined)
void SetHorizontalJustify(const GR_TEXT_H_ALIGN_T aHorizontalJustify)
virtual RENDER_TARGET GetTarget() const
Get the currently used target for rendering.
double GetMaxDepth() const
bool m_axesEnabled
Should the axes be drawn.
void SetRotation(double aRotation)
Get/set the rotation angle (in radians).
float m_gridLineWidth
Line width of the grid.
void SetFlip(bool xAxis, bool yAxis)
Sets flipping of the screen.
VECTOR2I m_screenSize
Screen size in screen (wx logical) coordinates.
virtual void Flush()
Force all remaining objects to be drawn.
virtual int GetSwapInterval() const
Return the swap interval. -1 for adaptive, 0 for disabled/unknown.
virtual void DeleteGroup(int aGroupNumber)
Delete the group from the memory.
std::stack< double > m_depthStack
Stored depth values.
GR_TEXT_H_ALIGN_T GetHorizontalJustify() const
void normalize(T &a, T &b)
Ensure that the first element is smaller than the second.
VECTOR2D m_depthRange
Range of the depth.
double GetZoomFactor() const
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
void OnGalDisplayOptionsChanged(const GAL_DISPLAY_OPTIONS &aOptions) override
Handler for observer settings changes.
double m_zoomFactor
The zoom factor.
virtual void Translate(const VECTOR2D &aTranslation)
Translate the context.
VECTOR2D ToScreen(const VECTOR2D &aPoint) const
Compute the point position in screen coordinates from given world coordinates.
void SetCursorEnabled(bool aCursorEnabled)
Enable/disable cursor.
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
virtual void DrawPolylines(const std::vector< std::vector< VECTOR2D > > &aPointLists)
Draw multiple polylines.
virtual bool HasTarget(RENDER_TARGET aTarget)
Return true if the target exists.
GRID_STYLE m_gridStyle
Grid display style.
void SetCursorColor(const COLOR4D &aCursorColor)
Set the cursor color.
COLOR4D m_cursorColor
Cursor color.
COLOR4D m_axesColor
Color of the axes.
int m_gridMinSpacing
Minimum screen size of the grid (pixels) below which the grid is not drawn.
void SetGridSize(const VECTOR2D &aGridSize)
Set the grid size.
const VECTOR2D & GetLookAtPoint() const
double GetRotation() const
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
bool IsFontUnderlined() const
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
virtual void Restore()
Restore the context.
float m_lineWidth
The line width.
virtual void DrawHoleWall(const VECTOR2D &aCenterPoint, double aHoleRadius, double aWallWidth)
Draw a hole wall ring.
const COLOR4D & GetStrokeColor() const
Get the stroke color.
virtual void ClearTarget(RENDER_TARGET aTarget)
Clear the target for rendering.
void SetZoomFactor(double aZoomFactor)
virtual void BeginDrawing()
Start/end drawing functions, draw calls can be only made in between the calls to BeginDrawing()/EndDr...
void computeWorldScale()
Compute the scaling factor for the world->screen matrix.
virtual bool IsOpenGlEngine()
Return true if the GAL engine is a OpenGL based type.
virtual int BeginGroup()
Begin a group.
TEXT_ATTRIBUTES m_attributes
static const int MIN_DEPTH
Possible depth range.
const VECTOR2D & GetGridSize() const
Return the grid size.
virtual void DrawPolygon(const VECTOR2D aPointList[], int aListSize)
virtual void SetLineWidth(float aLineWidth)
Set the line width.
double m_rotation
Rotation transformation (radians)
VECTOR2D m_gridSize
The grid size.
virtual void DrawPolygon(const SHAPE_POLY_SET &aPolySet, bool aStrokeTriangulation=false)
COLOR4D getCursorColor() const
Get the actual cursor color to draw.
virtual void ChangeGroupDepth(int aGroupNumber, int aDepth)
Change the depth (Z-axis position) of the group.
COLOR4D m_fillColor
The fill color.
virtual void EndNegativesLayer()
Ends rendering of a negatives layer and draws it to the main layer.
void DrawRectangle(const BOX2I &aRect)
double m_worldUnitLength
The unit length of the world coordinates [inch].
virtual void StartNegativesLayer()
Begins rendering in a new layer that will be copied to the main layer in EndNegativesLayer().
void SetTextMirrored(const bool aMirrored)
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
void SetCoarseGrid(int aInterval)
Draw every tick line wider.
virtual bool updatedGalDisplayOptions(const GAL_DISPLAY_OPTIONS &aOptions)
Handle updating display options.
void SetAxesColor(const COLOR4D &aAxesColor)
Set the axes color.
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual void ChangeGroupColor(int aGroupNumber, const COLOR4D &aNewColor)
Change the color used to draw the group.
virtual void DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aWidth, double aMaxError)
Draw an arc segment.
virtual bool IsContextLocked()
Checks the state of the context lock.
VECTOR2D m_cursorPosition
Current cursor position (world coordinates)
VECTOR2D m_gridOffset
The grid offset to compensate cursor position.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual void beginUpdate()
Enable item update mode.
virtual void DrawGroup(int aGroupNumber)
Draw the stored group.
double getLayerDepth() const
const VECTOR2I & GetGlyphSize() const
int m_gridTick
Every tick line gets the double width.
double m_worldScale
The scale factor world->screen.
void SetLookAtPoint(const VECTOR2D &aPoint)
Get/set the Point in world space to look at.
virtual void DrawPolygon(const SHAPE_LINE_CHAIN &aPolySet)
bool GetGridVisibility() const
void SetGridOrigin(const VECTOR2D &aGridOrigin)
Set the origin point for the grid.
virtual bool IsCairoEngine()
Return true if the GAL engine is a Cairo based type.
virtual void ClearScreen()
Clear the screen.
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
VECTOR2D m_gridOrigin
The grid origin.
virtual void endUpdate()
Disable item update mode.
void SetWorldUnitLength(double aWorldUnitLength)
Set the unit length.
virtual void DrawPolyline(const std::vector< VECTOR2D > &aPointList)
virtual void SetMinLineWidth(float aLineWidth)
Set the minimum line width in pixels.
KICURSOR m_currentNativeCursor
Current cursor.
bool m_globalFlipY
Flag for Y axis flipping.
virtual void UnlockContext(int aClientCookie)
void SetClearColor(const COLOR4D &aColor)
void SetScreenSize(const VECTOR2I &aSize)
const COLOR4D & GetClearColor() const
virtual void DrawSegmentChain(const SHAPE_LINE_CHAIN &aLineChain, double aWidth)
static const int GRID_DEPTH
Depth level on which the grid is drawn.
virtual bool IsInitialized() const
Return the initialization status for the canvas.
float GetMinLineWidth() const
Get the minimum line width in pixels.
void SetGlyphSize(const VECTOR2I aSize)
virtual void DrawGlyphs(const std::vector< std::unique_ptr< KIFONT::GLYPH > > &aGlyphs)
Draw polygons representing font glyphs.
virtual void Scale(const VECTOR2D &aScale)
Scale 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.
bool m_isFillEnabled
Is filling of graphic objects enabled ?
float m_minLineWidth
Minimum line width in pixels.
virtual void EndGroup()
End the group.
virtual void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle)
Draw an arc.
virtual void Transform(const MATRIX3x3D &aTransformation)
Transform the context.
virtual void SetNegativeDrawMode(bool aSetting)
Set negative draw mode in the renderer.
COLOR4D m_gridColor
Color of the grid.
VECTOR2D ToWorld(const VECTOR2D &aPoint) const
Compute the point position in world coordinates from given screen coordinates.
COLOR4D m_strokeColor
The color of the outlines.
double computeMinGridSpacing() const
Compute minimum grid spacing from the grid settings.
void SetFontItalic(bool aItalic)
bool m_isStrokeEnabled
Are the outlines stroked ?
virtual void DrawBitmap(const BITMAP_BASE &aBitmap, double alphaBlend=1.0)
Draw a bitmap image.
GAL_DISPLAY_OPTIONS & m_options
bool m_gridVisibility
Should the grid be shown.
double GetMinDepth() const
virtual void ClearCache()
Delete all data created during caching of graphic items.
virtual void SetTarget(RENDER_TARGET aTarget)
Set the target for rendering.
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
double m_screenDPI
The dots per inch of the screen.
virtual void DrawPolyline(const SHAPE_LINE_CHAIN &aLineChain)
const VECTOR2I & GetScreenPixelSize() const
Return GAL canvas size in pixels.
friend class GAL_UPDATE_CONTEXT
void SetGridVisibility(bool aVisibility)
Set the visibility setting of the grid.
float GetLineWidth() const
Get the line width.
virtual void Save()
Save the context.
bool m_globalFlipX
Flag for X axis flipping.
virtual void LockContext(int aClientCookie)
Use GAL_CONTEXT_LOCKER RAII object unless you know what you're doing.
virtual void DrawSegmentChain(const std::vector< VECTOR2D > &aPointList, double aWidth)
Draw a chain of rounded segments.
void SetWorldScreenMatrix(const MATRIX3x3D &aMatrix)
Set the world <-> screen transformation matrix.
GR_TEXT_V_ALIGN_T GetVerticalJustify() const
bool GetIsStroke() const
Get the stroke status.
KIGFX::CROSS_HAIR_MODE m_crossHairMode
Crosshair drawing mode.
virtual void DrawCursor(const VECTOR2D &aCursorPosition)
Draw the cursor.
void SetDepthRange(const VECTOR2D &aDepthRange)
Set the range of the layer depth.
double GetWorldScale() const
Get the world scale.
VECTOR2D m_lookAtPoint
Point to be looked at in world space.
GAL(GAL_DISPLAY_OPTIONS &aOptions)
virtual bool IsVisible() const
Return true if the GAL canvas is visible on the screen.
void SetScreenDPI(double aScreenDPI)
Set the dots per inch of the screen.
virtual void DrawPolyline(const VECTOR2D aPointList[], int aListSize)
virtual void EnableDepthTest(bool aEnabled=false)
bool m_forceDisplayCursor
Always show cursor.
static const int MAX_DEPTH
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:576
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a set of closed polygons.
KICURSOR
Definition cursors.h:44
#define GAL_API
Definition gal.h:28
MATRIX3x3< double > MATRIX3x3D
Definition matrix3x3.h:473
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:33
GRID_STYLE
Type definition of the grid style.
@ SMALL_CROSS
Use small cross instead of dots for the grid.
RENDER_TARGET
RENDER_TARGET: Possible rendering targets.
Definition definitions.h:36
@ TARGET_CACHED
Main rendering target (cached)
Definition definitions.h:37
PGM_BASE & Pgm()
The global program "get" accessor.
Definition pgm_base.cpp:913
see class PGM_BASE
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695
VECTOR2< double > VECTOR2D
Definition vector2d.h:694