##// END OF EJS Templates
New data sources system switch complete...
New data sources system switch complete Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r1495:9c439b3d7daf
r1495:9c439b3d7daf
Show More
VisualizationZoneWidget.cpp
695 lines | 25.5 KiB | text/x-c | CppLexer
/ gui / src / Visualization / VisualizationZoneWidget.cpp
mv visualization -> Visualization...
r95 #include "Visualization/VisualizationZoneWidget.h"
Add synchronization that keep delta
r444
Alexandre Leroux
Updates visitor interface...
r207 #include "Visualization/IVisualizationWidgetVisitor.h"
Alexandre Leroux
Sets sames margin sides for graphs in a same zone
r730 #include "Visualization/QCustomPlotSynchronizer.h"
Add synchronization that keep delta
r444 #include "Visualization/VisualizationGraphWidget.h"
drop of variables in the visualization
r850 #include "Visualization/VisualizationWidget.h"
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 #include "ui_VisualizationZoneWidget.h"
New data sources system switch complete...
r1495 #include "MimeTypes/MimeTypes.h"
Move the GRAPH_MINIMUM_HEIGHT constant in a place accessible everywhere and use it in the drag&drop
r851 #include "Common/VisualizationDef.h"
Made core module a git submodule, ready to start switching to new...
r1347 #include <Data/DateTimeRange.h>
All the codebase is modified to build with new Variable Controller...
r1348 #include <Data/DateTimeRangeHelper.h>
New data sources system switch complete...
r1495 #include <DataSource/datasources.h>
Drop of variable, graph and zones on the time widget
r878 #include <Time/TimeController.h>
Switched to new TS impl but quite broken!...
r1420 #include <Variable/Variable2.h>
All the codebase is modified to build with new Variable Controller...
r1348 #include <Variable/VariableController2.h>
Add the visualization gui classes
r118
drop of variables in the visualization
r850 #include <Visualization/operations/FindVariableOperation.h>
Rename "DragDropHelper" in "DragDropGuiController"
r1075 #include <DragAndDrop/DragDropGuiController.h>
Implementation of V5 acquisition
r539 #include <QUuid>
Alexandre Leroux
Adds a close button to a zone widget + calls close() method when clicked
r265 #include <SqpApplication.h>
Change cmath include order from clang format
r621 #include <cmath>
Alexandre Leroux
Adds a close button to a zone widget + calls close() method when clicked
r265
Integrates the drag&drop classes into the existing visualization classes.
r839 #include <QLayout>
Made core module a git submodule, ready to start switching to new...
r1347 #include <QStyle>
Integrates the drag&drop classes into the existing visualization classes.
r839
Alexandre Leroux
Adds logs for null visitors
r219 Q_LOGGING_CATEGORY(LOG_VisualizationZoneWidget, "VisualizationZoneWidget")
Switched to new TS impl but quite broken!...
r1420 namespace
{
Alexandre Leroux
Completes the method of creating a zone from a variable
r200
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 /**
* Applies a function to all graphs of the zone represented by its layout
* @param layout the layout that contains graphs
* @param fun the function to apply to each graph
*/
template <typename Fun>
Switched to new TS impl but quite broken!...
r1420 void processGraphs(QLayout& layout, Fun fun)
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 {
Switched to new TS impl but quite broken!...
r1420 for (auto i = 0; i < layout.count(); ++i)
{
if (auto item = layout.itemAt(i))
{
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 if (auto visualizationGraphWidget
Switched to new TS impl but quite broken!...
r1420 = qobject_cast<VisualizationGraphWidget*>(item->widget()))
{
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 fun(*visualizationGraphWidget);
}
}
}
}
Ensures graph and zone names are not duplicated in the visualization
r1137 /// Generates a default name for a new graph, according to the number of graphs already displayed in
/// the zone
Switched to new TS impl but quite broken!...
r1420 QString defaultGraphName(QLayout& layout)
Ensures graph and zone names are not duplicated in the visualization
r1137 {
QSet<QString> existingNames;
processGraphs(
Switched to new TS impl but quite broken!...
r1420 layout, [&existingNames](auto& graphWidget) { existingNames.insert(graphWidget.name()); });
Ensures graph and zone names are not duplicated in the visualization
r1137
int zoneNum = 1;
QString name;
Switched to new TS impl but quite broken!...
r1420 do
{
Ensures graph and zone names are not duplicated in the visualization
r1137 name = QObject::tr("Graph ").append(QString::number(zoneNum));
++zoneNum;
} while (existingNames.contains(name));
return name;
}
Alexandre Leroux
Completes the method of creating a zone from a variable
r200 } // namespace
Switched to new TS impl but quite broken!...
r1420 struct VisualizationZoneWidget::VisualizationZoneWidgetPrivate
{
Implementation of V5 acquisition
r539
Alexandre Leroux
Sets sames margin sides for graphs in a same zone
r730 explicit VisualizationZoneWidgetPrivate()
Switched to new TS impl but quite broken!...
r1420 : m_SynchronisationGroupId { QUuid::createUuid() }
, m_Synchronizer { std::make_unique<QCustomPlotSynchronizer>() }
Alexandre Leroux
Sets sames margin sides for graphs in a same zone
r730 {
}
Implementation of V5 acquisition
r539 QUuid m_SynchronisationGroupId;
Alexandre Leroux
Sets sames margin sides for graphs in a same zone
r730 std::unique_ptr<IGraphSynchronizer> m_Synchronizer;
drop of variables in the visualization
r850
Switched to new TS impl but quite broken!...
r1420 void dropGraph(int index, VisualizationZoneWidget* zoneWidget);
void dropVariables(const std::vector<std::shared_ptr<Variable2>>& variables, int index,
VisualizationZoneWidget* zoneWidget);
void dropProducts(
const QVariantList& productsData, int index, VisualizationZoneWidget* zoneWidget);
Implementation of V5 acquisition
r539 };
Switched to new TS impl but quite broken!...
r1420 VisualizationZoneWidget::VisualizationZoneWidget(const QString& name, QWidget* parent)
: VisualizationDragWidget { parent }
, ui { new Ui::VisualizationZoneWidget }
, impl { spimpl::make_unique_impl<VisualizationZoneWidgetPrivate>() }
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 {
ui->setupUi(this);
Alexandre Leroux
Adds a name for a zone...
r197
ui->zoneNameLabel->setText(name);
Alexandre Leroux
Adds a close button to a zone widget + calls close() method when clicked
r265
Rename "DragDropHelper" in "DragDropGuiController"
r1075 ui->dragDropContainer->setPlaceHolderType(DragDropGuiController::PlaceHolderType::Graph);
Switched to new TS impl but quite broken!...
r1420 ui->dragDropContainer->setMimeType(
New data sources system switch complete...
r1495 MIME::MIME_TYPE_GRAPH, VisualizationDragDropContainer::DropBehavior::Inserted);
drop of zone on the time widget
r936 ui->dragDropContainer->setMimeType(
New data sources system switch complete...
r1495 MIME::MIME_TYPE_VARIABLE_LIST, VisualizationDragDropContainer::DropBehavior::InsertedAndMerged);
drop of products in visu
r1287 ui->dragDropContainer->setMimeType(
New data sources system switch complete...
r1495 MIME::MIME_TYPE_PRODUCT_LIST, VisualizationDragDropContainer::DropBehavior::InsertedAndMerged);
Switched to new TS impl but quite broken!...
r1420 ui->dragDropContainer->setMimeType(
New data sources system switch complete...
r1495 MIME::MIME_TYPE_TIME_RANGE, VisualizationDragDropContainer::DropBehavior::Merged);
Switched to new TS impl but quite broken!...
r1420 ui->dragDropContainer->setMimeType(
New data sources system switch complete...
r1495 MIME::MIME_TYPE_ZONE, VisualizationDragDropContainer::DropBehavior::Forbidden);
Switched to new TS impl but quite broken!...
r1420 ui->dragDropContainer->setMimeType(
New data sources system switch complete...
r1495 MIME::MIME_TYPE_SELECTION_ZONE, VisualizationDragDropContainer::DropBehavior::Forbidden);
drop of variables in the visualization
r850 ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) {
Switched to new TS impl but quite broken!...
r1420 return sqpApp->dragDropGuiController().checkMimeDataForVisualization(
mimeData, ui->dragDropContainer);
drop of variables in the visualization
r850 });
drop of variable inside an existing graph
r875
Alexandre Leroux
Handle the previous prohibition for drag and drop
r1023 auto acceptDragWidgetFun = [](auto dragWidget, auto mimeData) {
Switched to new TS impl but quite broken!...
r1420 if (!mimeData)
{
Alexandre Leroux
Handle the previous prohibition for drag and drop
r1023 return false;
}
New data sources system switch complete...
r1495 if (mimeData->hasFormat(MIME::MIME_TYPE_VARIABLE_LIST))
Switched to new TS impl but quite broken!...
r1420 {
All the codebase is modified to build with new Variable Controller...
r1348 auto variables = sqpApp->variableController().variables(
New data sources system switch complete...
r1495 Variable2::IDs(mimeData->data(MIME::MIME_TYPE_VARIABLE_LIST)));
Alexandre Leroux
Handle the previous prohibition for drag and drop
r1023
Switched to new TS impl but quite broken!...
r1420 if (variables.size() != 1)
{
Alexandre Leroux
Handle the previous prohibition for drag and drop
r1023 return false;
}
All the codebase is modified to build with new Variable Controller...
r1348 auto variable = variables.front();
Alexandre Leroux
Handle the previous prohibition for drag and drop
r1023
Switched to new TS impl but quite broken!...
r1420 if (auto graphWidget = dynamic_cast<const VisualizationGraphWidget*>(dragWidget))
{
Alexandre Leroux
Handle the previous prohibition for drag and drop
r1023 return graphWidget->canDrop(*variable);
}
}
return true;
};
ui->dragDropContainer->setAcceptDragWidgetFunction(acceptDragWidgetFun);
drop of variable inside an existing graph
r875 connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccuredInContainer, this,
Switched to new TS impl but quite broken!...
r1420 &VisualizationZoneWidget::dropMimeData);
drop of variable inside an existing graph
r875 connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccuredOnWidget, this,
Switched to new TS impl but quite broken!...
r1420 &VisualizationZoneWidget::dropMimeDataOnGraph);
Integrates the drag&drop classes into the existing visualization classes.
r839
Alexandre Leroux
Adds a close button to a zone widget + calls close() method when clicked
r265 // 'Close' options : widget is deleted when closed
setAttribute(Qt::WA_DeleteOnClose);
connect(ui->closeButton, &QToolButton::clicked, this, &VisualizationZoneWidget::close);
ui->closeButton->setIcon(sqpApp->style()->standardIcon(QStyle::SP_TitleBarCloseButton));
Implementation of V5 acquisition
r539
// Synchronisation id
Switched to new TS impl but quite broken!...
r1420 // QMetaObject::invokeMethod(&sqpApp->variableController(), "onAddSynchronizationGroupId",
// Qt::QueuedConnection, Q_ARG(QUuid, impl->m_SynchronisationGroupId));
Creation of VisualizationWidget, VizualizationTabWidget, VisualizationZoneWidget, VisualizationGraphWidget
r58 }
VisualizationZoneWidget::~VisualizationZoneWidget()
{
delete ui;
}
Add the visualization gui classes
r118
Switched to new TS impl but quite broken!...
r1420 void VisualizationZoneWidget::setZoneRange(const DateTimeRange& range)
Time Zone Mode + prepare graph mode
r1138 {
Switched to new TS impl but quite broken!...
r1420 if (auto graph = firstGraph())
{
Time Zone Mode + prepare graph mode
r1138 graph->setGraphRange(range);
}
Switched to new TS impl but quite broken!...
r1420 else
{
Time Zone Mode + prepare graph mode
r1138 qCWarning(LOG_VisualizationZoneWidget())
<< tr("setZoneRange:Cannot set the range of an empty zone.");
}
}
Switched to new TS impl but quite broken!...
r1420 void VisualizationZoneWidget::addGraph(VisualizationGraphWidget* graphWidget)
Add the visualization gui classes
r118 {
Alexandre Leroux
Sets sames margin sides for graphs in a same zone
r730 // Synchronize new graph with others in the zone
Switched to new TS impl but quite broken!...
r1420 // impl->m_Synchronizer->addGraph(*graphWidget);
Added RAW graph sync implementation...
r1373
Switched to new TS impl but quite broken!...
r1420 // ui->dragDropContainer->addDragWidget(graphWidget);
insertGraph(0, graphWidget);
Integrates the drag&drop classes into the existing visualization classes.
r839 }
Switched to new TS impl but quite broken!...
r1420 void VisualizationZoneWidget::insertGraph(int index, VisualizationGraphWidget* graphWidget)
Integrates the drag&drop classes into the existing visualization classes.
r839 {
Added RAW graph sync implementation...
r1373 DEPRECATE(
Switched to new TS impl but quite broken!...
r1420 auto layout = ui->dragDropContainer->layout(); for (int i = 0; i < layout->count(); i++) {
auto graph = qobject_cast<VisualizationGraphWidget*>(layout->itemAt(i)->widget());
connect(graphWidget, &VisualizationGraphWidget::setrange_sig, graph,
&VisualizationGraphWidget::setGraphRange);
connect(graph, &VisualizationGraphWidget::setrange_sig, graphWidget,
&VisualizationGraphWidget::setGraphRange);
} if (auto graph = firstGraph()) { graphWidget->setGraphRange(graph->graphRange(), true); })
Added RAW graph sync implementation...
r1373
Integrates the drag&drop classes into the existing visualization classes.
r839 // Synchronize new graph with others in the zone
impl->m_Synchronizer->addGraph(*graphWidget);
ui->dragDropContainer->insertDragWidget(index, graphWidget);
Add the visualization gui classes
r118 }
Switched to new TS impl but quite broken!...
r1420 VisualizationGraphWidget* VisualizationZoneWidget::createGraph(std::shared_ptr<Variable2> variable)
Integrates the drag&drop classes into the existing visualization classes.
r839 {
return createGraph(variable, -1);
}
Switched to new TS impl but quite broken!...
r1420 VisualizationGraphWidget* VisualizationZoneWidget::createGraph(
std::shared_ptr<Variable2> variable, int index)
Add the visualization gui classes
r118 {
Format changes
r844 auto graphWidget
Switched to new TS impl but quite broken!...
r1420 = new VisualizationGraphWidget { defaultGraphName(*ui->dragDropContainer->layout()), this };
Alexandre Leroux
Adds scrollbar to tabs
r307
Add synchronization that keep delta
r444
Alexandre Leroux
Adds scrollbar to tabs
r307 // Set graph properties
graphWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
graphWidget->setMinimumHeight(GRAPH_MINIMUM_HEIGHT);
Alexandre Leroux
Completes the method of creating a zone from a variable
r200
Add synchronization that keep delta
r444 // Lambda to synchronize zone widget
Switched to new TS impl but quite broken!...
r1420 // auto synchronizeZoneWidget = [this, graphWidget](const DateTimeRange &graphRange,
// const DateTimeRange &oldGraphRange) {
// auto zoomType = DateTimeRangeHelper::getTransformationType(oldGraphRange, graphRange);
// auto frameLayout = ui->dragDropContainer->layout();
// for (auto i = 0; i < frameLayout->count(); ++i) {
// auto graphChild
// = dynamic_cast<VisualizationGraphWidget *>(frameLayout->itemAt(i)->widget());
// if (graphChild && (graphChild != graphWidget)) {
// auto graphChildRange = graphChild->graphRange();
// switch (zoomType) {
// case TransformationType::ZoomIn: {
// auto deltaLeft = graphRange.m_TStart - oldGraphRange.m_TStart;
// auto deltaRight = oldGraphRange.m_TEnd - graphRange.m_TEnd;
// graphChildRange.m_TStart += deltaLeft;
// graphChildRange.m_TEnd -= deltaRight;
// break;
// }
// case TransformationType::ZoomOut: {
// auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart;
// auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd;
// graphChildRange.m_TStart -= deltaLeft;
// graphChildRange.m_TEnd += deltaRight;
// break;
// }
// case TransformationType::PanRight: {
// auto deltaLeft = graphRange.m_TStart - oldGraphRange.m_TStart;
// auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd;
// graphChildRange.m_TStart += deltaLeft;
// graphChildRange.m_TEnd += deltaRight;
// break;
// }
// case TransformationType::PanLeft: {
// auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart;
// auto deltaRight = oldGraphRange.m_TEnd - graphRange.m_TEnd;
// graphChildRange.m_TStart -= deltaLeft;
// graphChildRange.m_TEnd -= deltaRight;
// break;
// }
// case TransformationType::Unknown: {
// break;
// }
// default:
// qCCritical(LOG_VisualizationZoneWidget())
// << tr("Impossible to synchronize: zoom type not take into
// account");
// // No action
// break;
// }
// graphChild->setFlags(GraphFlag::DisableAll);
// graphChild->setGraphRange(graphChildRange, true);
// graphChild->setFlags(GraphFlag::EnableAll);
// }
// }
// };
Add synchronization that keep delta
r444
// connection for synchronization
Switched to new TS impl but quite broken!...
r1420 // connect(graphWidget, &VisualizationGraphWidget::synchronize, synchronizeZoneWidget);
Add synchronization part of v5 acquisition
r540 connect(graphWidget, &VisualizationGraphWidget::variableAdded, this,
Switched to new TS impl but quite broken!...
r1420 &VisualizationZoneWidget::onVariableAdded);
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (1)...
r737 connect(graphWidget, &VisualizationGraphWidget::variableAboutToBeRemoved, this,
Switched to new TS impl but quite broken!...
r1420 &VisualizationZoneWidget::onVariableAboutToBeRemoved);
Add synchronization part of v5 acquisition
r540
Switched to new TS impl but quite broken!...
r1420 auto range = DateTimeRange {};
if (auto firstGraph = this->firstGraph())
{
Initialisation of the graph range at creation in a new graphe, or inside...
r548 // Case of a new graph in a existant zone
Drop of variable, graph and zones on the time widget
r878 range = firstGraph->graphRange();
Initialisation of the graph range at creation in a new graphe, or inside...
r548 }
Switched to new TS impl but quite broken!...
r1420 else
{
Initialisation of the graph range at creation in a new graphe, or inside...
r548 // Case of a new graph as the first of the zone
range = variable->range();
}
Integrates the drag&drop classes into the existing visualization classes.
r839 this->insertGraph(index, graphWidget);
Add synchronization part of v5 acquisition
r540
Initialisation of the graph range at creation in a new graphe, or inside...
r548 graphWidget->addVariable(variable, range);
Alexandre Leroux
Refactors VisualizationGraphWidget::setYRange()...
r900 graphWidget->setYRange(variable);
Add synchronization that keep delta
r444
Add the visualization gui classes
r118 return graphWidget;
}
Switched to new TS impl but quite broken!...
r1420 VisualizationGraphWidget* VisualizationZoneWidget::createGraph(
const std::vector<std::shared_ptr<Variable2>> variables, int index)
Integrates the drag&drop classes into the existing visualization classes.
r839 {
Switched to new TS impl but quite broken!...
r1420 if (variables.empty())
{
Integrates the drag&drop classes into the existing visualization classes.
r839 return nullptr;
Format changes
r844 }
Integrates the drag&drop classes into the existing visualization classes.
r839
All the codebase is modified to build with new Variable Controller...
r1348 auto graphWidget = createGraph(variables.front(), index);
Switched to new TS impl but quite broken!...
r1420 for (auto variableIt = variables.cbegin() + 1; variableIt != variables.cend(); ++variableIt)
{
Integrates the drag&drop classes into the existing visualization classes.
r839 graphWidget->addVariable(*variableIt, graphWidget->graphRange());
}
return graphWidget;
}
Switched to new TS impl but quite broken!...
r1420 VisualizationGraphWidget* VisualizationZoneWidget::firstGraph() const
Keep the selection zones when a graph is dropped in another synchro zone
r1048 {
Switched to new TS impl but quite broken!...
r1420 VisualizationGraphWidget* firstGraph = nullptr;
Keep the selection zones when a graph is dropped in another synchro zone
r1048 auto layout = ui->dragDropContainer->layout();
Switched to new TS impl but quite broken!...
r1420 if (layout->count() > 0)
{
Keep the selection zones when a graph is dropped in another synchro zone
r1048 if (auto visualizationGraphWidget
Switched to new TS impl but quite broken!...
r1420 = qobject_cast<VisualizationGraphWidget*>(layout->itemAt(0)->widget()))
{
Keep the selection zones when a graph is dropped in another synchro zone
r1048 firstGraph = visualizationGraphWidget;
}
}
return firstGraph;
}
Closes all graphs of the selected zone in graph mode
r1307 void VisualizationZoneWidget::closeAllGraphs()
{
processGraphs(*ui->dragDropContainer->layout(),
Switched to new TS impl but quite broken!...
r1420 [](VisualizationGraphWidget& graphWidget) { graphWidget.close(); });
Closes all graphs of the selected zone in graph mode
r1307 }
Switched to new TS impl but quite broken!...
r1420 void VisualizationZoneWidget::accept(IVisualizationWidgetVisitor* visitor)
Add the visualization gui classes
r118 {
Switched to new TS impl but quite broken!...
r1420 if (visitor)
{
Alexandre Leroux
Implements accept() method of visualization widgets
r208 visitor->visitEnter(this);
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 // Apply visitor to graph children: widgets different from graphs are not visited (no
// action)
Switched to new TS impl but quite broken!...
r1420 processGraphs(*ui->dragDropContainer->layout(),
[visitor](VisualizationGraphWidget& graphWidget) { graphWidget.accept(visitor); });
Alexandre Leroux
Implements accept() method of visualization widgets
r208
visitor->visitLeave(this);
}
Switched to new TS impl but quite broken!...
r1420 else
{
Alexandre Leroux
Adds logs for null visitors
r219 qCCritical(LOG_VisualizationZoneWidget()) << tr("Can't visit widget : the visitor is null");
}
Add the visualization gui classes
r118 }
Switched to new TS impl but quite broken!...
r1420 bool VisualizationZoneWidget::canDrop(Variable2& variable) const
Alexandre Leroux
Creates a interface that defines a variable container...
r209 {
// A tab can always accomodate a variable
Q_UNUSED(variable);
return true;
}
Switched to new TS impl but quite broken!...
r1420 bool VisualizationZoneWidget::contains(Variable2& variable) const
Alexandre Leroux
Unplot menu (5): adds contains() method to an IVariableContainer...
r327 {
Q_UNUSED(variable);
return false;
}
Add const and override
r119 QString VisualizationZoneWidget::name() const
Add the visualization gui classes
r118 {
Alexandre Leroux
Adds a name for a zone...
r197 return ui->zoneNameLabel->text();
Add the visualization gui classes
r118 }
Add synchronization part of v5 acquisition
r540
Switched to new TS impl but quite broken!...
r1420 QMimeData* VisualizationZoneWidget::mimeData(const QPoint& position) const
Integrates the drag&drop classes into the existing visualization classes.
r839 {
drag of selection zones
r1047 Q_UNUSED(position);
Fixes for review
r846 auto mimeData = new QMimeData;
New data sources system switch complete...
r1495 mimeData->setData(MIME::MIME_TYPE_ZONE, QByteArray {});
Integrates the drag&drop classes into the existing visualization classes.
r839
Switched to new TS impl but quite broken!...
r1420 if (auto firstGraph = this->firstGraph())
{
drop of zone on the time widget
r936 auto timeRangeData = TimeController::mimeDataForTimeRange(firstGraph->graphRange());
New data sources system switch complete...
r1495 mimeData->setData(MIME::MIME_TYPE_TIME_RANGE, timeRangeData);
drop of zone on the time widget
r936 }
Integrates the drag&drop classes into the existing visualization classes.
r839 return mimeData;
}
bool VisualizationZoneWidget::isDragAllowed() const
{
return true;
}
Switched to new TS impl but quite broken!...
r1420 void VisualizationZoneWidget::notifyMouseMoveInGraph(const QPointF& graphPosition,
const QPointF& plotPosition, VisualizationGraphWidget* graphWidget)
Implements cursor mode
r960 {
Switched to new TS impl but quite broken!...
r1420 processGraphs(*ui->dragDropContainer->layout(),
[&graphPosition, &plotPosition, &graphWidget](VisualizationGraphWidget& processedGraph) {
switch (sqpApp->plotsCursorMode())
{
case SqpApplication::PlotsCursorMode::Vertical:
Implements cursor mode
r960 processedGraph.removeHorizontalCursor();
processedGraph.addVerticalCursorAtViewportPosition(graphPosition.x());
Switched to new TS impl but quite broken!...
r1420 break;
case SqpApplication::PlotsCursorMode::Temporal:
processedGraph.addVerticalCursor(plotPosition.x());
Implements cursor mode
r960 processedGraph.removeHorizontalCursor();
Switched to new TS impl but quite broken!...
r1420 break;
case SqpApplication::PlotsCursorMode::Horizontal:
Implements cursor mode
r960 processedGraph.removeVerticalCursor();
Switched to new TS impl but quite broken!...
r1420 if (&processedGraph == graphWidget)
{
processedGraph.addHorizontalCursorAtViewportPosition(graphPosition.y());
}
else
{
processedGraph.removeHorizontalCursor();
}
break;
case SqpApplication::PlotsCursorMode::Cross:
if (&processedGraph == graphWidget)
{
processedGraph.addVerticalCursorAtViewportPosition(graphPosition.x());
processedGraph.addHorizontalCursorAtViewportPosition(graphPosition.y());
}
else
{
processedGraph.removeHorizontalCursor();
processedGraph.removeVerticalCursor();
}
break;
case SqpApplication::PlotsCursorMode::NoCursor:
processedGraph.removeHorizontalCursor();
processedGraph.removeVerticalCursor();
break;
}
});
Implements cursor mode
r960 }
Switched to new TS impl but quite broken!...
r1420 void VisualizationZoneWidget::notifyMouseLeaveGraph(VisualizationGraphWidget* graphWidget)
Implements cursor mode
r960 {
Switched to new TS impl but quite broken!...
r1420 processGraphs(*ui->dragDropContainer->layout(), [](VisualizationGraphWidget& processedGraph) {
Implements cursor mode
r960 processedGraph.removeHorizontalCursor();
processedGraph.removeVerticalCursor();
});
}
Switched to new TS impl but quite broken!...
r1420 void VisualizationZoneWidget::closeEvent(QCloseEvent* event)
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 {
// Closes graphs in the zone
Integrates the drag&drop classes into the existing visualization classes.
r839 processGraphs(*ui->dragDropContainer->layout(),
Switched to new TS impl but quite broken!...
r1420 [](VisualizationGraphWidget& graphWidget) { graphWidget.close(); });
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738
Alexandre Leroux
Removes synchronisation group from Variable controller when a zone is being closed
r739 // Delete synchronization group from variable controller
QMetaObject::invokeMethod(&sqpApp->variableController(), "onRemoveSynchronizationGroupId",
Switched to new TS impl but quite broken!...
r1420 Qt::QueuedConnection, Q_ARG(QUuid, impl->m_SynchronisationGroupId));
Alexandre Leroux
Removes synchronisation group from Variable controller when a zone is being closed
r739
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 QWidget::closeEvent(event);
}
Switched to new TS impl but quite broken!...
r1420 void VisualizationZoneWidget::onVariableAdded(std::shared_ptr<Variable2> variable)
Add synchronization part of v5 acquisition
r540 {
QMetaObject::invokeMethod(&sqpApp->variableController(), "onAddSynchronized",
Switched to new TS impl but quite broken!...
r1420 Qt::QueuedConnection, Q_ARG(std::shared_ptr<Variable2>, variable),
Q_ARG(QUuid, impl->m_SynchronisationGroupId));
Add synchronization part of v5 acquisition
r540 }
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (1)...
r737
Switched to new TS impl but quite broken!...
r1420 void VisualizationZoneWidget::onVariableAboutToBeRemoved(std::shared_ptr<Variable2> variable)
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (1)...
r737 {
QMetaObject::invokeMethod(&sqpApp->variableController(), "desynchronize", Qt::QueuedConnection,
Switched to new TS impl but quite broken!...
r1420 Q_ARG(std::shared_ptr<Variable2>, variable), Q_ARG(QUuid, impl->m_SynchronisationGroupId));
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (1)...
r737 }
Integrates the drag&drop classes into the existing visualization classes.
r839
Switched to new TS impl but quite broken!...
r1420 void VisualizationZoneWidget::dropMimeData(int index, const QMimeData* mimeData)
Integrates the drag&drop classes into the existing visualization classes.
r839 {
New data sources system switch complete...
r1495 if (mimeData->hasFormat(MIME::MIME_TYPE_GRAPH))
Switched to new TS impl but quite broken!...
r1420 {
drop of variables in the visualization
r850 impl->dropGraph(index, this);
}
New data sources system switch complete...
r1495 else if (mimeData->hasFormat(MIME::MIME_TYPE_VARIABLE_LIST))
Switched to new TS impl but quite broken!...
r1420 {
All the codebase is modified to build with new Variable Controller...
r1348 auto variables = sqpApp->variableController().variables(
New data sources system switch complete...
r1495 Variable2::IDs(mimeData->data(MIME::MIME_TYPE_VARIABLE_LIST)));
drop of variables in the visualization
r850 impl->dropVariables(variables, index, this);
}
New data sources system switch complete...
r1495 else if (mimeData->hasFormat(MIME::MIME_TYPE_PRODUCT_LIST))
Switched to new TS impl but quite broken!...
r1420 {
New data sources system switch complete...
r1495 auto products = MIME::decode(
mimeData->data(MIME::MIME_TYPE_PRODUCT_LIST));
drop of products in visu
r1287 impl->dropProducts(products, index, this);
}
Switched to new TS impl but quite broken!...
r1420 else
{
drop of variables in the visualization
r850 qCWarning(LOG_VisualizationZoneWidget())
<< tr("VisualizationZoneWidget::dropMimeData, unknown MIME data received.");
}
}
Switched to new TS impl but quite broken!...
r1420 void VisualizationZoneWidget::dropMimeDataOnGraph(
VisualizationDragWidget* dragWidget, const QMimeData* mimeData)
drop of variable inside an existing graph
r875 {
Switched to new TS impl but quite broken!...
r1420 auto graphWidget = qobject_cast<VisualizationGraphWidget*>(dragWidget);
if (!graphWidget)
{
drop of variable inside an existing graph
r875 qCWarning(LOG_VisualizationZoneWidget())
<< tr("VisualizationZoneWidget::dropMimeDataOnGraph, dropping in an unknown widget, "
"drop aborted");
Q_ASSERT(false);
return;
}
New data sources system switch complete...
r1495 if (mimeData->hasFormat(MIME::MIME_TYPE_VARIABLE_LIST))
Switched to new TS impl but quite broken!...
r1420 {
All the codebase is modified to build with new Variable Controller...
r1348 auto variables = sqpApp->variableController().variables(
New data sources system switch complete...
r1495 Variable2::IDs(mimeData->data(MIME::MIME_TYPE_VARIABLE_LIST)));
Switched to new TS impl but quite broken!...
r1420 for (const auto& var : variables)
{
drop of variable inside an existing graph
r875 graphWidget->addVariable(var, graphWidget->graphRange());
}
}
New data sources system switch complete...
r1495 else if (mimeData->hasFormat(MIME::MIME_TYPE_PRODUCT_LIST))
Switched to new TS impl but quite broken!...
r1420 {
New data sources system switch complete...
r1495 auto products = MIME::decode(
mimeData->data(MIME::MIME_TYPE_PRODUCT_LIST));
drop of products in visu
r1287
Switched to new TS impl but quite broken!...
r1420 auto context = new QObject { this };
New data sources system switch complete...
r1495 auto range = TimeController::timeRangeForMimeData(mimeData->data(MIME::MIME_TYPE_TIME_RANGE));
Quite fixed D&D from tree......
r1378 // BTW this is really dangerous, this assumes the next created variable will be this one...
All the codebase is modified to build with new Variable Controller...
r1348 connect(&sqpApp->variableController(), &VariableController2::variableAdded, context,
Switched to new TS impl but quite broken!...
r1420 [this, graphWidget, context, range](auto variable) {
if (sqpApp->variableController().isReady(variable))
{
graphWidget->addVariable(variable, range);
delete context;
}
else
{
// -> this is pure insanity! this is a workaround to make a bad design work
QObject::connect(variable.get(), &Variable2::updated, context,
[graphWidget, context, range, variable]() {
graphWidget->addVariable(variable, range);
delete context;
});
}
},
Qt::QueuedConnection);
Creates graph when dropping a product in the visu
r1288
New data sources system switch complete...
r1495 auto productPath = products.first().toString();
QMetaObject::invokeMethod(&sqpApp->dataSources(), "createVariable",
Qt::QueuedConnection, Q_ARG(QString, productPath));
drop of products in visu
r1287 }
New data sources system switch complete...
r1495 else if (mimeData->hasFormat(MIME::MIME_TYPE_TIME_RANGE))
Switched to new TS impl but quite broken!...
r1420 {
New data sources system switch complete...
r1495 auto range = TimeController::timeRangeForMimeData(mimeData->data(MIME::MIME_TYPE_TIME_RANGE));
Many synchronization fixes, most operations works, only product drag from tree is broken...
r1377 graphWidget->setGraphRange(range, true, true);
Drag of the time widget on a graph
r879 }
Switched to new TS impl but quite broken!...
r1420 else
{
drop of variable inside an existing graph
r875 qCWarning(LOG_VisualizationZoneWidget())
<< tr("VisualizationZoneWidget::dropMimeDataOnGraph, unknown MIME data received.");
}
}
drop of variables in the visualization
r850 void VisualizationZoneWidget::VisualizationZoneWidgetPrivate::dropGraph(
Switched to new TS impl but quite broken!...
r1420 int index, VisualizationZoneWidget* zoneWidget)
drop of variables in the visualization
r850 {
Switched to new TS impl but quite broken!...
r1420 auto& helper = sqpApp->dragDropGuiController();
drop of variables in the visualization
r850
Switched to new TS impl but quite broken!...
r1420 auto graphWidget = qobject_cast<VisualizationGraphWidget*>(helper.getCurrentDragWidget());
if (!graphWidget)
{
drop of variables in the visualization
r850 qCWarning(LOG_VisualizationZoneWidget())
<< tr("VisualizationZoneWidget::dropGraph, drop aborted, the dropped graph is not "
"found or invalid.");
Q_ASSERT(false);
return;
}
auto parentDragDropContainer
Switched to new TS impl but quite broken!...
r1420 = qobject_cast<VisualizationDragDropContainer*>(graphWidget->parentWidget());
if (!parentDragDropContainer)
{
drop of variables in the visualization
r850 qCWarning(LOG_VisualizationZoneWidget())
<< tr("VisualizationZoneWidget::dropGraph, drop aborted, the parent container of "
"the dropped graph is not found.");
Q_ASSERT(false);
return;
}
Switched to new TS impl but quite broken!...
r1420 const auto& variables = graphWidget->variables();
Manage drag&drop of empty graphs
r841
Switched to new TS impl but quite broken!...
r1420 if (parentDragDropContainer != zoneWidget->ui->dragDropContainer && !variables.empty())
{
drop of variables in the visualization
r850 // The drop didn't occur in the same zone
// Abort the requests for the variables (if any)
// Commented, because it's not sure if it's needed or not
// for (const auto& var : variables)
//{
// sqpApp->variableController().onAbortProgressRequested(var);
//}
auto previousParentZoneWidget = graphWidget->parentZoneWidget();
auto nbGraph = parentDragDropContainer->countDragWidget();
Switched to new TS impl but quite broken!...
r1420 if (nbGraph == 1)
{
drop of variables in the visualization
r850 // This is the only graph in the previous zone, close the zone
Thibaud Rabillard
Fix for D&D bug on mac
r911 helper.delayedCloseWidget(previousParentZoneWidget);
Manage drag&drop of empty graphs
r841 }
Switched to new TS impl but quite broken!...
r1420 else
{
drop of variables in the visualization
r850 // Close the graph
Thibaud Rabillard
Fix for D&D bug on mac
r911 helper.delayedCloseWidget(graphWidget);
drop of variables in the visualization
r850 }
// Creates the new graph in the zone
Keep the selection zones when a graph is dropped in another synchro zone
r1048 auto newGraphWidget = zoneWidget->createGraph(variables, index);
newGraphWidget->addSelectionZones(graphWidget->selectionZoneRanges());
drop of variables in the visualization
r850 }
Switched to new TS impl but quite broken!...
r1420 else
{
drop of variables in the visualization
r850 // The drop occurred in the same zone or the graph is empty
// Simple move of the graph, no variable operation associated
parentDragDropContainer->layout()->removeWidget(graphWidget);
Switched to new TS impl but quite broken!...
r1420 if (variables.empty() && parentDragDropContainer != zoneWidget->ui->dragDropContainer)
{
drop of variables in the visualization
r850 // The graph is empty and dropped in a different zone.
// Take the range of the first graph in the zone (if existing).
auto layout = zoneWidget->ui->dragDropContainer->layout();
Switched to new TS impl but quite broken!...
r1420 if (layout->count() > 0)
{
drop of variables in the visualization
r850 if (auto visualizationGraphWidget
Switched to new TS impl but quite broken!...
r1420 = qobject_cast<VisualizationGraphWidget*>(layout->itemAt(0)->widget()))
{
drop of variables in the visualization
r850 graphWidget->setGraphRange(visualizationGraphWidget->graphRange());
Manage drag&drop of empty graphs
r841 }
}
drop of variables in the visualization
r850 }
zoneWidget->ui->dragDropContainer->insertDragWidget(index, graphWidget);
}
}
void VisualizationZoneWidget::VisualizationZoneWidgetPrivate::dropVariables(
Switched to new TS impl but quite broken!...
r1420 const std::vector<std::shared_ptr<Variable2>>& variables, int index,
VisualizationZoneWidget* zoneWidget)
drop of variables in the visualization
r850 {
Drag of product
r868 // Note: the AcceptMimeDataFunction (set on the drop container) ensure there is a single and
// compatible variable here
Switched to new TS impl but quite broken!...
r1420 if (variables.size() > 1)
{
drop of variables in the visualization
r850 return;
}
Drop of product in variables
r870 zoneWidget->createGraph(variables, index);
Integrates the drag&drop classes into the existing visualization classes.
r839 }
drop of products in visu
r1287
void VisualizationZoneWidget::VisualizationZoneWidgetPrivate::dropProducts(
Switched to new TS impl but quite broken!...
r1420 const QVariantList& productsData, int index, VisualizationZoneWidget* zoneWidget)
drop of products in visu
r1287 {
// Note: the AcceptMimeDataFunction (set on the drop container) ensure there is a single and
// compatible variable here
Switched to new TS impl but quite broken!...
r1420 if (productsData.count() != 1)
{
drop of products in visu
r1287 qCWarning(LOG_VisualizationZoneWidget())
<< tr("VisualizationTabWidget::dropProducts, dropping multiple products, operation "
"aborted.");
return;
}
Switched to new TS impl but quite broken!...
r1420 auto context = new QObject { zoneWidget };
All the codebase is modified to build with new Variable Controller...
r1348 connect(&sqpApp->variableController(), &VariableController2::variableAdded, context,
Switched to new TS impl but quite broken!...
r1420 [this, index, zoneWidget, context](auto variable) {
zoneWidget->createGraph(variable, index);
delete context; // removes the connection
},
Qt::QueuedConnection);
Creates graph when dropping a product in the visu
r1288
New data sources system switch complete...
r1495 auto productPath = productsData.first().toString();
QMetaObject::invokeMethod(&sqpApp->dataSources(), "createVariable",
Qt::QueuedConnection, Q_ARG(QString, productPath));
drop of products in visu
r1287 }