iVS3D v2.0.9
Loading...
Searching...
No Matches
MCFG::ModelManager Class Reference

Manages model configurations in a directory and exposes UI-friendly state. More...

#include <ModelManager.h>

Inheritance diagram for MCFG::ModelManager:

Classes

struct  ModelEntry
 Cached record for one discovered model. More...
 

Public Types

enum class  ModelState
 High-level availability state of a model entry.
 

Public Slots

void onModelActivationRequested (const QString &modelName)
 Slot to handle model activation requests from UI thread.
 
void onClassSelectionRequested (const QString &modelName, uint classId, bool selected)
 Slot to handle class selection requests from UI thread.
 
void onModelsRefreshRequested ()
 Slot to handle refresh requests from UI thread.
 
void onApplyMeanStdRequested (const QString &modelName, bool apply)
 Slot to handle apply mean/std setting changes from UI thread.
 
void onNormalizeTo01Requested (const QString &modelName, bool normalize)
 Slot to handle normalize to [0,1] setting changes from UI thread.
 
void onInputAlignmentRequested (const QString &modelName, uint alignment)
 Slot to handle input alignment changes from UI thread.
 

Signals

void modelActivated (const QString &modelName, ModelManager::ModelState state, const QString &error)
 Emitted when a model is activated and initial data is ready.
 
void classListUpdated (const QVector< ModelConfig::ClassInfo > &classes)
 Emitted when class list is updated for the current model.
 
void modelsListUpdated (const QVector< ModelEntry > &models)
 Emitted when models list is refreshed.
 

Public Member Functions

 ModelManager (QString modelDir=defaultModelDirectory())
 Construct a manager for a specific model directory.
 
 ~ModelManager ()
 Destructor.
 
void setNameFilter (const QString &pattern)
 Set a filename filter pattern (wildcard style) Only model configs matching this pattern will be loaded. Uses wildcard matching (e.g., "Detection_*", "*yolo*") By default (empty string), all models are loaded.
 
QString nameFilter () const noexcept
 Get the current name filter pattern.
 
void refresh ()
 Re-scan the model directory and rebuild model list/state.
 
const QVector< ModelEntry > & models () const noexcept
 Get all discovered model entries (ready and invalid).
 
QStringList availableModelNames () const
 Get sorted names of models currently in Ready state.
 
ModelState modelState (const QString &name) const noexcept
 Get state of a model by name.
 
QString modelError (const QString &name) const noexcept
 Get error text of a model by name.
 
std::optional< ModelEntryactivateModel (const QString &name)
 Activate a model and emit activation/class-list signals.
 
std::optional< ModelEntryactiveModel () const noexcept
 Get currently active model entry.
 
const QString & activeModelName () const noexcept
 Get name of active model, or empty if none active.
 
bool setClassSelected (const QString &modelName, ModelConfig::ClassId id, bool selected)
 Update selected state of one class of one model.
 
void markModelIncompatible (const QString &name, const QString &reason)
 Mark a model as incompatible with runtime/model consumer.
 
QString modelToString (const QString &name) const noexcept
 Serialize model selection summary as user-friendly text.
 
QJsonObject modelToJson (const QString &name) const noexcept
 Serialize model class-selection state to JSON.
 
std::optional< ModelEntrymodelFromJson (const QJsonObject &obj) const noexcept
 Restore class-selection state from JSON for a known model.
 

Static Public Member Functions

static QString defaultModelDirectory ()
 Get the platform-specific default model directory.
 

Detailed Description

Manages model configurations in a directory and exposes UI-friendly state.

The manager scans a model directory for JSON/ONNX pairs, validates each model using ModelConfig::loadFromFile(), tracks per-model readiness/error states, and emits Qt signals for GUI synchronization.

The corresponding JSON schema is described in ModelConfig.md.

Author
Dominik Wüst (domin.nosp@m.ik.w.nosp@m.uest@.nosp@m.iosb.nosp@m..frau.nosp@m.nhof.nosp@m.er.de)
Date
March 2026

Constructor & Destructor Documentation

◆ ModelManager()

MCFG::ModelManager::ModelManager ( QString  modelDir = defaultModelDirectory())
explicit

Construct a manager for a specific model directory.

Parameters
modelDirDirectory to scan. Defaults to defaultModelDirectory().

Member Function Documentation

◆ activateModel()

std::optional< ModelManager::ModelEntry > MCFG::ModelManager::activateModel ( const QString &  name)

Activate a model and emit activation/class-list signals.

Parameters
nameModel base name.
Returns
Activated entry on success, std::nullopt otherwise.

◆ activeModel()

std::optional< ModelManager::ModelEntry > MCFG::ModelManager::activeModel ( ) const
noexcept

Get currently active model entry.

Returns
Active entry or std::nullopt if no valid model is active.

◆ availableModelNames()

QStringList MCFG::ModelManager::availableModelNames ( ) const

Get sorted names of models currently in Ready state.

Returns
List of usable model names.

◆ classListUpdated

void MCFG::ModelManager::classListUpdated ( const QVector< ModelConfig::ClassInfo > &  classes)
signal

Emitted when class list is updated for the current model.

Parameters
classIdsVector of class IDs for the current model

◆ defaultModelDirectory()

QString MCFG::ModelManager::defaultModelDirectory ( )
static

Get the platform-specific default model directory.

Returns
Absolute path used by default constructor.

◆ markModelIncompatible()

void MCFG::ModelManager::markModelIncompatible ( const QString &  name,
const QString &  reason 
)

Mark a model as incompatible with runtime/model consumer.

Parameters
nameModel base name.
reasonHuman-readable incompatibility reason.

◆ modelActivated

void MCFG::ModelManager::modelActivated ( const QString &  modelName,
ModelManager::ModelState  state,
const QString &  error 
)
signal

Emitted when a model is activated and initial data is ready.

Parameters
modelNameName of the activated model
stateCurrent state of the model
errorError message if state is not Ready, otherwise empty

◆ modelError()

QString MCFG::ModelManager::modelError ( const QString &  name) const
noexcept

Get error text of a model by name.

Parameters
nameModel base name.
Returns
Error string or a message indicating unknown model.

◆ modelFromJson()

std::optional< ModelManager::ModelEntry > MCFG::ModelManager::modelFromJson ( const QJsonObject &  obj) const
noexcept

Restore class-selection state from JSON for a known model.

Parameters
objJSON object previously produced by modelToJson().
Returns
Updated model entry, or std::nullopt if model name is unknown.

◆ modelsListUpdated

void MCFG::ModelManager::modelsListUpdated ( const QVector< ModelEntry > &  models)
signal

Emitted when models list is refreshed.

Parameters
modelsThe updated list of models

◆ modelState()

ModelManager::ModelState MCFG::ModelManager::modelState ( const QString &  name) const
noexcept

Get state of a model by name.

Parameters
nameModel base name.
Returns
Current model state, or MissingConfig for unknown names.

◆ modelToJson()

QJsonObject MCFG::ModelManager::modelToJson ( const QString &  name) const
noexcept

Serialize model class-selection state to JSON.

Parameters
nameModel base name.
Returns
JSON object containing model name and selected classes.

◆ modelToString()

QString MCFG::ModelManager::modelToString ( const QString &  name) const
noexcept

Serialize model selection summary as user-friendly text.

Parameters
nameModel base name.
Returns
Description string, empty if model is unknown.

◆ nameFilter()

QString MCFG::ModelManager::nameFilter ( ) const
noexcept

Get the current name filter pattern.

Returns
The wildcard pattern, or empty string if no filter is set

◆ onApplyMeanStdRequested

void MCFG::ModelManager::onApplyMeanStdRequested ( const QString &  modelName,
bool  apply 
)
slot

Slot to handle apply mean/std setting changes from UI thread.

Parameters
modelNameName of the model
applyWhether to apply mean/std normalization

◆ onClassSelectionRequested

void MCFG::ModelManager::onClassSelectionRequested ( const QString &  modelName,
uint  classId,
bool  selected 
)
slot

Slot to handle class selection requests from UI thread.

Parameters
modelNameName of the model
classIdID of the class
selectedWhether the class should be selected

◆ onInputAlignmentRequested

void MCFG::ModelManager::onInputAlignmentRequested ( const QString &  modelName,
uint  alignment 
)
slot

Slot to handle input alignment changes from UI thread.

Parameters
modelNameName of the model
alignmentInput alignment value

◆ onModelActivationRequested

void MCFG::ModelManager::onModelActivationRequested ( const QString &  modelName)
slot

Slot to handle model activation requests from UI thread.

Parameters
modelNameName of the model to activate

◆ onNormalizeTo01Requested

void MCFG::ModelManager::onNormalizeTo01Requested ( const QString &  modelName,
bool  normalize 
)
slot

Slot to handle normalize to [0,1] setting changes from UI thread.

Parameters
modelNameName of the model
normalizeWhether to normalize input to [0,1]

◆ setClassSelected()

bool MCFG::ModelManager::setClassSelected ( const QString &  modelName,
ModelConfig::ClassId  id,
bool  selected 
)

Update selected state of one class of one model.

Parameters
modelNameModel base name.
idClass ID.
selectedDesired selected state.
Returns
true if model/class was found and updated.

◆ setNameFilter()

void MCFG::ModelManager::setNameFilter ( const QString &  pattern)

Set a filename filter pattern (wildcard style) Only model configs matching this pattern will be loaded. Uses wildcard matching (e.g., "Detection_*", "*yolo*") By default (empty string), all models are loaded.

Parameters
patternWildcard pattern (e.g., "Detection_*")

The documentation for this class was generated from the following files: