mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 13:43:40 +00:00
ifcviewer: de-Qt QColor/QPoint/QSet/QElapsedTimer in ViewportWindow
Last round of straight-swap Qt value types in ViewportWindow + its
overlay co-pilot.
setBackgroundColor(const QColor&) → (float r, float g, float b, float a)
QColor background_color_ → Eigen::Vector4f (linear, 0..1)
QPoint {nav_,box_select_,fps_, } → Eigen::Vector2i
{section_drag_start_mouse_}
QSet<int> fps_keys_held_ → std::unordered_set<int>
QElapsedTimer fps_last_tick_, → Stopwatch (new header in
fly_render_clock_, IfcViewerCore — std::chrono-
render_thread_local_ backed, exposes the existing
timers in render() QElapsedTimer .start/.restart/
.elapsed/.nsecsElapsed surface)
Also propagates the QPoint → Eigen::Vector2i change through
OverlayRenderer::encodeMarquee since the marquee corner coords flow
through that interface.
API-level helpers:
toV2i(QPoint) — small inline in ViewportWindow.cpp, isolates
the QMouseEvent→Vector2i conversion at the
five mouse-event handlers
Stopwatch.h — new file, IfcViewerCore. Same call shape as
QElapsedTimer; backed by std::chrono::steady_clock.
QSet method swaps:
.isEmpty() → .empty()
.contains(k) → .count(k) (C++17, no std contains() until C++20)
.remove(k) → .erase(k)
Eigen::Vector2i doesn't have .manhattanLength(); the box-select drag
threshold uses std::abs(diff.x()) + std::abs(diff.y()) inline.
Bonsai side: View.cpp's setBackgroundColor wrapper now decomposes the
QColor into floats at the call site (kept locally so the bonsai UI
keeps its QColor-driven theming).
Closes #81 + the QElapsedTimer half of #83. QTimer
(pivot_indicator_hide_timer_) still uses Qt — it needs the host's
scheduleOnce mechanism that lands with #85.
Builds: desktop / bonsai / web all green. Tests 100/100.
This commit is contained in:
@@ -45,11 +45,14 @@ ViewportView::ViewportView(bonsaiviewer::SessionState* session_state,
|
||||
, length_measurement_(std::make_unique<LengthMeasurement>())
|
||||
{
|
||||
auto& settings = bonsaiviewer::ViewerSettings::instance();
|
||||
connect(&settings, &bonsaiviewer::ViewerSettings::themeChanged, this, [this]() {
|
||||
viewport_->setBackgroundColor(
|
||||
QColor(bonsaiviewer::ViewerSettings::instance().color("viewport_background")));
|
||||
});
|
||||
viewport_->setBackgroundColor(QColor(settings.color("viewport_background")));
|
||||
auto setBg = [this](const QString& name) {
|
||||
const QColor c(bonsaiviewer::ViewerSettings::instance().color(name));
|
||||
viewport_->setBackgroundColor(float(c.redF()), float(c.greenF()),
|
||||
float(c.blueF()), float(c.alphaF()));
|
||||
};
|
||||
connect(&settings, &bonsaiviewer::ViewerSettings::themeChanged, this,
|
||||
[setBg]() { setBg("viewport_background"); });
|
||||
setBg("viewport_background");
|
||||
|
||||
connect(session_state_, &SessionState::projectReset, this, &ViewportView::refresh);
|
||||
connect(session_state_, &SessionState::projectOpened, this, [this](const QString&) { refresh(); });
|
||||
|
||||
Reference in New Issue
Block a user