/******************************************************************************** * * * This file is part of IfcOpenShell. * * * * IfcOpenShell is free software: you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as published by * * the Free Software Foundation, either version 3.0 of the License, or * * (at your option) any later version. * * * * IfcOpenShell is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * Lesser GNU General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public License * * along with this program. If not, see . * * * ********************************************************************************/ #ifndef IFCVIEWER_OVERLAYRENDERER_H #define IFCVIEWER_OVERLAYRENDERER_H #include #include #include // Neutral overlay-primitive renderer attached to ViewportWindow. Today it // draws a single tinted, translucent triangle list in world space — used by // the area-measurement tool to shade selected coplanar patches. More // primitives (lines, points, world-anchored labels) will land here as // future tools require them. // // Lifetime: owned by ViewportWindow, initialised in the same context. All // public methods assume the caller has already made the GL context current. class OverlayRenderer { public: void initialize(QOpenGLFunctions_4_5_Core* gl); void release(); // Replace the highlight-triangle list. `world_xyz` is 3 floats per // vertex, 3 verts per triangle, in world space (post-composed-transform). // Empty disables the overlay. Color is RGBA in [0, 1]. void setHighlightTriangles(const std::vector& world_xyz, float r, float g, float b, float a); // Replace the overlay-line list (3 floats per vertex, 2 verts per // segment, world space). // // When stroke_a > 0, every segment is rendered twice — first a wider // (line_width + 2*stroke_extra) stroke pass, then the inner line_width // pass. Most desktop GL drivers clamp glLineWidth at ~1, so the // stroke pass on lines may visually collapse onto the inner; reliable // two-tone outlining will need a screen-space-quad thick-line shader. void setOverlayLines(const std::vector& world_xyz, float r, float g, float b, float a, float line_width, float stroke_r, float stroke_g, float stroke_b, float stroke_a, float stroke_extra); // Replace the overlay-point list (3 floats per point, world space). // `pixel_size` is the inner-dot diameter in physical pixels. // // When stroke_a > 0, every point is rendered twice: a wider // (pixel_size + 2*stroke_extra) outer dot in stroke_color, then the // pixel_size inner dot in the main color — giving a crisp halo that // reads on any background. void setOverlayPoints(const std::vector& world_xyz, float r, float g, float b, float a, float pixel_size, float stroke_r, float stroke_g, float stroke_b, float stroke_a, float stroke_extra); // World-anchored text labels: each one is projected to screen space // and drawn via QPainter at that pixel. Used today for per-segment // length readouts in the length tool. struct Label { float world_pos[3]; QString text; }; void setOverlayLabels(const std::vector