Engauge Digitizer  2
ChecklistGuideWizard.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 "ChecklistGuidePage.h"
11 #include "ChecklistGuideWizard.h"
12 #include "ChecklistTemplate.h"
13 #include "ColorFilterSettings.h"
14 #include "EngaugeAssert.h"
15 #include "Logger.h"
16 #include "MainWindow.h"
17 #include <QGridLayout>
18 #include <QHeaderView>
19 #include <QPushButton>
20 #include <QRadioButton>
21 #include <QTextStream>
22 #include <QVBoxLayout>
23 
25  unsigned int numberCoordSystem) :
26  m_mainWindow (mainWindow),
27  m_dialogName (tr ("Checklist Guide"))
28 {
29  setWindowTitle (tr ("Checklist Guide Wizard"));
30  setModal (true);
31  QPixmap splash (":/engauge/img/SpreadsheetsForDoc.png");
32  setPixmap (QWizard::WatermarkPixmap, splash); // For ClassicStyle and ModernStyle
33  setPixmap (QWizard::BackgroundPixmap, splash); // For MacStyle
34 
35  m_pageIntro = new ChecklistGuidePageIntro();
36  addPage(m_pageIntro);
37 
38  for (CoordSystemIndex coordSystemIndex = 0; coordSystemIndex < numberCoordSystem; coordSystemIndex++) {
39  m_pageCurves.push_back (new ChecklistGuidePageCurves(pageCurvesTitle (coordSystemIndex, numberCoordSystem)));
40  addPage(m_pageCurves.last());
41  }
42 
43  m_pageConclusion = new ChecklistGuidePageConclusion();
44  addPage(m_pageConclusion);
45 }
46 
47 QStringList ChecklistGuideWizard::curveNames(CoordSystemIndex coordSystemIndex) const
48 {
49  return m_pageCurves [signed (coordSystemIndex)]->curveNames();
50 }
51 
52 QString ChecklistGuideWizard::pageCurvesTitle (CoordSystemIndex coordSystemIndex,
53  unsigned int numberCoordSystem) const
54 {
55  LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuideWizard::pageCurvesTitle";
56 
57  ENGAUGE_ASSERT (coordSystemIndex < numberCoordSystem);
58 
59  if (numberCoordSystem == 1) {
60 
61  // Single curve needs no index information
62  return tr ("Curves");
63 
64  } else {
65 
66  // One of multiple curves needs index information
67  unsigned int indexOneBased = coordSystemIndex + 1;
68  return QString ("%1 %2")
69  .arg (QObject::tr ("Curves for coordinate system"))
70  .arg (indexOneBased);
71 
72  }
73 }
74 
76  CurvesGraphs &curvesGraphs)
77 {
78  LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuideWizard::populateCurvesGraphs";
79 
80  QStringList curveNames = m_pageCurves [signed (coordSystemIndex)]->curveNames();
81  QStringList::const_iterator itr;
82  for (itr = curveNames.begin(); itr != curveNames.end(); itr++) {
83 
84  QString curveName = *itr;
85 
86  curvesGraphs.addGraphCurveAtEnd(Curve (curveName,
89  PointStyle::defaultGraphCurve (curvesGraphs.numCurves ()))));
90  }
91 }
92 
93 QString ChecklistGuideWizard::templateHtml (CoordSystemIndex coordSystemIndex) const
94 {
95  LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuideWizard::templateHtml";
96 
97  QStringList curveNames = m_pageCurves [signed (coordSystemIndex)]->curveNames();
98  bool withLines = m_pageCurves [signed (coordSystemIndex)]->withLines();
99 
100  QString html;
101  QTextStream str (&html);
102 
103  // Insert additional space between successive list items, using stylesheet
104  str << "<style type='text/css'>li { margin-top: 10px 0; }</style>";
105 
106  str << "<p>" << tr ("Follow this checklist of steps to digitize your image. Each step will show a check when it has been completed.");
107  str << "<p>" << tr ("The coordinates are defined by creating axis points") << ":</p>\n";
108  str << "<p>" << TAG_ANCHOR_AXIS_1 << "&nbsp;" << tr ("Add first of three axis points.") << " " << TAG_AHREF_AXIS_1 << "</p>\n";
109  str << TAG_DIV_AXIS_START_1;
110  str << "<ul>\n";
111  str << "<li>" << tr ("Click on") << " <img src="":/engauge/img/16-DigitAxis""> " << tr ("for Axis Points mode") << "</li>\n";
112  str << "<li>" << tr ("Click on an axis tick mark, or intersection of two grid lines, with labeled coordinates") << "</li>\n";
113  str << "<li>" << tr ("Enter the coordinates of the axis point") << "</li>\n";
114  str << "<li>" << tr ("Click on Ok") << "</li>\n";
115  str << "</ul>\n";
116  str << TAG_DIV_AXIS_END_1;
117  str << "<p>" << TAG_ANCHOR_AXIS_2 << "&nbsp;" << tr ("Add second of three axis points.") << " " << TAG_AHREF_AXIS_2 << "</p>\n";
118  str << TAG_DIV_AXIS_START_2;
119  str << "<ul>\n";
120  str << "<li>" << tr ("Click on") << " <img src="":/engauge/img/16-DigitAxis""> " << tr ("for Axis Points mode") << "</li>\n";
121  str << "<li>" << tr ("Click on an axis tick mark, or intersection of two grid lines, with labeled coordinates, away from the other axis point") << "</li>\n";
122  str << "<li>" << tr ("Enter the coordinates of the axis point") << "</li>\n";
123  str << "<li>" << tr ("Click on Ok") << "</li>\n";
124  str << "</ul>\n";
125  str << TAG_DIV_AXIS_END_2;
126  str << "<p>" << TAG_ANCHOR_AXIS_3 << "&nbsp;" << tr ("Add third of three axis points.") << " " << TAG_AHREF_AXIS_3 << "</p>\n";
127  str << TAG_DIV_AXIS_START_3;
128  str << "<ul>\n";
129  str << "<li>" << tr ("Click on") << " <img src="":/engauge/img/16-DigitAxis""> " << tr ("for Axis Points mode") << "</li>\n";
130  str << "<li>" << tr ("Click on an axis tick mark, or intersection of two grid lines, with labeled coordinates, away from the other axis points") << "</li>\n";
131  str << "<li>" << tr ("Enter the coordinates of the axis point") << "</li>\n";
132  str << "<li>" << tr ("Click on Ok") << "</li>\n";
133  str << "</ul>\n";
134  str << TAG_DIV_AXIS_END_3;
135 
136  str << "<p>&nbsp;</p>\n";
137  str << "<p>" << tr ("Points are digitized along each curve") << ":</p>\n";
138  QStringList::const_iterator itr;
139  for (itr = curveNames.begin(); itr != curveNames.end(); itr++) {
140 
141  QString curveName = *itr;
142 
143  QString tagACurve = QString ("%1%2%3")
145  .arg (curveName)
147 
148  str << "<p>" << TAG_ANCHOR_DELIMITER_START << curveName << TAG_ANCHOR_DELIMITER_END
149  << "&nbsp;" << tr ("Add points for curve") << " <b>" << curveName << "</b>. " << tagACurve << "</p>\n";
150  str << TAG_DIV_DELIMITER_START << curveName << TAG_DIV_DELIMITER_END;
151  str << "<ul>\n";
152 
153  if (withLines) {
154 
155  str << "<li>" << tr ("Click on") << " <img src="":/engauge/img/16-DigitSegment""> " << tr ("for Segment Fill mode") << "</li>\n";
156  str << "<li>" << tr ("Select curve") << " <b>" << curveName << "</b> " << tr ("in the drop-down list") << "</li>\n";
157  str << "<li>" << tr ("Move the cursor over the curve. If a line does not appear then adjust the Color Filter settings for this curve") << ":\n";
158  str << templateHtmlToAdjustColorFilterSettings () << "</li>\n";
159  str << "<li>" << tr ("Move the cursor over the curve again. When the Segment Fill line appears, click on it to generate points") << "</li>\n";
160  str << "</ul>\n";
161 
162  } else {
163 
164  str << "<li>" << tr ("Click on") << " <img src="":/engauge/img/16-DigitPointMatch""> " << tr ("for Point Match mode") << "</li>\n";
165  str << "<li>" << tr ("Select curve") << " <b>" << curveName << "</b> " << tr ("in the drop-down list") << "</li>\n";
166  str << "<li>" << tr ("Move the cursor over a typical point in the curve. If the cursor circle does not change color then adjust "
167  "the Color Filter settings for this curve") << ":\n";
168  str << templateHtmlToAdjustColorFilterSettings () << "</li>\n";
169  str << "<li>" << tr ("Move the cursor over a typical point in the curve again. Click on the point to start point matching") << "</li>\n";
170  str << "<li>" << tr ("Engauge will display a candidate point. To accept that candidate point, press the right arrow key") << "</li>\n";
171  str << "<li>" << tr ("The previous step repeats until you select a different mode") << "</li>\n";
172  str << "</ul>\n";
173  }
174 
176  }
177 
178  str << "<p>&nbsp;</p>\n";
179  str << "<p>" << tr ("The digitized points can be exported") << ":</p>\n";
180  str << "<p>" << TAG_ANCHOR_EXPORT << "&nbsp;" << tr ("Export the points to a file") << ". " << TAG_AHREF_EXPORT << "</p>\n";
181  str << TAG_DIV_EXPORT_START;
182  str << "<ul>\n";
183  str << "<li>" << tr ("Select menu option File / Export") << "</li>\n";
184  str << "<li>" << tr ("Enter the file name") << "</li>\n";
185  str << "<li>" << tr ("Click on Ok") << "</li>\n";
186  str << "<li>" << tr ("Congratulations!") << "</li>\n";
187  str << "</ul>\n";
188  str << TAG_DIV_EXPORT_END;
189 
190  str << "<p>&nbsp;</p>\n";
191  str << "<p>" << tr ("Hint - The background image can be switched between the original image and filtered image.") << " " << TAG_AHREF_BACKGROUND << "</p>\n";
193  str << "<ul>\n";
194  str << "<li>" << tr ("Select menu option View / Background / Show Original Image to see the original image") << "</li>\n";
195  str << "<li>" << tr ("Select menu option View / Background / Show Filtered Image to see the image from Color Filter") << "</li>\n";
196  str << "</ul>\n";
197  str << TAG_DIV_BACKGROUND_END;
198 
199  return html;
200 }
201 
202 QString ChecklistGuideWizard::templateHtmlToAdjustColorFilterSettings () const
203 {
204  LOG4CPP_INFO_S ((*mainCat)) << "ChecklistGuideWizard::templateHtmlToAdjustColorFilterSettings";
205 
206  QString html;
207  QTextStream str (&html);
208 
209  str << " <ul>\n";
210  str << " <li>" << tr ("Select menu option Settings / Color Filter") << "<li>\n";
211  str << " <li>" << tr ("Select the method for filtering. Hue is best if the curves have different colors") << "</li>\n";
212  str << " <li>" << tr ("Slide the green buttons back and forth until the curve is easily visible in the preview window") << "</li>\n";
213  str << " <li>" << tr ("Click on Ok") << "</li>\n";
214  str << " </ul>\n";
215 
216  return html;
217 }
LineStyle::defaultGraphCurve
static LineStyle defaultGraphCurve(int index)
Initial default for index'th graph curve.
Definition: LineStyle.cpp:84
ChecklistGuideWizard::populateCurvesGraphs
void populateCurvesGraphs(CoordSystemIndex coordSystemIndex, CurvesGraphs &curvesGraphs)
Create entries in CurvesGraphs for each curve name that user provided.
Definition: ChecklistGuideWizard.cpp:75
ChecklistGuideWizard.h
TAG_DIV_AXIS_END_2
const QString TAG_DIV_AXIS_END_2
TAG_DIV_DELIMITER_START
const QString TAG_DIV_DELIMITER_START
TAG_DIV_AXIS_END_1
const QString TAG_DIV_AXIS_END_1
TAG_AHREF_EXPORT
const QString TAG_AHREF_EXPORT
TAG_DIV_AXIS_START_2
const QString TAG_DIV_AXIS_START_2
TAG_ANCHOR_AXIS_2
const QString TAG_ANCHOR_AXIS_2
PointStyle::defaultGraphCurve
static PointStyle defaultGraphCurve(int index)
Initial default for index'th graph curve.
Definition: PointStyle.cpp:88
TAG_ANCHOR_DELIMITER_START
const QString TAG_ANCHOR_DELIMITER_START
TAG_AHREF_AXIS_1
const QString TAG_AHREF_AXIS_1
EngaugeAssert.h
ChecklistGuideWizard::ChecklistGuideWizard
ChecklistGuideWizard(MainWindow &mainWindow, unsigned int numberCoordSystem)
Single constructor.
Definition: ChecklistGuideWizard.cpp:24
TAG_ANCHOR_EXPORT
const QString TAG_ANCHOR_EXPORT
TAG_DIV_AXIS_START_3
const QString TAG_DIV_AXIS_START_3
ChecklistGuidePageCurves.h
Curve
Container for one set of digitized Points.
Definition: Curve.h:32
ChecklistGuidePageIntro
This class sets up the introduction page.
Definition: ChecklistGuidePageIntro.h:12
CoordSystemIndex
unsigned int CoordSystemIndex
Zero-based index for identifying CoordSystem instantiations.
Definition: CoordSystemIndex.h:10
TAG_ANCHOR_DELIMITER_END
const QString TAG_ANCHOR_DELIMITER_END
TAG_DIV_EXPORT_END
const QString TAG_DIV_EXPORT_END
TAG_DIV_AXIS_END_3
const QString TAG_DIV_AXIS_END_3
TAG_DIV_AXIS_START_1
const QString TAG_DIV_AXIS_START_1
CurveStyle
Container for LineStyle and PointStyle for one Curve.
Definition: CurveStyle.h:17
TAG_AHREF_DELIMITER_END
const QString TAG_AHREF_DELIMITER_END
TAG_DIV_DELIMITER_START_SLASH
const QString TAG_DIV_DELIMITER_START_SLASH
MainWindow
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:90
ChecklistGuidePageIntro.h
Logger.h
ColorFilterSettings.h
ColorFilterSettings::defaultFilter
static ColorFilterSettings defaultFilter()
Initial default for any Curve.
Definition: ColorFilterSettings.cpp:128
TAG_AHREF_BACKGROUND
const QString TAG_AHREF_BACKGROUND
TAG_AHREF_AXIS_3
const QString TAG_AHREF_AXIS_3
ChecklistTemplate.h
LOG4CPP_INFO_S
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
CurvesGraphs
Container for all graph curves. The axes point curve is external to this class.
Definition: CurvesGraphs.h:23
TAG_DIV_BACKGROUND_END
const QString TAG_DIV_BACKGROUND_END
mainCat
log4cpp::Category * mainCat
Definition: Logger.cpp:14
MainWindow.h
TAG_DIV_EXPORT_START
const QString TAG_DIV_EXPORT_START
TAG_AHREF_AXIS_2
const QString TAG_AHREF_AXIS_2
TAG_DIV_BACKGROUND_START
const QString TAG_DIV_BACKGROUND_START
CurvesGraphs::numCurves
int numCurves() const
Current number of graphs curves.
Definition: CurvesGraphs.cpp:241
CurvesGraphs::addGraphCurveAtEnd
void addGraphCurveAtEnd(const Curve &curve)
Append new graph Curve to end of Curve list.
Definition: CurvesGraphs.cpp:24
ChecklistGuideWizard::curveNames
QStringList curveNames(CoordSystemIndex coordSystemIndex) const
Curve names to be placed into Document.
Definition: ChecklistGuideWizard.cpp:47
TAG_AHREF_DELIMITER_START
const QString TAG_AHREF_DELIMITER_START
TAG_ANCHOR_AXIS_1
const QString TAG_ANCHOR_AXIS_1
ChecklistGuidePageConclusion.h
ChecklistGuidePage.h
ChecklistGuideWizard::templateHtml
QString templateHtml(CoordSystemIndex coordSystemIndex) const
Template html comprising the checklist for display.
Definition: ChecklistGuideWizard.cpp:93
TAG_ANCHOR_AXIS_3
const QString TAG_ANCHOR_AXIS_3
ENGAUGE_ASSERT
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
Definition: EngaugeAssert.h:19
ChecklistGuidePageCurves
This class adds validation to the Curves page.
Definition: ChecklistGuidePageCurves.h:16
TAG_DIV_DELIMITER_END
const QString TAG_DIV_DELIMITER_END
ChecklistGuidePageConclusion
This class uses the validation method of the Conclusion page to perform final processing for Checklis...
Definition: ChecklistGuidePageConclusion.h:12