##// END OF EJS Templates
Quite fixed D&D from tree......
jeandet -
r1378:1667c88c4819
parent child
Show More
@@ -101,7 +101,9 struct AxisSetter<T, typename std::enable_if_t<std::is_base_of<ScalarSeries, T>:
101 auto valuesUnit = dataSeries.valuesUnit();
101 auto valuesUnit = dataSeries.valuesUnit();
102 dataSeries.unlock();
102 dataSeries.unlock();
103
103
104 setAxisProperties(*plot.xAxis, xAxisUnit);
104 // setAxisProperties(*plot.xAxis, xAxisUnit);
105 // This is cheating but it's ok ;)
106 setAxisProperties(*plot.xAxis, Unit{"s", true});
105 setAxisProperties(*plot.yAxis, valuesUnit);
107 setAxisProperties(*plot.yAxis, valuesUnit);
106 }
108 }
107 };
109 };
@@ -138,7 +140,9 struct AxisSetter<T, typename std::enable_if_t<std::is_base_of<SpectrogramSeries
138 auto valuesUnit = dataSeries.valuesUnit();
140 auto valuesUnit = dataSeries.valuesUnit();
139 dataSeries.unlock();
141 dataSeries.unlock();
140
142
141 setAxisProperties(*plot.xAxis, xAxisUnit);
143 //setAxisProperties(*plot.xAxis, xAxisUnit);
144 // This is cheating but it's ok ;)
145 setAxisProperties(*plot.xAxis, Unit{"s", true});
142 setAxisProperties(*plot.yAxis, yAxisUnit, QCPAxis::stLogarithmic);
146 setAxisProperties(*plot.yAxis, yAxisUnit, QCPAxis::stLogarithmic);
143 setAxisProperties(*colorScale.m_Scale->axis(), valuesUnit, QCPAxis::stLogarithmic);
147 setAxisProperties(*colorScale.m_Scale->axis(), valuesUnit, QCPAxis::stLogarithmic);
144 }
148 }
@@ -471,12 +471,23 void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable, D
471
471
472 impl->m_VariableToPlotMultiMap.insert({variable, std::move(createdPlottables)});
472 impl->m_VariableToPlotMultiMap.insert({variable, std::move(createdPlottables)});
473
473
474 setGraphRange(range);
474 // If the variable already has its data loaded, load its units and its range in the graph
475 // If the variable already has its data loaded, load its units and its range in the graph
475 if (variable->dataSeries() != nullptr) {
476 if (variable->dataSeries() != nullptr) {
476 impl->m_RenderingDelegate->setAxesUnits(*variable);
477 impl->m_RenderingDelegate->setAxesUnits(*variable);
477 this->setFlags(GraphFlag::DisableAll);
478 }
478 setGraphRange(range);
479 else
479 this->setFlags(GraphFlag::EnableAll);
480 {
481 auto context = new QObject{this};
482 connect(variable.get(), &Variable::updated, context,
483 [this, variable, context, range](QUuid)
484 {
485 this->impl->m_RenderingDelegate->setAxesUnits(*variable);
486 this->impl->rescaleY();
487 this->impl->m_plot->replot(QCustomPlot::rpQueuedReplot);
488 delete context;
489 }
490 );
480 }
491 }
481 //@TODO this is bad! when variable is moved to another graph it still fires
492 //@TODO this is bad! when variable is moved to another graph it still fires
482 // even if this has been deleted
493 // even if this has been deleted
@@ -528,10 +528,26 void VisualizationZoneWidget::dropMimeDataOnGraph(VisualizationDragWidget *dragW
528 mimeData->data(MIME_TYPE_PRODUCT_LIST));
528 mimeData->data(MIME_TYPE_PRODUCT_LIST));
529
529
530 auto context = new QObject{this};
530 auto context = new QObject{this};
531 auto range = TimeController::timeRangeForMimeData(mimeData->data(MIME_TYPE_TIME_RANGE));
532 // BTW this is really dangerous, this assumes the next created variable will be this one...
531 connect(&sqpApp->variableController(), &VariableController2::variableAdded, context,
533 connect(&sqpApp->variableController(), &VariableController2::variableAdded, context,
532 [this, graphWidget, context](auto variable) {
534 [this, graphWidget, context, range](auto variable) {
533 graphWidget->addVariable(variable, graphWidget->graphRange());
535 if(sqpApp->variableController().isReady(variable))
534 delete context; // removes the connection
536 {
537 graphWidget->addVariable(variable, range);
538 delete context;
539 }
540 else
541 {
542 // -> this is pure insanity! this is a workaround to make a bad design work
543 QObject::connect(variable.get(), &Variable::updated,context,
544 [graphWidget, context, range, variable]()
545 {
546 graphWidget->addVariable(variable, range);
547 delete context;
548 });
549 }
550
535 },
551 },
536 Qt::QueuedConnection);
552 Qt::QueuedConnection);
537
553
General Comments 0
You need to be logged in to leave comments. Login now