/********************************************************************************
* *
* 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
#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);
// One stylistic group of line segments rendered through the
// outlined / optionally-dashed line shader. Multiple groups in a
// single setOverlayLines call let the caller mix solid + dashed +
// axis-coloured legs in one frame (e.g. the length tool's white
// total line + RGB XYZ stair-step + dashed perpendicular).
struct LineGroup {
std::vector world_xyz; // 6 floats per segment (a, b)
float color[4] = {1, 1, 1, 1}; // inner color
float stroke_color[4] = {0, 0, 0, 1}; // outline (0 alpha = no outline)
float line_width = 1.5f; // pixels (inner)
float stroke_extra = 0.5f; // pixels per side outside inner
float dash_period_px = 0.0f; // 0 = solid; else screen-space dash period
float dash_on_ratio = 0.6f; // [0..1], used only when period > 0
};
void setOverlayLines(const std::vector& groups);
// 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