void BackgroundStateContext::setBackgroundImage (BackgroundImage backgroundImage)
{
  LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateContext::setBackgroundImage"
                              << " background=" << backgroundImageToString (backgroundImage).toLatin1().data();

  BackgroundState backgroundState= BACKGROUND_STATE_NONE;
  
  switch (backgroundImage) {
    case BACKGROUND_IMAGE_FILTERED:
      backgroundState = BACKGROUND_STATE_CURVE;
      break;

    case BACKGROUND_IMAGE_NONE:
      backgroundState = BACKGROUND_STATE_NONE;
      break;

     case BACKGROUND_IMAGE_ORIGINAL:
      backgroundState = BACKGROUND_STATE_ORIGINAL;
      break;
  }

  // It is safe to transition to the new state immediately since no BackgroundState classes are on the stack
  requestStateTransition (backgroundState);
  completeRequestedStateTransitionIfExists ();
}
Пример #2
0
void DigitizeStateContext::handleLeave ()
{
  m_states [m_currentState]->handleLeave ();

  completeRequestedStateTransitionIfExists();

}
Пример #3
0
void DigitizeStateContext::handleKeyPress (Qt::Key key)
{
  m_states [m_currentState]->handleKeyPress (key);

  completeRequestedStateTransitionIfExists();

}
Пример #4
0
void DigitizeStateContext::handleMousePress (QPointF pos)
{
  m_states [m_currentState]->handleMousePress (pos);

  completeRequestedStateTransitionIfExists();

}
void DigitizeStateContext::handleLeave (CmdMediator *cmdMediator)
{
  m_states [m_currentState]->handleLeave (cmdMediator);

  completeRequestedStateTransitionIfExists(cmdMediator);

}
void BackgroundStateContext::close()
{
  LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateContext::close";

  // It is safe to transition to the new state immediately since no BackgroundState classes are on the stack
  requestStateTransition (BACKGROUND_STATE_UNLOADED);
  completeRequestedStateTransitionIfExists ();
}
void DigitizeStateContext::handleMouseRelease (CmdMediator *cmdMediator,
                                               QPointF pos)
{
  m_states [m_currentState]->handleMouseRelease (cmdMediator,
                                                 pos);

  completeRequestedStateTransitionIfExists(cmdMediator);
}
void DigitizeStateContext::resetOnLoad (CmdMediator *cmdMediator)
{
  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateContext::resetOnLoad";

  // Reset current state. At this point, the current state is DIGITIZE_STATE_EMPTY when opening the first document
  // so for consistency we always reset it so succeeding documents work the same way
  if (m_currentState != DIGITIZE_STATE_EMPTY) {
    m_requestedState = DIGITIZE_STATE_EMPTY;
    completeRequestedStateTransitionIfExists(cmdMediator);
  }
}
void DigitizeStateContext::handleKeyPress (CmdMediator *cmdMediator,
                                           Qt::Key key,
                                           bool atLeastOneSelectedItem)
{
  m_states [m_currentState]->handleKeyPress (cmdMediator,
                                             key,
                                             atLeastOneSelectedItem);

  completeRequestedStateTransitionIfExists(cmdMediator);

}
BackgroundStateContext::BackgroundStateContext(MainWindow &mainWindow) :
  m_mainWindow (mainWindow)
{
  LOG4CPP_INFO_S ((*mainCat)) << "BackgroundStateContext::BackgroundStateContext";

  // These states follow the same order as the BackgroundState enumeration
  m_states.insert (BACKGROUND_STATE_CURVE   , new BackgroundStateCurve    (*this, mainWindow.scene()));
  m_states.insert (BACKGROUND_STATE_NONE    , new BackgroundStateNone     (*this, mainWindow.scene()));
  m_states.insert (BACKGROUND_STATE_ORIGINAL, new BackgroundStateOriginal (*this, mainWindow.scene()));
  m_states.insert (BACKGROUND_STATE_UNLOADED, new BackgroundStateUnloaded (*this, mainWindow.scene()));
  ENGAUGE_ASSERT (m_states.size () == NUM_BACKGROUND_STATES);

  m_currentState = NUM_BACKGROUND_STATES; // Value that forces a transition right away
  requestStateTransition (BACKGROUND_STATE_UNLOADED);
  completeRequestedStateTransitionIfExists();
}
void TutorialStateContext::createStates ()
{
  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateContext::createStates";

  // These states follow the same order as the TutorialState enumeration
  m_states.insert (TUTORIAL_STATE_AXIS_POINTS            , new TutorialStateAxisPoints            (*this));
  m_states.insert (TUTORIAL_STATE_CHECKLIST_WIZARD_LINES , new TutorialStateChecklistWizardLines  (*this));
  m_states.insert (TUTORIAL_STATE_CHECKLIST_WIZARD_POINTS, new TutorialStateChecklistWizardPoints (*this));
  m_states.insert (TUTORIAL_STATE_COLOR_FILTER           , new TutorialStateColorFilter           (*this));
  m_states.insert (TUTORIAL_STATE_CURVE_SELECTION        , new TutorialStateCurveSelection        (*this));
  m_states.insert (TUTORIAL_STATE_CURVE_TYPE             , new TutorialStateCurveType             (*this));
  m_states.insert (TUTORIAL_STATE_INTRODUCTION           , new TutorialStateIntroduction          (*this));
  m_states.insert (TUTORIAL_STATE_POINT_MATCH            , new TutorialStatePointMatch            (*this));
  m_states.insert (TUTORIAL_STATE_SEGMENT_FILL           , new TutorialStateSegmentFill           (*this));
  ENGAUGE_ASSERT (m_states.size () == NUM_TUTORIAL_STATES);

  m_currentState = NUM_TUTORIAL_STATES; // Value that forces a transition right away;
  requestImmediateStateTransition (TUTORIAL_STATE_INTRODUCTION);
  completeRequestedStateTransitionIfExists ();
}
Пример #12
0
void DigitizeStateContext::requestImmediateStateTransition (DigitizeState digitizeState)
{
  m_requestedState = digitizeState;
  completeRequestedStateTransitionIfExists();
}
void TutorialStateContext::slotTimeout()
{
  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateContext::slotTimeout";

  completeRequestedStateTransitionIfExists();
}
void DigitizeStateContext::requestImmediateStateTransition (CmdMediator *cmdMediator,
                                                            DigitizeState digitizeState)
{
  m_requestedState = digitizeState;
  completeRequestedStateTransitionIfExists(cmdMediator);
}