VariableController.h
122 lines
| 4.2 KiB
| text/x-c
|
CLexer
Alexandre Leroux
|
r106 | #ifndef SCIQLOP_VARIABLECONTROLLER_H | ||
#define SCIQLOP_VARIABLECONTROLLER_H | ||||
Alexandre Leroux
|
r425 | #include "CoreGlobal.h" | ||
r510 | #include <Data/AcquisitionDataPacket.h> | |||
r471 | #include <Data/SqpRange.h> | |||
r219 | ||||
Alexandre Leroux
|
r106 | #include <QLoggingCategory> | ||
#include <QObject> | ||||
r579 | #include <QUuid> | |||
Alexandre Leroux
|
r106 | |||
#include <Common/spimpl.h> | ||||
Alexandre Leroux
|
r154 | class IDataProvider; | ||
r281 | class QItemSelectionModel; | |||
r179 | class TimeController; | |||
Alexandre Leroux
|
r108 | class Variable; | ||
Alexandre Leroux
|
r143 | class VariableModel; | ||
Alexandre Leroux
|
r106 | Q_DECLARE_LOGGING_CATEGORY(LOG_VariableController) | ||
r510 | ||||
/** | ||||
* Possible types of zoom operation | ||||
*/ | ||||
enum class AcquisitionZoomType { ZoomOut, ZoomIn, PanRight, PanLeft, Unknown }; | ||||
Alexandre Leroux
|
r106 | /** | ||
* @brief The VariableController class aims to handle the variables in SciQlop. | ||||
*/ | ||||
Alexandre Leroux
|
r425 | class SCIQLOP_CORE_EXPORT VariableController : public QObject { | ||
Alexandre Leroux
|
r106 | Q_OBJECT | ||
public: | ||||
explicit VariableController(QObject *parent = 0); | ||||
virtual ~VariableController(); | ||||
Alexandre Leroux
|
r154 | VariableModel *variableModel() noexcept; | ||
r281 | QItemSelectionModel *variableSelectionModel() noexcept; | |||
Alexandre Leroux
|
r154 | |||
r179 | void setTimeController(TimeController *timeController) noexcept; | |||
Alexandre Leroux
|
r303 | /** | ||
* Deletes from the controller the variable passed in parameter. | ||||
* | ||||
Alexandre Leroux
|
r304 | * Delete a variable includes: | ||
Alexandre Leroux
|
r310 | * - the deletion of the various references to the variable in SciQlop | ||
Alexandre Leroux
|
r306 | * - the deletion of the model variable | ||
Alexandre Leroux
|
r304 | * - the deletion of the provider associated with the variable | ||
Alexandre Leroux
|
r305 | * - removing the cache associated with the variable | ||
Alexandre Leroux
|
r303 | * | ||
* @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; | ||||
r219 | ||||
r388 | /** | |||
* @brief abort the variable retrieve data progression | ||||
*/ | ||||
void abortProgress(std::shared_ptr<Variable> variable); | ||||
r510 | static AcquisitionZoomType getZoomType(const SqpRange &range, const SqpRange &oldRange); | |||
Alexandre Leroux
|
r154 | signals: | ||
Alexandre Leroux
|
r310 | /// Signal emitted when a variable is about to be deleted from the controller | ||
void variableAboutToBeDeleted(std::shared_ptr<Variable> variable); | ||||
Alexandre Leroux
|
r154 | |||
r403 | /// Signal emitted when a data acquisition is requested on a range for a variable | |||
r471 | void rangeChanged(std::shared_ptr<Variable> variable, const SqpRange &range); | |||
r403 | ||||
r538 | /// 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
|
r154 | public slots: | ||
r510 | /// Request the data loading of the variable whithin range | |||
void onRequestDataLoading(QVector<std::shared_ptr<Variable> > variables, const SqpRange &range, | ||||
const SqpRange &oldRange, bool synchronise); | ||||
Alexandre Leroux
|
r108 | /** | ||
Alexandre Leroux
|
r154 | * Creates a new variable and adds it to the model | ||
Alexandre Leroux
|
r108 | * @param name the name of the new variable | ||
Alexandre Leroux
|
r377 | * @param metadata the metadata of the new variable | ||
Alexandre Leroux
|
r154 | * @param provider the data provider for the new variable | ||
r553 | * @return the pointer to the new variable or nullptr if the creation failed | |||
Alexandre Leroux
|
r108 | */ | ||
r553 | std::shared_ptr<Variable> createVariable(const QString &name, const QVariantHash &metadata, | |||
std::shared_ptr<IDataProvider> provider) noexcept; | ||||
Alexandre Leroux
|
r108 | |||
r281 | /// Update the temporal parameters of every selected variable to dateTime | |||
r471 | void onDateTimeOnSelection(const SqpRange &dateTime); | |||
r281 | ||||
r369 | ||||
r510 | void onDataProvided(QUuid vIdentifier, const SqpRange &rangeRequested, | |||
const SqpRange &cacheRangeRequested, | ||||
QVector<AcquisitionDataPacket> dataAcquired); | ||||
r369 | void onVariableRetrieveDataInProgress(QUuid identifier, double progress); | |||
r510 | /// Cancel the current request for the variable | |||
r388 | void onAbortProgressRequested(std::shared_ptr<Variable> variable); | |||
r510 | /// synchronization group methods | |||
void onAddSynchronizationGroupId(QUuid synchronizationGroupId); | ||||
void onRemoveSynchronizationGroupId(QUuid synchronizationGroupId); | ||||
r511 | void onAddSynchronized(std::shared_ptr<Variable> variable, QUuid synchronizationGroupId); | |||
r510 | ||||
Alexandre Leroux
|
r106 | void initialize(); | ||
void finalize(); | ||||
private: | ||||
void waitForFinish(); | ||||
class VariableControllerPrivate; | ||||
spimpl::unique_impl_ptr<VariableControllerPrivate> impl; | ||||
}; | ||||
#endif // SCIQLOP_VARIABLECONTROLLER_H | ||||