##// END OF EJS Templates
Temporal parameters of the selected variables can be updated using the...
Temporal parameters of the selected variables can be updated using the time widget.

File last commit:

r281:08349e12a7ef
r281:08349e12a7ef
Show More
VariableController.cpp
176 lines | 5.7 KiB | text/x-c | CppLexer
/ core / src / Variable / VariableController.cpp
The mock plugin can now create data with view operation
r219 #include <Variable/Variable.h>
Create a variable notify the variable cache parameter
r209 #include <Variable/VariableCacheController.h>
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r106 #include <Variable/VariableController.h>
Alexandre Leroux
Adds Variable model in the Variable controller
r108 #include <Variable/VariableModel.h>
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r106
Alexandre Leroux
Updates VariableController::createVariable() method...
r154 #include <Data/DataProviderParameters.h>
#include <Data/IDataProvider.h>
#include <Data/IDataSeries.h>
Time widget is now used with the variable createion request
r179 #include <Time/TimeController.h>
Alexandre Leroux
Updates VariableController::createVariable() method...
r154
#include <QDateTime>
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r106 #include <QMutex>
#include <QThread>
Temporal parameters of the selected variables can be updated using the...
r281 #include <QtCore/QItemSelectionModel>
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r106
Create a variable notify the variable cache parameter
r209 #include <unordered_map>
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r106 Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
Alexandre Leroux
Updates VariableController::createVariable() method...
r154 namespace {
/// @todo Generates default dataseries, according to the provider passed in parameter. This method
/// will be deleted when the timerange is recovered from SciQlop
Time widget is now used with the variable createion request
r179 std::unique_ptr<IDataSeries> generateDefaultDataSeries(const IDataProvider &provider,
const SqpDateTime &dateTime) noexcept
Alexandre Leroux
Updates VariableController::createVariable() method...
r154 {
Time widget is now used with the variable createion request
r179 auto parameters = DataProviderParameters{dateTime};
Alexandre Leroux
Updates VariableController::createVariable() method...
r154
return provider.retrieveData(parameters);
}
} // namespace
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r106 struct VariableController::VariableControllerPrivate {
Alexandre Leroux
Use raw pointer for VariableModel (QObject class)
r148 explicit VariableControllerPrivate(VariableController *parent)
Create a variable notify the variable cache parameter
r209 : m_WorkingMutex{},
m_VariableModel{new VariableModel{parent}},
Temporal parameters of the selected variables can be updated using the...
r281 m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}},
Create a variable notify the variable cache parameter
r209 m_VariableCacheController{std::make_unique<VariableCacheController>()}
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r106 {
}
QMutex m_WorkingMutex;
Alexandre Leroux
Use raw pointer for VariableModel (QObject class)
r148 /// Variable model. The VariableController has the ownership
VariableModel *m_VariableModel;
Temporal parameters of the selected variables can be updated using the...
r281 QItemSelectionModel *m_VariableSelectionModel;
Time widget is now used with the variable createion request
r179
Create a variable notify the variable cache parameter
r209
Correction MR
r181 TimeController *m_TimeController{nullptr};
Create a variable notify the variable cache parameter
r209 std::unique_ptr<VariableCacheController> m_VariableCacheController;
The mock plugin can now create data with view operation
r219
std::unordered_map<std::shared_ptr<Variable>, std::shared_ptr<IDataProvider> >
m_VariableToProviderMap;
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r106 };
VariableController::VariableController(QObject *parent)
Alexandre Leroux
Use raw pointer for VariableModel (QObject class)
r148 : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)}
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r106 {
Add the TimeWidget
r126 qCDebug(LOG_VariableController()) << tr("VariableController construction")
<< QThread::currentThread();
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r106 }
VariableController::~VariableController()
{
Add the TimeWidget
r126 qCDebug(LOG_VariableController()) << tr("VariableController destruction")
<< QThread::currentThread();
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r106 this->waitForFinish();
}
Alexandre Leroux
Updates VariableController::createVariable() method...
r154 VariableModel *VariableController::variableModel() noexcept
Alexandre Leroux
Adds Variable model in the Variable controller
r108 {
Alexandre Leroux
Updates VariableController::createVariable() method...
r154 return impl->m_VariableModel;
Alexandre Leroux
Adds Variable model in the Variable controller
r108 }
Temporal parameters of the selected variables can be updated using the...
r281 QItemSelectionModel *VariableController::variableSelectionModel() noexcept
{
return impl->m_VariableSelectionModel;
}
Time widget is now used with the variable createion request
r179 void VariableController::setTimeController(TimeController *timeController) noexcept
{
impl->m_TimeController = timeController;
}
Alexandre Leroux
Updates VariableController::createVariable() method...
r154 void VariableController::createVariable(const QString &name,
std::shared_ptr<IDataProvider> provider) noexcept
Alexandre Leroux
Affects model to the Variable Widget
r143 {
Time widget is now used with the variable createion request
r179
if (!impl->m_TimeController) {
qCCritical(LOG_VariableController())
<< tr("Impossible to create variable: The time controller is null");
return;
}
Alexandre Leroux
Updates VariableController::createVariable() method...
r154 /// @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
Create a variable notify the variable cache parameter
r209 auto dateTime = impl->m_TimeController->dateTime();
Time widget is now used with the variable createion request
r179 if (auto newVariable = impl->m_VariableModel->createVariable(
A variable is now created with its dateTime too....
r212 name, dateTime, generateDefaultDataSeries(*provider, dateTime))) {
Create a variable notify the variable cache parameter
r209
The mock plugin can now create data with view operation
r219 // store the provider
impl->m_VariableToProviderMap[newVariable] = provider;
qRegisterMetaType<std::shared_ptr<IDataSeries> >();
qRegisterMetaType<SqpDateTime>();
connect(provider.get(), &IDataProvider::dataProvided, newVariable.get(),
&Variable::onAddDataSeries);
Create a variable notify the variable cache parameter
r209 // store in cache
impl->m_VariableCacheController->addDateTime(newVariable, dateTime);
// notify the creation
Alexandre Leroux
Updates VariableController::createVariable() method...
r154 emit variableCreated(newVariable);
}
Alexandre Leroux
Affects model to the Variable Widget
r143 }
Temporal parameters of the selected variables can be updated using the...
r281 void VariableController::onDateTimeOnSelection(const SqpDateTime &dateTime)
{
auto selectedRows = impl->m_VariableSelectionModel->selectedRows();
for (const auto &selectedRow : qAsConst(selectedRows)) {
if (auto selectedVariable = impl->m_VariableModel->variable(selectedRow.row())) {
selectedVariable->setDateTime(dateTime);
}
}
}
The mock plugin can now create data with view operation
r219
Fix the cosinus bug....
r276 void VariableController::onRequestDataLoading(std::shared_ptr<Variable> variable,
const SqpDateTime &dateTime)
The mock plugin can now create data with view operation
r219 {
// we want to load data of the variable for the dateTime.
// First we check if the cache contains some of them.
// For the other, we ask the provider to give them.
if (variable) {
auto dateTimeListNotInCache
= impl->m_VariableCacheController->provideNotInCacheDateTimeList(variable, dateTime);
Fix the cosinus bug....
r276 if (!dateTimeListNotInCache.empty()) {
// Ask the provider for each data on the dateTimeListNotInCache
impl->m_VariableToProviderMap.at(variable)->requestDataLoading(
std::move(dateTimeListNotInCache));
// store in cache
impl->m_VariableCacheController->addDateTime(variable, dateTime);
}
else {
emit variable->updated();
}
The mock plugin can now create data with view operation
r219 }
else {
qCCritical(LOG_VariableController()) << tr("Impossible to load data of a variable null");
}
}
Alexandre Leroux
Inits variable controller and adds it to the SciQlop app
r106 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};
}