Engauge Digitizer  2
TutorialStateAxisPoints.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 "TutorialStateAxisPoints.h"
15 #include "TutorialStateContext.h"
16 
19 {
20 }
21 
23 {
24  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateAxisPoints::begin ()";
25 
26  m_title = createTitle (tr ("Axis Points"));
27  m_background = createPixmapItem (":/engauge/img/panel_axis_points.png",
28  QPoint (0, 30));
29  m_text0 = createTextItem (tr ("Axis points are first defined to\n"
30  "define the coordinates. Step 1 -\n"
31  "Click on the Axis Points button"),
32  QPoint (320, 60));
33  m_text1 = createTextItem (tr ("Step 2 - Click on an axis or grid\n"
34  "line with known coordinates. An axis\n"
35  "point appears, with a dialog window\n"
36  "for entering the axis point's\n"
37  "coordinates"),
38  QPoint (300, 210));
39  m_text2 = createTextItem (tr ("Step 3 - Enter the two coordinates\n"
40  "of the axis point and then click Ok.\n"
41  "Repeat steps 2 and 3 twice more\n"
42  "until three axis points are created"),
43  QPoint (280, 320));
44 
45  QSize backgroundSize = context().tutorialDlg().backgroundSize();
46 
47  m_previous = new TutorialButton (tr ("Previous"),
48  context().tutorialDlg().scene());
49  m_previous->setGeometry (QPoint (buttonMargin (),
50  backgroundSize.height() - buttonMargin() - m_previous->size().height()));
51  connect (m_previous, SIGNAL (signalTriggered ()), this, SLOT (slotPrevious ()));
52 
53  m_next = new TutorialButton (tr ("Next"),
54  context().tutorialDlg().scene());
55  m_next->setGeometry (QPoint (backgroundSize.width () - buttonMargin () - m_next->size ().width (),
56  backgroundSize.height () - buttonMargin () - m_next->size ().height ()));
57  connect (m_next, SIGNAL (signalTriggered ()), this, SLOT (slotNext ()));
58 }
59 
61 {
62  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateAxisPoints::end ()";
63 
64  context().tutorialDlg().scene().removeItem (m_title);
65  context().tutorialDlg().scene().removeItem (m_background);
66  context().tutorialDlg().scene().removeItem (m_text0);
67  context().tutorialDlg().scene().removeItem (m_text1);
68  context().tutorialDlg().scene().removeItem (m_text2);
69  // TutorialButtons removes themselves from the scene
70 
71  delete m_title;
72  delete m_background;
73  delete m_text0;
74  delete m_text1;
75  delete m_text2;
76  delete m_next;
77  delete m_previous;
78 
79  m_title = 0;
80  m_background = 0;
81  m_text0 = 0;
82  m_text1 = 0;
83  m_text2 = 0;
84  m_next = 0;
85  m_previous = 0;
86 }
87 
89 {
90  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateAxisPoints::slotNextCurves";
91 
92  context().requestDelayedStateTransition (TUTORIAL_STATE_CURVE_SELECTION);
93 }
94 
96 {
97  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateAxisPoints::slotPrevious";
98 
99  context().requestDelayedStateTransition (TUTORIAL_STATE_INTRODUCTION);
100 }
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...
void slotNext()
Slot called when next button is triggered.
virtual void begin()
Transition into this state.
QGraphicsScene & scene()
Single scene the covers the entire tutorial dialog.
Definition: TutorialDlg.cpp:66
TutorialStateAxisPoints(TutorialStateContext &context)
Single constructor.
void slotPrevious()
Slot called to return to previous panel.
TutorialStateContext & context()
Context class for the tutorial state machine.
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.
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
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.