iVS3D v2.0.9
Loading...
Searching...
No Matches
ibase.h
1#pragma once
2
3#include <QObject>
4#include <QWidget>
5#include <QMap>
6#include <QVariant>
7#include <QStringList>
8#include <memory>
9#include <optional>
10#include <vector>
11#include <tl/expected.hpp>
12
13#include "ierror.h"
14
15class Reader;
16class MetaData;
17
37namespace PLUG {
38
44using SettingsWidgetResult = tl::expected<std::unique_ptr<QWidget>, Error>;
45
51using ApplySettingsResult = tl::expected<void, Error>;
52
58using InputLoadedResult = tl::expected<void, Error>;
59
65using MetaDataLoadedResult = tl::expected<void, Error>;
66
71struct InputData {
72 ::Reader* reader = nullptr;
73};
74
81 ::MetaData* metaData = nullptr;
82};
83
84
102class IBase : public QObject {
103 Q_OBJECT
104
105 public:
106 using QObject::QObject;
107 virtual ~IBase() {};
108
114 virtual QString getName() const = 0;
115
136
146 virtual QMap<QString, QVariant> getSettings() const = 0;
147
156 virtual QString getSettingsString() const {
157 QMap<QString, QVariant> settings = getSettings();
158 QStringList settingsList;
159 for (auto it = settings.constBegin(); it != settings.constEnd(); ++it) {
160 settingsList.append(it.key() + "=" + it.value().toString());
161 }
162 return settingsList.join(";");
163 }
164
173 virtual ApplySettingsResult applySettings(const QMap<QString, QVariant>& settings) = 0;
174
180 virtual void activate() {}
181
187 virtual void deactivate() {}
188
198 virtual void onCudaChanged(bool enabled) {}
199
207 (void)input;
208 return {};
209 }
210
232 const InputMetaData& inputMetaData) {
233 (void)inputMetaData;
234 return {};
235 }
236
250 virtual void onIndexChanged(uint index) { (void)index; }
251
265 const std::vector<uint>& selectedImages) {
266 (void)selectedImages;
267 }
268
269 signals:
284 void updatePreview(bool clearOldPreview = true);
285
300 void updateSelectedImages(std::vector<uint> selectedImages);
301
321 void updateProgress(int progress, QString message = QString());
322
323 void encounteredError(Error error);
324};
325
326} // namespace PLUG
327
328Q_DECLARE_INTERFACE(PLUG::IBase, "iVS3D.IBase")
329Q_DECLARE_METATYPE(PLUG::InputMetaData)
Interface to give plugins access to all parsed and loaded meta data.
Definition metadata.h:20
Represents an error with a code and a message. The message is intended for display to the user.
Definition ierror.h:28
The IBase interface provides a base class for all plugin interfaces in iVS3D. It inherits from QObjec...
Definition ibase.h:102
virtual void activate()
activate is called when the plugin is activated in iVS3D. Plugins can override this method to perform...
Definition ibase.h:180
virtual SettingsWidgetResult getSettingsWidget()=0
getSettingsWidget creates and returns a settings QWidget for this plugin.
virtual QString getName() const =0
getName returns the name of the plugin which will be displayed in the iVS3D interface.
virtual void onIndexChanged(uint index)
onIndexChanged is called when the currently displayed frame index changes in the viewer.
Definition ibase.h:250
virtual ApplySettingsResult applySettings(const QMap< QString, QVariant > &settings)=0
applySettings applies the provided settings to the plugin. This method is used to restore plugin conf...
virtual QString getSettingsString() const
getSettingsString is a helper method that converts the plugin settings into a human-readable string f...
Definition ibase.h:156
void updateSelectedImages(std::vector< uint > selectedImages)
[signal] updateSelectedImages(std::vector<uint> selectedImages) can be emitted when the plugin wants ...
virtual InputLoadedResult onInputLoaded(const InputData &input)
onInputLoaded is called when a new input video or image set is loaded.
Definition ibase.h:206
virtual MetaDataLoadedResult onMetaDataLoaded(const InputMetaData &inputMetaData)
onMetaDataLoaded is called whenever metadata was loaded or refreshed for the currently active input.
Definition ibase.h:231
virtual void deactivate()
deactivate is called when the plugin is deactivated in iVS3D. Plugins can override this method to per...
Definition ibase.h:187
virtual void onCudaChanged(bool enabled)
onCudaChanged is called when the CUDA usage setting is changed in iVS3D.
Definition ibase.h:198
void updatePreview(bool clearOldPreview=true)
[signal] updatePreview(bool clearOldPreview) can be emitted when the plugin requests an update of the...
virtual void onSelectedImagesChanged(const std::vector< uint > &selectedImages)
onSelectedImagesChanged is called when the current keyframe / selected-image list changed.
Definition ibase.h:264
void updateProgress(int progress, QString message=QString())
[signal] updateProgress(int progress, QString message) can be emitted to inform iVS3D about the progr...
virtual QMap< QString, QVariant > getSettings() const =0
getSettings retrieves the current settings of the plugin as a map of key-value pairs....
The Reader interface defines functions which are used for reading and parsing the import.
Definition reader.h:23
Plugin interface namespace containing common plugin contracts and helper types.
tl::expected< void, Error > InputLoadedResult
Type alias for the result of handling an input loaded event, which can be either a successful void re...
Definition ibase.h:58
tl::expected< void, Error > ApplySettingsResult
Type alias for the result of applying settings to a plugin, which can be either a successful void res...
Definition ibase.h:51
tl::expected< std::unique_ptr< QWidget >, Error > SettingsWidgetResult
Type alias for the result of a settings widget creation operation, which can be either a successful u...
Definition ibase.h:44
tl::expected< void, Error > MetaDataLoadedResult
Type alias for the result of handling a metadata-loaded event, either success (void) or an Error.
Definition ibase.h:65
Struct to encapsulate data related to the input loaded event in iVS3D.
Definition ibase.h:71
Struct containing metadata context that has been loaded for the currently opened input.
Definition ibase.h:80