mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-14 03:14:23 +00:00
ifcviewer: scaffold ViewportHost + ViewportCore (Path A step 1)
Define the boundary the Path-A web-bring-up refactor will move things
across:
- ViewportHost.h is the embedder interface — surface creation,
framebuffer geometry, frame scheduling, quit, and notification
callbacks (onObjectPicked, onToolModeChanged, …). Desktop hosts
forward notifications to Q_SIGNALS; the future web host pushes
them to JS callbacks.
- ViewportCore.{h,cpp} is the platform-agnostic render-core target.
Empty today — the body fills in across the #78-#86 sequence as
each Qt subsystem (matrices, vectors, strings, timers, render
path, input) gets de-Qt'd and moved over.
- ViewportWindow now multiply-inherits ViewportHost alongside QWindow
and implements the host overrides as thin forwarders: createSurface
returns the cached surface_, requestFrame -> requestUpdate, quit ->
QCoreApplication::quit, onObjectPicked -> emit objectPicked.
Renamed the DPR accessor `dpr()` (vs `devicePixelRatio`) to avoid
the inherited-virtual clash with QWindow's qreal-returning version.
No method movement yet — this is purely the architectural scaffold so
subsequent commits have a destination.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "StreamingLoader.h"
|
||||
#include "VertexQuantization.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QGuiApplication>
|
||||
#include <QResizeEvent>
|
||||
#include <QDebug>
|
||||
@@ -628,6 +629,57 @@ ViewportWindow::~ViewportWindow() {
|
||||
shutdown();
|
||||
}
|
||||
|
||||
// ---- ViewportHost overrides ------------------------------------------------
|
||||
//
|
||||
// Scaffolding for Path-A. ViewportCore is empty today, so these don't
|
||||
// yet have callers; the abstract methods exist only to define the
|
||||
// boundary that subsequent commits will rely on. Each notification
|
||||
// forwards to the existing Q_SIGNAL so bonsai-side consumers see no
|
||||
// change.
|
||||
|
||||
WGPUSurface ViewportWindow::createSurface(WGPUInstance /*instance*/) {
|
||||
// initWgpu() still drives surface creation through the private
|
||||
// no-arg createSurface() helper that populates surface_. Once
|
||||
// ViewportCore takes over the wgpu init flow it'll call this
|
||||
// override instead and the private helper goes away; for now the
|
||||
// override is a getter.
|
||||
return surface_;
|
||||
}
|
||||
|
||||
void ViewportWindow::framebufferSize(int& width_px, int& height_px) const {
|
||||
const float r = float(QWindow::devicePixelRatio());
|
||||
width_px = int(QWindow::width() * r);
|
||||
height_px = int(QWindow::height() * r);
|
||||
}
|
||||
|
||||
float ViewportWindow::dpr() const {
|
||||
return float(QWindow::devicePixelRatio());
|
||||
}
|
||||
|
||||
void ViewportWindow::requestFrame() {
|
||||
requestUpdate();
|
||||
}
|
||||
|
||||
void ViewportWindow::quit() {
|
||||
QCoreApplication::quit();
|
||||
}
|
||||
|
||||
void ViewportWindow::onObjectPicked(uint32_t object_id) {
|
||||
emit objectPicked(object_id);
|
||||
}
|
||||
|
||||
void ViewportWindow::onSurfacePickedInTool(int x_px, int y_px, int modifiers) {
|
||||
emit surfacePickedInTool(x_px, y_px, modifiers);
|
||||
}
|
||||
|
||||
void ViewportWindow::onToolModeChanged(int tool_mode) {
|
||||
emit toolModeChanged(static_cast<ToolMode>(tool_mode));
|
||||
}
|
||||
|
||||
void ViewportWindow::onToolBackspacePressed() {
|
||||
emit toolBackspacePressed();
|
||||
}
|
||||
|
||||
void ViewportWindow::setBackgroundColor(const QColor& color) {
|
||||
background_color_ = color;
|
||||
if (isExposed()) requestUpdate();
|
||||
|
||||
Reference in New Issue
Block a user