##// END OF EJS Templates
removed useless submodule...
removed useless submodule Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r1350:09a8c8a01145
r1356:1593f1666d7a
Show More
VisualizationZoneWidget.cpp
629 lines | 24.0 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"
Move Common MIME types constants in a Definition file in core module.
r848 #include "Common/MimeTypesDef.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>
drop of products in visu
r1287 #include <DataSource/DataSourceController.h>
Drop of variable, graph and zones on the time widget
r878 #include <Time/TimeController.h>
Initialisation of the graph range at creation in a new graphe, or inside...
r548 #include <Variable/Variable.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")
Alexandre Leroux
Completes the method of creating a zone from a variable
r200 namespace {
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>
void processGraphs(QLayout &layout, Fun fun)
{
for (auto i = 0; i < layout.count(); ++i) {
if (auto item = layout.itemAt(i)) {
if (auto visualizationGraphWidget
Implements cursor mode
r960 = 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
QString defaultGraphName(QLayout &layout)
{
QSet<QString> existingNames;
processGraphs(
layout, [&existingNames](auto &graphWidget) { existingNames.insert(graphWidget.name()); });
int zoneNum = 1;
QString name;
do {
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
Implementation of V5 acquisition
r539 struct VisualizationZoneWidget::VisualizationZoneWidgetPrivate {
Alexandre Leroux
Sets sames margin sides for graphs in a same zone
r730 explicit VisualizationZoneWidgetPrivate()
: m_SynchronisationGroupId{QUuid::createUuid()},
m_Synchronizer{std::make_unique<QCustomPlotSynchronizer>()}
{
}
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
void dropGraph(int index, VisualizationZoneWidget *zoneWidget);
All the codebase is modified to build with new Variable Controller...
r1348 void dropVariables(const std::vector<std::shared_ptr<Variable> > &variables, int index,
drop of variables in the visualization
r850 VisualizationZoneWidget *zoneWidget);
drop of products in visu
r1287 void dropProducts(const QVariantList &productsData, int index,
VisualizationZoneWidget *zoneWidget);
Implementation of V5 acquisition
r539 };
Alexandre Leroux
Adds a name for a zone...
r197 VisualizationZoneWidget::VisualizationZoneWidget(const QString &name, QWidget *parent)
Integrates the drag&drop classes into the existing visualization classes.
r839 : VisualizationDragWidget{parent},
Implementation of V5 acquisition
r539 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);
drop of zone on the time widget
r936 ui->dragDropContainer->setMimeType(MIME_TYPE_GRAPH,
VisualizationDragDropContainer::DropBehavior::Inserted);
ui->dragDropContainer->setMimeType(
Drag of the time widget on a graph
r879 MIME_TYPE_VARIABLE_LIST, VisualizationDragDropContainer::DropBehavior::InsertedAndMerged);
drop of products in visu
r1287 ui->dragDropContainer->setMimeType(
MIME_TYPE_PRODUCT_LIST, VisualizationDragDropContainer::DropBehavior::InsertedAndMerged);
drop of zone on the time widget
r936 ui->dragDropContainer->setMimeType(MIME_TYPE_TIME_RANGE,
VisualizationDragDropContainer::DropBehavior::Merged);
ui->dragDropContainer->setMimeType(MIME_TYPE_ZONE,
VisualizationDragDropContainer::DropBehavior::Forbidden);
drag of selection zones
r1047 ui->dragDropContainer->setMimeType(MIME_TYPE_SELECTION_ZONE,
VisualizationDragDropContainer::DropBehavior::Forbidden);
drop of variables in the visualization
r850 ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) {
Rename "DragDropHelper" in "DragDropGuiController"
r1075 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) {
if (!mimeData) {
return false;
}
if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST)) {
All the codebase is modified to build with new Variable Controller...
r1348 auto variables = sqpApp->variableController().variables(
Ported Mock plugin to new IDataProvider interface compatible with...
r1350 Variable::variablesIDs(mimeData->data(MIME_TYPE_VARIABLE_LIST)));
Alexandre Leroux
Handle the previous prohibition for drag and drop
r1023
All the codebase is modified to build with new Variable Controller...
r1348 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
if (auto graphWidget = dynamic_cast<const VisualizationGraphWidget *>(dragWidget)) {
return graphWidget->canDrop(*variable);
}
}
return true;
};
ui->dragDropContainer->setAcceptDragWidgetFunction(acceptDragWidgetFun);
drop of variable inside an existing graph
r875 connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccuredInContainer, this,
Format changes
r844 &VisualizationZoneWidget::dropMimeData);
drop of variable inside an existing graph
r875 connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccuredOnWidget, this,
&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
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
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 void VisualizationZoneWidget::setZoneRange(const DateTimeRange &range)
Time Zone Mode + prepare graph mode
r1138 {
if (auto graph = firstGraph()) {
graph->setGraphRange(range);
}
else {
qCWarning(LOG_VisualizationZoneWidget())
<< tr("setZoneRange:Cannot set the range of an empty zone.");
}
}
Add the visualization gui classes
r118 void VisualizationZoneWidget::addGraph(VisualizationGraphWidget *graphWidget)
{
Alexandre Leroux
Sets sames margin sides for graphs in a same zone
r730 // Synchronize new graph with others in the zone
impl->m_Synchronizer->addGraph(*graphWidget);
Integrates the drag&drop classes into the existing visualization classes.
r839 ui->dragDropContainer->addDragWidget(graphWidget);
}
void VisualizationZoneWidget::insertGraph(int index, VisualizationGraphWidget *graphWidget)
{
// Synchronize new graph with others in the zone
impl->m_Synchronizer->addGraph(*graphWidget);
ui->dragDropContainer->insertDragWidget(index, graphWidget);
Add the visualization gui classes
r118 }
Alexandre Leroux
Completes the method of creating a zone from a variable
r200 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<Variable> variable)
Integrates the drag&drop classes into the existing visualization classes.
r839 {
return createGraph(variable, -1);
}
Format changes
r844 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<Variable> variable,
int index)
Add the visualization gui classes
r118 {
Format changes
r844 auto graphWidget
= 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
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 auto synchronizeZoneWidget = [this, graphWidget](const DateTimeRange &graphRange,
const DateTimeRange &oldGraphRange) {
Implementation of V5 acquisition
r539
All the codebase is modified to build with new Variable Controller...
r1348 auto zoomType = DateTimeRangeHelper::getTransformationType(oldGraphRange, graphRange);
Integrates the drag&drop classes into the existing visualization classes.
r839 auto frameLayout = ui->dragDropContainer->layout();
Add synchronization that keep delta
r444 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) {
All the codebase is modified to build with new Variable Controller...
r1348 case TransformationType::ZoomIn: {
change grapheRange to graphRange
r545 auto deltaLeft = graphRange.m_TStart - oldGraphRange.m_TStart;
auto deltaRight = oldGraphRange.m_TEnd - graphRange.m_TEnd;
Add synchronization that keep delta
r444 graphChildRange.m_TStart += deltaLeft;
graphChildRange.m_TEnd -= deltaRight;
break;
}
All the codebase is modified to build with new Variable Controller...
r1348 case TransformationType::ZoomOut: {
change grapheRange to graphRange
r545 auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart;
auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd;
Add synchronization that keep delta
r444 graphChildRange.m_TStart -= deltaLeft;
graphChildRange.m_TEnd += deltaRight;
break;
}
All the codebase is modified to build with new Variable Controller...
r1348 case TransformationType::PanRight: {
Fix bug in synchro for operation (jump + rescaling)
r809 auto deltaLeft = graphRange.m_TStart - oldGraphRange.m_TStart;
change grapheRange to graphRange
r545 auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd;
Fix bug in synchro for operation (jump + rescaling)
r809 graphChildRange.m_TStart += deltaLeft;
Add synchronization that keep delta
r444 graphChildRange.m_TEnd += deltaRight;
break;
}
All the codebase is modified to build with new Variable Controller...
r1348 case TransformationType::PanLeft: {
change grapheRange to graphRange
r545 auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart;
Fix bug in synchro for operation (jump + rescaling)
r809 auto deltaRight = oldGraphRange.m_TEnd - graphRange.m_TEnd;
Add synchronization that keep delta
r444 graphChildRange.m_TStart -= deltaLeft;
Fix bug in synchro for operation (jump + rescaling)
r809 graphChildRange.m_TEnd -= deltaRight;
Add synchronization that keep delta
r444 break;
}
All the codebase is modified to build with new Variable Controller...
r1348 case TransformationType::Unknown: {
Add synchronization that keep delta
r444 break;
}
default:
qCCritical(LOG_VisualizationZoneWidget())
<< tr("Impossible to synchronize: zoom type not take into account");
// No action
break;
}
Alexandre Leroux
Corrects the problem of refreshing synchronized graphs from TimeWidget (1)...
r1271 graphChild->setFlags(GraphFlag::DisableAll);
Implementation of the calibration for the synchronization...
r445 graphChild->setGraphRange(graphChildRange);
Alexandre Leroux
Corrects the problem of refreshing synchronized graphs from TimeWidget (1)...
r1271 graphChild->setFlags(GraphFlag::EnableAll);
Add synchronization that keep delta
r444 }
}
};
// connection for synchronization
connect(graphWidget, &VisualizationGraphWidget::synchronize, synchronizeZoneWidget);
Add synchronization part of v5 acquisition
r540 connect(graphWidget, &VisualizationGraphWidget::variableAdded, this,
&VisualizationZoneWidget::onVariableAdded);
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (1)...
r737 connect(graphWidget, &VisualizationGraphWidget::variableAboutToBeRemoved, this,
&VisualizationZoneWidget::onVariableAboutToBeRemoved);
Add synchronization part of v5 acquisition
r540
Renamed SqpRange to DateTimeRange, introduced VariableController2 to...
r1346 auto range = DateTimeRange{};
Keep the selection zones when a graph is dropped in another synchro zone
r1048 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 }
else {
// 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;
}
Format changes
r844 VisualizationGraphWidget *
All the codebase is modified to build with new Variable Controller...
r1348 VisualizationZoneWidget::createGraph(const std::vector<std::shared_ptr<Variable> > variables, int index)
Integrates the drag&drop classes into the existing visualization classes.
r839 {
All the codebase is modified to build with new Variable Controller...
r1348 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);
Format changes
r844 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;
}
Keep the selection zones when a graph is dropped in another synchro zone
r1048 VisualizationGraphWidget *VisualizationZoneWidget::firstGraph() const
{
VisualizationGraphWidget *firstGraph = nullptr;
auto layout = ui->dragDropContainer->layout();
if (layout->count() > 0) {
if (auto visualizationGraphWidget
= qobject_cast<VisualizationGraphWidget *>(layout->itemAt(0)->widget())) {
firstGraph = visualizationGraphWidget;
}
}
return firstGraph;
}
Closes all graphs of the selected zone in graph mode
r1307 void VisualizationZoneWidget::closeAllGraphs()
{
processGraphs(*ui->dragDropContainer->layout(),
[](VisualizationGraphWidget &graphWidget) { graphWidget.close(); });
}
Alexandre Leroux
Updates visitor interface...
r207 void VisualizationZoneWidget::accept(IVisualizationWidgetVisitor *visitor)
Add the visualization gui classes
r118 {
Alexandre Leroux
Implements accept() method of visualization widgets
r208 if (visitor) {
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)
processGraphs(
Integrates the drag&drop classes into the existing visualization classes.
r839 *ui->dragDropContainer->layout(),
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 [visitor](VisualizationGraphWidget &graphWidget) { graphWidget.accept(visitor); });
Alexandre Leroux
Implements accept() method of visualization widgets
r208
visitor->visitLeave(this);
}
Alexandre Leroux
Adds logs for null visitors
r219 else {
qCCritical(LOG_VisualizationZoneWidget()) << tr("Can't visit widget : the visitor is null");
}
Add the visualization gui classes
r118 }
Alexandre Leroux
Creates a interface that defines a variable container...
r209 bool VisualizationZoneWidget::canDrop(const Variable &variable) const
{
// A tab can always accomodate a variable
Q_UNUSED(variable);
return true;
}
Alexandre Leroux
Unplot menu (5): adds contains() method to an IVariableContainer...
r327 bool VisualizationZoneWidget::contains(const Variable &variable) const
{
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
drag of selection zones
r1047 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;
Drag of product
r868 mimeData->setData(MIME_TYPE_ZONE, QByteArray{});
Integrates the drag&drop classes into the existing visualization classes.
r839
Keep the selection zones when a graph is dropped in another synchro zone
r1048 if (auto firstGraph = this->firstGraph()) {
drop of zone on the time widget
r936 auto timeRangeData = TimeController::mimeDataForTimeRange(firstGraph->graphRange());
mimeData->setData(MIME_TYPE_TIME_RANGE, timeRangeData);
}
Integrates the drag&drop classes into the existing visualization classes.
r839 return mimeData;
}
bool VisualizationZoneWidget::isDragAllowed() const
{
return true;
}
Implements cursor mode
r960 void VisualizationZoneWidget::notifyMouseMoveInGraph(const QPointF &graphPosition,
const QPointF &plotPosition,
VisualizationGraphWidget *graphWidget)
{
processGraphs(*ui->dragDropContainer->layout(), [&graphPosition, &plotPosition, &graphWidget](
VisualizationGraphWidget &processedGraph) {
switch (sqpApp->plotsCursorMode()) {
case SqpApplication::PlotsCursorMode::Vertical:
processedGraph.removeHorizontalCursor();
processedGraph.addVerticalCursorAtViewportPosition(graphPosition.x());
break;
case SqpApplication::PlotsCursorMode::Temporal:
processedGraph.addVerticalCursor(plotPosition.x());
processedGraph.removeHorizontalCursor();
break;
case SqpApplication::PlotsCursorMode::Horizontal:
processedGraph.removeVerticalCursor();
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;
}
});
}
void VisualizationZoneWidget::notifyMouseLeaveGraph(VisualizationGraphWidget *graphWidget)
{
processGraphs(*ui->dragDropContainer->layout(), [](VisualizationGraphWidget &processedGraph) {
processedGraph.removeHorizontalCursor();
processedGraph.removeVerticalCursor();
});
}
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 void VisualizationZoneWidget::closeEvent(QCloseEvent *event)
{
// Closes graphs in the zone
Integrates the drag&drop classes into the existing visualization classes.
r839 processGraphs(*ui->dragDropContainer->layout(),
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 [](VisualizationGraphWidget &graphWidget) { graphWidget.close(); });
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",
Qt::QueuedConnection, Q_ARG(QUuid, impl->m_SynchronisationGroupId));
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (2)...
r738 QWidget::closeEvent(event);
}
Add synchronization part of v5 acquisition
r540 void VisualizationZoneWidget::onVariableAdded(std::shared_ptr<Variable> variable)
{
QMetaObject::invokeMethod(&sqpApp->variableController(), "onAddSynchronized",
Qt::QueuedConnection, Q_ARG(std::shared_ptr<Variable>, variable),
Q_ARG(QUuid, impl->m_SynchronisationGroupId));
}
Alexandre Leroux
Handles desynchronisation when removing variable from a graph (1)...
r737
void VisualizationZoneWidget::onVariableAboutToBeRemoved(std::shared_ptr<Variable> variable)
{
QMetaObject::invokeMethod(&sqpApp->variableController(), "desynchronize", Qt::QueuedConnection,
Q_ARG(std::shared_ptr<Variable>, variable),
Q_ARG(QUuid, impl->m_SynchronisationGroupId));
}
Integrates the drag&drop classes into the existing visualization classes.
r839
void VisualizationZoneWidget::dropMimeData(int index, const QMimeData *mimeData)
{
Move Common MIME types constants in a Definition file in core module.
r848 if (mimeData->hasFormat(MIME_TYPE_GRAPH)) {
drop of variables in the visualization
r850 impl->dropGraph(index, this);
}
else if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST)) {
All the codebase is modified to build with new Variable Controller...
r1348 auto variables = sqpApp->variableController().variables(
Ported Mock plugin to new IDataProvider interface compatible with...
r1350 Variable::variablesIDs(mimeData->data(MIME_TYPE_VARIABLE_LIST)));
drop of variables in the visualization
r850 impl->dropVariables(variables, index, this);
}
drop of products in visu
r1287 else if (mimeData->hasFormat(MIME_TYPE_PRODUCT_LIST)) {
auto products = sqpApp->dataSourceController().productsDataForMimeData(
mimeData->data(MIME_TYPE_PRODUCT_LIST));
impl->dropProducts(products, index, this);
}
drop of variables in the visualization
r850 else {
qCWarning(LOG_VisualizationZoneWidget())
<< tr("VisualizationZoneWidget::dropMimeData, unknown MIME data received.");
}
}
drop of variable inside an existing graph
r875 void VisualizationZoneWidget::dropMimeDataOnGraph(VisualizationDragWidget *dragWidget,
const QMimeData *mimeData)
{
auto graphWidget = qobject_cast<VisualizationGraphWidget *>(dragWidget);
if (!graphWidget) {
qCWarning(LOG_VisualizationZoneWidget())
<< tr("VisualizationZoneWidget::dropMimeDataOnGraph, dropping in an unknown widget, "
"drop aborted");
Q_ASSERT(false);
return;
}
if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST)) {
All the codebase is modified to build with new Variable Controller...
r1348 auto variables = sqpApp->variableController().variables(
Ported Mock plugin to new IDataProvider interface compatible with...
r1350 Variable::variablesIDs(mimeData->data(MIME_TYPE_VARIABLE_LIST)));
drop of variable inside an existing graph
r875 for (const auto &var : variables) {
graphWidget->addVariable(var, graphWidget->graphRange());
}
}
drop of products in visu
r1287 else if (mimeData->hasFormat(MIME_TYPE_PRODUCT_LIST)) {
auto products = sqpApp->dataSourceController().productsDataForMimeData(
mimeData->data(MIME_TYPE_PRODUCT_LIST));
Creates graph when dropping a product in the visu
r1288 auto context = new QObject{this};
All the codebase is modified to build with new Variable Controller...
r1348 connect(&sqpApp->variableController(), &VariableController2::variableAdded, context,
Creates graph when dropping a product in the visu
r1288 [this, graphWidget, context](auto variable) {
graphWidget->addVariable(variable, graphWidget->graphRange());
delete context; // removes the connection
},
Qt::QueuedConnection);
drop of products in visu
r1287 auto productData = products.first().toHash();
QMetaObject::invokeMethod(&sqpApp->dataSourceController(), "requestVariable",
Qt::QueuedConnection, Q_ARG(QVariantHash, productData));
}
Drag of the time widget on a graph
r879 else if (mimeData->hasFormat(MIME_TYPE_TIME_RANGE)) {
auto range = TimeController::timeRangeForMimeData(mimeData->data(MIME_TYPE_TIME_RANGE));
graphWidget->setGraphRange(range);
}
drop of variable inside an existing graph
r875 else {
qCWarning(LOG_VisualizationZoneWidget())
<< tr("VisualizationZoneWidget::dropMimeDataOnGraph, unknown MIME data received.");
}
}
drop of variables in the visualization
r850 void VisualizationZoneWidget::VisualizationZoneWidgetPrivate::dropGraph(
int index, VisualizationZoneWidget *zoneWidget)
{
Rename "DragDropHelper" in "DragDropGuiController"
r1075 auto &helper = sqpApp->dragDropGuiController();
drop of variables in the visualization
r850
auto graphWidget = qobject_cast<VisualizationGraphWidget *>(helper.getCurrentDragWidget());
if (!graphWidget) {
qCWarning(LOG_VisualizationZoneWidget())
<< tr("VisualizationZoneWidget::dropGraph, drop aborted, the dropped graph is not "
"found or invalid.");
Q_ASSERT(false);
return;
}
auto parentDragDropContainer
= qobject_cast<VisualizationDragDropContainer *>(graphWidget->parentWidget());
if (!parentDragDropContainer) {
qCWarning(LOG_VisualizationZoneWidget())
<< tr("VisualizationZoneWidget::dropGraph, drop aborted, the parent container of "
"the dropped graph is not found.");
Q_ASSERT(false);
return;
}
const auto &variables = graphWidget->variables();
Manage drag&drop of empty graphs
r841
All the codebase is modified to build with new Variable Controller...
r1348 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();
if (nbGraph == 1) {
// 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 }
Format changes
r844 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 }
else {
// 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);
All the codebase is modified to build with new Variable Controller...
r1348 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();
if (layout->count() > 0) {
if (auto visualizationGraphWidget
= qobject_cast<VisualizationGraphWidget *>(layout->itemAt(0)->widget())) {
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(
All the codebase is modified to build with new Variable Controller...
r1348 const std::vector<std::shared_ptr<Variable> > &variables, int index,
drop of variables in the visualization
r850 VisualizationZoneWidget *zoneWidget)
{
Drag of product
r868 // Note: the AcceptMimeDataFunction (set on the drop container) ensure there is a single and
// compatible variable here
All the codebase is modified to build with new Variable Controller...
r1348 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(
const QVariantList &productsData, int index, VisualizationZoneWidget *zoneWidget)
{
// Note: the AcceptMimeDataFunction (set on the drop container) ensure there is a single and
// compatible variable here
if (productsData.count() != 1) {
qCWarning(LOG_VisualizationZoneWidget())
<< tr("VisualizationTabWidget::dropProducts, dropping multiple products, operation "
"aborted.");
return;
}
Creates graph when dropping a product in the visu
r1288 auto context = new QObject{zoneWidget};
All the codebase is modified to build with new Variable Controller...
r1348 connect(&sqpApp->variableController(), &VariableController2::variableAdded, context,
Creates graph when dropping a product in the visu
r1288 [this, index, zoneWidget, context](auto variable) {
zoneWidget->createGraph(variable, index);
delete context; // removes the connection
},
Qt::QueuedConnection);
drop of products in visu
r1287 auto productData = productsData.first().toHash();
QMetaObject::invokeMethod(&sqpApp->dataSourceController(), "requestVariable",
Qt::QueuedConnection, Q_ARG(QVariantHash, productData));
}