Engauge Digitizer  2
TutorialStateCurveType.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 "TutorialStateCurveType.h"
16 
19 {
20 }
21 
23 {
24  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateCurveType::begin ()";
25 
26  m_title = createTitle (tr ("Curve Type"));
27  m_background = createPixmapItem (":/engauge/img/panel_lines_points.png",
28  QPoint (0, 0));
29  m_text0 = createTextItem (tr ("The next steps depend on how the curves\n"
30  "are drawn, in terms of lines and points."),
31  QPoint (240, 40));
32  m_text1 = createTextItem (tr ("If the curves are drawn\n"
33  "with lines (with or without\n"
34  "points) then click on\n"
35  "Next (Lines)."),
36  QPoint (265, 110));
37  m_text2 = createTextItem (tr ("If the curves are drawn\n"
38  "without lines and only\n"
39  "with points, then click on\n"
40  "Next (Points)."),
41  QPoint (265, 270));
42 
43  QSize backgroundSize = context().tutorialDlg().backgroundSize();
44 
45  m_previous = new TutorialButton (tr ("Previous"),
46  context().tutorialDlg().scene());
47  m_previous->setGeometry (QPoint (buttonMargin (),
48  backgroundSize.height () - buttonMargin() - m_previous->size().height()));
49  connect (m_previous, SIGNAL (signalTriggered ()), this, SLOT (slotPrevious ()));
50 
51  m_nextLines = new TutorialButton (tr ("Next (Lines)"),
52  context().tutorialDlg().scene());
53  m_nextLines->setGeometry (QPoint (backgroundSize.width () - buttonMargin () - m_nextLines->size ().width (),
54  backgroundSize.height () / 3.0 - m_nextLines->size ().height () / 2.0));
55  connect (m_nextLines, SIGNAL (signalTriggered ()), this, SLOT (slotNextCurves ()));
56 
57  m_nextPoints = new TutorialButton (tr ("Next (Points)"),
58  context().tutorialDlg().scene());
59  m_nextPoints->setGeometry (QPoint (backgroundSize.width () - buttonMargin () - m_nextPoints->size ().width (),
60  backgroundSize.height () * 2.0 / 3.0 - m_nextPoints->size ().height () / 2.0));
61  connect (m_nextPoints, SIGNAL (signalTriggered ()), this, SLOT (slotNextLines ()));
62 }
63 
65 {
66  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateCurveType::end ()";
67 
68  context().tutorialDlg().scene().removeItem (m_title);
69  context().tutorialDlg().scene().removeItem (m_background);
70  context().tutorialDlg().scene().removeItem (m_text0);
71  context().tutorialDlg().scene().removeItem (m_text1);
72  context().tutorialDlg().scene().removeItem (m_text2);
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_nextLines;
81  delete m_nextPoints;
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_nextLines = 0;
90  m_nextPoints = 0;
91  m_previous = 0;
92 }
93 
95 {
96  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateCurveType::slotNextCurves";
97 
98  context().requestDelayedStateTransition (TUTORIAL_STATE_SEGMENT_FILL);
99 }
100 
102 {
103  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateCurveType::slotNextLines";
104 
105  context().requestDelayedStateTransition (TUTORIAL_STATE_POINT_MATCH);
106 }
107 
109 {
110  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateCurveType::slotNextCurves";
111 
112  context().requestDelayedStateTransition (TUTORIAL_STATE_CURVE_SELECTION);
113 }
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
void slotNextCurves()
Slot called when next button for curves is triggered.
TutorialStateContext & context()
Context class for the tutorial state machine.
void slotNextLines()
Slot called when next button for lines is triggered.
QGraphicsTextItem * createTextItem(const QString &text, const QPoint &pos)
Factory method for text items.
virtual void end()
Transition out of this state.
QGraphicsTextItem * createTitle(const QString &text)
Factory method for title items.
void slotPrevious()
Slot called to return to previous panel.
QGraphicsPixmapItem * createPixmapItem(const QString &resource, const QPoint &pos)
Factory method for pixmap items.
TutorialStateCurveType(TutorialStateContext &context)
Single constructor.
QSize backgroundSize() const
Make geometry available for layout.
Definition: TutorialDlg.cpp:34
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.
TutorialDlg & tutorialDlg()
Access to tutorial dialogs and its scene.