##// END OF EJS Templates
variable time is now set to range graphe displayed when it is displayed...
perrinel -
r314:85f427f84e81
parent child
Show More
@@ -28,6 +28,7 public:
28 28 virtual ~VisualizationGraphWidget();
29 29
30 30 void addVariable(std::shared_ptr<Variable> variable);
31 void addVariableUsingGraph(std::shared_ptr<Variable> variable);
31 32 /// Removes a variable from the graph
32 33 void removeVariable(std::shared_ptr<Variable> variable) noexcept;
33 34
@@ -80,6 +80,38 void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable)
80 80 connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated()));
81 81 }
82 82
83 void VisualizationGraphWidget::addVariableUsingGraph(std::shared_ptr<Variable> variable)
84 {
85
86 // when adding a variable, we need to set its time range to the current graph range
87 auto grapheRange = ui->widget->xAxis->range();
88 auto dateTime = SqpDateTime{grapheRange.lower, grapheRange.upper};
89 variable->setDateTime(dateTime);
90 qCInfo(LOG_VisualizationGraphWidget()) << "ADD Variable with range : " << dateTime;
91
92 auto variableDateTimeWithTolerance = dateTime;
93
94 // add 10% tolerance for each side
95 auto tolerance = 0.1 * (dateTime.m_TEnd - dateTime.m_TStart);
96 variableDateTimeWithTolerance.m_TStart -= tolerance;
97 variableDateTimeWithTolerance.m_TEnd += tolerance;
98
99 qCInfo(LOG_VisualizationGraphWidget()) << "ADD Variable with range TOL: "
100 << variableDateTimeWithTolerance;
101
102 // Uses delegate to create the qcpplot components according to the variable
103 auto createdPlottables = VisualizationGraphHelper::create(variable, *ui->widget);
104
105 for (auto createdPlottable : qAsConst(createdPlottables)) {
106 impl->m_VariableToPlotMultiMap.insert({variable, createdPlottable});
107 }
108
109 connect(variable.get(), SIGNAL(updated()), this, SLOT(onDataCacheVariableUpdated()));
110
111 // CHangement detected, we need to ask controller to request data loading
112 emit requestDataLoading(variable, variableDateTimeWithTolerance);
113 }
114
83 115 void VisualizationGraphWidget::removeVariable(std::shared_ptr<Variable> variable) noexcept
84 116 {
85 117 // Each component associated to the variable :
@@ -137,7 +137,7 void GenerateVariableMenuOperation::visit(VisualizationGraphWidget *graphWidget)
137 137 if (graphWidget) {
138 138 impl->visitLeaf(
139 139 *graphWidget, QObject::tr("Open in %1").arg(graphWidget->name()),
140 [ var = impl->m_Variable, graphWidget ]() { graphWidget->addVariable(var); });
140 [ var = impl->m_Variable, graphWidget ]() { graphWidget->addVariableUsingGraph(var); });
141 141 }
142 142 else {
143 143 qCCritical(LOG_GenerateVariableMenuOperation(),
General Comments 0
You need to be logged in to leave comments. Login now