Skip to main content

EditorRegistry

EditorRegistry

Central registry for editor types, instances, and selection. More…

#include <EditorRegistry.hpp>

Inherits from QObject

Public Classes

Name
struct EditorTypeInfo
struct EditorInstance
Result of creating an editor instance.

Public Types

Name
using std::function< std::shared_ptr< EditorState >(EditorTypeId const &)> OpenEditorCallback
Callback type for opening/focusing an editor and returning its state.

Public Signals

Name
void typeRegistered(EditorTypeId type_id)
Emitted when a new type is registered.
void typeUnregistered(EditorTypeId type_id)
Emitted when a type is unregistered.
void stateRegistered(EditorInstanceId instance_id, EditorTypeId type_id)
Emitted when a state is registered.
void stateUnregistered(EditorInstanceId instance_id)
Emitted when a state is unregistered.
void editorCreated(EditorInstanceId instance_id, EditorTypeId type_id)
Emitted when createEditor() succeeds.
void workspaceChanged()
Emitted when any state changes.
void unsavedChangesChanged(bool has_unsaved)
Emitted when dirty state changes.
void timeChanged(TimePosition position)
Emitted when the visualization time changes.
void activeTimeKeyChanged(TimeKey new_key, TimeKey old_key)
Emitted when the active TimeKey changes.
void applyDataDisplayConfig(std::vector< DataDisplayConfig > const & config)
Emitted after data is loaded from external sources (JSON config, batch processing).

Public Functions

Name
EditorRegistry(QObject * parent =[nullptr])
Construct EditorRegistry.
~EditorRegistry() override
bool registerType(EditorTypeInfo info)
Register an editor type.
bool unregisterType(EditorTypeId const & type_id)
Unregister an editor type.
bool hasType(EditorTypeId const & type_id) const
Check if a type is registered.
EditorTypeInfo typeInfo(EditorTypeId const & type_id) const
Get type info (returns default-constructed if not found).
std::vector< EditorTypeInfo > allTypes() const
Get all registered types.
std::vector< EditorTypeInfo > typesByMenuPath(QString const & path) const
Get types filtered by menu path.
EditorInstance createEditor(EditorTypeId const & type_id)
Create a complete editor instance.
std::shared_ptr< EditorState > createState(EditorTypeId const & type_id)
Create only the state (not auto-registered).
QWidget * createView(std::shared_ptr< EditorState > const & state)
Create view widget for an existing state.
QWidget * createProperties(std::shared_ptr< EditorState > const & state)
Create properties widget for an existing state.
void registerState(std::shared_ptr< EditorState > const & state)
Register an externally-created state.
void unregisterState(EditorInstanceId const & instance_id)
Unregister a state by instance ID.
std::shared_ptr< EditorState > state(EditorInstanceId const & instance_id) const
Get state by instance ID.
std::vector< std::shared_ptr< EditorState > > statesByType(EditorTypeId const & type_id) const
Get all states of a specific type.
std::vector< std::shared_ptr< EditorState > > allStates() const
Get all registered states.
size_t stateCount() const
Get number of registered states.
SelectionContext * selectionContext() const
Get the selection context for inter-widget communication.
EditorLib::OperationContext * operationContext() const
Get the operation context for transient data pipes.
void setOpenEditorCallback(OpenEditorCallback callback)
Set the callback used to open/focus an editor in the UI.
std::shared_ptr< EditorState > openEditor(EditorTypeId const & type_id)
Open or focus an editor and return its state.
void cacheClosedState(EditorTypeId const & type_id, std::string state_json)
Cache a closed editor’s state JSON for later reopen.
std::optional< std::string > getCachedState(EditorTypeId const & type_id) const
Get cached state JSON for a type, if any.
void clearStateCache()
Clear all cached closed states.
std::string toJson() const
Serialize workspace to JSON.
bool fromJson(std::string const & json)
Restore workspace from JSON.
bool hasUnsavedChanges() const
Check if any state has unsaved changes.
void markAllClean()
Mark all states as clean.
void setCurrentTime(TimePosition const & position)
Set the current visualization time with TimePosition.
void setCurrentTime(TimeFrameIndex index, std::shared_ptr< TimeFrame > time_frame)
Set the current visualization time with TimeFrameIndex and TimeFrame.
void setActiveTimeKey(TimeKey key)
Set the active TimeKey.
TimeKey activeTimeKey() const
Get the active TimeKey.
TimePosition currentPosition() const
Get the current time position (includes TimeFrame context).
TimeFrameIndex currentTimeIndex() const
Get the current time index.
std::shared_ptr< TimeFrame > currentTimeFrame() const
Get the current TimeFrame (may be nullptr).
TimeController * timeController() const
Non-owning pointer to the Qt-free time state (for CommandContext, tests, etc.).
void setCurrentTime(int64_t time)
Set the current visualization time (deprecated).

Detailed Description

class EditorRegistry;

Central registry for editor types, instances, and selection.

Single source of truth for:

  • What editor types exist (type_id → metadata + factories)
  • What editor instances are active (instance_id → state)
  • Current selection state (via SelectionContext)

Public Types Documentation

using OpenEditorCallback

using EditorRegistry::OpenEditorCallback =  std::function<std::shared_ptr<EditorState>(EditorTypeId const &)>;

Callback type for opening/focusing an editor and returning its state.

Public Signals Documentation

signal typeRegistered

void typeRegistered(
    EditorTypeId type_id
)

Emitted when a new type is registered.

signal typeUnregistered

void typeUnregistered(
    EditorTypeId type_id
)

Emitted when a type is unregistered.

signal stateRegistered

void stateRegistered(
    EditorInstanceId instance_id,
    EditorTypeId type_id
)

Emitted when a state is registered.

signal stateUnregistered

void stateUnregistered(
    EditorInstanceId instance_id
)

Emitted when a state is unregistered.

signal editorCreated

void editorCreated(
    EditorInstanceId instance_id,
    EditorTypeId type_id
)

Emitted when createEditor() succeeds.

signal workspaceChanged

void workspaceChanged()

Emitted when any state changes.

signal unsavedChangesChanged

void unsavedChangesChanged(
    bool has_unsaved
)

Emitted when dirty state changes.

signal timeChanged

void timeChanged(
    TimePosition position
)

Emitted when the visualization time changes.

Parameters:

Connect to this signal to update views when the user scrubs through time (e.g., via TimeScrollBar).

This is the preferred signal that includes TimePosition (index + TimeFrame pointer). Widgets can use TimePosition::sameClock() to check if they’re on the same clock and TimePosition::convertTo() to convert indices between different TimeFrames.

signal activeTimeKeyChanged

void activeTimeKeyChanged(
    TimeKey new_key,
    TimeKey old_key
)

Emitted when the active TimeKey changes.

Parameters:

This signal is emitted when setActiveTimeKey() is called and the TimeKey actually changes.

signal applyDataDisplayConfig

void applyDataDisplayConfig(
    std::vector< DataDisplayConfig > const & config
)

Emitted after data is loaded from external sources (JSON config, batch processing).

Parameters:

This signal carries UI configuration hints (colors, display styles) that widgets should apply to their visualizations. This is separate from DataManager’s observer notifications which handle data existence changes.

Typical flow:

  1. DataManager::load() adds data → DataManager notifies observers (data exists)
  2. This signal is emitted → widgets apply UI configuration (colors, styles)

Public Functions Documentation

function EditorRegistry

explicit EditorRegistry(
    QObject * parent =nullptr
)

Construct EditorRegistry.

Parameters:

  • parent Parent QObject

function ~EditorRegistry

~EditorRegistry() override

function registerType

bool registerType(
    EditorTypeInfo info
)

Register an editor type.

Parameters:

  • info Complete type definition including factories

Return: true if registered, false if type_id empty or already registered

function unregisterType

bool unregisterType(
    EditorTypeId const & type_id
)

Unregister an editor type.

Parameters:

  • type_id Type to unregister

Return: true if was registered and removed

function hasType

bool hasType(
    EditorTypeId const & type_id
) const

Check if a type is registered.

function typeInfo

EditorTypeInfo typeInfo(
    EditorTypeId const & type_id
) const

Get type info (returns default-constructed if not found).

function allTypes

std::vector< EditorTypeInfo > allTypes() const

Get all registered types.

function typesByMenuPath

std::vector< EditorTypeInfo > typesByMenuPath(
    QString const & path
) const

Get types filtered by menu path.

function createEditor

EditorInstance createEditor(
    EditorTypeId const & type_id
)

Create a complete editor instance.

Parameters:

  • type_id Type of editor to create

Return: EditorInstance with all components, or empty if type not found

Creates state + view + optional properties. The state is automatically registered with the registry.

function createState

std::shared_ptr< EditorState > createState(
    EditorTypeId const & type_id
)

Create only the state (not auto-registered).

Use registerState() after calling this to add to the registry. Useful for deserialization where you need to restore state before registering.

function createView

QWidget * createView(
    std::shared_ptr< EditorState > const & state
)

Create view widget for an existing state.

function createProperties

QWidget * createProperties(
    std::shared_ptr< EditorState > const & state
)

Create properties widget for an existing state.

Return: Properties widget, or nullptr if type has no properties factory

function registerState

void registerState(
    std::shared_ptr< EditorState > const & state
)

Register an externally-created state.

Use for states created via createState() or deserialized.

function unregisterState

void unregisterState(
    EditorInstanceId const & instance_id
)

Unregister a state by instance ID.

function state

std::shared_ptr< EditorState > state(
    EditorInstanceId const & instance_id
) const

Get state by instance ID.

Return: State or nullptr if not found

function statesByType

std::vector< std::shared_ptr< EditorState > > statesByType(
    EditorTypeId const & type_id
) const

Get all states of a specific type.

function allStates

std::vector< std::shared_ptr< EditorState > > allStates() const

Get all registered states.

function stateCount

size_t stateCount() const

Get number of registered states.

function selectionContext

SelectionContext * selectionContext() const

Get the selection context for inter-widget communication.

function operationContext

EditorLib::OperationContext * operationContext() const

Get the operation context for transient data pipes.

OperationContext manages temporary connections where one widget requests output from another (e.g., LinePlot requesting transform configuration from DataTransformWidget).

function setOpenEditorCallback

void setOpenEditorCallback(
    OpenEditorCallback callback
)

Set the callback used to open/focus an editor in the UI.

Parameters:

  • callback Called with editor type_id, returns the state of the opened (or reused) editor instance

MainWindow sets this after construction. ContextActions use it to open editors and get the state back for configuration.

function openEditor

std::shared_ptr< EditorState > openEditor(
    EditorTypeId const & type_id
)

Open or focus an editor and return its state.

Parameters:

  • type_id The editor type to open

Return: The state of the opened editor, or nullptr if unavailable

Delegates to the callback set by setOpenEditorCallback(). For allow_multiple=false types, reuses the existing instance. For allow_multiple=true types, creates a new instance.

function cacheClosedState

void cacheClosedState(
    EditorTypeId const & type_id,
    std::string state_json
)

Cache a closed editor’s state JSON for later reopen.

Parameters:

  • type_id The editor type
  • state_json The serialized state JSON

When an editor is closed (destroyed), its state is serialized and stored here keyed by type_id. When a new editor of the same type is created, the cached state is automatically applied so the new instance starts with the last-closed settings.

The cache is:

  • Per type_id (last-closed wins for multi-instance types)
  • NOT included in workspace save (toJson)
  • Cleared on workspace restore (fromJson)
  • Session-scoped (lost on application exit)

function getCachedState

std::optional< std::string > getCachedState(
    EditorTypeId const & type_id
) const

Get cached state JSON for a type, if any.

Return: The cached JSON string, or std::nullopt if none exists

function clearStateCache

void clearStateCache()

Clear all cached closed states.

Called automatically during workspace restore (fromJson).

function toJson

std::string toJson() const

Serialize workspace to JSON.

Includes all registered states and current selection. Does NOT include the closed-state cache.

function fromJson

bool fromJson(
    std::string const & json
)

Restore workspace from JSON.

Return: true if successful

Clears existing states and recreates from JSON. Also clears the closed-state cache. Types must be registered before calling this.

function hasUnsavedChanges

bool hasUnsavedChanges() const

Check if any state has unsaved changes.

function markAllClean

void markAllClean()

Mark all states as clean.

function setCurrentTime

void setCurrentTime(
    TimePosition const & position
)

Set the current visualization time with TimePosition.

Parameters:

This is the preferred method for setting the current visualization time. It includes the TimeFrame pointer for clock identity, allowing widgets to efficiently check if they’re on the same clock.

This represents which point in time the UI is currently displaying. All time-aware widgets should connect to timeChanged(TimePosition) to update their views.

Note: This is a UI/visualization concept, not data storage. The actual time data lives in DataManager’s TimeFrame objects.

Time updates are handled by an internal [TimeController](/api_generated/Classes/classTimeController.md) (re-entrancy guard and equality checks); this method forwards to it and [timeChanged](/api_generated/Classes/classEditorRegistry.md#signal-timechanged) is emitted from the controller callback.

function setCurrentTime

void setCurrentTime(
    TimeFrameIndex index,
    std::shared_ptr< TimeFrame > time_frame
)

Set the current visualization time with TimeFrameIndex and TimeFrame.

Parameters:

Convenience overload for widgets that already have a TimeFrame pointer.

function setActiveTimeKey

void setActiveTimeKey(
    TimeKey key
)

Set the active TimeKey.

Parameters:

Changes which TimeFrame is considered active. This will emit activeTimeKeyChanged() if the key actually changes.

function activeTimeKey

TimeKey activeTimeKey() const

Get the active TimeKey.

Return: The currently active TimeKey (defaults to “time”)

function currentPosition

TimePosition currentPosition() const

Get the current time position (includes TimeFrame context).

Return: Current TimePosition being displayed

function currentTimeIndex

TimeFrameIndex currentTimeIndex() const

Get the current time index.

Return: Current TimeFrameIndex being displayed

function currentTimeFrame

std::shared_ptr< TimeFrame > currentTimeFrame() const

Get the current TimeFrame (may be nullptr).

Return: The TimeFrame for the current position

function timeController

TimeController * timeController() const

Non-owning pointer to the Qt-free time state (for CommandContext, tests, etc.).

Return: Pointer owned by this registry; never null after construction

function setCurrentTime

void setCurrentTime(
    int64_t time
)

Set the current visualization time (deprecated).

Parameters:

  • time The frame index to display

Deprecated:

Use setCurrentTime(TimeKey, TimeFrameIndex) instead

This method is kept for backward compatibility during migration. It uses the active TimeKey and converts the int64_t to TimeFrameIndex.


Updated on 2026-11-13 at 20:25:40 +0000