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