VariableController.h
142 lines
| 5.3 KiB
| text/x-c
|
CLexer
Alexandre Leroux
|
r111 | #ifndef SCIQLOP_VARIABLECONTROLLER_H | ||
#define SCIQLOP_VARIABLECONTROLLER_H | ||||
Alexandre Leroux
|
r461 | #include "CoreGlobal.h" | ||
r539 | #include <Data/AcquisitionDataPacket.h> | |||
r512 | #include <Data/SqpRange.h> | |||
r235 | ||||
Alexandre Leroux
|
r111 | #include <QLoggingCategory> | ||
#include <QObject> | ||||
r620 | #include <QUuid> | |||
Alexandre Leroux
|
r111 | |||
#include <Common/spimpl.h> | ||||
Alexandre Leroux
|
r166 | class IDataProvider; | ||
r304 | class QItemSelectionModel; | |||
r193 | class TimeController; | |||
Alexandre Leroux
|
r113 | class Variable; | ||
Alexandre Leroux
|
r152 | class VariableModel; | ||
Alexandre Leroux
|
r111 | Q_DECLARE_LOGGING_CATEGORY(LOG_VariableController) | ||
r539 | ||||
/** | ||||
* Possible types of zoom operation | ||||
*/ | ||||
enum class AcquisitionZoomType { ZoomOut, ZoomIn, PanRight, PanLeft, Unknown }; | ||||
Alexandre Leroux
|
r111 | /** | ||
* @brief The VariableController class aims to handle the variables in SciQlop. | ||||
*/ | ||||
Alexandre Leroux
|
r461 | class SCIQLOP_CORE_EXPORT VariableController : public QObject { | ||
Alexandre Leroux
|
r111 | Q_OBJECT | ||
public: | ||||
explicit VariableController(QObject *parent = 0); | ||||
virtual ~VariableController(); | ||||
Alexandre Leroux
|
r166 | VariableModel *variableModel() noexcept; | ||
r304 | QItemSelectionModel *variableSelectionModel() noexcept; | |||
Alexandre Leroux
|
r166 | |||
r193 | void setTimeController(TimeController *timeController) noexcept; | |||
Alexandre Leroux
|
r706 | /** | ||
* Clones the variable passed in parameter and adds the duplicate to the controller | ||||
* @param variable the variable to duplicate | ||||
* @return the duplicate created, nullptr if the variable couldn't be created | ||||
*/ | ||||
std::shared_ptr<Variable> cloneVariable(std::shared_ptr<Variable> variable) noexcept; | ||||
Alexandre Leroux
|
r329 | /** | ||
* Deletes from the controller the variable passed in parameter. | ||||
* | ||||
Alexandre Leroux
|
r330 | * Delete a variable includes: | ||
Alexandre Leroux
|
r336 | * - the deletion of the various references to the variable in SciQlop | ||
Alexandre Leroux
|
r332 | * - the deletion of the model variable | ||
Alexandre Leroux
|
r330 | * - the deletion of the provider associated with the variable | ||
Alexandre Leroux
|
r331 | * - removing the cache associated with the variable | ||
Alexandre Leroux
|
r329 | * | ||
* @param variable the variable to delete from the controller. | ||||
*/ | ||||
void deleteVariable(std::shared_ptr<Variable> variable) noexcept; | ||||
/** | ||||
* Deletes from the controller the variables passed in parameter. | ||||
* @param variables the variables to delete from the controller. | ||||
* @sa deleteVariable() | ||||
*/ | ||||
void deleteVariables(const QVector<std::shared_ptr<Variable> > &variables) noexcept; | ||||
r235 | ||||
r878 | /// Returns the MIME data associated to a list of variables | |||
r849 | QByteArray mimeDataForVariables(const QList<std::shared_ptr<Variable> > &variables) const; | |||
r878 | ||||
/// Returns the list of variables contained in a MIME data | ||||
r849 | QList<std::shared_ptr<Variable> > variablesForMimeData(const QByteArray &mimeData) const; | |||
r422 | ||||
r539 | static AcquisitionZoomType getZoomType(const SqpRange &range, const SqpRange &oldRange); | |||
Alexandre Leroux
|
r166 | signals: | ||
Alexandre Leroux
|
r336 | /// Signal emitted when a variable is about to be deleted from the controller | ||
void variableAboutToBeDeleted(std::shared_ptr<Variable> variable); | ||||
Alexandre Leroux
|
r166 | |||
r437 | /// Signal emitted when a data acquisition is requested on a range for a variable | |||
r512 | void rangeChanged(std::shared_ptr<Variable> variable, const SqpRange &range); | |||
r437 | ||||
r571 | /// Signal emitted when a sub range of the cacheRange of the variable can be displayed | |||
void updateVarDisplaying(std::shared_ptr<Variable> variable, const SqpRange &range); | ||||
Alexandre Leroux
|
r1214 | /// Signal emitted when all acquisitions related to the variables have been completed (whether | ||
/// validated, canceled, or failed) | ||||
void acquisitionFinished(); | ||||
Alexandre Leroux
|
r166 | public slots: | ||
r539 | /// Request the data loading of the variable whithin range | |||
void onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables, const SqpRange &range, | ||||
r811 | bool synchronise); | |||
Alexandre Leroux
|
r113 | /** | ||
Alexandre Leroux
|
r166 | * Creates a new variable and adds it to the model | ||
Alexandre Leroux
|
r113 | * @param name the name of the new variable | ||
Alexandre Leroux
|
r410 | * @param metadata the metadata of the new variable | ||
Alexandre Leroux
|
r166 | * @param provider the data provider for the new variable | ||
r590 | * @return the pointer to the new variable or nullptr if the creation failed | |||
Alexandre Leroux
|
r113 | */ | ||
r590 | std::shared_ptr<Variable> createVariable(const QString &name, const QVariantHash &metadata, | |||
std::shared_ptr<IDataProvider> provider) noexcept; | ||||
Alexandre Leroux
|
r113 | |||
r304 | /// Update the temporal parameters of every selected variable to dateTime | |||
r512 | void onDateTimeOnSelection(const SqpRange &dateTime); | |||
r304 | ||||
r933 | /// Update the temporal parameters of the specified variable | |||
void onUpdateDateTime(std::shared_ptr<Variable> variable, const SqpRange &dateTime); | ||||
r401 | ||||
r539 | void onDataProvided(QUuid vIdentifier, const SqpRange &rangeRequested, | |||
const SqpRange &cacheRangeRequested, | ||||
QVector<AcquisitionDataPacket> dataAcquired); | ||||
r401 | void onVariableRetrieveDataInProgress(QUuid identifier, double progress); | |||
r539 | /// Cancel the current request for the variable | |||
r422 | void onAbortProgressRequested(std::shared_ptr<Variable> variable); | |||
r761 | void onAbortAcquisitionRequested(QUuid vIdentifier); | |||
r422 | ||||
Alexandre Leroux
|
r737 | // synchronization group methods | ||
r539 | void onAddSynchronizationGroupId(QUuid synchronizationGroupId); | |||
void onRemoveSynchronizationGroupId(QUuid synchronizationGroupId); | ||||
r540 | void onAddSynchronized(std::shared_ptr<Variable> variable, QUuid synchronizationGroupId); | |||
r539 | ||||
Alexandre Leroux
|
r737 | /// Desynchronizes the variable of the group whose identifier is passed in parameter | ||
/// @remarks the method does nothing if the variable is not part of the group | ||||
void desynchronize(std::shared_ptr<Variable> variable, QUuid synchronizationGroupId); | ||||
Alexandre Leroux
|
r111 | void initialize(); | ||
void finalize(); | ||||
private: | ||||
void waitForFinish(); | ||||
class VariableControllerPrivate; | ||||
spimpl::unique_impl_ptr<VariableControllerPrivate> impl; | ||||
}; | ||||
#endif // SCIQLOP_VARIABLECONTROLLER_H | ||||