43 #include <unordered_map> 44 #include <boost/smart_ptr/shared_array.hpp> 57 class GL_BITMAP_CACHE;
83 wxEvtHandler* aMouseListener =
nullptr, wxEvtHandler* aPaintListener =
nullptr,
84 const wxString& aName = wxT(
"GLCanvas" ) );
102 return IsShownOnScreen() && !GetClientRect().IsEmpty();
108 return IsShownOnScreen() && !GetClientRect().IsEmpty();
120 double aWidth )
override;
127 double aStartAngle,
double aEndAngle )
override;
131 double aStartAngle,
double aEndAngle,
double aWidth )
override;
137 void DrawPolyline(
const std::deque<VECTOR2D>& aPointList )
override;
142 void DrawPolygon(
const std::deque<VECTOR2D>& aPointList )
override;
150 double aFilterValue = 0.0 )
override;
157 double aRotationAngle )
override;
170 bool Show(
bool aShow )
override;
173 void Flush()
override;
186 void Rotate(
double aAngle )
override;
195 void Save()
override;
211 void DrawGroup(
int aGroupNumber )
override;
307 typedef std::unordered_map< unsigned int, std::shared_ptr<VERTEX_ITEM> >
GROUPS_MAP;
423 void drawPolygon( GLdouble* aPoints,
int aPointCount );
468 void onPaint( wxPaintEvent& aEvent );
502 return std::min( 1e6 / aRadius, 2.0 * M_PI /
CIRCLE_POINTS );
518 #endif // OPENGLGAL_H_ An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
void onSetNativeCursor(wxSetCursorEvent &aEvent)
Give the correct cursor image when the native widget asks for it.
void beginUpdate() override
unsigned int m_overlayBuffer
Auxiliary rendering target (for menus etc.)
GROUPS_MAP m_groups
Stores information about VBO objects (groups)
void DrawBitmap(const BITMAP_BASE &aBitmap) override
Draw a bitmap image.
wxEvtHandler * m_paintListener
static bool m_isBitmapFontLoaded
Is the bitmap font texture loaded?
The Cairo implementation of the graphics abstraction layer.
std::deque< boost::shared_array< GLdouble > > & intersectPoints
Intersect points, that have to be freed after tessellation.
void Scale(const VECTOR2D &aScale) override
Scale the context.
void ClearTarget(RENDER_TARGET aTarget) override
Clear the target for rendering.
static int m_instanceCounter
GL GAL instance counter.
void DrawCurve(const VECTOR2D &startPoint, const VECTOR2D &controlPointA, const VECTOR2D &controlPointB, const VECTOR2D &endPoint, double aFilterValue=0.0) override
Draw a cubic bezier spline.
void Translate(const VECTOR2D &aTranslation) override
Translate the context.
void drawPolygon(GLdouble *aPoints, int aPointCount)
Draw a filled polygon.
VERTEX_MANAGER * m_overlayManager
Container for storing overlaid VERTEX_ITEMs.
void drawLineQuad(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a quad for the line.
std::deque< boost::shared_array< GLdouble > > m_tessIntersects
OpenGL implementation of the Graphics Abstraction Layer.
VECTOR2D getScreenPixelSize() const
void ComputeWorldScreenMatrix() override
Compute the world <-> screen transformation matrix.
void Restore() override
Restore the context.
void ChangeGroupDepth(int aGroupNumber, int aDepth) override
Change the depth (Z-axis position) of the group.
void EnableDepthTest(bool aEnabled=false) override
wxGLCanvas wrapper for HiDPI/Retina support.
int BeginGroup() override
Begin a group.
void DrawPolygon(const std::deque< VECTOR2D > &aPointList) override
Draw a polygon.
void SetPaintListener(wxEvtHandler *aPaintListener)
unsigned int m_mainBuffer
Main rendering target.
Handle multitarget rendering (ie.
VERTEX_MANAGER * m_cachedManager
Container for storing cached VERTEX_ITEMs.
std::unordered_map< unsigned int, std::shared_ptr< VERTEX_ITEM > > GROUPS_MAP
bool IsInitialized() const override
Return the initialization status for the canvas.
OPENGL_GAL(GAL_DISPLAY_OPTIONS &aDisplayOptions, wxWindow *aParent, wxEvtHandler *aMouseListener=nullptr, wxEvtHandler *aPaintListener=nullptr, const wxString &aName=wxT("GLCanvas"))
void ResizeScreen(int aWidth, int aHeight) override
Resizes the canvas.
void unlockContext(int aClientCookie) override
void Transform(const MATRIX3x3D &aTransformation) override
Transform the context.
VERTEX_MANAGER * vboManager
Manager used for storing new vertices.
double getWorldPixelSize() const
RENDER_TARGET m_currentTarget
Current rendering target.
void DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth) override
Draw an arc segment.
RENDER_TARGET GetTarget() const override
Get the currently used target for rendering.
static const int CURVE_POINTS
The number of points for curve approximation.
This class handle bitmap images in KiCad.
wxEvtHandler * m_mouseListener
void endUpdate() override
bool SetNativeCursorStyle(KICURSOR aCursor) override
Set the cursor in the native panel.
void Save() override
Save the context.
void init()
Basic OpenGL initialization and feature checks.
VERTEX_MANAGER * m_currentManager
Currently used VERTEX_MANAGER (for storing VERTEX_ITEMs).
static wxGLContext * m_glMainContext
Parent OpenGL context.
bool Show(bool aShow) override
Shows/hides the GAL canvas.
void SetMouseListener(wxEvtHandler *aMouseListener)
Represent a set of closed polygons.
void SetNegativeDrawMode(bool aSetting) override
Set negative draw mode in the renderer.
void EndGroup() override
End the group.
void DeleteGroup(int aGroupNumber) override
Delete the group from the memory.
double calcAngleStep(double aRadius) const
Compute the angle step when drawing arcs/circles approximated with lines.
SHADER * m_shader
There is only one shader used for different objects.
bool m_isInitialized
Basic initialization flag, has to be done when the window is visible.
bool updatedGalDisplayOptions(const GAL_DISPLAY_OPTIONS &aOptions) override
Handle updating display options.
OPENGL_COMPOSITOR * m_compositor
Handles multiple rendering targets.
void PostPaint(wxPaintEvent &aEvent)
Function PostPaint posts an event to m_paint_listener.
void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint) override
Draw a line.
GLUtesselator * m_tesselator
void onPaint(wxPaintEvent &aEvent)
This is the OnPaint event handler.
GLint ufm_screenPixelSize
void endDrawing() override
void DrawGroup(int aGroupNumber) override
Draw the stored group.
void ClearCache() override
Delete all data created during caching of graphic items.
bool IsOpenGlEngine() override
Return true if the GAL engine is a OpenGL based type.
void drawTriangulatedPolyset(const SHAPE_POLY_SET &aPoly)
Draw a set of polygons with a cached triangulation.
bool IsContextLocked() override
Parameters passed to the GLU tesselator.
Provide the access to the OpenGL shaders.
void lockContext(int aClientCookie) override
Use GAL_CONTEXT_LOCKER RAII object.
GAL super
Super class definition.
void Rotate(double aAngle) override
Rotate the context.
void drawStrokedSemiCircle(const VECTOR2D &aCenterPoint, double aRadius, double aAngle)
Draw a stroked semicircle.
bool m_isContextLocked
Used for assertion checking.
void blitCursor()
Blit cursor into the current screen.
static GLuint g_fontTexture
Bitmap font texture handle (shared)
void DrawPolyline(const std::deque< VECTOR2D > &aPointList) override
Draw a polyline.
void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth) override
Draw a rounded segment.
void DrawArc(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle) override
Draw an arc.
void SetTarget(RENDER_TARGET aTarget) override
Set the target for rendering.
wxGLContext * m_glPrivContext
Canvas-specific OpenGL context.
Class to store instances of VERTEX without caching.
bool m_isFramebufferInitialized
Are the framebuffers initialized?
wxCursor m_currentwxCursor
wxCursor showing the current native cursor
void drawSemiCircle(const VECTOR2D &aCenterPoint, double aRadius, double aAngle)
Draw a semicircle.
static wxString CheckFeatures(GAL_DISPLAY_OPTIONS &aOptions)
Checks OpenGL features.
Class to handle an item held in a container.
virtual bool HasTarget(RENDER_TARGET aTarget) override
Return true if the target exists.
int drawBitmapChar(unsigned long aChar)
Draw a single character using bitmap font.
void ClearScreen() override
Clear the screen.
std::unique_ptr< GL_BITMAP_CACHE > m_bitmapCache
unsigned int getNewGroupNumber()
Return a valid key that can be used as a new group number.
void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint) override
Draw a rectangle.
void Flush() override
Force all remaining objects to be drawn.
void DrawCursor(const VECTOR2D &aCursorPosition) override
Draw the cursor.
void drawPolyline(const std::function< VECTOR2D(int)> &aPointGetter, int aPointCount)
Generic way of drawing a polyline stored in different containers.
Class to control vertex container and GPU with possibility of emulating old-style OpenGL 1....
unsigned int m_groupCounter
Counter used for generating keys for groups.
std::pair< VECTOR2D, float > computeBitmapTextSize(const UTF8 &aText) const
Compute a size of text drawn using bitmap font with current text setting applied.
RENDER_TARGET
RENDER_TARGET: Possible rendering targets.
void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle) override
Draw a text using a bitmap font.
bool m_isBitmapFontInitialized
Is the shader set to use bitmap fonts?
VERTEX_MANAGER * m_nonCachedManager
Container for storing non-cached VERTEX_ITEMs.
bool IsVisible() const override
Return true if the GAL canvas is visible on the screen.
void beginDrawing() override
GLint ufm_pixelSizeMultiplier
void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius) override
Draw a circle using world coordinates.
void skipMouseEvent(wxMouseEvent &aEvent)
Skip the mouse event to the parent.
bool m_isGrouping
Was a group started?
void drawFilledSemiCircle(const VECTOR2D &aCenterPoint, double aRadius, double aAngle)
Draw a filled semicircle.
void ChangeGroupColor(int aGroupNumber, const COLOR4D &aNewColor) override
Change the color used to draw the group.
Abstract interface for drawing on a 2D-surface.
A color representation with 4 components: red, green, blue, alpha.
void drawBitmapOverbar(double aLength, double aHeight)
Draw an overbar over the currently drawn text.