Esempio n. 1
0
 void stop()
 {
     if(localSM().isRunning())
     {
         on_cancel();
         localSM().stop();
     }
 }
Esempio n. 2
0
void CreationTool::on_pressed(QPointF scene, Scenario::Point sp)
{
    mapTopItem(itemUnderMouse(scene),

    // Press a state
    [&] (const Id<StateModel>& id)
    { localSM().postEvent(new ClickOnState_Event{id, sp}); },

    // Press an event
    [&] (const Id<EventModel>& id)
    { localSM().postEvent(new ClickOnEvent_Event{id, sp}); },

    // Press a TimeNode
    [&] (const Id<TimeNodeModel>& id)
    { localSM().postEvent(new ClickOnTimeNode_Event{id, sp}); },

    // Press a Constraint
    [&] (const Id<ConstraintModel>&)
    { },

    // Press a slot handle
    [&] (const SlotModel&)
    { },

    // Click on the background
    [&] ()
    {

        // Here we have the logic for the creation in nothing
        // where we instead choose the latest state if selected
        if(auto state = furthestSelectedState(m_parentSM.model()))
        {
            if(m_parentSM.model().events.at(state->eventId()).date() < sp.date)
            {
                localSM().postEvent(new ClickOnState_Event{
                                        state->id(),
                                        sp});
                return;
            }
        }

        localSM().postEvent(new ClickOnNothing_Event{sp});

    });
}
Esempio n. 3
0
void CreationTool::on_released(QPointF scene, Scenario::Point sp)
{
    if(auto cs = currentState())
    {
        mapWithCollision(scene,
        [&] (const Id<StateModel>& id)
        { localSM().postEvent(new ReleaseOnState_Event{id, sp}); },
        [&] (const Id<EventModel>& id)
        { localSM().postEvent(new ReleaseOnEvent_Event{id, sp}); },
        [&] (const Id<TimeNodeModel>& id)
        { localSM().postEvent(new ReleaseOnTimeNode_Event{id, sp}); },
        [&] ()
        { localSM().postEvent(new ReleaseOnNothing_Event{sp}); },
        cs->createdStates,
        cs->createdEvents,
        cs->createdTimeNodes);
    }
}
Esempio n. 4
0
ToolState::ToolState(const QGraphicsScene &scene, QState* parent):
    QState{parent},
    m_scene{scene}
{
    auto t_click = iscore::make_transition<iscore::Press_Transition>(this, this);
    connect(t_click, &QAbstractTransition::triggered,
            this,    &ToolState::on_pressed);

    auto t_move = iscore::make_transition<iscore::Move_Transition>(this, this);
    connect(t_move, &QAbstractTransition::triggered,
            this,   &ToolState::on_moved);

    auto t_rel = iscore::make_transition<iscore::Release_Transition>(this, this);
    connect(t_rel, &QAbstractTransition::triggered,
            this,  &ToolState::on_released);

    auto t_cancel = iscore::make_transition<iscore::Cancel_Transition>(this, this);
    connect(t_cancel, &QAbstractTransition::triggered,
            [&] () { localSM().postEvent(new iscore::Cancel_Event); });
}
Esempio n. 5
0
 void on_cancel()
 {
     localSM().postEvent(new iscore::Cancel_Event);
     QApplication::processEvents();
 }
Esempio n. 6
0
 void start()
 {
     if(!localSM().isRunning())
         localSM().start();
 }
Esempio n. 7
0
void ToolState::stop()
{
    if(localSM().isRunning())
        localSM().stop();
}
Esempio n. 8
0
void ToolState::start()
{
    if(!localSM().isRunning())
        localSM().start();
}
Esempio n. 9
0
CreationTool::CreationTool(ToolPalette& sm) :
    ToolBase{sm}
{
    m_waitState = new QState;
    localSM().addState(m_waitState);
    localSM().setInitialState(m_waitState);

    Path<ScenarioModel> scenarioPath = m_parentSM.model();

    //// Create from nothing ////
    m_createFromNothingState = new Creation_FromNothing{
            m_parentSM,
            scenarioPath,
            m_parentSM.commandStack(), nullptr};

    iscore::make_transition<ClickOnNothing_Transition>(m_waitState, m_createFromNothingState, *m_createFromNothingState);
    m_createFromNothingState->addTransition(m_createFromNothingState, SIGNAL(finished()), m_waitState);

    localSM().addState(m_createFromNothingState);


    //// Create from an event ////
    m_createFromEventState = new Creation_FromEvent{
            m_parentSM,
            scenarioPath,
            m_parentSM.commandStack(), nullptr};

    iscore::make_transition<ClickOnEvent_Transition>(m_waitState, m_createFromEventState, *m_createFromEventState);
    m_createFromEventState->addTransition(m_createFromEventState, SIGNAL(finished()), m_waitState);

    localSM().addState(m_createFromEventState);


    //// Create from a timenode ////
    m_createFromTimeNodeState = new Creation_FromTimeNode{
            m_parentSM,
            scenarioPath,
            m_parentSM.commandStack(), nullptr};

    iscore::make_transition<ClickOnTimeNode_Transition>(m_waitState,
                                                m_createFromTimeNodeState,
                                                *m_createFromTimeNodeState);
    m_createFromTimeNodeState->addTransition(m_createFromTimeNodeState, SIGNAL(finished()), m_waitState);

    localSM().addState(m_createFromTimeNodeState);


    //// Create from a State ////
    m_createFromStateState = new Creation_FromState{
            m_parentSM,
            scenarioPath,
            m_parentSM.commandStack(), nullptr};

    iscore::make_transition<ClickOnState_Transition>(m_waitState,
                                             m_createFromStateState,
                                             *m_createFromStateState);

    m_createFromStateState->addTransition(m_createFromStateState, SIGNAL(finished()), m_waitState);

    localSM().addState(m_createFromStateState);

    localSM().start();
}