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 (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * Graphics Abstraction Layer (GAL) - base class
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
27#ifndef GRAPHICSABSTRACTIONLAYER_H_
28#define GRAPHICSABSTRACTIONLAYER_H_
29
30#include <deque>
31#include <stack>
32#include <limits>
33
34#include <math/matrix3x3.h>
35
36#include <gal/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
45class SHAPE_POLY_SET;
46class BITMAP_BASE;
47
48namespace KIGFX
49{
61{
62 // These friend declarations allow us to hide routines that should not be called. The
63 // corresponding RAII objects must be used instead.
64 friend class GAL_CONTEXT_LOCKER;
65 friend class GAL_UPDATE_CONTEXT;
66 friend class GAL_DRAWING_CONTEXT;
67
68public:
69 // Constructor / Destructor
70 GAL( GAL_DISPLAY_OPTIONS& aOptions );
71 virtual ~GAL();
72
74 virtual bool IsInitialized() const { return true; }
75
77 virtual bool IsVisible() const { return true; }
78
80 virtual bool IsCairoEngine() { return false; }
81
83 virtual bool IsOpenGlEngine() { return false; }
84
85 // ---------------
86 // Drawing methods
87 // ---------------
88
97 virtual void DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) {};
98
108 virtual void DrawSegment( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint,
109 double aWidth ){};
110
117 virtual void DrawSegmentChain( const std::vector<VECTOR2D>& aPointList, double aWidth ){};
118 virtual void DrawSegmentChain( const SHAPE_LINE_CHAIN& aLineChain, double aWidth ){};
119
125 virtual void DrawPolyline( const std::deque<VECTOR2D>& aPointList ) {};
126 virtual void DrawPolyline( const std::vector<VECTOR2D>& aPointList ) {};
127 virtual void DrawPolyline( const VECTOR2D aPointList[], int aListSize ) {};
128 virtual void DrawPolyline( const SHAPE_LINE_CHAIN& aLineChain ) {};
129
135 virtual void DrawPolylines( const std::vector<std::vector<VECTOR2D>>& aPointLists ){};
136
143 virtual void DrawCircle( const VECTOR2D& aCenterPoint, double aRadius ) {};
144
153 virtual void DrawArc( const VECTOR2D& aCenterPoint, double aRadius,
154 const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aAngle ){};
155
174 virtual void DrawArcSegment( const VECTOR2D& aCenterPoint, double aRadius,
175 const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aAngle,
176 double aWidth, double aMaxError ){};
177
184 virtual void DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoint ) {};
185
186 void DrawRectangle( const BOX2I& aRect )
187 {
188 DrawRectangle( aRect.GetOrigin(), aRect.GetEnd() );
189 }
190
194 virtual void DrawGlyph( const KIFONT::GLYPH& aGlyph, int aNth = 0, int aTotal = 1 ) {};
195
199 virtual void DrawGlyphs( const std::vector<std::unique_ptr<KIFONT::GLYPH>>& aGlyphs )
200 {
201 for( size_t i = 0; i < aGlyphs.size(); i++ )
202 DrawGlyph( *aGlyphs[i], i, aGlyphs.size() );
203 }
204
205
211 virtual void DrawPolygon( const std::deque<VECTOR2D>& aPointList ) {};
212 virtual void DrawPolygon( const VECTOR2D aPointList[], int aListSize ) {};
213 virtual void DrawPolygon( const SHAPE_POLY_SET& aPolySet, bool aStrokeTriangulation = false ) {};
214 virtual void DrawPolygon( const SHAPE_LINE_CHAIN& aPolySet ) {};
215
227 virtual void DrawCurve( const VECTOR2D& startPoint, const VECTOR2D& controlPointA,
228 const VECTOR2D& controlPointB, const VECTOR2D& endPoint,
229 double aFilterValue = 0.0 ) {};
230
234 virtual void DrawBitmap( const BITMAP_BASE& aBitmap, double alphaBlend = 1.0 ) {};
235
236 // --------------
237 // Screen methods
238 // --------------
239
241 virtual void ResizeScreen( int aWidth, int aHeight ) {};
242
244 virtual bool Show( bool aShow ) { return true; };
245
248 {
249 return m_screenSize;
250 }
251
253 virtual int GetSwapInterval() const { return 0; };
254
256 virtual void Flush() {};
257
258 void SetClearColor( const COLOR4D& aColor )
259 {
260 m_clearColor = aColor;
261 }
262
263 const COLOR4D& GetClearColor( ) const
264 {
265 return m_clearColor;
266 }
267
273 virtual void ClearScreen() {};
274
275 // -----------------
276 // Attribute setting
277 // -----------------
278
284 virtual void SetIsFill( bool aIsFillEnabled )
285 {
286 m_isFillEnabled = aIsFillEnabled;
287 }
288
294 virtual void SetIsStroke( bool aIsStrokeEnabled )
295 {
296 m_isStrokeEnabled = aIsStrokeEnabled;
297 }
298
304 virtual void SetFillColor( const COLOR4D& aColor )
305 {
306 m_fillColor = aColor;
307 }
308
314 inline const COLOR4D& GetFillColor() const
315 {
316 return m_fillColor;
317 }
318
324 virtual void SetStrokeColor( const COLOR4D& aColor )
325 {
326 m_strokeColor = aColor;
327 }
328
334 inline const COLOR4D& GetStrokeColor() const
335 {
336 return m_strokeColor;
337 }
338
344 virtual void SetLineWidth( float aLineWidth )
345 {
346 m_lineWidth = aLineWidth;
347 }
348
354 inline float GetLineWidth() const
355 {
356 return m_lineWidth;
357 }
358
364 virtual void SetLayerDepth( double aLayerDepth )
365 {
366 wxCHECK_MSG( aLayerDepth <= m_depthRange.y, /*void*/, wxT( "SetLayerDepth: below minimum" ) );
367 wxCHECK_MSG( aLayerDepth >= m_depthRange.x, /*void*/, wxT( "SetLayerDepth: above maximum" ) );
368
369 m_layerDepth = aLayerDepth;
370 }
371
372 // ----
373 // Text
374 // ----
375
384 virtual void BitmapText( const wxString& aText, const VECTOR2I& aPosition,
385 const EDA_ANGLE& aAngle );
386
393 void ResetTextAttributes();
394
395 void SetGlyphSize( const VECTOR2I aSize ) { m_attributes.m_Size = aSize; }
396 const VECTOR2I& GetGlyphSize() const { return m_attributes.m_Size; }
397
398 inline void SetFontBold( const bool aBold ) { m_attributes.m_Bold = aBold; }
399 inline bool IsFontBold() const { return m_attributes.m_Bold; }
400
401 inline void SetFontItalic( bool aItalic ) { m_attributes.m_Italic = aItalic; }
402 inline bool IsFontItalic() const { return m_attributes.m_Italic; }
403
404 inline void SetFontUnderlined( bool aUnderlined ) { m_attributes.m_Underlined = aUnderlined; }
405 inline bool IsFontUnderlined() const { return m_attributes.m_Underlined; }
406
407 void SetTextMirrored( const bool aMirrored ) { m_attributes.m_Mirrored = aMirrored; }
408 bool IsTextMirrored() const { return m_attributes.m_Mirrored; }
409
410 void SetHorizontalJustify( const GR_TEXT_H_ALIGN_T aHorizontalJustify )
411 {
412 m_attributes.m_Halign = aHorizontalJustify;
413 }
414
415 GR_TEXT_H_ALIGN_T GetHorizontalJustify() const { return m_attributes.m_Halign; }
416
417 void SetVerticalJustify( const GR_TEXT_V_ALIGN_T aVerticalJustify )
418 {
419 m_attributes.m_Valign = aVerticalJustify;
420 }
421
422 GR_TEXT_V_ALIGN_T GetVerticalJustify() const { return m_attributes.m_Valign; }
423
424
425 // --------------
426 // Transformation
427 // --------------
428
434 virtual void Transform( const MATRIX3x3D& aTransformation ) {};
435
441 virtual void Rotate( double aAngle ) {};
442
448 virtual void Translate( const VECTOR2D& aTranslation ) {};
449
455 virtual void Scale( const VECTOR2D& aScale ) {};
456
458 virtual void Save() {};
459
461 virtual void Restore() {};
462
463 // --------------------------------------------
464 // Group methods
465 // ---------------------------------------------
466
475 virtual int BeginGroup() { return 0; };
476
478 virtual void EndGroup() {};
479
485 virtual void DrawGroup( int aGroupNumber ) {};
486
493 virtual void ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor ) {};
494
501 virtual void ChangeGroupDepth( int aGroupNumber, int aDepth ) {};
502
508 virtual void DeleteGroup( int aGroupNumber ) {};
509
513 virtual void ClearCache() {};
514
515 // --------------------------------------------------------
516 // Handling the world <-> screen transformation
517 // --------------------------------------------------------
518
520 virtual void ComputeWorldScreenMatrix();
521
528 {
529 return m_worldScreenMatrix;
530 }
531
538 {
539 return m_screenWorldMatrix;
540 }
541
547 inline void SetWorldScreenMatrix( const MATRIX3x3D& aMatrix )
548 {
549 m_worldScreenMatrix = aMatrix;
550 }
551
555 BOX2D GetVisibleWorldExtents() const;
556
564 void SetWorldUnitLength( double aWorldUnitLength ) { m_worldUnitLength = aWorldUnitLength; }
565
566 void SetScreenSize( const VECTOR2I& aSize ) { m_screenSize = aSize; }
567
574 void SetScreenDPI( double aScreenDPI ) { m_screenDPI = aScreenDPI; }
575
581 void SetLookAtPoint( const VECTOR2D& aPoint ) { m_lookAtPoint = aPoint; }
582 const VECTOR2D& GetLookAtPoint() const { return m_lookAtPoint; }
583
584 void SetZoomFactor( double aZoomFactor ) { m_zoomFactor = aZoomFactor; }
585 double GetZoomFactor() const { return m_zoomFactor; }
586
590 void SetRotation( double aRotation ) { m_rotation = aRotation; }
591 double GetRotation() const { return m_rotation; }
592
601 void SetDepthRange( const VECTOR2D& aDepthRange ) { m_depthRange = aDepthRange; }
602 double GetMinDepth() const { return m_depthRange.x; }
603 double GetMaxDepth() const { return m_depthRange.y; }
604
610 double GetWorldScale() const { return m_worldScale; }
611
618 inline void SetFlip( bool xAxis, bool yAxis )
619 {
620 m_globalFlipX = xAxis;
621 m_globalFlipY = yAxis;
622 }
623
624 bool IsFlippedX() const { return m_globalFlipX; }
625 bool IsFlippedY() const { return m_globalFlipY; }
626
627 // ---------------------------
628 // Buffer manipulation methods
629 // ---------------------------
630
636 virtual void SetTarget( RENDER_TARGET aTarget ) {};
637
643 virtual RENDER_TARGET GetTarget() const { return TARGET_CACHED; };
644
650 virtual void ClearTarget( RENDER_TARGET aTarget ) {};
651
657 virtual bool HasTarget( RENDER_TARGET aTarget )
658 {
659 return true;
660 };
661
673 virtual void SetNegativeDrawMode( bool aSetting ) {};
674
682 virtual void StartDiffLayer() {};
683
689 virtual void EndDiffLayer() {};
690
699 virtual void StartNegativesLayer(){};
700
705 virtual void EndNegativesLayer(){};
706
707 // -------------
708 // Grid methods
709 // -------------
710
716 void SetGridVisibility( bool aVisibility ) { m_gridVisibility = aVisibility; }
717
718 bool GetGridVisibility() const { return m_gridVisibility; }
719
720 bool GetGridSnapping() const
721 {
722 return m_options.m_gridSnapping == KIGFX::GRID_SNAPPING::ALWAYS ||
723 ( m_gridVisibility && m_options.m_gridSnapping == KIGFX::GRID_SNAPPING::WITH_GRID );
724 }
725
731 inline void SetGridOrigin( const VECTOR2D& aGridOrigin )
732 {
733 m_gridOrigin = aGridOrigin;
734
735 if( m_gridSize.x == 0.0 || m_gridSize.y == 0.0 )
736 {
737 m_gridOffset = VECTOR2D( 0.0, 0.0);
738 }
739 else
740 {
741 m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x,
742 (long) m_gridOrigin.y % (long) m_gridSize.y );
743 }
744 }
745
746 inline const VECTOR2D& GetGridOrigin() const
747 {
748 return m_gridOrigin;
749 }
750
756 inline void SetGridSize( const VECTOR2D& aGridSize )
757 {
758 m_gridSize = aGridSize;
759
760 // Avoid stupid grid size values: a grid size should be >= 1 in internal units
761 m_gridSize.x = std::max( 1.0, m_gridSize.x );
762 m_gridSize.y = std::max( 1.0, m_gridSize.y );
763
764 m_gridOffset = VECTOR2D( (long) m_gridOrigin.x % (long) m_gridSize.x,
765 (long) m_gridOrigin.y % (long) m_gridSize.y );
766 }
767
773 inline const VECTOR2D& GetGridSize() const
774 {
775 return m_gridSize;
776 }
777
784 {
785 VECTOR2D gridScreenSize( m_gridSize );
786
787 double gridThreshold = computeMinGridSpacing() / m_worldScale;
788
789 if( m_gridStyle == GRID_STYLE::SMALL_CROSS )
790 gridThreshold *= 2.0;
791
792 // If we cannot display the grid density, scale down by a tick size and
793 // try again. Eventually, we get some representation of the grid
794 while( std::min( gridScreenSize.x, gridScreenSize.y ) <= gridThreshold )
795 {
796 gridScreenSize = gridScreenSize * static_cast<double>( m_gridTick );
797 }
798
799 return gridScreenSize;
800 }
801
807 inline void SetGridColor( const COLOR4D& aGridColor )
808 {
809 m_gridColor = aGridColor;
810 }
811
817 inline void SetAxesColor( const COLOR4D& aAxesColor )
818 {
819 m_axesColor = aAxesColor;
820 }
821
825 inline void SetAxesEnabled( bool aAxesEnabled )
826 {
827 m_axesEnabled = aAxesEnabled;
828 }
829
835 inline void SetCoarseGrid( int aInterval )
836 {
837 m_gridTick = aInterval;
838 }
839
845 inline float GetGridLineWidth() const
846 {
847 return m_gridLineWidth;
848 }
849
851 virtual void DrawGrid() {};
852
859 VECTOR2D GetGridPoint( const VECTOR2D& aPoint ) const;
860
867 inline VECTOR2D ToWorld( const VECTOR2D& aPoint ) const
868 {
869 return VECTOR2D( m_screenWorldMatrix * aPoint );
870 }
871
878 inline VECTOR2D ToScreen( const VECTOR2D& aPoint ) const
879 {
880 return VECTOR2D( m_worldScreenMatrix * aPoint );
881 }
882
889 virtual bool SetNativeCursorStyle( KICURSOR aCursor );
890
896 inline void SetCursorEnabled( bool aCursorEnabled )
897 {
898 m_isCursorEnabled = aCursorEnabled;
899 }
900
906 bool IsCursorEnabled() const
907 {
908 return m_isCursorEnabled || m_forceDisplayCursor;
909 }
910
916 inline void SetCursorColor( const COLOR4D& aCursorColor )
917 {
918 m_cursorColor = aCursorColor;
919 }
920
926 virtual void DrawCursor( const VECTOR2D& aCursorPosition ) {};
927
932 inline void AdvanceDepth()
933 {
934 m_layerDepth -= 0.1;
935 }
936
940 inline void PushDepth()
941 {
942 m_depthStack.push( m_layerDepth );
943 }
944
948 inline void PopDepth()
949 {
950 m_layerDepth = m_depthStack.top();
951 m_depthStack.pop();
952 }
953
954 virtual void EnableDepthTest( bool aEnabled = false ) {};
955
960 virtual bool IsContextLocked()
961 {
962 return false;
963 }
964
965
967 virtual void LockContext( int aClientCookie ) {}
968
969 virtual void UnlockContext( int aClientCookie ) {}
970
975
978 virtual void BeginDrawing() {};
979
982 virtual void EndDrawing() {};
983protected:
984
987 virtual void beginUpdate() {}
988
990 virtual void endUpdate() {}
991
992
993
995 inline void computeWorldScale()
996 {
997 m_worldScale = m_screenDPI * m_worldUnitLength * m_zoomFactor;
998 }
999
1005 double computeMinGridSpacing() const;
1006
1008 static const int MIN_DEPTH;
1009 static const int MAX_DEPTH;
1010
1012 static const int GRID_DEPTH;
1013
1017 COLOR4D getCursorColor() const;
1018
1019 // ---------------
1020 // Settings observer interface
1021 // ---------------
1025 void OnGalDisplayOptionsChanged( const GAL_DISPLAY_OPTIONS& aOptions ) override;
1026
1035 virtual bool updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions );
1036
1039
1040 std::stack<double> m_depthStack;
1042
1046
1048 double m_rotation;
1052
1055
1057
1060
1064
1067
1068 // Grid settings
1081
1082 // Cursor settings
1088
1090
1091private:
1093};
1094
1095
1097{
1098public:
1100 m_gal( aGal )
1101 {
1102 m_cookie = rand();
1104 }
1105
1107 {
1109 }
1110
1111protected:
1114};
1115
1116
1118{
1119public:
1121 GAL_CONTEXT_LOCKER( aGal )
1122 {
1123 m_gal->beginUpdate();
1124 }
1125
1127 {
1128 m_gal->endUpdate();
1129 }
1130};
1131
1132
1134{
1135public:
1137 GAL_CONTEXT_LOCKER( aGal )
1138 {
1140 }
1141
1142 ~GAL_DRAWING_CONTEXT() noexcept( false )
1143 {
1144 m_gal->EndDrawing();
1145 }
1146};
1147
1148
1149}; // namespace KIGFX
1150
1151#endif /* GRAPHICSABSTRACTIONLAYER_H_ */
This class handle bitmap images in KiCad.
Definition: bitmap_base.h:48
const Vec & GetOrigin() const
Definition: box2.h:184
const Vec GetEnd() const
Definition: box2.h:186
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
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.
bool IsTextMirrored() const
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)
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.
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)
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 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
VECTOR2D m_depthRange
Range of the depth.
double GetZoomFactor() const
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
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.
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.
void PushDepth()
Store current drawing depth on the depth stack.
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 DrawGrid()
virtual void DrawPolygon(const SHAPE_POLY_SET &aPolySet, bool aStrokeTriangulation=false)
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.
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.
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)
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
bool m_fullscreenCursor
Shape of the cursor (fullscreen or small cross)
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.
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 ?
bool GetGridSnapping() const
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.
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.
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 PopDepth()
Restore previously stored drawing depth for the depth stack.
void SetWorldScreenMatrix(const MATRIX3x3D &aMatrix)
Set the world <-> screen transformation matrix.
GR_TEXT_V_ALIGN_T GetVerticalJustify() const
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.
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
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:34
#define GAL_API
Definition: gal.h:28
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
GRID_STYLE
GRID_STYLE: Type definition of the grid style.
RENDER_TARGET
RENDER_TARGET: Possible rendering targets.
Definition: definitions.h:47
@ TARGET_CACHED
Main rendering target (cached)
Definition: definitions.h:48
GR_TEXT_H_ALIGN_T
GR_TEXT_V_ALIGN_T
VECTOR2< double > VECTOR2D
Definition: vector2d.h:587