2 #include <Scenario/Document/ScenarioDocument/ScenarioDocumentViewConstants.hpp>
3 #include <Scenario/Palette/ScenarioPaletteBaseTransitions.hpp>
4 #include <Scenario/Palette/ScenarioPoint.hpp>
5 #include <Scenario/Palette/Tools/ObjectMapper.hpp>
7 #include <score/model/Identifier.hpp>
8 #include <score/statemachine/GraphicsSceneTool.hpp>
10 #include <QGraphicsItem>
19 template <
typename Element>
20 bool isUnderMouse(Element ev,
const QPointF& scenePos)
22 return ev->mapRectToScene(ev->boundingRect()).contains(scenePos);
25 template <
typename PresenterContainer,
typename IdToIgnore>
26 QList<Id<typename PresenterContainer::model_type>> getCollidingModels(
27 const PresenterContainer& array,
const QVector<IdToIgnore>& ids, QPointF scenePt)
30 QList<Id<typename PresenterContainer::model_type>> colliding;
32 for(
const auto& elt : array)
34 if(!ids.contains(elt.id()) && isUnderMouse(elt.view(), scenePt))
36 colliding.push_back(elt.model().id());
45 template <
typename ToolPalette_T>
51 ToolBase(
const ToolPalette_T& palette)
59 typename EventFun,
typename StateFun,
typename TimeSyncFun,
typename IntervalFun,
60 typename LeftBraceFun,
typename RightBraceFun,
typename SlotHandleFun,
63 const QGraphicsItem* item, StateFun st_fun, EventFun ev_fun, TimeSyncFun tn_fun,
64 IntervalFun cst_fun, LeftBraceFun lbrace_fun, RightBraceFun rbrace_fun,
65 SlotHandleFun handle_fun, NothingFun nothing_fun)
const
72 auto tryFun = [=](
auto fun,
const auto& id) {
82 auto parent = &this->m_palette.model();
86 case ItemType::Condition:
87 tryFun(ev_fun, itemToConditionId(item, parent));
90 tryFun(ev_fun, itemToEventId(item, parent));
93 case ItemType::Interval:
94 tryFun(cst_fun, itemToIntervalId(item, parent));
96 case ItemType::GraphInterval:
97 tryFun(cst_fun, itemToGraphIntervalId(item, parent));
99 case ItemType::IntervalHeader:
100 tryFun(cst_fun, itemToIntervalId(item->parentItem(), parent));
102 case ItemType::LeftBrace:
103 tryFun(lbrace_fun, itemToIntervalId(item->parentItem(), parent));
105 case ItemType::RightBrace:
106 tryFun(rbrace_fun, itemToIntervalId(item->parentItem(), parent));
109 case ItemType::Trigger:
110 tryFun(tn_fun, itemToTriggerId(item, parent));
112 case ItemType::TimeSync:
113 tryFun(tn_fun, itemToTimeSyncId(item, parent));
116 case ItemType::StateOverlay:
117 tryFun(st_fun, itemToStateId(item->parentItem(), parent));
119 case ItemType::State:
120 tryFun(st_fun, itemToStateId(item, parent));
123 case ItemType::SlotFooter: {
124 if(
auto slot = itemToIntervalFromFooter(item, parent))
130 case ItemType::SlotFooterDelegate: {
131 if(
auto slot = itemToIntervalFromFooter(item->parentItem(), parent))
144 const ToolPalette_T& m_palette;
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: ObjectMapper.hpp:15