VisualizationActionManager.cpp
109 lines
| 4.8 KiB
| text/x-c
|
CppLexer
r1113 | #include "Visualization/VisualizationActionManager.h" | |||
r1114 | #include "Visualization/VisualizationGraphWidget.h" | |||
#include "Visualization/VisualizationSelectionZoneItem.h" | ||||
r1113 | ||||
#include <Actions/ActionsGuiController.h> | ||||
#include <SqpApplication.h> | ||||
VisualizationActionManager::VisualizationActionManager() {} | ||||
void VisualizationActionManager::installSelectionZoneActions() | ||||
{ | ||||
auto &actionController = sqpApp->actionsGuiController(); | ||||
r1115 | ||||
r1117 | auto removeZonesAction | |||
= actionController.addSectionZoneAction("Remove Selected Zone(s)", [](auto zones) { | ||||
for (auto selectionZone : zones) { | ||||
if (auto graph = selectionZone->parentGraphWidget()) { | ||||
graph->removeSelectionZone(selectionZone); | ||||
} | ||||
} | ||||
}); | ||||
removeZonesAction->setDisplayedShortcut(QKeySequence::Delete); | ||||
r1115 | ||||
r1116 | auto alignEnableFuntion = [](auto items) { return items.count() > 1; }; | |||
r1115 | ||||
r1116 | // Vertical alignment actions | |||
r1118 | auto alignLeftAction = actionController.addSectionZoneAction( | |||
QStringList{"Align Vertically"}, "Left", [](auto zones) { | ||||
Q_ASSERT(zones.count() > 1); | ||||
auto ref = zones.takeFirst(); | ||||
ref->alignZonesVerticallyOnLeft(zones, false); | ||||
}); | ||||
r1115 | alignLeftAction->setEnableFunction(alignEnableFuntion); | |||
r1118 | auto alignLeftBorderAction = actionController.addSectionZoneAction( | |||
QStringList{"Align Vertically"}, "Left Borders", [](auto zones) { | ||||
Q_ASSERT(zones.count() > 1); | ||||
auto ref = zones.takeFirst(); | ||||
ref->alignZonesVerticallyOnLeft(zones, true); | ||||
}); | ||||
r1116 | alignLeftBorderAction->setEnableFunction(alignEnableFuntion); | |||
r1118 | auto alignRightAction = actionController.addSectionZoneAction( | |||
QStringList{"Align Vertically"}, "Right", [](auto zones) { | ||||
Q_ASSERT(zones.count() > 1); | ||||
auto ref = zones.takeFirst(); | ||||
ref->alignZonesVerticallyOnRight(zones, false); | ||||
}); | ||||
r1115 | alignRightAction->setEnableFunction(alignEnableFuntion); | |||
r1116 | ||||
r1118 | auto alignRightBorderAction = actionController.addSectionZoneAction( | |||
QStringList{"Align Vertically"}, "Right Borders", [](auto zones) { | ||||
Q_ASSERT(zones.count() > 1); | ||||
auto ref = zones.takeFirst(); | ||||
ref->alignZonesVerticallyOnRight(zones, true); | ||||
}); | ||||
r1116 | alignRightBorderAction->setEnableFunction(alignEnableFuntion); | |||
auto alignLeftAndRightAction = actionController.addSectionZoneAction( | ||||
r1118 | QStringList{"Align Vertically"}, "Left and Right", [](auto zones) { | |||
r1116 | Q_ASSERT(zones.count() > 1); | |||
auto ref = zones.takeFirst(); | ||||
ref->alignZonesVerticallyOnLeft(zones, false); | ||||
ref->alignZonesVerticallyOnRight(zones, true); | ||||
}); | ||||
alignLeftAndRightAction->setEnableFunction(alignEnableFuntion); | ||||
// Temporal alignment actions | ||||
r1118 | auto alignLeftTemporallyAction = actionController.addSectionZoneAction( | |||
QStringList{"Align Temporally"}, "Left", [](auto zones) { | ||||
Q_ASSERT(zones.count() > 1); | ||||
auto ref = zones.takeFirst(); | ||||
ref->alignZonesTemporallyOnLeft(zones, false); | ||||
}); | ||||
r1116 | alignLeftTemporallyAction->setEnableFunction(alignEnableFuntion); | |||
r1118 | auto alignLeftBorderTemporallyAction = actionController.addSectionZoneAction( | |||
QStringList{"Align Temporally"}, "Left Borders", [](auto zones) { | ||||
Q_ASSERT(zones.count() > 1); | ||||
auto ref = zones.takeFirst(); | ||||
ref->alignZonesTemporallyOnLeft(zones, true); | ||||
}); | ||||
r1116 | alignLeftBorderTemporallyAction->setEnableFunction(alignEnableFuntion); | |||
r1118 | auto alignRightTemporallyAction = actionController.addSectionZoneAction( | |||
QStringList{"Align Temporally"}, "Right", [](auto zones) { | ||||
Q_ASSERT(zones.count() > 1); | ||||
auto ref = zones.takeFirst(); | ||||
ref->alignZonesTemporallyOnRight(zones, false); | ||||
}); | ||||
r1116 | alignRightTemporallyAction->setEnableFunction(alignEnableFuntion); | |||
r1118 | auto alignRightBorderTemporallyAction = actionController.addSectionZoneAction( | |||
QStringList{"Align Temporally"}, "Right Borders", [](auto zones) { | ||||
Q_ASSERT(zones.count() > 1); | ||||
auto ref = zones.takeFirst(); | ||||
ref->alignZonesTemporallyOnRight(zones, true); | ||||
}); | ||||
r1116 | alignRightBorderTemporallyAction->setEnableFunction(alignEnableFuntion); | |||
auto alignLeftAndRightTemporallyAction = actionController.addSectionZoneAction( | ||||
r1118 | QStringList{"Align Temporally"}, "Left and Right", [](auto zones) { | |||
r1116 | Q_ASSERT(zones.count() > 1); | |||
auto ref = zones.takeFirst(); | ||||
ref->alignZonesTemporallyOnLeft(zones, false); | ||||
ref->alignZonesTemporallyOnRight(zones, true); | ||||
}); | ||||
alignLeftAndRightTemporallyAction->setEnableFunction(alignEnableFuntion); | ||||
r1113 | } | |||