Engauge Digitizer  2
TutorialStatePointMatch.cpp
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #include "Logger.h"
8 #include <qdebug.h>
9 #include <QGraphicsPixmapItem>
10 #include <QGraphicsScene>
11 #include <QGraphicsView>
12 #include "TutorialButton.h"
13 #include "TutorialDlg.h"
14 #include "TutorialStateContext.h"
15 #include "TutorialStatePointMatch.h"
16 
19 {
20 }
21 
23 {
24  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStatePointMatch::begin ()";
25 
26  m_title = createTitle (tr ("Point Match"));
27  m_background = createPixmapItem (":/engauge/img/panel_point_match.png",
28  QPoint (0, 30));
29  m_text0 = createTextItem (tr ("In Point Match mode, you pick\n"
30  "one sample point, and Engauge\n"
31  "then finds all matching points.\n\n"
32  "Step 1 - Click on Point Match mode."),
33  QPoint (300, 40));
34  m_text1 = createTextItem (tr ("Step 2 - Select the curve the new\n"
35  "points will belong to."),
36  QPoint (320, 140));
37  m_text2 = createTextItem (tr ("Step 3 - Click on a typical point.\n"
38  "The circle turns green when it\n"
39  "contains what may be a point."),
40  QPoint (320, 200));
41  m_text3 = createTextItem (tr ("Step 4 - Engauge will show a\n"
42  "matched point with a yellow cross.\n"
43  "Press the Right Arrow key to accept\n"
44  "the matched point. Repeat this step\n"
45  "until there are no more points."),
46  QPoint (320, 270));
47 
48  QSize backgroundSize = context().tutorialDlg().backgroundSize();
49 
50  m_previous = new TutorialButton (tr ("Previous"),
51  context().tutorialDlg().scene());
52  m_previous->setGeometry (QPoint (buttonMargin (),
53  backgroundSize.height() - buttonMargin() - m_previous->size().height()));
54  connect (m_previous, SIGNAL (signalTriggered ()), this, SLOT (slotPrevious ()));
55 
56  m_next = new TutorialButton (tr ("Next"),
57  context().tutorialDlg().scene());
58  m_next->setGeometry (QPoint (backgroundSize.width () - buttonMargin () - m_next->size ().width (),
59  backgroundSize.height () - buttonMargin () - m_next->size ().height ()));
60  connect (m_next, SIGNAL (signalTriggered ()), this, SLOT (slotNext ()));
61 }
62 
64 {
65  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStatePointMatch::end ()";
66 
67  context().tutorialDlg().scene().removeItem (m_title);
68  context().tutorialDlg().scene().removeItem (m_background);
69  context().tutorialDlg().scene().removeItem (m_text0);
70  context().tutorialDlg().scene().removeItem (m_text1);
71  context().tutorialDlg().scene().removeItem (m_text2);
72  context().tutorialDlg().scene().removeItem (m_text3);
73  // TutorialButtons removes themselves from the scene
74 
75  delete m_title;
76  delete m_background;
77  delete m_text0;
78  delete m_text1;
79  delete m_text2;
80  delete m_text3;
81  delete m_next;
82  delete m_previous;
83 
84  m_title = 0;
85  m_background = 0;
86  m_text0 = 0;
87  m_text1 = 0;
88  m_text2 = 0;
89  m_text3 = 0;
90  m_next = 0;
91  m_previous = 0;
92 }
93 
95 {
96  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStatePointMatch::slotNext";
97 
98  context().requestDelayedStateTransition (TUTORIAL_STATE_CHECKLIST_WIZARD_POINTS);
99 }
100 
102 {
103  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStatePointMatch::slotPrevious";
104 
105  context().requestDelayedStateTransition (TUTORIAL_STATE_CURVE_TYPE);
106 }
One state manages one panel of the tutorial.
QSize size() const
Size of this button.
void setGeometry(const QPoint &pos)
Set the position. This is called after creation so screen extent is available for positioning calcula...
Show a button with text for clicking ion. The button is implemented using layering of two graphics it...
virtual void begin()
Transition into this state.
QGraphicsScene & scene()
Single scene the covers the entire tutorial dialog.
Definition: TutorialDlg.cpp:66
TutorialStateContext & context()
Context class for the tutorial state machine.
QGraphicsTextItem * createTextItem(const QString &text, const QPoint &pos)
Factory method for text items.
QGraphicsTextItem * createTitle(const QString &text)
Factory method for title items.
QGraphicsPixmapItem * createPixmapItem(const QString &resource, const QPoint &pos)
Factory method for pixmap items.
QSize backgroundSize() const
Make geometry available for layout.
Definition: TutorialDlg.cpp:34
virtual void end()
Transition out of this state.
Context class for tutorial state machine.
int buttonMargin() const
Buttons are placed up against bottom side, and left or right side, separated by this margin...
void requestDelayedStateTransition(TutorialState tutorialState)
Request a transition to the specified state from the current state.
TutorialStatePointMatch(TutorialStateContext &context)
Single constructor.
void slotNext()
Slot called when next button is triggered.
TutorialDlg & tutorialDlg()
Access to tutorial dialogs and its scene.
void slotPrevious()
Slot called to return to previous panel.