Domain visualizer

The 2/3D visualizer (see Domain Visualizer) renders through QRhi, Qt’s portable graphics abstraction.

solvcon::RDomainWidget is the Python-facing control object.

enum class Mode

The interaction mode that selects how drag, wheel, and key input move the camera.

Values:

enumerator PanZoom

2D: drag pans, wheel zooms the orthographic box.

enumerator FirstPerson

3D: drag looks around, wheel dollies forward.

enumerator Orbit

3D: drag swings the eye around the target, wheel dollies in.

enum class OrbitStyle

The orbit style.

Turntable holds the up axis fixed so the horizon never rolls; Trackball tumbles freely, rolling the up axis with the drag.

Values:

enumerator Turntable
enumerator Trackball
enum class Kind

The shader variant.

More variants are added as the renderer grows.

Values:

enumerator FlatColor

One uniform color for the whole primitive.

enumerator VertexColor

A per-vertex color attribute.

enumerator Textured

A sampled texture tinted by the uniform color.

enumerator Lit

A per-vertex normal shaded by a directional light.

enumerator ScalarColor

A per-vertex scalar mapped through a LUT texture.

struct DrawPoint
#include <DrawTool.hpp>

A point in world coordinates, the unit a drawing gesture is built from.

class DrawToolBase
#include <DrawTool.hpp>

Abstract base class for a 2D canvas drawing tool.

Public Functions

virtual std::string name() const = 0

Stable tool name shared with the Python binding and the toolbox.

virtual bool can_draw_shape() const = 0

Wether this tool draws a shape or just navigates the view.

void paint_preview(QPainter &painter, ViewTransform2dFp64 const &view, std::span<DrawPoint const> points) const

Paint the rubber-band preview of the gesture points.

Sets the shared preview pen, then defers to paint_outline.

virtual void commit(WorldFp64 &world, std::span<DrawPoint const> points) const = 0

Commit the shape described by the gesture points into world.

class R2DWidget : public QWidget
#include <R2DWidget.hpp>

Strictly-2D drawing widget for the pilot.

Paints the geometry of a World<double> by mapping it to screen space through a 2D view transform, drawn with QPainter.

Public Functions

inline ViewTransform2dFp64 const &viewTransform() const

Read-only access to the current view state.

inline std::string drawTool() const

Get the name of the active draw tool.

void setDrawTool(std::string const &name)

Select the active pointer tool by name.

inline int32_t selectedShape() const

Id of the shape selected with the pan tool, or -1 when none is selected.

Selection is cleared by switching tools or worlds.

coord2_type rotateHandleScreen() const

Screen position [x, y] of the selection’s rotate handle, or [-1, -1] when nothing is selected.

Exposed for tests and tooling.

void setViewTransform(ViewTransform2dFp64 const &v)

Replace the view state.

Non-finite inputs are ignored and zoom is clamped to the widget’s internal bounds, so the widget’s invariants survive any caller. Setting a well-formed transform also disables the deferred auto-centering that runs on the first positive-size resize.

void resetView()

Re-center the view so the world origin sits at the widget center.

void updateWorld(std::shared_ptr<WorldFp64> const &world)

Update the world being painted by this widget.

inline std::shared_ptr<WorldFp64> const &world() const

Get the world currently being painted.

inline void requestRepaint()

Hook for subsequent stages; current implementation triggers a repaint.

class RAction : public QAction
#include <RAction.hpp>

A QAction that invokes a stored callback when the action is triggered.

The constructor wires the QAction text and status tip and connects the triggered signal to the supplied callback, so callers can build a menu or toolbar action from a single function object.

class RAxisGizmo
#include <RAxisGizmo.hpp>

A small orientation guide drawn in a corner of the viewport.

Renders a 2- or 3-axis triad of colored arrows (hand-built cones on shafts) with X/Y/Z labels (QPainter glyphs uploaded as textures and drawn as camera-facing billboards). The guide has its own orthographic camera whose orientation mirrors the main camera, so it always shows which way the domain axes point. It is drawn over the scene in the same render pass with the depth test off, confined to a corner viewport.

Resource updates happen in update() before the render pass begins; the draw calls happen in draw() inside the pass.

Public Functions

inline void setAxisCount(int count)

Show 2 axes (X, Y) or 3 axes (X, Y, Z).

void update(QRhi *rhi, QRhiRenderPassDescriptor *rpdesc, int sample_count, QSize pixel_size, QVector3D const &forward, QVector3D const &up, QRhiResourceUpdateBatch *batch)

Create or update the device resources and the per-frame transforms.

Call before the render pass begins. forward and up come from the main camera so the triad mirrors the current view orientation.

void draw(QRhiCommandBuffer *cb)

Record the draw calls into the active render pass.

void release()

Drop every device resource.

class RBoundary : public solvcon::RDrawable
#include <RBoundary.hpp>

A single boundary set drawn as thick colored ribbons over the wireframe so the set stands out.

Each boundary edge is widened into a flat quad (two triangles) lifted slightly toward the viewer, because line width is clamped to one pixel in the core profile. ibc identifies which boundary set this draws.

class RCameraController
#include <RCameraController.hpp>

A single camera controller with three interaction modes.

PanZoom frames a 2D domain head-on: dragging pans and the wheel zooms an orthographic view. FirstPerson flies through a 3D domain: dragging looks around and the wheel dollies along the view direction. Orbit inspects a 3D domain from outside: dragging swings the eye around the fixed target and the wheel dollies toward it, the up axis held fixed so the view never rolls (a turntable orbit). The controller holds one pose (position, target, up) plus an orthographic zoom factor, and feeds a QMatrix4x4 view matrix.

The widget drives the controller from mouse and key events, and Python drives the same primitives (rotate / zoom / pan) and reads or sets the pose directly, so the domain navigates the same way from code as from the mouse.

Public Functions

inline void setPivot(QVector3D const &pivot)

Set the orbit pivot: the point the Orbit mode swings the eye around.

The eye stays put, so the next drag rotates about the new center.

inline void setOrbitSensitivity(float factor)

Scale the rotate/look speed. A positive factor only; ignored otherwise.

inline void orbitStep(float yaw_deg, float pitch_deg)

Orbit by a fixed number of degrees, a discrete step independent of the per-pixel drag scaling (what a numpad-style fixed rotation drives).

void fitToBoundingBox(QVector3D const &lo, QVector3D const &hi, uint32_t ndim, float aspect)

Frame the camera onto the bounding box [lo, hi] for an ndim domain at the given viewport aspect (width / height).

QMatrix4x4 viewMatrix() const

The view matrix for the current pose.

inline float orthoScale() const

The orthographic zoom factor (smaller means zoomed in).

void rotate(float dx, float dy)

Drag interaction: pan in PanZoom, look around in FirstPerson, swing the eye around the target in Orbit.

dx and dy are pixel deltas.

void pan(float dx, float dy)

Pan the view in its own plane by the pixel deltas (both modes).

void zoom(float steps)

Wheel interaction: change the orthographic zoom in PanZoom, dolly along the view direction in FirstPerson, dolly toward the target in Orbit.

steps is the wheel notch count.

void pinch(float factor)

Pinch interaction: zoom by a multiplicative factor (greater than 1 zooms in, less than 1 zooms out), as a trackpad or touch pinch reports.

Maps onto the same zoom path as the wheel.

void moveForward(float amount)

Move along the view direction (forward, +) or sideways (strafe, +right) by a fraction of the scene size; used by the first-person keys.

class RColormap
#include <RColormap.hpp>

A named one-dimensional color lookup table.

A colormap is a piecewise-linear ramp over a static table of RGB anchor points spaced uniformly on [0, 1]. It bakes into a one-row QImage that a drawable uploads as the LUT texture sampled by the scalar-color material, and the same table drives the scalar-bar strip so the on-screen report always matches the mapping on the GPU.

Public Functions

QVector3D sample(float t) const

Piecewise-linear sample of the ramp at t clamped to [0, 1].

QImage image(int width = 256) const

Bake the ramp into a width x 1 RGBA image for the LUT texture.

Public Static Functions

static RColormap named(std::string const &name)

The available names: “viridis”, “coolwarm”, “jet”, “grayscale”.

Throws std::invalid_argument for anything else.

static RColormap categorical()

A qualitative map for categorical coloring: a fixed set of visually distinct colors.

Used with an integer scalar over [0, ncat - 1].

class RDomainWidget : public QRhiWidget
#include <RDomainWidget.hpp>

Interactive 2D/3D viewer for spatial domains and fields on unstructured meshes, rendered with QRhi and controlled from Python.

It derived from QRhiWidget: Qt owns the swapchain, color and depth buffers, and drives the render loop through initialize()/render(). The widget hosts an RScene (the drawables, the domain bounding box, and the framing camera) and drives it.

Public Functions

void updateMesh(std::shared_ptr<StaticMesh> const &mesh)

Replace the rendered mesh with the wireframe of mesh.

void showMesh(bool show)

Show or hide the mesh, in whatever representation is active.

void showMeshStyle(std::string const &name, bool show)

Show or hide one mesh style independently of the others, so any combination can be drawn at once (a wireframe over a lit surface, say).

name is “surface” (lit shaded), “wireframe” (edges), or “points” (nodes); an unknown name is ignored.

void setMeshOpacity(float opacity)

Set the mesh wireframe opacity, a [0, 1] fraction (1 opaque).

void setFieldOpacity(float opacity)

Set the color-field surface opacity, a [0, 1] fraction (1 opaque).

Lower it to read the wireframe drawn over the shaded surface.

void updateColorField(SimpleArray<float> const &vertices, SimpleArray<float> const &colors, SimpleArray<uint32_t> const &indices)

Replace the colored field: per-vertex-colored triangles from a vertex table (nvert, 3), a matching color table (nvert, 3), and a triangle index table (ntri, 3).

Swappable at runtime.

void updateScalarField(SimpleArray<float> const &vertices, SimpleArray<float> const &scalars, SimpleArray<uint32_t> const &indices)

Replace the scalar field: triangles from a vertex table (nvert, 3), a per-vertex scalar table (nvert,), and a triangle index table (ntri, 3), colored on the GPU through the active colormap LUT.

Swappable at runtime.

void setColormap(std::string const &name)

Select the named colormap (“viridis”, “coolwarm”, “jet”, “grayscale”) for the scalar field and the scalar bar.

void setScalarRange(float lo, float hi)

Pin the scalar-to-color mapping range.

Until called, each updateScalarField maps its own data min/max.

void showScalarBar(bool show)

Show or hide the on-screen scalar bar.

void setScalarBarTitle(std::string const &title)

Set the title text over the scalar bar.

void showBoundary(int ibc, bool show)

Show or hide the highlight ribbon for boundary set ibc.

void showFeatureEdges(bool show)

Show or hide the domain’s boundary (feature) edges as one bold overlay.

void showNormals(bool show)

Show or hide a short arrow at every face center along its normal.

void clearSelection()

Drop the current selection and its highlight.

double measureDistance(QVector3D const &p0, QVector3D const &p1)

Measure and draw the distance between two world points; returns the distance.

double measureAngle(QVector3D const &p0, QVector3D const &p1, QVector3D const &p2)

Measure and draw the angle at p1 between the arms to p0 and p2; returns the angle in degrees.

void clearMeasurements()

Remove the measurement ruler.

int addClip(QVector3D const &origin, QVector3D const &normal)

Clip the mesh by a plane, keeping the side the normal points away from (the near half, toward the normal, is removed).

Returns the number of surface primitives kept.

int addSlice(QVector3D const &origin, QVector3D const &normal)

Slice the mesh by a plane, drawing the cross-section outline where the plane cuts the cells.

Returns the number of segments drawn.

void clearFilters()

Remove the slice and clip filters.

void colorByQuality(std::string const &metric)

Color the mesh by a per-cell geometric quality metric through the continuous colormap and scalar bar.

metric is one of “volume”, “aspect_ratio”, “skewness”, “min_angle”, “max_angle”.

std::pair<float, float> qualityRange(std::string const &metric) const

The (min, max) range of the named quality metric over the cells.

void fitCameraToScene()

Frame the camera so the whole domain is in view.

void setView(std::string const &name)

Point the camera along a named view preset and frame the scene: “front”, “back”, “left”, “right”, “top”, “bottom”, the axis names “+x”..”-z”, or “iso”.

void setProjection(std::string const &name)

Set the projection independently of the 2D/3D default: “auto”, “parallel”, or “perspective”.

void setOrbitStyle(std::string const &name)

Select the orbit style: “turntable” (up axis fixed, horizon level) or “trackball” (free tumble that can roll the horizon).

void setPivot(float x, float y, float z)

Set the orbit pivot, the point the orbit swings the eye around.

void frameSelected()

Recenter and frame the whole scene (the selection once picking lands).

void zoomToSelection()

Frame the current selection (from a pick), or the whole scene when nothing is selected.

void resetCamera()

Reset the camera to the fit-to-scene default: auto projection, turntable orbit, the whole scene framed.

void setNavigationMapping(std::string const &name)

Choose the mouse navigation mapping: “default” (left rotates, other buttons pan) or “blender” (middle orbits; Shift+middle pans; Ctrl+middle zooms; Alt+middle recenters the pivot; Alt+left aliases the middle button for trackpads without one).

void setOrbitSensitivity(float factor)

Scale the orbit/look speed for drags.

void orbitStep(float yaw_deg, float pitch_deg)

Orbit by a fixed number of degrees, a discrete step.

void showAxis(bool show)

Show or hide the orientation-guide triad in the corner.

void showCubeAxes(bool show)

Show or hide a bounding-box cube-axes grid with tick marks.

std::vector<float> cubeAxesTicks(int axis) const

The cube-axes tick coordinates per axis (x, y, z), in mesh units.

void setTitle(std::string const &text)

Set the figure title drawn as a top overlay; an empty string clears it.

void setCameraMode(std::string const &name)

Select the camera mode: “pan” (2D pan/zoom), “fps” (3D fly-through), or “orbit” (3D orbit around the target).

void pinchCamera(float factor)

Zoom by a multiplicative pinch factor (what a trackpad/touch pinch drives); greater than 1 zooms in, less than 1 zooms out.

QImage grabImage()

Render the current frame offscreen and return it as a QImage.

Thin wrapper over QRhiWidget::grabFramebuffer() for the Python control path.

QImage renderToImage(int width, int height, bool transparent = false)

Render the scene offscreen at a requested width and height, decoupled from the widget size, optionally over a transparent background.

The widget size is restored afterward.

struct PickResult
#include <RDomainWidget.hpp>

The result of a pick: the entity kind (“cell”, “node”, “face”, or “none” for a miss), its id, its element type (for a cell), a measure (cell volume or face area), and its centroid.

class RDrawable
#include <RDrawable.hpp>

Base class for a renderable object in the domain scene.

A drawable owns its vertex (and optional index) buffer, a per-object uniform buffer holding the model-view-projection matrix and a flat color, the shader-resource bindings, and the graphics pipeline built from its RMaterial. Subclasses supply the geometry and the pipeline configuration (material variant, primitive topology, vertex input layout).

The device-owned resources are created lazily through prepare() once the QRhi and the render target are known, and dropped through release() when the device is lost or replaced.

Subclassed by solvcon::RBoundary, solvcon::RFeatureEdges, solvcon::RField, solvcon::RMeshFrame, solvcon::RNormals, solvcon::RScalarField, solvcon::RSegments

Public Functions

inline void setModel(QMatrix4x4 const &model)

The model transform applied before the view-projection; identity by default, so a single object renders where its geometry already sits.

inline void setName(std::string const &name)

An optional name, used by the scene’s named-object registry.

inline void setLightDir(QVector3D const &dir)

World-space direction toward the light, read by the lit material and ignored by the others.

The widget refreshes it as the camera moves.

inline void setOpacity(float opacity)

Set the drawable opacity, a [0, 1] multiplier on the color alpha.

1 is fully opaque, 0 fully transparent. Clamped to the range.

void prepare(QRhi *rhi, QRhiRenderPassDescriptor *rpdesc, int sample_count, QRhiResourceUpdateBatch *batch)

Create the device resources if they do not exist yet. Idempotent.

virtual void release()

Drop all device resources (device lost or render target changed).

virtual void updateUniform(QRhiResourceUpdateBatch *batch, QMatrix4x4 const &view_proj)

Write the current model-view-projection and color into the uniform buffer.

The model transform is identity for now.

void draw(QRhiCommandBuffer *cb)

Record the draw call.

Requires an active render pass and a viewport already set on the command buffer. A no-op while hidden or unprepared.

class RFeatureEdges : public solvcon::RDrawable
#include <RFeatureEdges.hpp>

The domain’s boundary (feature) edges drawn as one bold colored overlay over the hairline wireframe.

The edges are the rim edges of every boundary face, gathered across all boundary sets and widened into flat ribbons in a single color, so the whole domain outline reads as one distinct layer. This complements the per-set highlight (RBoundary), which colors one set at a time.

class RField : public solvcon::RDrawable
#include <RField.hpp>

A field drawn as per-vertex-colored triangles.

Takes a vertex table (nvert, 3), a matching color table (nvert, 3) in the [0, 1] range, and a triangle index table (ntri, 3). The colors are uploaded interleaved with the positions and read by the per-vertex-color material, so the field is swappable at runtime by replacing the drawable.

class RManager : public QObject
#include <RManager.hpp>

Singleton that owns the pilot main window and coordinates its widgets, menus, and the active canvas drawing tool.

The manager holds the QCoreApplication, the QMainWindow with its menus and MDI area, and the Python console dock. It creates and tracks the 2D and 3D domain widgets, exposes the currently focused canvas, and routes the active drawing tool to it. Access the single instance through instance().

Public Functions

inline std::string drawTool() const

Name of the active canvas drawing tool.

void setDrawTool(std::string const &name)

Select the active drawing tool and apply it to the focused 2D canvas.

inline RMenuModel *menuModel()

The live model of the menu bar, addressable by path from Python.

void reset()

Only call reset() when the program is to be stopped.

class RMaterial
#include <RMaterial.hpp>

A rendering material: a baked GLSL shader pair plus the helper that turns it into a QRhiGraphicsPipeline.

The shader sources live next to this file under shaders/ and are baked to .qsb by the qsb tool at build time (see cpp/solvcon/CMakeLists.txt). They are embedded in the Qt resource system and loaded by resource path.

Public Functions

QRhiGraphicsPipeline *buildPipeline(QRhi *rhi, QRhiShaderResourceBindings *srb, QRhiRenderPassDescriptor *rpdesc, QRhiVertexInputLayout const &input_layout, QRhiGraphicsPipeline::Topology topology, int sample_count, bool depth_test = true, bool alpha_blend = false, int depth_bias = 0, float slope_scaled_depth_bias = 0.0f) const

Build a graphics pipeline for this material.

Ownership of the returned pipeline is transferred to the caller; nullptr on failure.

Public Static Functions

static QShader loadShader(QString const &resource_path)

Load a baked shader from the Qt resource system.

class RMenuModel : public QObject
#include <RMenuModel.hpp>

A live, incrementally built model of the pilot menu bar.

Menus are addressed by a slash-separated path (“View/Panels”). menu() resolves a path, creating any missing ancestor on demand, and place() drops an action (or a separator) into the menu at a path. Every entry in a menu, whether a submenu or an item, is ordered by a weight: a smaller weight sits earlier, equal weights keep arrival order, and a negative weight appends. The weight-with-gaps ordering follows the convention plugin systems use for contributed items (for example Drupal’s #weight): a declared integer key, with room left between values to slot an entry in without renumbering.

Placed actions are registered under their objectName, so action(id) looks one up and remove(id) takes it out. group(id) returns a named QActionGroup for exclusive selections. The model owns the menus and groups it creates, so clear() empties the bar and lets a fresh setUp rebuild it.

Public Functions

QMenu *menu(std::string const &path, int weight = -1)

Resolve or create the menu at path, creating ancestors on demand.

weight orders the final node among its siblings; a negative weight leaves an existing node’s order untouched and appends a new one.

void place(std::string const &path, QAction *action, int weight = 50)

Place action in the menu at path, ordered by weight among the menu’s current entries.

The action is registered under its objectName when that name is set.

void placeSeparator(std::string const &path, int weight = 50)

Place a separator in the menu at path, ordered by weight.

QAction *action(std::string const &id) const

The action registered under id, or nullptr when none is.

void remove(std::string const &id)

Remove and unregister the action registered under id, if any.

QActionGroup *group(std::string const &id)

The named action group, created on first use.

void clear()

Delete every menu and group the model created and empty the bar.

class RMeshFrame : public solvcon::RDrawable
#include <RMeshFrame.hpp>

The unstructured-mesh domain rendered as an edge wireframe, a node point cloud, or a lit, shaded surface.

The wireframe draws the mesh edge list (StaticMesh::ednds) as lines and the point cloud draws the nodes themselves, both over the shared node-coordinate buffer and flat-colored. The surface instead fills the domain: a 2D mesh fills its cells in the z = 0 plane facing +z, a 3D mesh draws its boundary shell with each face’s outward normal, every face fan-triangulated into flat-shaded triangles that the lit material shades two-sided over an ambient floor. Works for both 2D and 3D meshes.

Public Types

enum class Style

Which primitive the geometry is assembled into.

Values:

enumerator Wireframe

Mesh edges as lines.

enumerator Points

Mesh nodes as points.

enumerator Surface

Cell or boundary faces as a lit, shaded surface.

class RNormals : public solvcon::RDrawable
#include <RNormals.hpp>

The face normals drawn as short line arrows, one per face.

Each arrow starts at the face center (StaticMesh::fccnd) and points along the unit face normal (StaticMesh::fcnml); its length is a small fraction of the mesh extent, so the field reads as short quills. A two-segment head marks the direction. Both are precomputed by StaticMesh, so no geometry is derived here beyond scaling.

class RPythonCommandTextEdit : public QTextEdit
#include <RPythonConsoleDockWidget.hpp>

The command input editor that drives Python auto-completion and reports execution and history navigation.

On Tab the editor extracts the identifier prefix behind the cursor and emits completionRequested, or inserts a literal tab when there is no prefix. It emits execute on Enter, navigate on Up or Down at the first or last line, and inserts the match chosen from the completer popup.

class RPythonHistoryTextEdit : public QTextEdit
#include <RPythonConsoleDockWidget.hpp>

The read-only transcript view that shows committed commands and their captured output.

A double-click selects the entire transcript.

class RPythonConsoleDockWidget : public QDockWidget
#include <RPythonConsoleDockWidget.hpp>

The dockable Python console that pairs a transcript view with a command editor and runs each command in the embedded interpreter.

Submitting a command appends it to the history, executes it through the Python interpreter, and writes the captured stdout and stderr to the transcript when the redirect is active. Up and Down walk the committed-command history, and the widget brokers the editor’s completion requests against the interpreter’s completer.

class RPythonConsoleHistory
#include <RPythonConsoleHistory.hpp>

A capped ring of committed console commands, persisted to a file and searchable backward for reverse incremental search.

The store is intentionally free of Qt so the persistence and search logic can be exercised by the C++ test suite. Commands may span several lines; they are escaped when written so each entry stays on one line in the file.

Public Functions

void add(std::string const &command)

Append a command, skipping an empty one or a consecutive duplicate, cap the ring at the limit, and persist when a file path is set.

void load()

Replace the in-memory ring with the content of the file path.

void save() const

Persist the whole ring to the file path, creating parent directories.

std::size_t searchBackward(std::string const &query, std::size_t from) const

The most recent entry at or before from whose text contains query.

Returns npos when none matches; an empty query matches the entry at from.

class RPythonSyntaxHighlighter : public QSyntaxHighlighter
#include <RPythonSyntaxHighlighter.hpp>

Paints Python keywords, builtins, strings, comments, and numbers in a text document.

The lexing lives in tokenizePython so it can be tested without a display; this class only maps each category to a format.

class RScalarBar
#include <RScalarBar.hpp>

An on-screen scalar bar reporting the active scalar-color mapping.

Renders the title, the colormap name, the color strip (painted from the same RColormap table the GPU LUT is baked from), and the range end labels into one QImage, uploaded as a texture and drawn as a single overlay quad along the right edge of the viewport with the depth test off. The bar follows the gizmo pattern: resource updates happen in update() before the render pass, draw calls in draw() inside the pass.

Public Functions

void update(QRhi *rhi, QRhiRenderPassDescriptor *rpdesc, int sample_count, QSize pixel_size, QRhiResourceUpdateBatch *batch)

Create or update the device resources. Call before the render pass.

void draw(QRhiCommandBuffer *cb)

Record the draw calls into the active render pass.

void release()

Drop every device resource.

class RScalarField : public solvcon::RDrawable
#include <RScalarField.hpp>

A field of triangles colored by a per-vertex scalar on the GPU.

Takes a vertex table (nvert, 3), a matching scalar table (nvert,), and a triangle index table (ntri, 3). The scalar is uploaded interleaved with the positions as a vertex attribute; the fragment stage normalizes it by the mapping range and samples the colormap LUT texture, so recoloring by range or by map never touches the vertex data.

The mapping range rides the color slot of the shared uniform block as (vmin, 1/(vmax - vmin)); see shaders/scalar.frag.

Public Functions

void setColormap(RColormap colormap)

Swap the lookup table; takes effect on the next frame.

void setScalarRange(float lo, float hi)

Set the value-to-[0, 1] mapping range for the LUT sampling.

virtual void updateUniform(QRhiResourceUpdateBatch *batch, QMatrix4x4 const &view_proj) override

Write the current model-view-projection and color into the uniform buffer.

The model transform is identity for now.

virtual void release() override

Drop all device resources (device lost or render target changed).

class RScene
#include <RScene.hpp>

The renderable scene: the drawables, the domain bounding box, and the framing camera with a per-dimension projection.

The scene owns the list of RDrawable objects and the domain bounding box, picks an orthographic projection for 2D domains and a perspective projection for 3D ones, and frames the camera onto the box. RDomainWidget holds one scene and drives it; the scene itself is free of Qt widget and device-loop concerns.

Public Types

enum class Projection

The projection selector.

Auto picks orthographic for a 2D domain and perspective for a 3D one; the others force the choice.

Values:

enumerator Auto
enumerator Parallel
enumerator Perspective

Public Functions

void addDrawable(std::unique_ptr<RDrawable> drawable)

Add a drawable; ownership transfers to the scene.

void removeDrawable(RDrawable const *drawable)

Remove a specific drawable (no-op for nullptr or a foreign pointer).

void removeDrawableIf(std::function<bool(RDrawable const*)> const &pred)

Remove every drawable the predicate accepts.

void releaseAll()

Release the device resources of every drawable.

void resetBoundingBox()

Forget the bounding box so the next extendBoundingBox sets it afresh.

void extendBoundingBox(QVector3D const &lo, QVector3D const &hi)

Grow the bounding box to include the point range [lo, hi].

void setProjection(std::string const &name)

Override the projection: “auto”, “parallel”, or “perspective”.

An unknown name is ignored.

void setViewPreset(std::string const &name, float aspect)

Point the camera along an axis-aligned or isometric preset and frame the scene: “front”, “back”, “left”, “right”, “top”, “bottom”, the axis names “+x”..”-z”, or “iso”.

An unknown name is ignored.

void fitCameraToScene(float aspect)

Frame the camera so the whole bounding box is in view at the given viewport aspect (width / height).

Resets any zoomed-in framing.

void frameBox(QVector3D const &lo, QVector3D const &hi, float aspect)

Frame the camera on an arbitrary box [lo, hi] (a picked selection, say) so the projection sizes to that box, not the whole scene.

QMatrix4x4 viewProjection(QSize pixel_size, QRhi *rhi) const

The model-view-projection for the framed scene at the given viewport.

2D domains use an orthographic projection, 3D domains a perspective one. rhi supplies the backend clip-space correction.

class RSegments : public solvcon::RDrawable
#include <RSegments.hpp>

A set of independent line segments in world space, flat-colored.

The constructor takes points in consecutive pairs (p0, p1, p2, p3, …), each pair drawn as one line. It backs the measurement ruler, which draws the measured distance segment or the two angle arms over the scene.

class RTextOverlay
#include <RTextOverlay.hpp>

A title string painted into a texture and drawn as a top-center overlay quad, following the scalar-bar overlay pattern.

class RWorldRenderer2d
#include <RWorldRenderer2d.hpp>

Renders a world’s live points, segments, and curves into a QPainter in screen space, mapping math-convention world coordinates through a 2D view transform.

paint() draws geometry only; paint_canvas() adds the backdrop and optional grid/axes/origin chrome. m_world is non-owning and may be null.

Public Functions

void paint_canvas(QPainter &painter, int width, int height, bool full_canvas) const

Paint backdrop, geometry, and optional chrome.

Parameters:
  • painter – Target painter in screen space.

  • width – Canvas width in pixels.

  • height – Canvas height in pixels.

  • full_canvas – If true, draw grid, axes, and the origin marker.