Skip to content

VTK and ROOT

mutomVtk supplies 3D representations and interactive viewports for Core and Math objects. mutomRoot supplies ROOT-oriented data, plot, and file adapters. Both are optional presentation/I/O layers above the domain model: applications should keep the model in uLib::Object classes and attach one or both adapters at the boundary.

VTK: object to representation

The central VTK abstraction is uLib::Vtk::Prop3D: a Core object which owns or adapts the corresponding VTK props. A uLib::Vtk::ObjectsContext observes a Core ObjectsContext, creates a Prop3D per supported object, and keeps the representations synchronized as objects are added, removed, or updated.

uLib::Object
    │  Prop3DFactory selects an adapter
    ▼
uLib::Vtk::Prop3D
    │
    ├── vtkProp / vtkProp3D
    └── Viewport or QViewport
Type Responsibility
Prop3D Base model-to-VTK representation, display state, selection, and renderer connections.
Prop3DFactory Registry that creates a representation for a domain object.
Prop3DRegistrar, Prop3DCustomRegistrar, Prop3DAggregateVisualRegistrar Registration helpers for built-in libraries and plugins.
Vtk::ObjectsContext Context-level synchronizer and object-to-prop lookup.
Viewport, Viewer VTK render window, camera, selection, and rendering control.
QViewport Qt widget embedding a Viewport, with Qt selection and edit-tool signals.
HandlerWidget, MultiSelectionProp, EditKeymap, KeyStroke Interactive object manipulation and selection support.
ViewportProperties Serializable viewport display settings.

The standard Math adapters are Vtk::Assembly, Vtk::ContainerBox, Vtk::Cylinder, Vtk::Polydata, Vtk::QuadMesh, Vtk::StructuredGrid, Vtk::TessellatedMesh, Vtk::TriangleMesh, Vtk::VoxImage, and Vtk::TransformModifier.

Create a representation registry entry

This is the usual extension point for a domain or plugin library. Register at static initialization time in the library that defines both types; the Prop3DFactory will then find it when a context is synchronized.

#include <Vtk/Prop3DFactory.h>
#include "DetectorChamberProp3D.h"
#include <HEP/Detectors/DetectorChamber.h>

ULIB_REGISTER_PROP3D(uLib::DetectorChamber, DetectorChamberProp3D)

The adapter must remain a view of the model. Put detector geometry and serialization in DetectorChamber; put actors, mappers, picking, and display-only state in its Prop3D.

Synchronize a context

#include <Core/ObjectsContext.h>
#include <Vtk/vtkObjectsContext.h>

uLib::ObjectsContext model;
uLib::Vtk::ObjectsContext visual{&model};

// Add model objects to model, then materialize/update their VTK adapters.
visual.Synchronize();

Use Viewport::FindProp3D or Vtk::ObjectsContext::GetProp3D to navigate from a model object to its visual counterpart. Do not use a VTK pointer as the durable model identity; Prop3Ds can be recreated during synchronization.

For property synchronization and editing behavior, see Prop3D bridge and viewport editing tools.

ROOT: plots, event data, and scene files

ROOT classes live in uLib::Root except where a legacy ROOT data type intentionally has a global-facing name. The modern adapters make data objects inspectable by ROOT without making the Core model dependent on ROOT.

Type Responsibility
QCanvas Qt widget containing a ROOT canvas.
RootPlottable, RootPlotGroup A plottable item and a group/overlay of items.
RootHistogram ROOT histogram view of uLib::Histogram.
RootScatter, RootScatterWriter, RootScatterReader Scatter-event visualization and ROOT tree I/O.
ROOT::Mutom::MuonTrack, ROOT::Mutom::MuonScatter ROOT-facing muon tree rows.
ROOT::Mutom::SceneBlob, uLib::RootSceneSummary, WriteContextToRootFile, ReadContextFromRootFile Lossless Core scene document in a ROOT file plus an inspectable contents tree.
ROOT::Mutom::Hit32, Hit64, HitRaw, Line3D ROOT-compatible low-level data records.
muCastor*, SkinDetectorWriter Experiment-specific ROOT records and writers.

Plot a domain histogram

RootHistogram observes a uLib::Histogram. Give it the source, then refresh on the owning GUI/ROOT thread; ROOT itself is not thread-safe, so do not refresh it directly from a simulation worker.

#include <Math/Histogram.h>
#include <Root/RootHistogram.h>

uLib::Histogram counts;
uLib::Root::RootHistogram plot;
plot.SetSource(&counts);

// After fills have completed on the appropriate thread:
plot.Refresh();

Complete API

The class catalog records every installed public VTK and ROOT type. The plugin guide shows how a plugin can contribute a new Core class, its VTK adapter, and its own documentation page without modifying this navigation hierarchy.