VisualizationActionManager.cpp
109 lines
| 4.8 KiB
| text/x-c
|
CppLexer
r1078 | #include "Visualization/VisualizationActionManager.h" | |||
r1079 | #include "Visualization/VisualizationGraphWidget.h" | |||
#include "Visualization/VisualizationSelectionZoneItem.h" | ||||
r1078 | ||||
#include <Actions/ActionsGuiController.h> | ||||
#include <SqpApplication.h> | ||||
VisualizationActionManager::VisualizationActionManager() {} | ||||
void VisualizationActionManager::installSelectionZoneActions() | ||||
{ | ||||
auto &actionController = sqpApp->actionsGuiController(); | ||||
r1080 | ||||
r1082 | 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); | ||||
r1080 | ||||
r1081 | auto alignEnableFuntion = [](auto items) { return items.count() > 1; }; | |||
r1080 | ||||
r1081 | // Vertical alignment actions | |||
r1083 | auto alignLeftAction = actionController.addSectionZoneAction( | |||
QStringList{"Align Vertically"}, "Left", [](auto zones) { | ||||
Q_ASSERT(zones.count() > 1); | ||||
auto ref = zones.takeFirst(); | ||||
ref->alignZonesVerticallyOnLeft(zones, false); | ||||
}); | ||||
r1080 | alignLeftAction->setEnableFunction(alignEnableFuntion); | |||
r1083 | auto alignLeftBorderAction = actionController.addSectionZoneAction( | |||
QStringList{"Align Vertically"}, "Left Borders", [](auto zones) { | ||||
Q_ASSERT(zones.count() > 1); | ||||
auto ref = zones.takeFirst(); | ||||
ref->alignZonesVerticallyOnLeft(zones, true); | ||||
}); | ||||
r1081 | alignLeftBorderAction->setEnableFunction(alignEnableFuntion); | |||
r1083 | auto alignRightAction = actionController.addSectionZoneAction( | |||
QStringList{"Align Vertically"}, "Right", [](auto zones) { | ||||
Q_ASSERT(zones.count() > 1); | ||||
auto ref = zones.takeFirst(); | ||||
ref->alignZonesVerticallyOnRight(zones, false); | ||||
}); | ||||
r1080 | alignRightAction->setEnableFunction(alignEnableFuntion); | |||
r1081 | ||||
r1083 | auto alignRightBorderAction = actionController.addSectionZoneAction( | |||
QStringList{"Align Vertically"}, "Right Borders", [](auto zones) { | ||||
Q_ASSERT(zones.count() > 1); | ||||
auto ref = zones.takeFirst(); | ||||
ref->alignZonesVerticallyOnRight(zones, true); | ||||
}); | ||||
r1081 | alignRightBorderAction->setEnableFunction(alignEnableFuntion); | |||
auto alignLeftAndRightAction = actionController.addSectionZoneAction( | ||||
r1083 | QStringList{"Align Vertically"}, "Left and Right", [](auto zones) { | |||
r1081 | Q_ASSERT(zones.count() > 1); | |||
auto ref = zones.takeFirst(); | ||||
ref->alignZonesVerticallyOnLeft(zones, false); | ||||
ref->alignZonesVerticallyOnRight(zones, true); | ||||
}); | ||||
alignLeftAndRightAction->setEnableFunction(alignEnableFuntion); | ||||
// Temporal alignment actions | ||||
r1083 | auto alignLeftTemporallyAction = actionController.addSectionZoneAction( | |||
QStringList{"Align Temporally"}, "Left", [](auto zones) { | ||||
Q_ASSERT(zones.count() > 1); | ||||
auto ref = zones.takeFirst(); | ||||
ref->alignZonesTemporallyOnLeft(zones, false); | ||||
}); | ||||
r1081 | alignLeftTemporallyAction->setEnableFunction(alignEnableFuntion); | |||
r1083 | auto alignLeftBorderTemporallyAction = actionController.addSectionZoneAction( | |||
QStringList{"Align Temporally"}, "Left Borders", [](auto zones) { | ||||
Q_ASSERT(zones.count() > 1); | ||||
auto ref = zones.takeFirst(); | ||||
ref->alignZonesTemporallyOnLeft(zones, true); | ||||
}); | ||||
r1081 | alignLeftBorderTemporallyAction->setEnableFunction(alignEnableFuntion); | |||
r1083 | auto alignRightTemporallyAction = actionController.addSectionZoneAction( | |||
QStringList{"Align Temporally"}, "Right", [](auto zones) { | ||||
Q_ASSERT(zones.count() > 1); | ||||
auto ref = zones.takeFirst(); | ||||
ref->alignZonesTemporallyOnRight(zones, false); | ||||
}); | ||||
r1081 | alignRightTemporallyAction->setEnableFunction(alignEnableFuntion); | |||
r1083 | auto alignRightBorderTemporallyAction = actionController.addSectionZoneAction( | |||
QStringList{"Align Temporally"}, "Right Borders", [](auto zones) { | ||||
Q_ASSERT(zones.count() > 1); | ||||
auto ref = zones.takeFirst(); | ||||
ref->alignZonesTemporallyOnRight(zones, true); | ||||
}); | ||||
r1081 | alignRightBorderTemporallyAction->setEnableFunction(alignEnableFuntion); | |||
auto alignLeftAndRightTemporallyAction = actionController.addSectionZoneAction( | ||||
r1083 | QStringList{"Align Temporally"}, "Left and Right", [](auto zones) { | |||
r1081 | Q_ASSERT(zones.count() > 1); | |||
auto ref = zones.takeFirst(); | ||||
ref->alignZonesTemporallyOnLeft(zones, false); | ||||
ref->alignZonesTemporallyOnRight(zones, true); | ||||
}); | ||||
alignLeftAndRightTemporallyAction->setEnableFunction(alignEnableFuntion); | ||||
r1078 | } | |||