##// END OF EJS Templates
Makes the connection between Variable controller and Visualization controller...
Makes the connection between Variable controller and Visualization controller - Adds a slot in the visualization controller to be warned that a variable has been created - Connects the slot to the signal of the variable controller when that is emitted after variable creation

File last commit:

r166:ab6272d8de5a
r170:a3d07f8af710
Show More
VariableController.cpp
88 lines | 2.8 KiB | text/x-c | CppLexer
/ core / src / Variable / VariableController.cpp
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 #include <Variable/VariableController.h>
Alexandre Leroux
Adds Variable model in the Variable controller
r113 #include <Variable/VariableModel.h>
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111
Alexandre Leroux
Updates VariableController::createVariable() method...
r166 #include <Data/DataProviderParameters.h>
#include <Data/IDataProvider.h>
#include <Data/IDataSeries.h>
#include <QDateTime>
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 #include <QMutex>
#include <QThread>
Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
Alexandre Leroux
Updates VariableController::createVariable() method...
r166 namespace {
/// @todo Generates default dataseries, according to the provider passed in parameter. This method
/// will be deleted when the timerange is recovered from SciQlop
std::unique_ptr<IDataSeries> generateDefaultDataSeries(const IDataProvider &provider) noexcept
{
auto parameters = DataProviderParameters{
static_cast<double>(QDateTime{QDate{2017, 01, 01}}.toSecsSinceEpoch()),
static_cast<double>(QDateTime{QDate{2017, 01, 03}}.toSecsSinceEpoch())};
return provider.retrieveData(parameters);
}
} // namespace
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 struct VariableController::VariableControllerPrivate {
Alexandre Leroux
Use raw pointer for VariableModel (QObject class)
r159 explicit VariableControllerPrivate(VariableController *parent)
: m_WorkingMutex{}, m_VariableModel{new VariableModel{parent}}
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 {
}
QMutex m_WorkingMutex;
Alexandre Leroux
Use raw pointer for VariableModel (QObject class)
r159 /// Variable model. The VariableController has the ownership
VariableModel *m_VariableModel;
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 };
VariableController::VariableController(QObject *parent)
Alexandre Leroux
Use raw pointer for VariableModel (QObject class)
r159 : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)}
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 {
Add the TimeWidget
r134 qCDebug(LOG_VariableController()) << tr("VariableController construction")
<< QThread::currentThread();
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 }
VariableController::~VariableController()
{
Add the TimeWidget
r134 qCDebug(LOG_VariableController()) << tr("VariableController destruction")
<< QThread::currentThread();
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 this->waitForFinish();
}
Alexandre Leroux
Updates VariableController::createVariable() method...
r166 VariableModel *VariableController::variableModel() noexcept
Alexandre Leroux
Adds Variable model in the Variable controller
r113 {
Alexandre Leroux
Updates VariableController::createVariable() method...
r166 return impl->m_VariableModel;
Alexandre Leroux
Adds Variable model in the Variable controller
r113 }
Alexandre Leroux
Updates VariableController::createVariable() method...
r166 void VariableController::createVariable(const QString &name,
std::shared_ptr<IDataProvider> provider) noexcept
Alexandre Leroux
Affects model to the Variable Widget
r152 {
Alexandre Leroux
Updates VariableController::createVariable() method...
r166 /// @todo : for the moment :
/// - the provider is only used to retrieve data from the variable for its initialization, but
/// it will be retained later
/// - default data are generated for the variable, without taking into account the timerange set
/// in sciqlop
if (auto newVariable
= impl->m_VariableModel->createVariable(name, generateDefaultDataSeries(*provider))) {
emit variableCreated(newVariable);
}
Alexandre Leroux
Affects model to the Variable Widget
r152 }
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r111 void VariableController::initialize()
{
qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread();
impl->m_WorkingMutex.lock();
qCDebug(LOG_VariableController()) << tr("VariableController init END");
}
void VariableController::finalize()
{
impl->m_WorkingMutex.unlock();
}
void VariableController::waitForFinish()
{
QMutexLocker locker{&impl->m_WorkingMutex};
}