Engauge Digitizer  2
TutorialStateCurveSelection.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 "TutorialStateCurveSelection.h"
15 #include "TutorialStateContext.h"
16 
19 {
20 }
21 
23 {
24  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateCurveSelection::begin ()";
25 
26  m_title = createTitle ("Curve Selection");
27  m_background = createPixmapItem (":/engauge/img/panel_curve_selection.png",
28  QPoint (0, 30));
29  m_text0 = createTextItem (tr ("After the axis points have been created, a\n"
30  "curve is selected to receive curve points.\n"
31  "Step 1 - click on Curve, Point Match, Color\n"
32  "Picker or Segment Fill buttons."),
33  QPoint (250, 40));
34  m_text1 = createTextItem (tr ("Step 2 - Select the desired curve name. If\n"
35  "that curve name has not been created yet,\n"
36  "use the menu option Settings / Curve Names\n"
37  "to create it."),
38  QPoint (250, 120));
39  m_text2 = createTextItem (tr ("Step 3 - Change the background from the\n"
40  "original image to the filtered image\n"
41  "produced for the current curve, using the\n"
42  "menu option View / Background / Filtered\n"
43  "Image. This filtering enables the powerful\n"
44  "automated algorithms discussed later in\n"
45  "the tutorial."),
46  QPoint (250, 200));
47  m_text3 = createTextItem (tr ("If the current curve is no longer visible\n"
48  "in the filtered image, then change the\n"
49  "current Color Filter settings. In the figure,\n"
50  "the orange points have disappeared."),
51  QPoint (250, 330));
52 
53  QSize backgroundSize = context().tutorialDlg().backgroundSize();
54 
55  m_previous = new TutorialButton (tr ("Previous"),
56  context().tutorialDlg().scene());
57  m_previous->setGeometry (QPoint (buttonMargin (),
58  backgroundSize.height() - buttonMargin() - m_previous->size().height()));
59  connect (m_previous, SIGNAL (signalTriggered ()), this, SLOT (slotPrevious ()));
60 
61  m_colorFilter = new TutorialButton (tr ("Color Filter Settings"),
62  context().tutorialDlg().scene());
63  m_colorFilter->setGeometry (QPoint (backgroundSize.width () / 2.0 - m_colorFilter->size ().width () / 2,
64  backgroundSize.height () - buttonMargin () - m_colorFilter->size ().height ()));
65  connect (m_colorFilter, SIGNAL (signalTriggered ()), this, SLOT (slotColorFilter ()));
66 
67  m_next = new TutorialButton (tr ("Next"),
68  context().tutorialDlg().scene());
69  m_next->setGeometry (QPoint (backgroundSize.width () - buttonMargin () - m_next->size ().width (),
70  backgroundSize.height () - buttonMargin () - m_next->size ().height ()));
71  connect (m_next, SIGNAL (signalTriggered ()), this, SLOT (slotNext ()));
72 }
73 
75 {
76  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateCurveSelection::end ()";
77 
78  context().tutorialDlg().scene().removeItem (m_title);
79  context().tutorialDlg().scene().removeItem (m_background);
80  context().tutorialDlg().scene().removeItem (m_text0);
81  context().tutorialDlg().scene().removeItem (m_text1);
82  context().tutorialDlg().scene().removeItem (m_text2);
83  context().tutorialDlg().scene().removeItem (m_text3);
84  // TutorialButtons removes themselves from the scene
85 
86  delete m_title;
87  delete m_background;
88  delete m_text0;
89  delete m_text1;
90  delete m_text2;
91  delete m_text3;
92  delete m_next;
93  delete m_colorFilter;
94  delete m_previous;
95 
96  m_title = 0;
97  m_background = 0;
98  m_text0 = 0;
99  m_text1 = 0;
100  m_text2 = 0;
101  m_text3 = 0;
102  m_next = 0;
103  m_colorFilter = 0;
104  m_previous = 0;
105 }
106 
108 {
109  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateCurveSelection::slotColorFilter";
110 
111  context().requestDelayedStateTransition (TUTORIAL_STATE_COLOR_FILTER);
112 }
113 
115 {
116  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateCurveSelection::slotNextCurves";
117 
118  context().requestDelayedStateTransition (TUTORIAL_STATE_CURVE_TYPE);
119 }
120 
122 {
123  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateCurveSelection::slotPrevious";
124 
125  context().requestDelayedStateTransition (TUTORIAL_STATE_AXIS_POINTS);
126 }
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 end()
Transition out of this state.
TutorialStateCurveSelection(TutorialStateContext &context)
Single constructor.
QGraphicsScene & scene()
Single scene the covers the entire tutorial dialog.
Definition: TutorialDlg.cpp:66
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.
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
void slotNext()
Slot called when next button is triggered.
Context class for tutorial state machine.
void slotColorFilter()
Slot called when settings button is triggered.
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.
virtual void begin()
Transition into this state.