44#include <unordered_map>
53#define SEG_PER_CIRCLE_COUNT 64
88 wxEvtHandler* aMouseListener =
nullptr, wxEvtHandler* aPaintListener =
nullptr,
89 const wxString& aName = wxT(
"GLCanvas" ) );
107 return IsShownOnScreen() && !GetClientRect().IsEmpty();
113 return IsShownOnScreen() && !GetClientRect().IsEmpty();
121 void DrawLine(
const VECTOR2D& aStartPoint,
const VECTOR2D& aEndPoint )
override;
125 double aWidth )
override;
128 void DrawSegmentChain(
const std::vector<VECTOR2D>& aPointList,
double aWidth )
override;
129 void DrawSegmentChain(
const SHAPE_LINE_CHAIN& aLineChain,
double aWidth )
override;
132 void DrawCircle(
const VECTOR2D& aCenterPoint,
double aRadius )
override;
135 void DrawArc(
const VECTOR2D& aCenterPoint,
double aRadius,
const EDA_ANGLE& aStartAngle,
139 void DrawArcSegment(
const VECTOR2D& aCenterPoint,
double aRadius,
const EDA_ANGLE& aStartAngle,
140 const EDA_ANGLE& aAngle,
double aWidth,
double aMaxError )
override;
143 void DrawRectangle(
const VECTOR2D& aStartPoint,
const VECTOR2D& aEndPoint )
override;
146 void DrawPolyline(
const std::deque<VECTOR2D>& aPointList )
override;
147 void DrawPolyline(
const std::vector<VECTOR2D>& aPointList )
override;
148 void DrawPolyline(
const VECTOR2D aPointList[],
int aListSize )
override;
152 void DrawPolylines(
const std::vector<std::vector<VECTOR2D>>& aPointLists )
override;
155 void DrawPolygon(
const std::deque<VECTOR2D>& aPointList )
override;
156 void DrawPolygon(
const VECTOR2D aPointList[],
int aListSize )
override;
157 void DrawPolygon(
const SHAPE_POLY_SET& aPolySet,
bool aStrokeTriangulation =
false )
override;
161 virtual void DrawGlyph(
const KIFONT::GLYPH& aGlyph,
int aNth,
int aTotal )
override;
164 virtual void DrawGlyphs(
const std::vector<std::unique_ptr<KIFONT::GLYPH>>& aGlyphs )
override;
169 double aFilterValue = 0.0 )
override;
172 void DrawBitmap(
const BITMAP_BASE& aBitmap,
double alphaBlend = 1.0 )
override;
175 void BitmapText(
const wxString& aText,
const VECTOR2I& aPosition,
179 void DrawGrid()
override;
186 void ResizeScreen(
int aWidth,
int aHeight )
override;
189 bool Show(
bool aShow )
override;
195 void Flush()
override;
198 void ClearScreen( )
override;
205 void Transform(
const MATRIX3x3D& aTransformation )
override;
208 void Rotate(
double aAngle )
override;
211 void Translate(
const VECTOR2D& aTranslation )
override;
214 void Scale(
const VECTOR2D& aScale )
override;
217 void Save()
override;
220 void Restore()
override;
227 int BeginGroup()
override;
230 void EndGroup()
override;
233 void DrawGroup(
int aGroupNumber )
override;
236 void ChangeGroupColor(
int aGroupNumber,
const COLOR4D& aNewColor )
override;
239 void ChangeGroupDepth(
int aGroupNumber,
int aDepth )
override;
242 void DeleteGroup(
int aGroupNumber )
override;
245 void ClearCache()
override;
267 void StartDiffLayer()
override;
270 void EndDiffLayer()
override;
272 void ComputeWorldScreenMatrix()
override;
279 bool SetNativeCursorStyle(
KICURSOR aCursor,
bool aHiDPI )
override;
282 void DrawCursor(
const VECTOR2D& aCursorPosition )
override;
290 void PostPaint( wxPaintEvent& aEvent );
294 m_mouseListener = aMouseListener;
299 m_paintListener = aPaintListener;
302 void EnableDepthTest(
bool aEnabled =
false )
override;
306 return m_isContextLocked;
309 void LockContext(
int aClientCookie )
override;
311 void UnlockContext(
int aClientCookie )
override;
314 void BeginDrawing()
override;
317 void EndDrawing()
override;
343 typedef std::unordered_map< unsigned int, std::shared_ptr<VERTEX_ITEM> >
GROUPS_MAP;
388 void beginUpdate()
override;
391 void endUpdate()
override;
405 bool aReserve =
true );
412 void reserveLineQuads(
const int aLineCount );
425 void drawSemiCircle(
const VECTOR2D& aCenterPoint,
double aRadius,
double aAngle );
435 void drawFilledSemiCircle(
const VECTOR2D& aCenterPoint,
double aRadius,
double aAngle );
446 void drawStrokedSemiCircle(
const VECTOR2D& aCenterPoint,
double aRadius,
double aAngle,
447 bool aReserve =
true );
454 void drawCircle(
const VECTOR2D& aCenterPoint,
double aRadius,
bool aReserve =
true );
463 void drawPolyline(
const std::function<
VECTOR2D(
int )>& aPointGetter,
int aPointCount,
464 bool aReserve =
true );
473 void drawSegmentChain(
const std::function<
VECTOR2D(
int )>& aPointGetter,
int aPointCount,
474 double aWidth,
bool aReserve =
true );
479 void drawSegment(
const VECTOR2D& aStartPoint,
const VECTOR2D& aEndPoint,
double aWidth,
480 bool aReserve =
true );
489 void drawPolygon( GLdouble* aPoints,
int aPointCount );
497 void drawTriangulatedPolyset(
const SHAPE_POLY_SET& aPoly,
bool aStrokeTriangulation );
508 int drawBitmapChar(
unsigned long aChar,
bool aReserve =
true );
521 void drawBitmapOverbar(
double aLength,
double aHeight,
bool aReserve =
true );
530 std::pair<VECTOR2D, float> computeBitmapTextSize(
const UTF8& aText )
const;
538 void onPaint( wxPaintEvent& aEvent );
545 void skipMouseEvent( wxMouseEvent& aEvent );
552 void skipGestureEvent( wxGestureEvent& aEvent );
559 void onSetNativeCursor( wxSetCursorEvent& aEvent );
571 unsigned int getNewGroupNumber();
582 double getWorldPixelSize()
const;
584 VECTOR2D getScreenPixelSize()
const;
This class handle bitmap images in KiCad.
wxGLCanvas wrapper for HiDPI/Retina support.
A color representation with 4 components: red, green, blue, alpha.
Abstract interface for drawing on a 2D-surface.
OpenGL implementation of the Graphics Abstraction Layer.
unsigned int m_groupCounter
Counter used for generating keys for groups.
std::unordered_map< unsigned int, std::shared_ptr< VERTEX_ITEM > > GROUPS_MAP
VERTEX_MANAGER * m_overlayManager
Container for storing overlaid VERTEX_ITEMs.
bool m_isInitialized
Basic initialization flag, has to be done when the window is visible.
VERTEX_MANAGER * m_currentManager
Currently used VERTEX_MANAGER (for storing VERTEX_ITEMs).
std::deque< std::shared_ptr< GLdouble > > m_tessIntersects
void SetNegativeDrawMode(bool aSetting) override
Set negative draw mode in the renderer.
bool IsInitialized() const override
Return the initialization status for the canvas.
unsigned int m_mainBuffer
Main rendering target.
std::unique_ptr< GL_BITMAP_CACHE > m_bitmapCache
bool IsContextLocked() override
Checks the state of the context lock.
bool m_isBitmapFontInitialized
Is the shader set to use bitmap fonts?
unsigned int m_overlayBuffer
Auxiliary rendering target (for menus etc.)
OPENGL_COMPOSITOR * m_compositor
Handles multiple rendering targets.
VERTEX_MANAGER * m_cachedManager
Container for storing cached VERTEX_ITEMs.
void SetPaintListener(wxEvtHandler *aPaintListener)
GLint ufm_antialiasingOffset
bool IsVisible() const override
Return true if the GAL canvas is visible on the screen.
wxEvtHandler * m_mouseListener
int m_swapInterval
Used to store swap interval information.
GROUPS_MAP m_groups
Stores information about VBO objects (groups)
int GetSwapInterval() const override
Return the swap interval. -1 for adaptive, 0 for disabled/unknown.
GAL super
Super class definition.
void SetMouseListener(wxEvtHandler *aMouseListener)
VERTEX_MANAGER * m_nonCachedManager
Container for storing non-cached VERTEX_ITEMs.
GLUtesselator * m_tesselator
wxEvtHandler * m_paintListener
bool m_isContextLocked
Used for assertion checking.
wxCursor m_currentwxCursor
wxCursor showing the current native cursor
bool m_isFramebufferInitialized
Are the framebuffers initialized?
static GLuint g_fontTexture
Bitmap font texture handle (shared)
double calcAngleStep(double aRadius) const
Compute the angle step when drawing arcs/circles approximated with lines.
bool m_isGrouping
Was a group started?
GLint ufm_screenPixelSize
GLint ufm_pixelSizeMultiplier
VERTEX_MANAGER * m_tempManager
Container for storing temp (diff mode) VERTEX_ITEMs.
SHADER * m_shader
There is only one shader used for different objects.
RENDER_TARGET m_currentTarget
Current rendering target.
wxGLContext * m_glPrivContext
Canvas-specific OpenGL context.
static bool m_isBitmapFontLoaded
Is the bitmap font texture loaded?
static wxGLContext * m_glMainContext
Parent OpenGL context.
unsigned int m_tempBuffer
Temporary rendering target (for diffing etc.)
static int m_instanceCounter
GL GAL instance counter.
bool IsOpenGlEngine() override
Return true if the GAL engine is a OpenGL based type.
Provide the access to the OpenGL shaders.
Class to control vertex container and GPU with possibility of emulating old-style OpenGL 1....
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.
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
The Cairo implementation of the graphics abstraction layer.
RENDER_TARGET
RENDER_TARGET: Possible rendering targets.
Class to store instances of VERTEX without caching.
Handle multitarget rendering (ie.
#define SEG_PER_CIRCLE_COUNT
void DrawSegment(const ROUND_SEGMENT_2D &aSegment, unsigned int aNrSidesPerCircle)
Draw a thick line segment with rounded ends.
VERTEX_MANAGER * vboManager
Manager used for storing new vertices.
std::deque< std::shared_ptr< GLdouble > > & intersectPoints
Intersect points, that have to be freed after tessellation.
Structure to keep VIEW_CONTROLS settings for easy store/restore operations.
VECTOR2< double > VECTOR2D
Class to handle an item held in a container.