Engauge Digitizer  2
TutorialStateCurveSelection.cpp
Go to the documentation of this file.
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 <qmath.h>
13 #include "TutorialButton.h"
14 #include "TutorialDlg.h"
16 #include "TutorialStateContext.h"
17 
19  TutorialStateAbstractBase (context),
20  m_title (nullptr),
21  m_background (nullptr),
22  m_text0 (nullptr),
23  m_text1 (nullptr),
24  m_text2 (nullptr),
25  m_text3 (nullptr),
26  m_previous (nullptr),
27  m_colorFilter (nullptr),
28  m_next (nullptr)
29 {
30  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateCurveSelection::TutorialStateCurveSelection";
31 }
32 
34 {
35  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateCurveSelection::begin ()";
36 
37  context().tutorialDlg().scene().clear ();
38 
39  m_title = createTitle ("Curve Selection");
40  m_background = createPixmapItem (":/engauge/img/panel_curve_selection.png",
41  QPoint (0, 30));
42  m_text0 = createTextItem (tr ("After the axis points have been created, a\n"
43  "curve is selected to receive curve points.\n"
44  "Step 1 - click on Curve, Point Match, Color\n"
45  "Picker or Segment Fill buttons."),
46  QPoint (250, 40));
47  m_text1 = createTextItem (tr ("Step 2 - Select the desired curve name. If\n"
48  "that curve name has not been created yet,\n"
49  "use the menu option Settings / Curve Names\n"
50  "to create it."),
51  QPoint (250, 120));
52  m_text2 = createTextItem (tr ("Step 3 - Change the background from the\n"
53  "original image to the filtered image\n"
54  "produced for the current curve, using the\n"
55  "menu option View / Background / Filtered\n"
56  "Image. This filtering enables the powerful\n"
57  "automated algorithms discussed later in\n"
58  "the tutorial."),
59  QPoint (250, 200));
60  m_text3 = createTextItem (tr ("If the current curve is no longer visible\n"
61  "in the filtered image, then change the\n"
62  "current Color Filter settings. In the figure,\n"
63  "the orange points have disappeared."),
64  QPoint (250, 330));
65 
66  QSize backgroundSize = context().tutorialDlg().backgroundSize();
67 
68  m_previous = new TutorialButton (tr ("Previous"),
69  context().tutorialDlg().scene());
70  m_previous->setGeometry (QPoint (buttonMargin (),
71  backgroundSize.height() - buttonMargin() - m_previous->size().height()));
72  connect (m_previous, SIGNAL (signalTriggered ()), this, SLOT (slotPrevious ()));
73 
74  m_colorFilter = new TutorialButton (tr ("Color Filter Settings"),
75  context().tutorialDlg().scene());
76  m_colorFilter->setGeometry (QPoint (qFloor (backgroundSize.width () / 2.0 - m_colorFilter->size ().width () / 2),
77  qFloor (backgroundSize.height () - buttonMargin () - m_colorFilter->size ().height ())));
78  connect (m_colorFilter, SIGNAL (signalTriggered ()), this, SLOT (slotColorFilter ()));
79 
80  m_next = new TutorialButton (tr ("Next"),
81  context().tutorialDlg().scene());
82  m_next->setGeometry (QPoint (backgroundSize.width () - buttonMargin () - m_next->size ().width (),
83  backgroundSize.height () - buttonMargin () - m_next->size ().height ()));
84  connect (m_next, SIGNAL (signalTriggered ()), this, SLOT (slotNext ()));
85 }
86 
88 {
89  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateCurveSelection::end ()";
90 
91  // It is not safe to remove and deallocate items here since an active TutorialButton
92  // may be on the stack. So we clear the scene as the first step in the next begin()
93 }
94 
96 {
97  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateCurveSelection::slotColorFilter";
98 
100 }
101 
103 {
104  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateCurveSelection::slotNextCurves";
105 
107 }
108 
110 {
111  LOG4CPP_INFO_S ((*mainCat)) << "TutorialStateCurveSelection::slotPrevious";
112 
114 }
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.
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
QGraphicsScene & scene()
Single scene the covers the entire tutorial dialog.
Definition: TutorialDlg.cpp:76
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:44
void slotNext()
Slot called when next button is triggered.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
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.