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, see <https://www.gnu.org/licenses/>.
21 */
22
23#ifndef GRAPHICSABSTRACTIONLAYER_H_
24#define GRAPHICSABSTRACTIONLAYER_H_
25
26#include <array>
27#include <cstdint>
28#include <deque>
29#include <stack>
30#include <limits>
31#include <tuple>
32
33#include <math/matrix3x3.h>
34#include <math/box2.h>
36
37#include <gal/gal.h>
38#include <gal/color4d.h>
39#include <gal/cursors.h>
40#include <gal/definitions.h>
42#include <font/stroke_font.h>
43#include <geometry/eda_angle.h>
44#include <pgm_base.h>
46
48class SHAPE_POLY_SET;
49class BITMAP_BASE;
50
51namespace KIGFX
52{
53
55{
56 int64_t priority = 0;
57 std::array<int, 4> bbox{};
58 wxString className;
59 double lodScale = 0.0;
60 std::array<uint64_t, 2> contentHash{};
61 bool contentTie = false;
62
63 bool SamePrefix( const RETAINED_GROUP_ORDER& aOther ) const
64 {
65 return std::tie( priority, bbox, className, lodScale )
66 == std::tie( aOther.priority, aOther.bbox, aOther.className, aOther.lodScale );
67 }
68
69 bool operator<( const RETAINED_GROUP_ORDER& aOther ) const
70 {
71 return std::tie( priority, bbox, className, lodScale, contentHash )
72 < std::tie( aOther.priority, aOther.bbox, aOther.className, aOther.lodScale, aOther.contentHash );
73 }
74};
75
82inline double AutoSparsePitch( double aPitch, unsigned aTick, double aThreshold )
83{
84 const unsigned mult = ( aTick > 1 ) ? aTick : 2u;
85
86 while( aPitch > 0.0 && aPitch <= aThreshold )
87 aPitch *= mult;
88
89 return aPitch;
90}
91
92
99{
100 bool unbounded = false;
102 bool axesEnabled = false;
104 bool snapCursor = false;
105 bool highlighted = false;
106
107 unsigned tick = 0;
108
111};
112
113
116constexpr double GRID_DIM_ALPHA = 0.4;
117
119constexpr double GRID_EDGE_DARKEN = 0.75;
120
122constexpr double GRID_SELECTED_BRIGHTEN = 0.5;
123
124
132
133
144class GAL_API GAL : GAL_DISPLAY_OPTIONS_OBSERVER
145{
146 // These friend declarations allow us to hide routines that should not be called. The
147 // corresponding RAII objects must be used instead.
148 friend class GAL_CONTEXT_LOCKER;
149 friend class GAL_UPDATE_CONTEXT;
151
152public:
153 // Constructor / Destructor
154 GAL( GAL_DISPLAY_OPTIONS& aOptions );
155 virtual ~GAL();
156
158 virtual bool IsInitialized() const { return true; }
159
161 virtual bool IsVisible() const { return true; }
162
164 virtual bool IsCairoEngine() { return false; }
165
167 virtual bool IsOpenGlEngine() { return false; }
168
173 virtual bool RefillsNonCachedTargets() const { return false; }
174
179 virtual bool HasStaticRebuildPending() const { return false; }
180
187 virtual bool HasRetainedScene() const { return false; }
188
195 virtual void BeginSceneLayer( int aLayer ) {}
196
206 virtual void SetSceneLayerState( int aLayer, int aOrder, bool aVisible, bool aHasNegatives ) {}
207
216 virtual void SetSceneLayerDim( int aLayer, const COLOR4D& aToward, double aKeep ) {}
217
224 virtual void SetSceneLayerOverlayAlpha( int aLayer ) {}
225
231 virtual void SetSceneDrawOrdered( bool aOrdered ) {}
232
241 virtual void SetGroupPlacement( int aGroup, int aLayer, double aLodScale, bool aShown,
242 const RETAINED_GROUP_ORDER& aOrder ) {}
243
245 virtual void SetSceneScale( double aScale ) {}
246
248 virtual bool IsDrawingMode() const { return false; }
249
254 virtual bool SupportsTypedPads() const { return false; }
255
260 virtual bool UsesPolygonTriangulationCache() const { return false; }
261
262 // ---------------
263 // Drawing methods
264 // ---------------
265
274 virtual void DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) {};
275
285 virtual void DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint,
286 double aWidth ){};
287
292 virtual void DrawTrack( const VECTOR2D& aStart, const VECTOR2D& aEnd,
293 double aWidth, const COLOR4D& aColor );
294
300 virtual void DrawPad( const VECTOR2D& aCenter, double aHalfWidth, double aHalfHeight,
301 double aCornerRadius, float aShapeType, double aRotation,
302 const COLOR4D& aColor ) {}
303
310 virtual void DrawSegmentChain( const std::vector<VECTOR2D>& aPointList, double aWidth ){};
311 virtual void DrawSegmentChain( const SHAPE_LINE_CHAIN& aLineChain, double aWidth ){};
312
318 virtual void DrawPolyline( const std::deque<VECTOR2D>& aPointList ) {};
319 virtual void DrawPolyline( const std::vector<VECTOR2D>& aPointList ) {};
320 virtual void DrawPolyline( const VECTOR2D aPointList[], int aListSize ) {};
321 virtual void DrawPolyline( const SHAPE_LINE_CHAIN& aLineChain ) {};
322
328 virtual void DrawPolylines( const std::vector<std::vector<VECTOR2D>>& aPointLists ){};
329
336 virtual void DrawCircle( const VECTOR2D& aCenterPoint, double aRadius ) {};
337
345 virtual void DrawHoleWall( const VECTOR2D& aCenterPoint, double aHoleRadius,
346 double aWallWidth ) {};
347
356 virtual void DrawArc( const VECTOR2D& aCenterPoint, double aRadius,
357 const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aAngle ){};
358
379 virtual void DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius,
380 const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aAngle,
381 double aWidth, double aMaxError ){};
382
391 virtual void DrawEllipse( const VECTOR2D& aCenterPoint, double aMajorRadius, double aMinorRadius,
392 const EDA_ANGLE& aRotation );
393
404 virtual void DrawEllipseArc( const VECTOR2D& aCenterPoint, double aMajorRadius, double aMinorRadius,
405 const EDA_ANGLE& aRotation, const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aEndAngle );
406
413 virtual void DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) {};
414
415 void DrawRectangle( const BOX2I& aRect )
416 {
417 DrawRectangle( aRect.GetOrigin(), aRect.GetEnd() );
418 }
419
423 virtual void DrawGlyph( const KIFONT::GLYPH& aGlyph, int aNth = 0, int aTotal = 1 ) {};
424
428 virtual void DrawGlyphs( const std::vector<std::unique_ptr<KIFONT::GLYPH>>& aGlyphs )
429 {
430 COLOR4D fillColor = GetFillColor();
431 COLOR4D strokeColor = GetStrokeColor();
432
433 for( size_t i = 0; i < aGlyphs.size(); i++ )
434 {
435 if( aGlyphs[i]->IsHover() )
436 {
439 }
440
441 DrawGlyph( *aGlyphs[i], i, aGlyphs.size() );
442
443 if( aGlyphs[i]->IsHover() )
444 {
445 SetFillColor( fillColor );
446 SetStrokeColor( strokeColor );
447 }
448 }
449 }
450
451
457 virtual void DrawPolygon( const std::deque<VECTOR2D>& aPointList ) {};
458 virtual void DrawPolygon( const VECTOR2D aPointList[], int aListSize ) {};
459 virtual void DrawPolygon( const SHAPE_POLY_SET& aPolySet,
460 bool aStrokeTriangulation = false ) {};
461 virtual void DrawPolygon( const SHAPE_LINE_CHAIN& aPolySet ) {};
462
474 virtual void DrawCurve( const VECTOR2D& startPoint, const VECTOR2D& controlPointA,
475 const VECTOR2D& controlPointB, const VECTOR2D& endPoint,
476 double aFilterValue = 0.0 ) {};
477
481 virtual void DrawBitmap( const BITMAP_BASE& aBitmap, double alphaBlend = 1.0 ) {};
482
483 // --------------
484 // Screen methods
485 // --------------
486
488 virtual void ResizeScreen( int aWidth, int aHeight ) {};
489
491 virtual bool Show( bool aShow ) { return true; };
492
495 {
496 return m_screenSize;
497 }
498
503 virtual VECTOR2I GetLayoutPixelSize() const { return m_screenSize; }
504
506 virtual int GetSwapInterval() const { return 0; };
507
509 virtual void Flush() {};
510
512 virtual void MarkStaticDirty() {};
513
514 void SetClearColor( const COLOR4D& aColor )
515 {
516 m_clearColor = aColor;
517 }
518
519 const COLOR4D& GetClearColor( ) const
520 {
521 return m_clearColor;
522 }
523
527 virtual void ClearScreen() {};
528
529 // -----------------
530 // Attribute setting
531 // -----------------
532
538 virtual void SetIsFill( bool aIsFillEnabled )
539 {
540 m_isFillEnabled = aIsFillEnabled;
541 }
542
548 inline bool GetIsFill() const
549 {
550 return m_isFillEnabled;
551 }
552
558 virtual void SetIsStroke( bool aIsStrokeEnabled )
559 {
560 m_isStrokeEnabled = aIsStrokeEnabled;
561 }
562
568 inline bool GetIsStroke() const
569 {
570 return m_isStrokeEnabled;
571 }
572
578 virtual void SetFillColor( const COLOR4D& aColor )
579 {
580 m_fillColor = aColor;
581 }
582
588 inline const COLOR4D& GetFillColor() const
589 {
590 return m_fillColor;
591 }
592
598 virtual void SetStrokeColor( const COLOR4D& aColor )
599 {
600 m_strokeColor = aColor;
601 }
602
603 virtual void SetHoverColor( const COLOR4D& aColor )
604 {
605 m_hoverColor = aColor;
606 }
607
613 inline const COLOR4D& GetStrokeColor() const
614 {
615 return m_strokeColor;
616 }
617
623 virtual void SetLineWidth( float aLineWidth )
624 {
625 m_lineWidth = aLineWidth;
626 }
627
633 virtual void SetMinLineWidth( float aLineWidth )
634 {
635 m_minLineWidth = aLineWidth;
636 }
637
643 inline float GetLineWidth() const
644 {
645 return m_lineWidth;
646 }
647
653 inline float GetMinLineWidth() const
654 {
655 return m_minLineWidth;
656 }
657
666 virtual void SetLayerDepth( double aLayerDepth )
667 {
668 wxCHECK_MSG( aLayerDepth <= m_depthRange.y, /*void*/,
669 wxT( "SetLayerDepth: below minimum" ) );
670 wxCHECK_MSG( aLayerDepth >= m_depthRange.x, /*void*/,
671 wxT( "SetLayerDepth: above maximum" ) );
672
673 m_layerDepth = aLayerDepth;
674 }
675
683 inline void AdvanceDepth()
684 {
686 }
687
688 // ----
689 // Text
690 // ----
691
700 virtual void BitmapText( const wxString& aText, const VECTOR2I& aPosition,
701 const EDA_ANGLE& aAngle );
702
709 void ResetTextAttributes();
710
711 void SetGlyphSize( const VECTOR2I aSize ) { m_attributes.m_Size = aSize; }
712 const VECTOR2I& GetGlyphSize() const { return m_attributes.m_Size; }
713
714 inline void SetFontBold( const bool aBold ) { m_attributes.m_Bold = aBold; }
715 inline bool IsFontBold() const { return m_attributes.m_Bold; }
716
717 inline void SetFontItalic( bool aItalic ) { m_attributes.m_Italic = aItalic; }
718 inline bool IsFontItalic() const { return m_attributes.m_Italic; }
719
720 inline void SetFontUnderlined( bool aUnderlined ) { m_attributes.m_Underlined = aUnderlined; }
721 inline bool IsFontUnderlined() const { return m_attributes.m_Underlined; }
722
723 void SetTextMirrored( const bool aMirrored ) { m_attributes.m_Mirrored = aMirrored; }
724 bool IsTextMirrored() const { return m_attributes.m_Mirrored; }
725
726 void SetHorizontalJustify( const GR_TEXT_H_ALIGN_T aHorizontalJustify )
727 {
728 m_attributes.m_Halign = aHorizontalJustify;
729 }
730
732
733 void SetVerticalJustify( const GR_TEXT_V_ALIGN_T aVerticalJustify )
734 {
735 m_attributes.m_Valign = aVerticalJustify;
736 }
737
739
740
741 // --------------
742 // Transformation
743 // --------------
744
750 virtual void Transform( const MATRIX3x3D& aTransformation ) {};
751
757 virtual void Rotate( double aAngle ) {};
758
764 virtual void Translate( const VECTOR2D& aTranslation ) {};
765
771 virtual void Scale( const VECTOR2D& aScale ) {};
772
774 virtual void Save() {};
775
777 virtual void Restore() {};
778
779 // --------------------------------------------
780 // Group methods
781 // ---------------------------------------------
782
791 virtual int BeginGroup() { return 0; };
792
794 virtual void EndGroup() {};
795
796 virtual std::array<uint64_t, 2> GroupContentFingerprint( int aGroupNumber ) const { return {}; }
797
803 virtual void DrawGroup( int aGroupNumber ) {};
804
811 virtual void ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor ) {};
812
819 virtual void ChangeGroupDepth( int aGroupNumber, int aDepth ) {};
820
827 virtual void ChangeGroupUndimmed( int aGroupNumber, bool aUndimmed ) {};
828
834 virtual void DeleteGroup( int aGroupNumber ) {};
835
839 virtual void ClearCache() {};
840
841 // --------------------------------------------------------
842 // Handling the world <-> screen transformation
843 // --------------------------------------------------------
844
846 virtual void ComputeWorldScreenMatrix();
847
856 {
857 m_worldScaleRead = true;
858 return m_worldScreenMatrix;
859 }
860
869 {
870 m_worldScaleRead = true;
871 return m_screenWorldMatrix;
872 }
873
879 inline void SetWorldScreenMatrix( const MATRIX3x3D& aMatrix )
880 {
881 m_worldScreenMatrix = aMatrix;
882 }
883
887 BOX2D GetVisibleWorldExtents() const;
888
896 void SetWorldUnitLength( double aWorldUnitLength ) { m_worldUnitLength = aWorldUnitLength; }
897
898 double GetWorldUnitLength() const { return m_worldUnitLength; }
899
900 void SetScreenSize( const VECTOR2I& aSize ) { m_screenSize = aSize; }
901
908 void SetScreenDPI( double aScreenDPI ) { m_screenDPI = aScreenDPI; }
909 double GetScreenDPI() const { return m_screenDPI; }
910
916 void SetLookAtPoint( const VECTOR2D& aPoint ) { m_lookAtPoint = aPoint; }
917 const VECTOR2D& GetLookAtPoint() const { return m_lookAtPoint; }
918
919 void SetZoomFactor( double aZoomFactor ) { m_zoomFactor = aZoomFactor; }
920 double GetZoomFactor() const { return m_zoomFactor; }
921
925 void SetRotation( double aRotation ) { m_rotation = aRotation; }
926 double GetRotation() const { return m_rotation; }
927
936 void SetDepthRange( const VECTOR2D& aDepthRange ) { m_depthRange = aDepthRange; }
937 double GetMinDepth() const { return m_depthRange.x; }
938 double GetMaxDepth() const { return m_depthRange.y; }
939
945 double GetWorldScale() const
946 {
947 m_worldScaleRead = true;
948 return m_worldScale;
949 }
950
955 double GetWorldScaleForScreenSpace() const { return m_worldScale; }
956
961 bool WorldScaleBelow( double aLimit ) const
962 {
963 const bool below = m_worldScale < aLimit;
964
965 if( below )
966 m_scaleLimitAbove = std::min( m_scaleLimitAbove, aLimit );
967 else
968 m_scaleLimitBelow = std::max( m_scaleLimitBelow, aLimit );
969
970 return below;
971 }
972
974 void TakeWorldScaleLimits( double& aBelow, double& aAbove ) const
975 {
976 aBelow = m_scaleLimitBelow;
977 aAbove = m_scaleLimitAbove;
978 m_scaleLimitBelow = 0.0;
979 m_scaleLimitAbove = std::numeric_limits<double>::max();
980 }
981
987 {
988 const bool read = m_worldScaleRead;
989
990 m_worldScaleRead = false;
991 return read;
992 }
993
1000 inline void SetFlip( bool xAxis, bool yAxis )
1001 {
1002 m_globalFlipX = xAxis;
1003 m_globalFlipY = yAxis;
1004 }
1005
1006 bool IsFlippedX() const { return m_globalFlipX; }
1007 bool IsFlippedY() const { return m_globalFlipY; }
1008
1009 // ---------------------------
1010 // Buffer manipulation methods
1011 // ---------------------------
1012
1018 virtual void SetTarget( RENDER_TARGET aTarget ) {};
1019
1025 virtual RENDER_TARGET GetTarget() const { return TARGET_CACHED; };
1026
1032 virtual void ClearTarget( RENDER_TARGET aTarget ) {};
1033
1039 virtual bool HasTarget( RENDER_TARGET aTarget )
1040 {
1041 return true;
1042 };
1043
1055 virtual void SetNegativeDrawMode( bool aSetting ) {};
1056
1061 virtual void SetScreenSpaceMode( bool aEnabled ) {}
1062
1064 virtual bool SupportsStrokePixelPad() const { return false; }
1065
1067 virtual bool SupportsStrokeLengthPad() const { return false; }
1068
1073 virtual void SetStrokeLengthPad( double aPixels ) {}
1074
1079 virtual void SetStrokePixelPad( double aPixels ) {}
1080
1082 virtual bool SupportsStrokeLevelOfDetail() const { return false; }
1083
1088 virtual void SetStrokeLevelOfDetail( double aLod ) {}
1089
1097 virtual void StartDiffLayer() {};
1098
1104 virtual void EndDiffLayer() {};
1105
1114 virtual void StartNegativesLayer(){};
1115
1120 virtual void EndNegativesLayer(){};
1121
1122 // -------------
1123 // Grid methods
1124 // -------------
1125
1131 void SetGridVisibility( bool aVisibility ) { m_gridVisibility = aVisibility; }
1132
1133 bool GetGridVisibility() const { return m_gridVisibility; }
1134
1135 bool GetGridSnapping() const
1136 {
1137 return m_options.m_gridSnapping == KIGFX::GRID_SNAPPING::ALWAYS ||
1139 }
1140
1146 inline void SetGridOrigin( const VECTOR2D& aGridOrigin )
1147 {
1148 m_gridOrigin = aGridOrigin;
1149
1150 if( m_gridSize.x == 0.0 || m_gridSize.y == 0.0 )
1151 {
1152 m_gridOffset = VECTOR2D( 0.0, 0.0);
1153 }
1154 else
1155 {
1156 m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x,
1157 (long) m_gridOrigin.y % (long) m_gridSize.y );
1158 }
1159 }
1160
1161 inline const VECTOR2D& GetGridOrigin() const
1162 {
1163 return m_gridOrigin;
1164 }
1165
1171 inline void SetGridSize( const VECTOR2D& aGridSize )
1172 {
1173 m_gridSize = aGridSize;
1174
1175 // Avoid stupid grid size values: a grid size should be >= 1 in internal units
1176 m_gridSize.x = std::max( 1.0, m_gridSize.x );
1177 m_gridSize.y = std::max( 1.0, m_gridSize.y );
1178
1179 m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x,
1180 (long) m_gridOrigin.y % (long) m_gridSize.y );
1181 }
1182
1188 inline const VECTOR2D& GetGridSize() const
1189 {
1190 return m_gridSize;
1191 }
1192
1199 {
1200 VECTOR2D gridScreenSize( m_gridSize );
1201 gridScreenSize.x = std::max( 100.0, gridScreenSize.x );
1202 gridScreenSize.y = std::max( 100.0, gridScreenSize.y );
1203
1204 double gridThreshold = computeMinGridSpacing() / m_worldScale;
1205
1207 gridThreshold *= 2.0;
1208
1209 // If we cannot display the grid density, scale down by a tick size and
1210 // try again. Eventually, we get some representation of the grid
1211 const double minSize = std::min( gridScreenSize.x, gridScreenSize.y );
1212 const double sparsed = AutoSparsePitch( minSize, m_gridTick, gridThreshold );
1213
1214 if( minSize > 0.0 && sparsed != minSize )
1215 gridScreenSize *= sparsed / minSize;
1216
1217 return gridScreenSize;
1218 }
1219
1225 inline void SetGridColor( const COLOR4D& aGridColor )
1226 {
1227 m_gridColor = aGridColor;
1228 }
1229
1235 inline void SetAxesColor( const COLOR4D& aAxesColor )
1236 {
1237 m_axesColor = aAxesColor;
1238 }
1239
1243 inline void SetAxesEnabled( bool aAxesEnabled )
1244 {
1245 m_axesEnabled = aAxesEnabled;
1246 }
1247
1253 inline void SetCoarseGrid( int aInterval )
1254 {
1255 m_gridTick = aInterval;
1256 }
1257
1263 inline float GetGridLineWidth() const
1264 {
1265 return m_gridLineWidth;
1266 }
1267
1275 void SetGridSources( std::vector<GRID_SOURCE> aSources );
1276
1277 const std::vector<GRID_SOURCE>& GetGridSources() const { return m_gridSources; }
1278
1280 int GetCoarseGrid() const { return m_gridTick; }
1281 const COLOR4D& GetGridColor() const { return m_gridColor; }
1282
1284 virtual void DrawGrid() {};
1285
1292 VECTOR2D GetGridPoint( const VECTOR2D& aPoint ) const;
1293
1300 inline VECTOR2D ToWorld( const VECTOR2D& aPoint ) const
1301 {
1302 return VECTOR2D( m_screenWorldMatrix * aPoint );
1303 }
1304
1311 inline VECTOR2D ToScreen( const VECTOR2D& aPoint ) const
1312 {
1313 return VECTOR2D( m_worldScreenMatrix * aPoint );
1314 }
1315
1323 virtual bool SetNativeCursorStyle( KICURSOR aCursor, bool aHiDPI );
1324
1330 inline void SetCursorEnabled( bool aCursorEnabled )
1331 {
1332 m_isCursorEnabled = aCursorEnabled;
1333 }
1334
1340 bool IsCursorEnabled() const
1341 {
1343 }
1344
1350 inline void SetCursorColor( const COLOR4D& aCursorColor )
1351 {
1352 m_cursorColor = aCursorColor;
1353 }
1354
1360 virtual void DrawCursor( const VECTOR2D& aCursorPosition ) {};
1361
1362 virtual void EnableDepthTest( bool aEnabled = false ) {};
1363
1368 virtual bool IsContextLocked()
1369 {
1370 return false;
1371 }
1372
1381 virtual bool IsContextValid() const
1382 {
1383 return true;
1384 }
1385
1392 {
1394 }
1395
1401 virtual bool IsResetSettled()
1402 {
1403 return true;
1404 }
1405
1406
1408 virtual void LockContext( int aClientCookie ) {}
1409
1410 virtual void UnlockContext( int aClientCookie ) {}
1411
1416
1419 virtual void BeginDrawing() {};
1420
1423 virtual void EndDrawing() {};
1424protected:
1425
1428 virtual void beginUpdate() {}
1429
1431 virtual void endUpdate() {}
1432
1433
1434
1436 inline void computeWorldScale()
1437 {
1439
1440 PGM_BASE* pgm = PgmOrNull();
1441
1442 if( pgm && pgm->GetCommonSettings() )
1444 }
1445
1451 double computeMinGridSpacing() const;
1452
1460 float gridMinorLineWidth( double aWorldPixelSize, double aScaleFactor ) const
1461 {
1462 return std::fmax( 1.0f, m_gridLineWidth ) * aWorldPixelSize / aScaleFactor;
1463 }
1464
1466 static constexpr int SEG_PER_CIRCLE_COUNT = 64;
1467
1469 static double calcAngleStep( double aRadius )
1470 {
1472 return std::min( 1e6 / aRadius, 2.0 * M_PI / SEG_PER_CIRCLE_COUNT );
1473 }
1474
1479 BOX2D gridScreenBBox( const GRID_SOURCE& aSrc ) const;
1480
1483 {
1486 unsigned tick = 0;
1487
1488 bool IsMajor( int aIndex ) const { return tick > 0 && aIndex % static_cast<int>( tick ) == 0; }
1489 };
1490
1495 GRID_LATTICE gridLattice( const GRID_SOURCE& aSrc ) const;
1496
1498 COLOR4D gridSourceColor( const GRID_SOURCE& aSrc ) const;
1499
1504 void drawGridCoverageShape( const GRID_SOURCE& aSrc );
1505
1507 static const int MIN_DEPTH;
1508 static const int MAX_DEPTH;
1509
1511 static const int GRID_DEPTH;
1512
1516 COLOR4D getCursorColor() const;
1517
1518 // ---------------
1519 // Settings observer interface
1520 // ---------------
1524 void OnGalDisplayOptionsChanged( const GAL_DISPLAY_OPTIONS& aOptions ) override;
1525
1534 virtual bool updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions );
1535
1539 template <typename T>
1540 void normalize( T &a, T &b )
1541 {
1542 if( a > b )
1543 {
1544 T tmp = a;
1545 a = b;
1546 b = tmp;
1547 }
1548 }
1549
1552
1553 std::stack<double> m_depthStack;
1555
1559
1561 double m_rotation;
1565 mutable bool m_worldScaleRead = false;
1566 mutable double m_scaleLimitBelow = 0.0;
1567 mutable double m_scaleLimitAbove = std::numeric_limits<double>::max();
1568
1571
1574
1577
1582
1585
1586 // Grid settings
1599
1600 std::vector<GRID_SOURCE> m_gridSources;
1601
1602 // Cursor settings
1608
1610
1611private:
1612
1613 inline double getLayerDepth() const
1614 {
1615 return m_layerDepth;
1616 }
1617
1619
1620 friend class GAL_SCOPED_ATTRS;
1621};
1622
1623
1625{
1626public:
1628 m_gal( aGal )
1629 {
1630 m_cookie = rand();
1631 m_gal->LockContext( m_cookie );
1632 }
1633
1635 {
1636 m_gal->UnlockContext( m_cookie );
1637 }
1638
1639protected:
1642};
1643
1644
1646{
1647public:
1649 GAL_CONTEXT_LOCKER( aGal ),
1650 m_updating( aGal->IsContextValid() )
1651 {
1652 if( m_updating )
1653 m_gal->beginUpdate();
1654 }
1655
1657 {
1658 if( m_updating )
1659 m_gal->endUpdate();
1660 }
1661
1663 bool IsUpdating() const
1664 {
1665 return m_updating;
1666 }
1667
1668private:
1670};
1671
1672
1674{
1675public:
1677 GAL_CONTEXT_LOCKER( aGal ),
1678 m_drawing( aGal->IsContextValid() )
1679 {
1680 if( m_drawing )
1681 m_gal->BeginDrawing();
1682 }
1683
1684 ~GAL_DRAWING_CONTEXT() noexcept( false )
1685 {
1686 if( m_drawing )
1687 m_gal->EndDrawing();
1688 }
1689
1691 bool IsDrawing() const
1692 {
1693 return m_drawing;
1694 }
1695
1696private:
1698};
1699
1700
1705{
1706public:
1708 {
1715
1716 // It is not clear to me that GAL needs to save text attributes.
1717 // Only BitmapText uses it, and maybe that should be passed in
1718 // explicitly (like for Draw) - every caller of BitmapText sets
1719 // the text attributes anyway.
1720 // TEXT_ATTRS = 64,
1721
1722 // Convenience flags
1726
1728 };
1729
1735 GAL_SCOPED_ATTRS( KIGFX::GAL& aGal, int aFlags ) :
1736 m_gal( aGal ),
1737 m_flags( aFlags ),
1738 // Save what we need to restore later.
1739 // These are all so cheap to copy, it's likely not worth if'ing
1740 m_strokeColor( aGal.GetStrokeColor() ),
1741 m_strokeWidth( aGal.GetLineWidth() ),
1742 m_isStroke( aGal.GetIsStroke() ),
1743 m_fillColor( aGal.GetFillColor() ),
1744 m_isFill( aGal.GetIsFill() ),
1745 m_layerDepth( aGal.getLayerDepth() )
1746 {
1747 }
1748
1750 {
1751 // Restore the attributes that were saved
1752 // based on the flags that were set.
1753
1754 if( m_flags & STROKE_WIDTH )
1755 m_gal.SetLineWidth( m_strokeWidth );
1756
1757 if( m_flags & STROKE_COLOR )
1758 m_gal.SetStrokeColor( m_strokeColor );
1759
1760 if( m_flags & IS_STROKE )
1761 m_gal.SetIsStroke( m_isStroke );
1762
1763 if( m_flags & FILL_COLOR )
1764 m_gal.SetFillColor( m_fillColor );
1765
1766 if( m_flags & IS_FILL )
1767 m_gal.SetIsFill( m_isFill );
1768
1769 if( m_flags & LAYER_DEPTH )
1770 m_gal.SetLayerDepth( m_layerDepth );
1771 }
1772
1773 // No copying or it can lead to double-restoring of the GAL attributes.
1776
1777private:
1780
1784
1787
1789};
1790
1791
1792}; // namespace KIGFX
1793
1794#endif /* GRAPHICSABSTRACTIONLAYER_H_ */
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
BOX2< VECTOR2D > BOX2D
Definition box2.h:915
This class handle bitmap images in KiCad.
Definition bitmap_base.h:47
constexpr const Vec GetEnd() const
Definition box2.h:209
constexpr const Vec & GetOrigin() const
Definition box2.h:207
APPEARANCE m_Appearance
GAL(GAL_DISPLAY_OPTIONS &aOptions)
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
GAL_SCOPED_ATTRS & operator=(const GAL_SCOPED_ATTRS &)=delete
GAL_SCOPED_ATTRS(const GAL_SCOPED_ATTRS &)=delete
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.
virtual void ChangeGroupUndimmed(int aGroupNumber, bool aUndimmed)
Exempt the group from its layer's dim, see SetSceneLayerDim().
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 bool SupportsStrokeLevelOfDetail() const
Tell whether strokes can carry a level of detail, see SetStrokeLevelOfDetail().
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
COLOR4D m_hoverColor
Color for hovered (active) links.
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)
virtual VECTOR2I GetLayoutPixelSize() const
Return the size the view is centred in and panned by.
virtual void BeginSceneLayer(int aLayer)
Open a cached layer of the retained scene during a rebuild.
void SetHorizontalJustify(const GR_TEXT_H_ALIGN_T aHorizontalJustify)
virtual bool SupportsTypedPads() const
Return true if DrawPad() renders every standard pad shape.
virtual RENDER_TARGET GetTarget() const
Get the currently used target for rendering.
double GetMaxDepth() const
bool m_axesEnabled
Should the axes be drawn.
virtual bool IsContextValid() const
Check whether the locked context is actually the current one.
const std::vector< GRID_SOURCE > & GetGridSources() const
void SetRotation(double aRotation)
Get/set the rotation angle (in radians).
float m_gridLineWidth
Line width of the grid.
virtual void SetSceneLayerDim(int aLayer, const COLOR4D &aToward, double aKeep)
Fade a cached layer towards a colour in the shader, so dimming it recolours none of its groups.
void SetFlip(bool xAxis, bool yAxis)
Sets flipping of the screen.
virtual void MarkStaticDirty()
Make a backend that keeps a static geometry pool rebuild it on the next frame.
virtual void SetSceneLayerState(int aLayer, int aOrder, bool aVisible, bool aHasNegatives)
Describe a cached layer to the retained scene.
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
virtual void SetScreenSpaceMode(bool aEnabled)
Store sizes of what is drawn next in pixels rather than world units, so it keeps its pixel size throu...
bool TakeWorldScaleRead() const
Tell whether GetWorldScale() or a transformation matrix was read since the last call.
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.
virtual void DrawPad(const VECTOR2D &aCenter, double aHalfWidth, double aHalfHeight, double aCornerRadius, float aShapeType, double aRotation, const COLOR4D &aColor)
Draw a filled pad as one primitive in aColor.
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.
virtual void SetGroupPlacement(int aGroup, int aLayer, double aLodScale, bool aShown, const RETAINED_GROUP_ORDER &aOrder)
Declare where a cached group belongs in the retained scene.
virtual GAL_CONTEXT_LOSS GetContextLoss() const
Check whether a GPU reset destroyed this canvas' rendering context.
bool m_worldScaleRead
see TakeWorldScaleRead()
virtual void SetSceneDrawOrdered(bool aOrdered)
Tell the retained scene whether cached groups are placed in an order that matters.
double GetWorldScaleForScreenSpace() const
Get the world scale to size something drawn in screen space mode.
const VECTOR2D & GetLookAtPoint() const
double GetRotation() const
const MATRIX3x3D & GetScreenWorldMatrix() const
Get the screen <-> world transformation matrix.
bool IsFontUnderlined() const
virtual bool UsesPolygonTriangulationCache() const
Return true if filled polygons are drawn from the SHAPE_POLY_SET triangulation cache,...
virtual bool HasRetainedScene() const
Return true if the backend keeps cached groups in a persistent scene that it patches in place,...
virtual bool SupportsStrokePixelPad() const
Tell whether strokes can carry part of their width in pixels, see SetStrokePixelPad().
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.
virtual void SetSceneScale(double aScale)
Set the view scale that group placements are tested against.
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 bool IsDrawingMode() const
Return true if the GAL is inside a BeginDrawing/EndDrawing pair.
virtual std::array< uint64_t, 2 > GroupContentFingerprint(int aGroupNumber) const
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 bool IsResetSettled()
Check whether the driver has finished the reset that destroyed this canvas' context.
virtual void DrawGrid()
Draw the grid.
virtual void DrawPolygon(const SHAPE_POLY_SET &aPolySet, bool aStrokeTriangulation=false)
virtual void SetStrokeLevelOfDetail(double aLod)
Show every stroke drawn from now on only while the view scale is above aLod, as VIEW::IsShownAtScale(...
COLOR4D getCursorColor() const
Get the actual cursor color to draw.
virtual void SetStrokeLengthPad(double aPixels)
Extend every stroke drawn from now on by aPixels at each end.
virtual void ChangeGroupDepth(int aGroupNumber, int aDepth)
Change the depth (Z-axis position) of the group.
virtual void SetHoverColor(const COLOR4D &aColor)
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)
double m_scaleLimitBelow
see TakeWorldScaleLimits()
GRID_STYLE GetGridStyle() const
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 SupportsStrokeLengthPad() const
Tell whether strokes can be longer by a number of pixels, see SetStrokeLengthPad().
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.
const COLOR4D & GetGridColor() const
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)
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.
double GetWorldUnitLength() const
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 bool RefillsNonCachedTargets() const
Return true if the backend empties every non-cached target each frame, so VIEW must emit them again e...
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.
bool WorldScaleBelow(double aLimit) const
Tell whether the world scale is below a limit.
virtual void Transform(const MATRIX3x3D &aTransformation)
Transform the context.
virtual void SetNegativeDrawMode(bool aSetting)
Set negative draw mode in the renderer.
float gridMinorLineWidth(double aWorldPixelSize, double aScaleFactor) const
Compute the world width of a minor grid line.
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 ?
std::vector< GRID_SOURCE > m_gridSources
Sources overlayed on the display grid.
void TakeWorldScaleLimits(double &aBelow, double &aAbove) const
Give and forget the nearest limits on either side of the scale passed to WorldScaleBelow().
virtual void DrawBitmap(const BITMAP_BASE &aBitmap, double alphaBlend=1.0)
Draw a bitmap image.
GAL_DISPLAY_OPTIONS & m_options
virtual bool HasStaticRebuildPending() const
Return true if the backend dropped its cached geometry and VIEW must draw the cached layers again,...
bool m_gridVisibility
Should the grid be shown.
static constexpr int SEG_PER_CIRCLE_COUNT
The default number of segments approximating a full circle.
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 SetSceneLayerOverlayAlpha(int aLayer)
Blend a cached layer the way the other canvases blend the overlay they draw it in.
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 void SetStrokePixelPad(double aPixels)
Widen every stroke, circle and pad drawn from now on by aPixels.
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
static double calcAngleStep(double aRadius)
Compute the angle step when drawing arcs/circles approximated with lines.
Container for data for KiCad programs.
Definition pgm_base.h:101
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:562
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:41
const int minSize
Push and Shove router track width and via size dialog.
#define GAL_API
Definition gal.h:27
MATRIX3x3< double > MATRIX3x3D
Definition matrix3x3.h:469
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:30
constexpr double GRID_DIM_ALPHA
Opacity of the background wash laid over a selected grid item's area, to fade the grids showing throu...
GAL_CONTEXT_LOSS
State of a canvas' rendering context after a GPU reset.
@ REPEATED
Contexts keep being lost; stop using this backend.
@ RECOVERABLE
Context was lost; rebuild the canvas.
GRID_STYLE
Type definition of the grid style.
@ SMALL_CROSS
Use small cross instead of dots for the grid.
@ LINES
Use lines for the grid.
constexpr double GRID_SELECTED_BRIGHTEN
How far the grid being edited is lifted above its own colour.
double AutoSparsePitch(double aPitch, unsigned aTick, double aThreshold)
Multiply aPitch by aTick until it exceeds aThreshold, so a sub-threshold grid still shows every Nth l...
@ NONE
No updates are required.
Definition view_item.h:48
RENDER_TARGET
RENDER_TARGET: Possible rendering targets.
Definition definitions.h:32
@ TARGET_CACHED
Main rendering target (cached)
Definition definitions.h:33
constexpr double GRID_EDGE_DARKEN
How far the hairline round a grid's coverage sits below its own colour.
PGM_BASE * PgmOrNull()
Return a reference that can be nullptr when running a shared lib from a script, not from a kicad app.
see class PGM_BASE
The spacing of a grid source's lattice as it is drawn at the current zoom.
Geometry of a regular grid (cartesian or polar) and the math operations for snapping and coverage tes...
VECTOR2D extent
as GRID_SOURCE::extent, with an unbounded polar grid reaching past the screen
unsigned tick
every tick-th line is a major one
VECTOR2D pitch
along x and y, or of radius and angle for a polar grid
Render-time projection of a grid: GRID_GEOMETRY (kind/origin/pitch/orientation/extent) plus rendering...
bool snapCursor
Participate in the cursor snap (GAL::GetGridPoint).
unsigned tick
Major-tick interval (0 = inherit default).
bool axesEnabled
Skip grid lines coincident with the world axes (only meaningful for unbounded cartesian).
bool highlighted
Render with edit-mode emphasis (selected grid).
bool unbounded
No extent; visible range derived from screen corners.
std::array< uint64_t, 2 > contentHash
bool operator<(const RETAINED_GROUP_ORDER &aOther) const
bool SamePrefix(const RETAINED_GROUP_ORDER &aOther) const
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.
#define M_PI
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707