7 #include "BackgroundImage.h"
8 #include "BackgroundStateContext.h"
9 #include "img/bannerapp_16.xpm"
10 #include "img/bannerapp_32.xpm"
11 #include "img/bannerapp_64.xpm"
12 #include "img/bannerapp_128.xpm"
13 #include "img/bannerapp_256.xpm"
14 #include "ChecklistGuide.h"
15 #include "ChecklistGuideWizard.h"
18 #include "CmdDelete.h"
19 #include "CmdMediator.h"
20 #include "CmdSelectCoordSystem.h"
21 #include "CmdStackShadow.h"
22 #include "ColorFilter.h"
25 #include "DigitizeStateContext.h"
26 #include "DigitAxis.xpm"
27 #include "DigitColorPicker.xpm"
28 #include "DigitCurve.xpm"
29 #include "DigitPointMatch.xpm"
30 #include "DigitSegment.xpm"
31 #include "DigitSelect.xpm"
33 #include "DlgErrorReport.h"
34 #include "DlgImportAdvanced.h"
35 #include "DlgRequiresTransform.h"
36 #include "DlgSettingsAxesChecker.h"
37 #include "DlgSettingsColorFilter.h"
38 #include "DlgSettingsCoords.h"
39 #include "DlgSettingsCurveAddRemove.h"
40 #include "DlgSettingsCurveProperties.h"
41 #include "DlgSettingsDigitizeCurve.h"
42 #include "DlgSettingsExportFormat.h"
43 #include "DlgSettingsGeneral.h"
44 #include "DlgSettingsGridDisplay.h"
45 #include "DlgSettingsGridRemoval.h"
46 #include "DlgSettingsMainWindow.h"
47 #include "DlgSettingsPointMatch.h"
48 #include "DlgSettingsSegments.h"
49 #include "DocumentSerialize.h"
50 #include "EngaugeAssert.h"
51 #include "EnumsToQt.h"
52 #include "ExportToFile.h"
53 #include "FileCmdScript.h"
55 #include "GraphicsItemType.h"
56 #include "GraphicsScene.h"
57 #include "GraphicsView.h"
58 #include "GridLineFactory.h"
59 #include "HelpWindow.h"
60 #ifdef ENGAUGE_JPEG2000
62 #endif // ENGAUGE_JPEG2000
63 #include "LoadFileInfo.h"
64 #include "LoadImageFromUrl.h"
66 #include "MainTitleBarFormat.h"
67 #include "MainWindow.h"
68 #include "NetworkClient.h"
70 #include <QApplication>
71 #include <QCloseEvent>
74 #include <QDesktopServices>
75 #include <QDockWidget>
76 #include <QDomDocument>
78 #include <QFileDialog>
80 #include <QGraphicsLineItem>
81 #include <QImageReader>
83 #include <QKeySequence>
87 #include <QMessageBox>
88 #include <QMouseEvent>
89 #include <QPrintDialog>
92 #include <QTextStream>
96 #include <QToolButton>
97 #include "QtToString.h"
98 #include <QVBoxLayout>
100 #include <QXmlStreamReader>
101 #include <QXmlStreamWriter>
102 #include "Settings.h"
103 #include "StatusBar.h"
104 #include "TransformationStateContext.h"
105 #include "TutorialDlg.h"
107 #include "ViewPointStyle.h"
108 #include "ViewSegmentFilter.h"
109 #include "ZoomFactor.h"
110 #include "ZoomFactorInitial.h"
112 const QString EMPTY_FILENAME (
"");
113 const char *ENGAUGE_FILENAME_DESCRIPTION =
"Engauge Document";
114 const QString ENGAUGE_FILENAME_EXTENSION (
"dig");
115 const int REGRESSION_INTERVAL = 400;
116 const unsigned int MAX_RECENT_FILE_LIST_SIZE = 8;
119 const QString &fileCmdScriptFile,
120 bool isRegressionTest,
122 QStringList loadStartupFiles,
125 m_isDocumentExported (false),
126 m_engaugeFile (EMPTY_FILENAME),
127 m_currentFile (EMPTY_FILENAME),
132 m_digitizeStateContext (0),
133 m_transformationStateContext (0),
134 m_backgroundStateContext (0),
135 m_isGnuplot (isGnuplot),
137 m_timerRegressionErrorReport(0),
139 m_isRegressionTest (isRegressionTest),
140 m_timerRegressionFileCmdScript(0)
142 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::MainWindow"
143 <<
" curDir=" << QDir::currentPath().toLatin1().data();
146 qApp->setApplicationName (
"Engauge Digitizer");
147 qApp->setOrganizationDomain (
"Mark Mitchell");
152 QString initialPath = QDir::currentPath();
156 setWindowFlags (Qt::WindowContextHelpButtonHint | windowFlags ());
157 setWindowTitle (engaugeWindowTitle ());
159 createCentralWidget();
168 createLoadImageFromUrl ();
169 createStateContextBackground ();
170 createStateContextDigitize ();
171 createStateContextTransformation ();
172 createSettingsDialogs ();
173 createCommandStackShadow ();
179 setUnifiedTitleAndToolBarOnMac(
true);
181 installEventFilter(
this);
182 if (!errorReportFile.isEmpty()) {
183 loadErrorReportFile(initialPath,
185 if (m_isRegressionTest) {
186 startRegressionTestErrorReport(initialPath,
189 }
else if (!fileCmdScriptFile.isEmpty()) {
191 startRegressionTestFileCmdScript();
196 m_loadStartupFiles = loadStartupFiles;
200 MainWindow::~MainWindow()
204 void MainWindow::applyZoomFactorAfterLoad()
206 ZoomFactor zoomFactor;
209 if (m_zoomMap.contains (zoomFactorInitial)) {
210 zoomFactor = m_zoomMap [zoomFactorInitial];
211 }
else if (zoomFactorInitial == ZOOM_INITIAL_PREVIOUS) {
212 zoomFactor = currentZoomFactor ();
214 ENGAUGE_ASSERT (
false);
215 zoomFactor = currentZoomFactor();
218 slotViewZoom (zoomFactor);
221 void MainWindow::closeEvent(QCloseEvent *event)
233 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::cmdFileClose";
235 setWindowModified (
false);
241 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::cmdFileExport";
250 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::cmdFileImport";
252 m_regressionFile = exportFilenameFromInputFilename (fileName);
253 fileImport (fileName,
259 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::cmdFileOpen";
261 m_regressionFile = exportFilenameFromInputFilename (fileName);
262 loadDocumentFile(fileName);
268 return m_cmdMediator;
271 void MainWindow::createActions()
273 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createActions";
275 createActionsFile ();
276 createActionsEdit ();
277 createActionsDigitize ();
278 createActionsView ();
279 createActionsSettings ();
280 createActionsHelp ();
283 void MainWindow::createActionsDigitize ()
285 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createActionsDigitize";
287 QPixmap pixmapAxis (DigitAxis_xpm);
288 QPixmap pixmapCurve (DigitCurve_xpm);
289 QPixmap pixmapColorPicker (DigitColorPicker_xpm);
290 QPixmap pixmapPointMatch (DigitPointMatch_xpm);
291 QPixmap pixmapSegment (DigitSegment_xpm);
292 QPixmap pixmapSelect (DigitSelect_xpm);
294 QIcon iconAxis (pixmapAxis);
295 QIcon iconCurve (pixmapCurve);
296 QIcon iconColorPicker (pixmapColorPicker);
297 QIcon iconPointMatch (pixmapPointMatch);
298 QIcon iconSegment (pixmapSegment);
299 QIcon iconSelect (pixmapSelect);
301 m_actionDigitizeSelect =
new QAction (iconSelect, tr (
"Select Tool"),
this);
302 m_actionDigitizeSelect->setShortcut (QKeySequence (tr (
"Shift+F2")));
303 m_actionDigitizeSelect->setCheckable (
true);
304 m_actionDigitizeSelect->setStatusTip (tr (
"Select points on screen."));
305 m_actionDigitizeSelect->setWhatsThis (tr (
"Select\n\n"
306 "Select points on the screen."));
307 connect (m_actionDigitizeSelect, SIGNAL (triggered ()),
this, SLOT (slotDigitizeSelect ()));
309 m_actionDigitizeAxis =
new QAction (iconAxis, tr (
"Axis Point Tool"),
this);
310 m_actionDigitizeAxis->setShortcut (QKeySequence (tr (
"Shift+F3")));
311 m_actionDigitizeAxis->setCheckable (
true);
312 m_actionDigitizeAxis->setStatusTip (tr (
"Digitize axis points."));
313 m_actionDigitizeAxis->setWhatsThis (tr (
"Digitize Axis Point\n\n"
314 "Digitizes an axis point by placing a new point at the cursor "
315 "after a mouse click. The coordinates of the axis point are then "
316 "entered. In a graph, three axis points are required to define "
317 "the graph coordinates."));
318 connect (m_actionDigitizeAxis, SIGNAL (triggered ()),
this, SLOT (slotDigitizeAxis ()));
320 m_actionDigitizeCurve =
new QAction (iconCurve, tr (
"Curve Point Tool"),
this);
321 m_actionDigitizeCurve->setShortcut (QKeySequence (tr (
"Shift+F4")));
322 m_actionDigitizeCurve->setCheckable (
true);
323 m_actionDigitizeCurve->setStatusTip (tr (
"Digitize curve points."));
324 m_actionDigitizeCurve->setWhatsThis (tr (
"Digitize Curve Point\n\n"
325 "Digitizes a curve point by placing a new point at the cursor "
326 "after a mouse click. Use this mode to digitize points along curves "
328 "New points will be assigned to the currently selected curve."));
329 connect (m_actionDigitizeCurve, SIGNAL (triggered ()),
this, SLOT (slotDigitizeCurve ()));
331 m_actionDigitizePointMatch =
new QAction (iconPointMatch, tr (
"Point Match Tool"),
this);
332 m_actionDigitizePointMatch->setShortcut (QKeySequence (tr (
"Shift+F5")));
333 m_actionDigitizePointMatch->setCheckable (
true);
334 m_actionDigitizePointMatch->setStatusTip (tr (
"Digitize curve points in a point plot by matching a point."));
335 m_actionDigitizePointMatch->setWhatsThis (tr (
"Digitize Curve Points by Point Matching\n\n"
336 "Digitizes curve points in a point plot by finding points that match a sample point. The process "
337 "starts by selecting a representative sample point.\n\n"
338 "New points will be assigned to the currently selected curve."));
339 connect (m_actionDigitizePointMatch, SIGNAL (triggered ()),
this, SLOT (slotDigitizePointMatch ()));
341 m_actionDigitizeColorPicker =
new QAction (iconColorPicker, tr (
"Color Picker Tool"),
this);
342 m_actionDigitizeColorPicker->setShortcut (QKeySequence (tr (
"Shift+F6")));
343 m_actionDigitizeColorPicker->setCheckable (
true);
344 m_actionDigitizeColorPicker->setStatusTip (tr (
"Select color settings for filtering in Segment Fill mode."));
345 m_actionDigitizeColorPicker->setWhatsThis (tr (
"Select color settings for Segment Fill filtering\n\n"
346 "Select a pixel along the currently selected curve. That pixel and its neighbors will "
347 "define the filter settings (color, brightness, and so on) of the currently selected curve "
348 "while in Segment Fill mode."));
349 connect (m_actionDigitizeColorPicker, SIGNAL (triggered ()),
this, SLOT (slotDigitizeColorPicker ()));
351 m_actionDigitizeSegment =
new QAction (iconSegment, tr (
"Segment Fill Tool"),
this);
352 m_actionDigitizeSegment->setShortcut (QKeySequence (tr (
"Shift+F7")));
353 m_actionDigitizeSegment->setCheckable (
true);
354 m_actionDigitizeSegment->setStatusTip (tr (
"Digitize curve points along a segment of a curve."));
355 m_actionDigitizeSegment->setWhatsThis (tr (
"Digitize Curve Points With Segment Fill\n\n"
356 "Digitizes curve points by placing new points along the highlighted "
357 "segment under the cursor. Use this mode to quickly digitize multiple points along a "
358 "curve with a single click.\n\n"
359 "New points will be assigned to the currently selected curve."));
360 connect (m_actionDigitizeSegment, SIGNAL (triggered ()),
this, SLOT (slotDigitizeSegment ()));
362 m_groupDigitize =
new QActionGroup (
this);
363 m_groupDigitize->addAction (m_actionDigitizeSelect);
364 m_groupDigitize->addAction (m_actionDigitizeAxis);
365 m_groupDigitize->addAction (m_actionDigitizeCurve);
366 m_groupDigitize->addAction (m_actionDigitizePointMatch);
367 m_groupDigitize->addAction (m_actionDigitizeColorPicker);
368 m_groupDigitize->addAction (m_actionDigitizeSegment);
371 void MainWindow::createActionsEdit ()
373 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createActionsEdit";
375 m_actionEditUndo =
new QAction(tr (
"&Undo"),
this);
376 m_actionEditUndo->setShortcut (QKeySequence::Undo);
377 m_actionEditUndo->setStatusTip (tr (
"Undo the last operation."));
378 m_actionEditUndo->setWhatsThis (tr (
"Undo\n\n"
379 "Undo the last operation."));
382 m_actionEditRedo =
new QAction(tr (
"&Redo"),
this);
383 m_actionEditRedo->setShortcut (QKeySequence::Redo);
384 m_actionEditRedo->setStatusTip (tr (
"Redo the last operation."));
385 m_actionEditRedo->setWhatsThis (tr (
"Redo\n\n"
386 "Redo the last operation."));
389 m_actionEditCut =
new QAction (tr (
"Cut"),
this);
390 m_actionEditCut->setShortcut (QKeySequence::Cut);
391 m_actionEditCut->setStatusTip (tr (
"Cuts the selected points and copies them to the clipboard."));
392 m_actionEditCut->setWhatsThis (tr (
"Cut\n\n"
393 "Cuts the selected points and copies them to the clipboard."));
394 connect (m_actionEditCut, SIGNAL (triggered ()),
this, SLOT (slotEditCut ()));
396 m_actionEditCopy =
new QAction (tr (
"Copy"),
this);
397 m_actionEditCopy->setShortcut (QKeySequence::Copy);
398 m_actionEditCopy->setStatusTip (tr (
"Copies the selected points to the clipboard."));
399 m_actionEditCopy->setWhatsThis (tr (
"Copy\n\n"
400 "Copies the selected points to the clipboard."));
401 connect (m_actionEditCopy, SIGNAL (triggered ()),
this, SLOT (slotEditCopy ()));
403 m_actionEditPaste =
new QAction (tr (
"Paste"),
this);
404 m_actionEditPaste->setShortcut (QKeySequence::Paste);
405 m_actionEditPaste->setStatusTip (tr (
"Pastes the selected points from the clipboard."));
406 m_actionEditPaste->setWhatsThis (tr (
"Paste\n\n"
407 "Pastes the selected points from the clipboard. They will be assigned to the current curve."));
408 connect (m_actionEditPaste, SIGNAL (triggered ()),
this, SLOT (slotEditPaste ()));
410 m_actionEditDelete =
new QAction (tr (
"Delete"),
this);
411 m_actionEditDelete->setShortcut (QKeySequence::Delete);
412 m_actionEditDelete->setStatusTip (tr (
"Deletes the selected points, after copying them to the clipboard."));
413 m_actionEditDelete->setWhatsThis (tr (
"Delete\n\n"
414 "Deletes the selected points, after copying them to the clipboard."));
415 connect (m_actionEditDelete, SIGNAL (triggered ()),
this, SLOT (slotEditDelete ()));
417 m_actionEditPasteAsNew =
new QAction (tr (
"Paste As New"),
this);
418 m_actionEditPasteAsNew->setStatusTip (tr (
"Pastes an image from the clipboard."));
419 m_actionEditPasteAsNew->setWhatsThis (tr (
"Paste as New\n\n"
420 "Creates a new document by pasting an image from the clipboard."));
421 connect (m_actionEditPasteAsNew, SIGNAL (triggered ()),
this, SLOT (slotEditPasteAsNew ()));
423 m_actionEditPasteAsNewAdvanced =
new QAction (tr (
"Paste As New (Advanced)..."),
this);
424 m_actionEditPasteAsNewAdvanced->setStatusTip (tr (
"Pastes an image from the clipboard, in advanced mode."));
425 m_actionEditPasteAsNewAdvanced->setWhatsThis (tr (
"Paste as New (Advanced)\n\n"
426 "Creates a new document by pasting an image from the clipboard, in advanced mode."));
427 connect (m_actionEditPasteAsNewAdvanced, SIGNAL (triggered ()),
this, SLOT (slotEditPasteAsNewAdvanced ()));
430 void MainWindow::createActionsFile ()
432 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createActionsFile";
434 m_actionImport =
new QAction(tr (
"&Import..."),
this);
435 m_actionImport->setShortcut (tr (
"Ctrl+I"));
436 m_actionImport->setStatusTip (tr (
"Creates a new document by importing an simple image."));
437 m_actionImport->setWhatsThis (tr (
"Import Image\n\n"
438 "Creates a new document by importing an image with a single coordinate system, "
439 "and axes both coordinates known.\n\n"
440 "For more complicated images with multiple coordinate systems, "
441 "and/or floating axes, Import (Advanced) is used instead."));
442 connect (m_actionImport, SIGNAL (triggered ()),
this, SLOT (slotFileImport ()));
444 m_actionImportAdvanced =
new QAction(tr (
"Import (Advanced)..."),
this);
445 m_actionImportAdvanced->setStatusTip (tr (
"Creates a new document by importing an image with support for advanced feaures."));
446 m_actionImportAdvanced->setWhatsThis (tr (
"Import (Advanced)\n\n"
447 "Creates a new document by importing an image with support for advanced feaures. In "
448 "advanced mode, there can be multiple coordinate systems and/or floating axes."));
449 connect (m_actionImportAdvanced, SIGNAL (triggered ()),
this, SLOT (slotFileImportAdvanced ()));
451 m_actionOpen =
new QAction(tr (
"&Open..."),
this);
452 m_actionOpen->setShortcut (QKeySequence::Open);
453 m_actionOpen->setStatusTip (tr (
"Opens an existing document."));
454 m_actionOpen->setWhatsThis (tr (
"Open Document\n\n"
455 "Opens an existing document."));
456 connect (m_actionOpen, SIGNAL (triggered ()),
this, SLOT (slotFileOpen ()));
459 for (
unsigned int i = 0; i < MAX_RECENT_FILE_LIST_SIZE; i++) {
460 QAction *recentFileAction =
new QAction (
this);
461 recentFileAction->setVisible (
true);
462 connect (recentFileAction, SIGNAL (triggered ()),
this, SLOT (slotRecentFileAction ()));
463 m_actionRecentFiles.append (recentFileAction);
467 m_actionClose =
new QAction(tr (
"&Close"),
this);
468 m_actionClose->setShortcut (QKeySequence::Close);
469 m_actionClose->setStatusTip (tr (
"Closes the open document document."));
470 m_actionClose->setWhatsThis (tr (
"Close Document\n\n"
471 "Closes the open document."));
472 connect (m_actionClose, SIGNAL (triggered ()),
this, SLOT (slotFileClose ()));
474 m_actionSave =
new QAction(tr (
"&Save"),
this);
475 m_actionSave->setShortcut (QKeySequence::Save);
476 m_actionSave->setStatusTip (tr (
"Saves the current document."));
477 m_actionSave->setWhatsThis (tr (
"Save Document\n\n"
478 "Saves the current document."));
479 connect (m_actionSave, SIGNAL (triggered ()),
this, SLOT (slotFileSave ()));
481 m_actionSaveAs =
new QAction(tr (
"Save As..."),
this);
482 m_actionSaveAs->setShortcut (QKeySequence::SaveAs);
483 m_actionSaveAs->setStatusTip (tr (
"Saves the current document under a new filename."));
484 m_actionSaveAs->setWhatsThis (tr (
"Save Document As\n\n"
485 "Saves the current document under a new filename."));
486 connect (m_actionSaveAs, SIGNAL (triggered ()),
this, SLOT (slotFileSaveAs ()));
488 m_actionExport =
new QAction (tr (
"Export..."),
this);
489 m_actionExport->setShortcut (tr (
"Ctrl+E"));
490 m_actionExport->setStatusTip (tr (
"Exports the current document into a text file."));
491 m_actionExport->setWhatsThis (tr (
"Export Document\n\n"
492 "Exports the current document into a text file."));
493 connect (m_actionExport, SIGNAL (triggered ()),
this, SLOT (slotFileExport ()));
495 m_actionPrint =
new QAction (tr (
"&Print..."),
this);
496 m_actionPrint->setShortcut (QKeySequence::Print);
497 m_actionPrint->setStatusTip (tr (
"Print the current document."));
498 m_actionPrint->setWhatsThis (tr (
"Print Document\n\n"
499 "Print the current document to a printer or file."));
500 connect (m_actionPrint, SIGNAL (triggered ()),
this, SLOT (slotFilePrint ()));
502 m_actionExit =
new QAction(tr (
"&Exit"),
this);
503 m_actionExit->setShortcut (QKeySequence::Quit);
504 m_actionExit->setStatusTip (tr (
"Quits the application."));
505 m_actionExit->setWhatsThis (tr (
"Exit\n\n"
506 "Quits the application."));
507 connect (m_actionExit, SIGNAL (triggered ()),
this, SLOT (close ()));
510 void MainWindow::createActionsHelp ()
512 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createActionsHelp";
514 m_actionHelpChecklistGuideWizard =
new QAction (tr (
"Checklist Guide Wizard"),
this);
515 m_actionHelpChecklistGuideWizard->setCheckable (
true);
516 m_actionHelpChecklistGuideWizard->setStatusTip (tr (
"Open Checklist Guide Wizard during import to define digitizing steps"));
517 m_actionHelpChecklistGuideWizard->setWhatsThis (tr (
"Checklist Guide Wizard\n\n"
518 "Use Checklist Guide Wizard during import to generate a checklist of steps "
519 "for the imported document"));
521 m_actionHelpWhatsThis = QWhatsThis::createAction(
this);
522 m_actionHelpWhatsThis->setShortcut (QKeySequence::WhatsThis);
524 m_actionHelpTutorial =
new QAction (tr (
"Tutorial"),
this);
525 m_actionHelpTutorial->setStatusTip (tr (
"Play tutorial showing steps for digitizing curves"));
526 m_actionHelpTutorial->setWhatsThis (tr (
"Tutorial\n\n"
527 "Play tutorial showing steps for digitizing points from curves drawn with lines "
529 connect (m_actionHelpTutorial, SIGNAL (triggered ()),
this, SLOT (slotHelpTutorial()));
531 m_actionHelpHelp =
new QAction (tr (
"Help"),
this);
532 m_actionHelpHelp->setShortcut (QKeySequence::HelpContents);
533 m_actionHelpHelp->setStatusTip (tr (
"Help documentation"));
534 m_actionHelpHelp->setWhatsThis (tr (
"Help Documentation\n\n"
535 "Searchable help documentation"));
538 m_actionHelpAbout =
new QAction(tr (
"About Engauge"),
this);
539 m_actionHelpAbout->setStatusTip (tr (
"About the application."));
540 m_actionHelpAbout->setWhatsThis (tr (
"About Engauge\n\nAbout the application."));
541 connect (m_actionHelpAbout, SIGNAL (triggered ()),
this, SLOT (slotHelpAbout ()));
544 void MainWindow::createActionsSettings ()
546 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createActionsSettings";
548 m_actionSettingsCoords =
new QAction (tr (
"Coordinates..."),
this);
549 m_actionSettingsCoords->setStatusTip (tr (
"Edit Coordinate settings."));
550 m_actionSettingsCoords->setWhatsThis (tr (
"Coordinate Settings\n\n"
551 "Coordinate settings determine how the graph coordinates are mapped to the pixels in the image"));
552 connect (m_actionSettingsCoords, SIGNAL (triggered ()),
this, SLOT (slotSettingsCoords ()));
554 m_actionSettingsCurveAddRemove =
new QAction (tr (
"Add/Remove Curve..."),
this);
555 m_actionSettingsCurveAddRemove->setStatusTip (tr (
"Add or Remove Curves."));
556 m_actionSettingsCurveAddRemove->setWhatsThis (tr (
"Add/Remove Curve\n\n"
557 "Add/Remove Curve settings control which curves are included in the current document"));
558 connect (m_actionSettingsCurveAddRemove, SIGNAL (triggered ()),
this, SLOT (slotSettingsCurveAddRemove ()));
560 m_actionSettingsCurveProperties =
new QAction (tr (
"Curve Properties..."),
this);
561 m_actionSettingsCurveProperties->setStatusTip (tr (
"Edit Curve Properties settings."));
562 m_actionSettingsCurveProperties->setWhatsThis (tr (
"Curve Properties Settings\n\n"
563 "Curves properties settings determine how each curve appears"));
564 connect (m_actionSettingsCurveProperties, SIGNAL (triggered ()),
this, SLOT (slotSettingsCurveProperties ()));
566 m_actionSettingsDigitizeCurve =
new QAction (tr (
"Digitize Curve..."),
this);
567 m_actionSettingsDigitizeCurve->setStatusTip (tr (
"Edit Digitize Axis and Graph Curve settings."));
568 m_actionSettingsDigitizeCurve->setWhatsThis (tr (
"Digitize Axis and Graph Curve Settings\n\n"
569 "Digitize Curve settings determine how points are digitized in Digitize Axis Point and "
570 "Digitize Graph Point modes"));
571 connect (m_actionSettingsDigitizeCurve, SIGNAL (triggered ()),
this, SLOT (slotSettingsDigitizeCurve ()));
573 m_actionSettingsExport =
new QAction (tr (
"Export Format..."),
this);
574 m_actionSettingsExport->setStatusTip (tr (
"Edit Export Format settings."));
575 m_actionSettingsExport->setWhatsThis (tr (
"Export Format Settings\n\n"
576 "Export format settings affect how exported files are formatted"));
577 connect (m_actionSettingsExport, SIGNAL (triggered ()),
this, SLOT (slotSettingsExportFormat ()));
579 m_actionSettingsColorFilter =
new QAction (tr (
"Color Filter..."),
this);
580 m_actionSettingsColorFilter->setStatusTip (tr (
"Edit Color Filter settings."));
581 m_actionSettingsColorFilter->setWhatsThis (tr (
"Color Filter Settings\n\n"
582 "Color filtering simplifies the graphs for easier Point Matching and Segment Filling"));
583 connect (m_actionSettingsColorFilter, SIGNAL (triggered ()),
this, SLOT (slotSettingsColorFilter ()));
585 m_actionSettingsAxesChecker =
new QAction (tr (
"Axes Checker..."),
this);
586 m_actionSettingsAxesChecker->setStatusTip (tr (
"Edit Axes Checker settings."));
587 m_actionSettingsAxesChecker->setWhatsThis (tr (
"Axes Checker Settings\n\n"
588 "Axes checker can reveal any axis point mistakes, which are otherwise hard to find."));
589 connect (m_actionSettingsAxesChecker, SIGNAL (triggered ()),
this, SLOT (slotSettingsAxesChecker ()));
591 m_actionSettingsGridDisplay =
new QAction (tr (
"Grid Line Display..."),
this);
592 m_actionSettingsGridDisplay->setStatusTip (tr (
"Edit Grid Line Display settings."));
593 m_actionSettingsGridDisplay->setWhatsThis (tr (
"Grid Line Display Settings\n\n"
594 "Grid lines displayed on the graph can provide more accuracy than the Axis Checker, for distorted graphs. "
595 "In a distorted graph, the grid lines can be used to adjust the axis points for more accuracy in different regions."));
596 connect (m_actionSettingsGridDisplay, SIGNAL (triggered ()),
this, SLOT (slotSettingsGridDisplay ()));
598 m_actionSettingsGridRemoval =
new QAction (tr (
"Grid Line Removal..."),
this);
599 m_actionSettingsGridRemoval->setStatusTip (tr (
"Edit Grid Line Removal settings."));
600 m_actionSettingsGridRemoval->setWhatsThis (tr (
"Grid Line Removal Settings\n\n"
601 "Grid line removal isolates curve lines for easier Point Matching and Segment Filling, when "
602 "Color Filtering is not able to separate grid lines from curve lines."));
603 connect (m_actionSettingsGridRemoval, SIGNAL (triggered ()),
this, SLOT (slotSettingsGridRemoval ()));
605 m_actionSettingsPointMatch =
new QAction (tr (
"Point Match..."),
this);
606 m_actionSettingsPointMatch->setStatusTip (tr (
"Edit Point Match settings."));
607 m_actionSettingsPointMatch->setWhatsThis (tr (
"Point Match Settings\n\n"
608 "Point match settings determine how points are matched while in Point Match mode"));
609 connect (m_actionSettingsPointMatch, SIGNAL (triggered ()),
this, SLOT (slotSettingsPointMatch ()));
611 m_actionSettingsSegments =
new QAction (tr (
"Segment Fill..."),
this);
612 m_actionSettingsSegments->setStatusTip (tr (
"Edit Segment Fill settings."));
613 m_actionSettingsSegments->setWhatsThis (tr (
"Segment Fill Settings\n\n"
614 "Segment fill settings determine how points are generated in the Segment Fill mode"));
615 connect (m_actionSettingsSegments, SIGNAL (triggered ()),
this, SLOT (slotSettingsSegments ()));
617 m_actionSettingsGeneral =
new QAction (tr (
"General..."),
this);
618 m_actionSettingsGeneral->setStatusTip (tr (
"Edit General settings."));
619 m_actionSettingsGeneral->setWhatsThis (tr (
"General Settings\n\n"
620 "General settings are document-specific settings that affect multiple modes. For example, the cursor size setting affects "
621 "both Color Picker and Point Match modes"));
622 connect (m_actionSettingsGeneral, SIGNAL (triggered ()),
this, SLOT (slotSettingsGeneral ()));
624 m_actionSettingsMainWindow =
new QAction (tr (
"Main Window..."),
this);
625 m_actionSettingsMainWindow->setEnabled (
true);
626 m_actionSettingsMainWindow->setStatusTip (tr (
"Edit Main Window settings."));
627 m_actionSettingsMainWindow->setWhatsThis (tr (
"Main Window Settings\n\n"
628 "Main window settings affect the user interface and are not specific to any document"));
629 connect (m_actionSettingsMainWindow, SIGNAL (triggered ()),
this, SLOT (slotSettingsMainWindow ()));
632 void MainWindow::createActionsView ()
634 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createActionsView";
636 m_actionViewBackground =
new QAction (tr (
"Background Toolbar"),
this);
637 m_actionViewBackground->setCheckable (
true);
638 m_actionViewBackground->setChecked (
true);
639 m_actionViewBackground->setStatusTip (tr (
"Show or hide the background toolbar."));
640 m_actionViewBackground->setWhatsThis (tr (
"View Background ToolBar\n\n"
641 "Show or hide the background toolbar"));
642 connect (m_actionViewBackground, SIGNAL (triggered ()),
this, SLOT (slotViewToolBarBackground ()));
644 m_actionViewChecklistGuide =
new QAction (tr (
"Checklist Guide Toolbar"),
this);
645 m_actionViewChecklistGuide->setCheckable (
true);
646 m_actionViewChecklistGuide->setChecked (
false);
647 m_actionViewChecklistGuide->setStatusTip (tr (
"Show or hide the checklist guide toolbar."));
648 m_actionViewChecklistGuide->setWhatsThis (tr (
"View Checklist Guide ToolBar\n\n"
649 "Show or hide the checklist guide toolbar"));
650 connect (m_actionViewChecklistGuide, SIGNAL (changed ()),
this, SLOT (slotViewToolBarChecklistGuide()));
652 m_actionViewDigitize =
new QAction (tr (
"Digitizing Tools Toolbar"),
this);
653 m_actionViewDigitize->setCheckable (
true);
654 m_actionViewDigitize->setChecked (
true);
655 m_actionViewDigitize->setStatusTip (tr (
"Show or hide the digitizing tools toolbar."));
656 m_actionViewDigitize->setWhatsThis (tr (
"View Digitizing Tools ToolBar\n\n"
657 "Show or hide the digitizing tools toolbar"));
658 connect (m_actionViewDigitize, SIGNAL (triggered ()),
this, SLOT (slotViewToolBarDigitize()));
660 m_actionViewSettingsViews =
new QAction (tr (
"Settings Views Toolbar"),
this);
661 m_actionViewSettingsViews->setCheckable (
true);
662 m_actionViewSettingsViews->setChecked (
true);
663 m_actionViewSettingsViews->setStatusTip (tr (
"Show or hide the settings views toolbar."));
664 m_actionViewSettingsViews->setWhatsThis (tr (
"View Settings Views ToolBar\n\n"
665 "Show or hide the settings views toolbar. These views graphically show the "
666 "most important settings."));
667 connect (m_actionViewSettingsViews, SIGNAL (triggered ()),
this, SLOT (slotViewToolBarSettingsViews()));
669 m_actionViewCoordSystem =
new QAction (tr (
"Coordinate System Toolbar"),
this);
670 m_actionViewCoordSystem->setCheckable (
true);
671 m_actionViewCoordSystem->setChecked (
false);
672 m_actionViewCoordSystem->setStatusTip (tr (
"Show or hide the coordinate system toolbar."));
673 m_actionViewCoordSystem->setWhatsThis (tr (
"View Coordinate Systems ToolBar\n\n"
674 "Show or hide the coordinate system selection toolbar. This toolbar is used "
675 "to select the current coordinate system when the document has multiple "
676 "coordinate systems. This toolbar is also used to view and print all coordinate "
678 "This toolbar is disabled when there is only one coordinate system."));
679 connect (m_actionViewCoordSystem, SIGNAL (triggered ()),
this, SLOT (slotViewToolBarCoordSystem()));
681 m_actionViewToolTips =
new QAction (tr (
"Tool Tips"),
this);
682 m_actionViewToolTips->setCheckable (
true);
683 m_actionViewToolTips->setChecked (
true);
684 m_actionViewToolTips->setStatusTip (tr (
"Show or hide the tool tips."));
685 m_actionViewToolTips->setWhatsThis (tr (
"View Tool Tips\n\n"
686 "Show or hide the tool tips"));
687 connect (m_actionViewToolTips, SIGNAL (triggered ()),
this, SLOT (slotViewToolTips()));
689 m_actionViewGridLines =
new QAction (tr (
"Grid Lines"),
this);
690 m_actionViewGridLines->setCheckable (
true);
691 m_actionViewGridLines->setChecked (
false);
692 m_actionViewGridLines->setStatusTip (tr (
"Show or hide grid lines."));
693 m_actionViewGridLines->setWhatsThis (tr (
"View Grid Lines\n\n"
694 "Show or hide grid lines that are added for accurate adjustments of the axes points, "
695 "which can improve accuracy in distorted graphs"));
696 connect (m_actionViewGridLines, SIGNAL (triggered ()),
this, SLOT (slotViewGridLines()));
698 m_actionViewBackgroundNone =
new QAction (tr (
"No Background"),
this);
699 m_actionViewBackgroundNone->setCheckable (
true);
700 m_actionViewBackgroundNone->setStatusTip (tr (
"Do not show the image underneath the points."));
701 m_actionViewBackgroundNone->setWhatsThis (tr (
"No Background\n\n"
702 "No image is shown so points are easier to see"));
704 m_actionViewBackgroundOriginal =
new QAction (tr (
"Show Original Image"),
this);
705 m_actionViewBackgroundOriginal->setCheckable (
true);
706 m_actionViewBackgroundOriginal->setStatusTip (tr (
"Show the original image underneath the points."));
707 m_actionViewBackgroundOriginal->setWhatsThis (tr (
"Show Original Image\n\n"
708 "Show the original image underneath the points"));
710 m_actionViewBackgroundFiltered =
new QAction (tr (
"Show Filtered Image"),
this);
711 m_actionViewBackgroundFiltered->setCheckable (
true);
712 m_actionViewBackgroundFiltered->setChecked (
true);
713 m_actionViewBackgroundFiltered->setStatusTip (tr (
"Show the filtered image underneath the points."));
714 m_actionViewBackgroundFiltered->setWhatsThis (tr (
"Show Filtered Image\n\n"
715 "Show the filtered image underneath the points.\n\n"
716 "The filtered image is created from the original image according to the "
717 "Filter preferences so unimportant information is hidden and important "
718 "information is emphasized"));
720 m_actionViewCurvesNone =
new QAction (tr (
"Hide All Curves"),
this);
721 m_actionViewCurvesNone->setCheckable (
true);
722 m_actionViewCurvesNone->setStatusTip (tr (
"Hide all digitized curves."));
723 m_actionViewCurvesNone->setWhatsThis (tr (
"Hide All Curves\n\n"
724 "No axis points or digitized graph curves are shown so the image is easier to see."));
726 m_actionViewCurvesSelected =
new QAction (tr (
"Show Selected Curve"),
this);
727 m_actionViewCurvesSelected->setCheckable (
true);
728 m_actionViewCurvesSelected->setStatusTip (tr (
"Show only the currently selected curve."));
729 m_actionViewCurvesSelected->setWhatsThis (tr (
"Show Selected Curve\n\n"
730 "Show only the digitized points and line that belong to the currently selected curve."));
732 m_actionViewCurvesAll =
new QAction (tr (
"Show All Curves"),
this);
733 m_actionViewCurvesAll->setCheckable (
true);
734 m_actionViewCurvesAll->setChecked (
true);
735 m_actionViewCurvesAll->setStatusTip (tr (
"Show all curves."));
736 m_actionViewCurvesAll->setWhatsThis (tr (
"Show All Curves\n\n"
737 "Show all digitized axis points and graph curves"));
739 m_groupBackground =
new QActionGroup(
this);
740 m_groupBackground->addAction (m_actionViewBackgroundNone);
741 m_groupBackground->addAction (m_actionViewBackgroundOriginal);
742 m_groupBackground->addAction (m_actionViewBackgroundFiltered);
743 connect (m_groupBackground, SIGNAL(triggered (QAction*)),
this, SLOT (slotViewGroupBackground(QAction*)));
745 m_groupCurves =
new QActionGroup(
this);
746 m_groupCurves->addAction (m_actionViewCurvesNone);
747 m_groupCurves->addAction (m_actionViewCurvesSelected);
748 m_groupCurves->addAction (m_actionViewCurvesAll);
749 connect (m_groupCurves, SIGNAL(triggered (QAction*)),
this, SLOT (slotViewGroupCurves(QAction*)));
751 m_actionStatusNever =
new QAction (tr (
"Hide Always"),
this);
752 m_actionStatusNever->setCheckable(
true);
753 m_actionStatusNever->setStatusTip (tr (
"Always hide the status bar."));
754 m_actionStatusNever->setWhatsThis (tr (
"Hide the status bar. No temporary status or feedback messages will appear."));
756 m_actionStatusTemporary =
new QAction (tr (
"Show Temporary Messages"),
this);
757 m_actionStatusTemporary->setCheckable(
true);
758 m_actionStatusTemporary->setStatusTip (tr (
"Hide the status bar except when display temporary messages."));
759 m_actionStatusTemporary->setWhatsThis (tr (
"Hide the status bar, except when displaying temporary status and feedback messages."));
761 m_actionStatusAlways =
new QAction (tr (
"Show Always"),
this);
762 m_actionStatusAlways->setCheckable(
true);
763 m_actionStatusAlways->setStatusTip (tr (
"Always show the status bar."));
764 m_actionStatusAlways->setWhatsThis (tr (
"Show the status bar. Besides displaying temporary status and feedback messages, "
765 "the status bar also displays information about the cursor position."));
767 m_groupStatus =
new QActionGroup(
this);
768 m_groupStatus->addAction (m_actionStatusNever);
769 m_groupStatus->addAction (m_actionStatusTemporary);
770 m_groupStatus->addAction (m_actionStatusAlways);
771 connect (m_groupStatus, SIGNAL (triggered (QAction*)),
this, SLOT (slotViewGroupStatus(QAction*)));
773 m_actionZoomOut =
new QAction (tr (
"Zoom Out"),
this);
774 m_actionZoomOut->setStatusTip (tr (
"Zoom out"));
776 connect (m_actionZoomOut, SIGNAL (triggered ()),
this, SLOT (slotViewZoomOut ()));
778 m_actionZoomIn =
new QAction (tr (
"Zoom In"),
this);
779 m_actionZoomIn->setStatusTip (tr (
"Zoom in"));
781 connect (m_actionZoomIn, SIGNAL (triggered ()),
this, SLOT (slotViewZoomIn ()));
783 m_actionZoom16To1 =
new QAction (tr (
"16:1 (1600%)"),
this);
784 m_actionZoom16To1->setCheckable (
true);
785 m_actionZoom16To1->setStatusTip (tr (
"Zoom 16:1"));
786 connect (m_actionZoom16To1, SIGNAL (triggered ()),
this, SLOT (slotViewZoom16To1 ()));
788 m_actionZoom8To1 =
new QAction (tr (
"8:1 (800%)"),
this);
789 m_actionZoom8To1->setCheckable (
true);
790 m_actionZoom8To1->setStatusTip (tr (
"Zoom 8:1"));
791 connect (m_actionZoom8To1, SIGNAL (triggered ()),
this, SLOT (slotViewZoom8To1 ()));
793 m_actionZoom4To1 =
new QAction (tr (
"4:1 (400%)"),
this);
794 m_actionZoom4To1->setCheckable (
true);
795 m_actionZoom4To1->setStatusTip (tr (
"Zoom 4:1"));
796 connect (m_actionZoom4To1, SIGNAL (triggered ()),
this, SLOT (slotViewZoom4To1 ()));
798 m_actionZoom2To1 =
new QAction (tr (
"2:1 (200%)"),
this);
799 m_actionZoom2To1->setCheckable (
true);
800 m_actionZoom2To1->setStatusTip (tr (
"Zoom 2:1"));
801 connect (m_actionZoom2To1, SIGNAL (triggered ()),
this, SLOT (slotViewZoom2To1 ()));
803 m_actionZoom1To1 =
new QAction (tr (
"1:1 (100%)"),
this);
804 m_actionZoom1To1->setCheckable (
true);
805 m_actionZoom1To1->setChecked (
true);
806 m_actionZoom1To1->setStatusTip (tr (
"Zoom 6:1"));
807 connect (m_actionZoom1To1, SIGNAL (triggered ()),
this, SLOT (slotViewZoom1To1 ()));
809 m_actionZoom1To2 =
new QAction (tr (
"1:2 (50%)"),
this);
810 m_actionZoom1To2->setCheckable (
true);
811 m_actionZoom1To2->setStatusTip (tr (
"Zoom 1:2"));
812 connect (m_actionZoom1To2, SIGNAL (triggered ()),
this, SLOT (slotViewZoom1To2 ()));
814 m_actionZoom1To4 =
new QAction (tr (
"1:4 (25%)"),
this);
815 m_actionZoom1To4->setCheckable (
true);
816 m_actionZoom1To4->setStatusTip (tr (
"Zoom 1:4"));
817 connect (m_actionZoom1To4, SIGNAL (triggered ()),
this, SLOT (slotViewZoom1To4 ()));
819 m_actionZoom1To8 =
new QAction (tr (
"1:8 (12.5%)"),
this);
820 m_actionZoom1To8->setCheckable (
true);
821 m_actionZoom1To8->setStatusTip (tr (
"Zoom 1:8"));
822 connect (m_actionZoom1To8, SIGNAL (triggered ()),
this, SLOT (slotViewZoom1To8 ()));
824 m_actionZoom1To16 =
new QAction (tr (
"1:16 (6.25%)"),
this);
825 m_actionZoom1To16->setCheckable (
true);
826 m_actionZoom1To16->setStatusTip (tr (
"Zoom 1:16"));
827 connect (m_actionZoom1To16, SIGNAL (triggered ()),
this, SLOT (slotViewZoom1To16 ()));
829 m_actionZoomFill =
new QAction (tr (
"Fill"),
this);
830 m_actionZoomFill->setCheckable (
true);
831 m_actionZoomFill->setStatusTip (tr (
"Zoom with stretching to fill window"));
832 connect (m_actionZoomFill, SIGNAL (triggered ()),
this, SLOT (slotViewZoomFill ()));
834 m_groupZoom =
new QActionGroup (
this);
835 m_groupZoom->addAction (m_actionZoom16To1);
836 m_groupZoom->addAction (m_actionZoom8To1);
837 m_groupZoom->addAction (m_actionZoom4To1);
838 m_groupZoom->addAction (m_actionZoom2To1);
839 m_groupZoom->addAction (m_actionZoom1To1);
840 m_groupZoom->addAction (m_actionZoom1To2);
841 m_groupZoom->addAction (m_actionZoom1To4);
842 m_groupZoom->addAction (m_actionZoom1To8);
843 m_groupZoom->addAction (m_actionZoom1To16);
844 m_groupZoom->addAction (m_actionZoomFill);
847 void MainWindow::createCentralWidget ()
849 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createCentralWidget";
851 QWidget *widget =
new QWidget;
852 setCentralWidget (widget);
853 m_layout =
new QVBoxLayout;
854 widget->setLayout (m_layout);
857 void MainWindow::createCommandStackShadow ()
859 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createCommandStackShadow";
864 void MainWindow::createHelpWindow ()
866 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createHelpWindow";
869 m_helpWindow->hide ();
870 addDockWidget (Qt::RightDockWidgetArea,
872 m_helpWindow->setFloating (
true);
874 connect (m_actionHelpHelp, SIGNAL (triggered ()), m_helpWindow, SLOT (show ()));
877 void MainWindow::createIcons()
879 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createIcons";
882 QPixmap icon16 (bannerapp_16);
883 QPixmap icon32 (bannerapp_32);
884 QPixmap icon64 (bannerapp_64);
885 QPixmap icon128 (bannerapp_128);
886 QPixmap icon256 (bannerapp_256);
888 icon.addPixmap (icon16);
889 icon.addPixmap (icon32);
890 icon.addPixmap (icon64);
891 icon.addPixmap (icon128);
892 icon.addPixmap (icon256);
894 setWindowIcon (icon);
897 void MainWindow::createLoadImageFromUrl ()
902 void MainWindow::createMenus()
904 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createMenus";
906 m_menuFile = menuBar()->addMenu(tr(
"&File"));
907 m_menuFile->addAction (m_actionImport);
908 m_menuFile->addAction (m_actionImportAdvanced);
909 m_menuFile->addAction (m_actionOpen);
911 m_menuFileOpenRecent =
new QMenu (tr (
"Open &Recent"));
912 for (
unsigned int i = 0; i < MAX_RECENT_FILE_LIST_SIZE; i++) {
913 m_menuFileOpenRecent->addAction (m_actionRecentFiles.at (i));
915 m_menuFile->addMenu (m_menuFileOpenRecent);
917 m_menuFile->addAction (m_actionClose);
918 m_menuFile->insertSeparator (m_actionSave);
919 m_menuFile->addAction (m_actionSave);
920 m_menuFile->addAction (m_actionSaveAs);
921 m_menuFile->addAction (m_actionExport);
922 m_menuFile->insertSeparator (m_actionPrint);
923 m_menuFile->addAction (m_actionPrint);
924 m_menuFile->insertSeparator (m_actionExit);
925 m_menuFile->addAction (m_actionExit);
927 m_menuEdit = menuBar()->addMenu(tr(
"&Edit"));
928 connect (m_menuEdit, SIGNAL (aboutToShow ()),
this, SLOT (slotEditMenu ()));
929 m_menuEdit->addAction (m_actionEditUndo);
930 m_menuEdit->addAction (m_actionEditRedo);
931 m_menuEdit->insertSeparator (m_actionEditCut);
932 m_menuEdit->addAction (m_actionEditCut);
933 m_menuEdit->addAction (m_actionEditCopy);
934 m_menuEdit->addAction (m_actionEditPaste);
935 m_menuEdit->addAction (m_actionEditDelete);
936 m_menuEdit->insertSeparator (m_actionEditPasteAsNew);
937 m_menuEdit->addAction (m_actionEditPasteAsNew);
938 m_menuEdit->addAction (m_actionEditPasteAsNewAdvanced);
940 m_menuDigitize = menuBar()->addMenu(tr(
"Digitize"));
941 m_menuDigitize->addAction (m_actionDigitizeSelect);
942 m_menuDigitize->addAction (m_actionDigitizeAxis);
943 m_menuDigitize->addAction (m_actionDigitizeCurve);
944 m_menuDigitize->addAction (m_actionDigitizePointMatch);
945 m_menuDigitize->addAction (m_actionDigitizeColorPicker);
946 m_menuDigitize->addAction (m_actionDigitizeSegment);
948 m_menuView = menuBar()->addMenu(tr(
"View"));
949 m_menuView->addAction (m_actionViewBackground);
950 m_menuView->addAction (m_actionViewDigitize);
951 m_menuView->addAction (m_actionViewChecklistGuide);
952 m_menuView->addAction (m_actionViewSettingsViews);
953 m_menuView->addAction (m_actionViewCoordSystem);
954 m_menuView->insertSeparator (m_actionViewToolTips);
955 m_menuView->addAction (m_actionViewToolTips);
956 m_menuView->addAction (m_actionViewGridLines);
957 m_menuView->insertSeparator (m_actionViewBackgroundNone);
958 m_menuViewBackground =
new QMenu (tr (
"Background"));
959 m_menuViewBackground->addAction (m_actionViewBackgroundNone);
960 m_menuViewBackground->addAction (m_actionViewBackgroundOriginal);
961 m_menuViewBackground->addAction (m_actionViewBackgroundFiltered);
962 m_menuView->addMenu (m_menuViewBackground);
963 m_menuViewCurves =
new QMenu (tr (
"Curves"));
964 m_menuViewCurves->addAction (m_actionViewCurvesNone);
965 m_menuViewCurves->addAction (m_actionViewCurvesSelected);
966 m_menuViewCurves->addAction (m_actionViewCurvesAll);
967 m_menuView->addMenu (m_menuViewCurves);
968 m_menuViewStatus =
new QMenu (tr (
"Status Bar"));
969 m_menuViewStatus->addAction (m_actionStatusNever);
970 m_menuViewStatus->addAction (m_actionStatusTemporary);
971 m_menuViewStatus->addAction (m_actionStatusAlways);
972 m_menuView->addMenu (m_menuViewStatus);
973 m_menuViewZoom =
new QMenu (tr (
"Zoom"));
974 m_menuViewZoom->addAction (m_actionZoomOut);
975 m_menuViewZoom->addAction (m_actionZoomIn);
976 m_menuViewZoom->insertSeparator (m_actionZoom16To1);
977 m_menuViewZoom->addAction (m_actionZoom16To1);
978 m_menuViewZoom->addAction (m_actionZoom8To1);
979 m_menuViewZoom->addAction (m_actionZoom4To1);
980 m_menuViewZoom->addAction (m_actionZoom2To1);
981 m_menuViewZoom->addAction (m_actionZoom1To1);
982 m_menuViewZoom->addAction (m_actionZoom1To2);
983 m_menuViewZoom->addAction (m_actionZoom1To4);
984 m_menuViewZoom->addAction (m_actionZoom1To8);
985 m_menuViewZoom->addAction (m_actionZoom1To16);
986 m_menuViewZoom->addAction (m_actionZoomFill);
987 m_menuView->addMenu (m_menuViewZoom);
989 m_menuSettings = menuBar()->addMenu(tr (
"Settings"));
990 m_menuSettings->addAction (m_actionSettingsCoords);
991 m_menuSettings->addAction (m_actionSettingsCurveAddRemove);
992 m_menuSettings->addAction (m_actionSettingsCurveProperties);
993 m_menuSettings->addAction (m_actionSettingsDigitizeCurve);
994 m_menuSettings->addAction (m_actionSettingsExport);
995 m_menuSettings->addAction (m_actionSettingsColorFilter);
996 m_menuSettings->addAction (m_actionSettingsAxesChecker);
997 m_menuSettings->addAction (m_actionSettingsGridDisplay);
998 m_menuSettings->addAction (m_actionSettingsGridRemoval);
999 m_menuSettings->addAction (m_actionSettingsPointMatch);
1000 m_menuSettings->addAction (m_actionSettingsSegments);
1001 m_menuSettings->insertSeparator (m_actionSettingsGeneral);
1002 m_menuSettings->addAction (m_actionSettingsGeneral);
1003 m_menuSettings->addAction (m_actionSettingsMainWindow);
1005 m_menuHelp = menuBar()->addMenu(tr(
"&Help"));
1006 m_menuHelp->addAction (m_actionHelpChecklistGuideWizard);
1007 m_menuHelp->insertSeparator(m_actionHelpWhatsThis);
1008 m_menuHelp->addAction (m_actionHelpWhatsThis);
1009 m_menuHelp->addAction (m_actionHelpTutorial);
1010 m_menuHelp->addAction (m_actionHelpHelp);
1011 m_menuHelp->addAction (m_actionHelpAbout);
1013 updateRecentFileList();
1016 void MainWindow::createNetwork ()
1018 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createNetwork";
1023 void MainWindow::createSettingsDialogs ()
1025 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createSettingsDialogs";
1041 m_dlgSettingsCoords->setVisible (
false);
1042 m_dlgSettingsCurveAddRemove->setVisible (
false);
1043 m_dlgSettingsCurveProperties->setVisible (
false);
1044 m_dlgSettingsDigitizeCurve->setVisible (
false);
1045 m_dlgSettingsExportFormat->setVisible (
false);
1046 m_dlgSettingsColorFilter->setVisible (
false);
1047 m_dlgSettingsAxesChecker->setVisible (
false);
1048 m_dlgSettingsGridDisplay->setVisible (
false);
1049 m_dlgSettingsGridRemoval->setVisible (
false);
1050 m_dlgSettingsPointMatch->setVisible (
false);
1051 m_dlgSettingsSegments->setVisible (
false);
1052 m_dlgSettingsGeneral->setVisible (
false);
1053 m_dlgSettingsMainWindow->setVisible (
false);
1056 void MainWindow::createScene ()
1058 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createScene";
1062 m_layout->addWidget (m_view);
1065 void MainWindow::createStateContextBackground ()
1067 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createStateContextBackground";
1072 void MainWindow::createStateContextDigitize ()
1074 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createStateContextDigitize";
1081 void MainWindow::createStateContextTransformation ()
1083 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createStateContextTransformation";
1085 ENGAUGE_CHECK_PTR (m_scene);
1091 void MainWindow::createStatusBar ()
1093 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createStatusBar";
1095 m_statusBar =
new StatusBar (*statusBar ());
1096 connect (
this, SIGNAL (
signalZoom(
int)), m_statusBar, SLOT (slotZoom(
int)));
1097 connect (m_statusBar, SIGNAL (
signalZoom (
int)),
this, SLOT (slotViewZoom (
int)));
1100 void MainWindow::createToolBars ()
1102 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createToolBars";
1104 const int VIEW_SIZE = 22;
1107 m_cmbBackground =
new QComboBox ();
1108 m_cmbBackground->setEnabled (
false);
1109 m_cmbBackground->setStatusTip (tr (
"Select background image"));
1110 m_cmbBackground->setWhatsThis (tr (
"Selected Background\n\n"
1111 "Select background image:\n"
1112 "1) No background which highlights points\n"
1113 "2) Original image which shows everything\n"
1114 "3) Filtered image which highlights important details"));
1115 m_cmbBackground->addItem (tr (
"No background"), QVariant (BACKGROUND_IMAGE_NONE));
1116 m_cmbBackground->addItem (tr (
"Original image"), QVariant (BACKGROUND_IMAGE_ORIGINAL));
1117 m_cmbBackground->addItem (tr (
"Filtered image"), QVariant (BACKGROUND_IMAGE_FILTERED));
1119 connect (m_cmbBackground, SIGNAL (currentIndexChanged (
int)),
this, SLOT (slotCmbBackground (
int)));
1122 m_toolBackground =
new QToolBar (tr (
"Background"),
this);
1123 m_toolBackground->addWidget (m_cmbBackground);
1124 addToolBar (m_toolBackground);
1127 m_cmbCurve =
new QComboBox ();
1128 m_cmbCurve->setEnabled (
false);
1129 m_cmbCurve->setMinimumWidth (180);
1130 m_cmbCurve->setStatusTip (tr (
"Select curve for new points."));
1131 m_cmbCurve->setWhatsThis (tr (
"Selected Curve Name\n\n"
1132 "Select curve for any new points. Every point belongs to one curve."));
1133 connect (m_cmbCurve, SIGNAL (activated (
int)),
this, SLOT (slotCmbCurve (
int)));
1136 m_toolDigitize =
new QToolBar (tr (
"Drawing"),
this);
1137 m_toolDigitize->addAction (m_actionDigitizeSelect);
1138 m_toolDigitize->insertSeparator (m_actionDigitizeAxis);
1139 m_toolDigitize->addAction (m_actionDigitizeAxis);
1140 m_toolDigitize->insertSeparator (m_actionDigitizeCurve);
1141 m_toolDigitize->addAction (m_actionDigitizeCurve);
1142 m_toolDigitize->addAction (m_actionDigitizePointMatch);
1143 m_toolDigitize->addAction (m_actionDigitizeColorPicker);
1144 m_toolDigitize->addAction (m_actionDigitizeSegment);
1145 m_toolDigitize->addWidget (m_cmbCurve);
1146 addToolBar (m_toolDigitize);
1150 m_viewPointStyle->setMinimumSize(VIEW_SIZE, VIEW_SIZE);
1151 m_viewPointStyle->setMaximumSize(VIEW_SIZE, VIEW_SIZE);
1152 m_viewPointStyle->setStatusTip (tr (
"Points style for the currently selected curve"));
1153 m_viewPointStyle->setWhatsThis (tr (
"Points Style\n\n"
1154 "Points style for the currently selected curve. The points style is only "
1155 "displayed in this toolbar. To change the points style, "
1156 "use the Curve Properties dialog."));
1159 m_viewSegmentFilter->setMinimumSize(VIEW_SIZE, VIEW_SIZE);
1160 m_viewSegmentFilter->setMaximumSize(VIEW_SIZE, VIEW_SIZE);
1161 m_viewSegmentFilter->setStatusTip (tr (
"View of filter for current curve in Segment Fill mode"));
1162 m_viewSegmentFilter->setWhatsThis (tr (
"Segment Fill Filter\n\n"
1163 "View of filter for the current curve in Segment Fill mode. The filter settings are only "
1164 "displayed in this toolbar. To changed the filter settings, "
1165 "use the Color Picker mode or the Filter Settings dialog."));
1168 m_toolSettingsViews =
new QToolBar (tr (
"Views"),
this);
1169 m_toolSettingsViews->addWidget (m_viewPointStyle);
1170 m_toolSettingsViews->addWidget (
new QLabel (
" "));
1171 m_toolSettingsViews->addWidget (m_viewSegmentFilter);
1172 addToolBar (m_toolSettingsViews);
1175 m_cmbCoordSystem =
new QComboBox;
1176 m_cmbCoordSystem->setEnabled (
false);
1177 m_cmbCoordSystem->setStatusTip (tr (
"Currently selected coordinate system"));
1178 m_cmbCoordSystem->setWhatsThis (tr (
"Selected Coordinate System\n\n"
1179 "Currently selected coordinate system. This is used to switch between coordinate systems "
1180 "in documents with multiple coordinate systems"));
1181 connect (m_cmbCoordSystem, SIGNAL (activated (
int)),
this, SLOT (slotCmbCoordSystem (
int)));
1183 m_btnShowAll =
new QPushButton(QIcon(
":/engauge/img/icon_show_all.png"),
"");
1184 m_btnShowAll->setEnabled (
false);
1185 m_btnShowAll->setAcceptDrops(
false);
1186 m_btnShowAll->setStatusTip (tr (
"Show all coordinate systems"));
1187 m_btnShowAll->setWhatsThis (tr (
"Show All Coordinate Systems\n\n"
1188 "When pressed and held, this button shows all digitized points and lines for all coordinate systems."));
1189 connect (m_btnShowAll, SIGNAL (pressed ()),
this, SLOT (slotBtnShowAllPressed ()));
1190 connect (m_btnShowAll, SIGNAL (released ()),
this, SLOT (slotBtnShowAllReleased ()));
1192 m_btnPrintAll =
new QPushButton(QIcon(
":/engauge/img/icon_print_all.png"),
"");
1193 m_btnPrintAll->setEnabled (
false);
1194 m_btnPrintAll->setAcceptDrops(
false);
1195 m_btnPrintAll->setStatusTip (tr (
"Print all coordinate systems"));
1196 m_btnPrintAll->setWhatsThis (tr (
"Print All Coordinate Systems\n\n"
1197 "When pressed, this button Prints all digitized points and lines for all coordinate systems."));
1198 connect (m_btnPrintAll, SIGNAL (pressed ()),
this, SLOT (slotBtnPrintAll ()));
1200 m_toolCoordSystem =
new QToolBar (tr (
"Coordinate System"),
this);
1201 m_toolCoordSystem->addWidget (m_cmbCoordSystem);
1202 m_toolCoordSystem->addWidget (m_btnShowAll);
1203 m_toolCoordSystem->addWidget (m_btnPrintAll);
1204 addToolBar (m_toolCoordSystem);
1208 connect (m_dockChecklistGuide, SIGNAL (signalChecklistClosed()),
this, SLOT (slotChecklistClosed()));
1211 void MainWindow::createTutorial ()
1213 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createTutorial";
1216 m_tutorialDlg->setModal (
true);
1217 m_tutorialDlg->setMinimumSize (500, 400);
1218 m_tutorialDlg->hide();
1221 void MainWindow::createZoomMap ()
1223 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createZoomMap";
1225 m_zoomMap [ZOOM_INITIAL_16_TO_1] = ZOOM_16_TO_1;
1226 m_zoomMap [ZOOM_INITIAL_8_TO_1] = ZOOM_8_TO_1;
1227 m_zoomMap [ZOOM_INITIAL_4_TO_1] = ZOOM_4_TO_1;
1228 m_zoomMap [ZOOM_INITIAL_2_TO_1] = ZOOM_2_TO_1;
1229 m_zoomMap [ZOOM_INITIAL_1_TO_1] = ZOOM_1_TO_1;
1230 m_zoomMap [ZOOM_INITIAL_1_TO_2] = ZOOM_1_TO_2;
1231 m_zoomMap [ZOOM_INITIAL_1_TO_4] = ZOOM_1_TO_4;
1232 m_zoomMap [ZOOM_INITIAL_1_TO_8] = ZOOM_1_TO_8;
1233 m_zoomMap [ZOOM_INITIAL_1_TO_16] = ZOOM_1_TO_16;
1234 m_zoomMap [ZOOM_INITIAL_FILL] = ZOOM_FILL;
1237 ZoomFactor MainWindow::currentZoomFactor ()
const
1239 if (m_actionZoom1To1->isChecked()) {
1241 }
else if (m_actionZoom1To2->isChecked()) {
1243 }
else if (m_actionZoom1To4->isChecked()) {
1245 }
else if (m_actionZoom1To8->isChecked()) {
1247 }
else if (m_actionZoom1To16->isChecked()) {
1248 return ZOOM_1_TO_16;
1249 }
else if (m_actionZoom2To1->isChecked()) {
1251 }
else if (m_actionZoom4To1->isChecked()) {
1253 }
else if (m_actionZoom8To1->isChecked()) {
1255 }
else if (m_actionZoom16To1->isChecked()) {
1256 return ZOOM_16_TO_1;
1257 }
else if (m_actionZoomFill->isChecked()) {
1260 ENGAUGE_ASSERT (
false);
1266 if (event->type () == QEvent::KeyPress) {
1268 QKeyEvent *eventKeyPress = (QKeyEvent *) event;
1271 if ((eventKeyPress->key() == Qt::Key_E) &&
1272 ((eventKeyPress->modifiers() & Qt::ShiftModifier) != 0) &&
1273 ((eventKeyPress->modifiers() & Qt::ControlModifier) != 0)) {
1283 return QObject::eventFilter (target, event);
1287 void MainWindow::exportAllCoordinateSystems()
1289 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::exportAllCoordinateSystems";
1298 QString regressionFile = QString (
"%1_%2")
1299 .arg (m_regressionFile)
1301 fileExport (regressionFile,
1307 QString MainWindow::exportFilenameFromInputFilename (
const QString &fileName)
const
1309 QString outFileName = fileName;
1311 outFileName = outFileName.replace (
".xml",
".csv_actual");
1312 outFileName = outFileName.replace (
".dig",
".csv_actual");
1317 void MainWindow::fileExport(
const QString &fileName,
1320 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::fileExport"
1321 <<
" fileName=" << fileName.toLatin1().data();
1323 QFile file (fileName);
1324 if (file.open(QIODevice::WriteOnly)) {
1326 QTextStream str (&file);
1338 m_isDocumentExported =
true;
1339 m_dockChecklistGuide->
update (*m_cmdMediator,
1340 m_isDocumentExported);
1344 LOG4CPP_ERROR_S ((*mainCat)) <<
"MainWindow::fileExport"
1345 <<
" file=" << fileName.toLatin1().data()
1346 <<
" curDir=" << QDir::currentPath().toLatin1().data();
1347 QMessageBox::critical (0,
1348 engaugeWindowTitle(),
1349 tr (
"Unable to export to file ") + fileName);
1353 void MainWindow::fileImport (
const QString &fileName,
1354 ImportType importType)
1356 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::fileImport"
1357 <<
" fileName=" << fileName.toLatin1 ().data ()
1358 <<
" curDir=" << QDir::currentPath().toLatin1().data()
1359 <<
" importType=" << importType;
1361 QString originalFileOld = m_originalFile;
1362 bool originalFileWasImported = m_originalFileWasImported;
1364 m_originalFile = fileName;
1365 m_originalFileWasImported =
true;
1367 if (importType == IMPORT_TYPE_ADVANCED) {
1378 bool loaded =
false;
1379 #ifdef ENGAUGE_JPEG2000
1381 loaded = jpeg2000.
load (fileName,
1383 #endif // ENGAUGE_JPEG2000
1385 loaded = image.load (fileName);
1389 QMessageBox::warning (
this,
1390 engaugeWindowTitle(),
1392 .arg (tr (
"Cannot read file"))
1396 m_originalFile = originalFileOld;
1397 m_originalFileWasImported = originalFileWasImported;
1401 loaded = loadImage (fileName,
1408 if (importType == IMPORT_TYPE_ADVANCED) {
1418 m_originalFile = originalFileOld;
1419 m_originalFileWasImported = originalFileWasImported;
1425 void MainWindow::fileImportWithPrompts (ImportType importType)
1427 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::fileImportWithPrompts"
1428 <<
" importType=" << importType;
1433 QTextStream str (&filter);
1436 QList<QByteArray>::const_iterator itr;
1437 QList<QByteArray> supportedImageFormats = QImageReader::supportedImageFormats();
1438 QStringList supportedImageFormatStrings;
1439 for (itr = supportedImageFormats.begin (); itr != supportedImageFormats.end (); itr++) {
1440 QByteArray arr = *itr;
1441 QString extensionAsWildcard = QString (
"*.%1").arg (QString (arr));
1442 supportedImageFormatStrings << extensionAsWildcard;
1444 #ifdef ENGAUGE_JPEG2000
1447 #endif // ENGAUGE_JPEG2000
1449 supportedImageFormatStrings.sort();
1451 str <<
"Image Files (" << supportedImageFormatStrings.join (
" ") <<
")";
1455 str <<
";; All Files (*.*)";
1457 QString fileName = QFileDialog::getOpenFileName (
this,
1459 QDir::currentPath (),
1461 if (!fileName.isEmpty ()) {
1464 fileImport (fileName,
1470 void MainWindow::filePaste (ImportType importType)
1472 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::filePaste"
1473 <<
" importType=" << importType;
1475 QString originalFileOld = m_originalFile;
1476 bool originalFileWasImported = m_originalFileWasImported;
1478 QString fileName (
"clipboard");
1479 m_originalFile = fileName;
1480 m_originalFileWasImported =
true;
1482 if (importType == IMPORT_TYPE_ADVANCED) {
1493 QImage image = QApplication::clipboard()->image();
1495 bool loaded =
false;
1497 loaded = !image.isNull();
1501 QMessageBox::warning (
this,
1502 engaugeWindowTitle(),
1504 .arg (tr (
"Cannot read file"))
1508 m_originalFile = originalFileOld;
1509 m_originalFileWasImported = originalFileWasImported;
1513 loaded = loadImage (fileName,
1520 if (importType == IMPORT_TYPE_ADVANCED) {
1530 m_originalFile = originalFileOld;
1531 m_originalFileWasImported = originalFileWasImported;
1537 void MainWindow::ghostsCreate ()
1539 LOG4CPP_DEBUG_S ((*mainCat)) <<
"MainWindow::ghostsCreate";
1541 ENGAUGE_ASSERT (m_ghosts == 0);
1563 void MainWindow::ghostsDestroy ()
1565 LOG4CPP_DEBUG_S ((*mainCat)) <<
"MainWindow::ghostsDestroy";
1567 ENGAUGE_CHECK_PTR (m_ghosts);
1585 void MainWindow::loadCoordSystemListFromCmdMediator ()
1587 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::loadCoordSystemListFromCmdMediator";
1589 m_cmbCoordSystem->clear();
1593 for (
unsigned int i = 0; i < numberCoordSystem; i++) {
1594 int index1Based = i + 1;
1595 m_cmbCoordSystem->addItem (QString::number (index1Based),
1600 m_cmbCoordSystem->setCurrentIndex (0);
1603 bool enable = (m_cmbCoordSystem->count() > 1);
1604 m_cmbCoordSystem->setEnabled (enable);
1605 m_btnShowAll->setEnabled (enable);
1606 m_btnPrintAll->setEnabled (enable);
1609 void MainWindow::loadCurveListFromCmdMediator ()
1611 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::loadCurveListFromCmdMediator";
1613 m_cmbCurve->clear ();
1615 QStringList::iterator itr;
1616 for (itr = curvesGraphsNames.begin (); itr != curvesGraphsNames.end (); itr++) {
1618 QString curvesGraphName = *itr;
1619 m_cmbCurve->addItem (curvesGraphName);
1626 void MainWindow::loadDocumentFile (
const QString &fileName)
1628 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::loadDocumentFile fileName=" << fileName.toLatin1 ().data ();
1630 QApplication::setOverrideCursor(Qt::WaitCursor);
1633 QApplication::restoreOverrideCursor();
1637 setCurrentPathFromFile (fileName);
1638 rebuildRecentFileListForCurrentFile(fileName);
1639 m_currentFile = fileName;
1641 if (m_cmdMediator != 0) {
1642 delete m_cmdMediator;
1647 setupAfterLoad(fileName,
1649 IMPORT_TYPE_SIMPLE);
1652 m_actionDigitizeSelect->setChecked (
true);
1653 slotDigitizeSelect();
1655 m_engaugeFile = fileName;
1656 m_originalFile = fileName;
1657 m_originalFileWasImported =
false;
1664 QMessageBox::warning (
this,
1665 engaugeWindowTitle(),
1666 QString(
"%1 %2:\n%3.")
1667 .arg (tr (
"Cannot read file"))
1675 void MainWindow::loadErrorReportFile(
const QString &initialPath,
1676 const QString &errorReportFile)
1678 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::loadErrorReportFile"
1679 <<
" path=" << initialPath.toLatin1().data()
1680 <<
" file=" << errorReportFile.toLatin1().data();
1686 QString originalPath = QDir::currentPath();
1687 QDir::setCurrent(initialPath);
1689 QFile file (errorReportFile);
1690 if (!file.exists()) {
1692 QFileInfo fileInfo (errorReportFile);
1694 QMessageBox::critical (
this,
1695 engaugeWindowTitle(),
1696 tr (
"File not found:") +
" " + fileInfo.absoluteFilePath());
1701 QXmlStreamReader reader (&file);
1702 file.open(QIODevice::ReadOnly | QIODevice::Text);
1713 QDir::setCurrent(originalPath);
1715 setupAfterLoad(errorReportFile,
1716 "Error report opened",
1717 IMPORT_TYPE_SIMPLE);
1720 m_actionDigitizeSelect->setChecked (
true);
1721 slotDigitizeSelect();
1726 bool MainWindow::loadImage (
const QString &fileName,
1727 const QImage &image,
1728 ImportType importType)
1730 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::loadImage"
1731 <<
" fileName=" << fileName.toLatin1 ().data ()
1732 <<
" importType=" << importType;
1734 QApplication::setOverrideCursor(Qt::WaitCursor);
1737 QApplication::restoreOverrideCursor();
1739 setCurrentPathFromFile (fileName);
1741 m_engaugeFile = EMPTY_FILENAME;
1743 if (m_cmdMediator != 0) {
1744 delete m_cmdMediator;
1749 bool accepted = setupAfterLoad(fileName,
1750 tr (
"File imported"),
1756 if (m_actionHelpChecklistGuideWizard->isChecked () &&
1757 (m_fileCmdScript == 0)) {
1762 if (wizard->exec() == QDialog::Accepted) {
1764 for (CoordSystemIndex coordSystemIndex = 0; coordSystemIndex < m_cmdMediator->
document().
coordSystemCount(); coordSystemIndex++) {
1778 m_actionViewChecklistGuide->setChecked (
true);
1781 loadCurveListFromCmdMediator();
1784 loadCoordSystemListFromCmdMediator();
1790 m_actionDigitizeAxis->setChecked (
true);
1791 slotDigitizeAxis ();
1799 void MainWindow::loadInputFileForErrorReport(QDomDocument &domInputFile)
const
1801 QFile file (m_originalFile);
1805 if (!file.open (QIODevice::ReadOnly)) {
1809 domInputFile.setContent (&file);
1813 void MainWindow::loadToolTips()
1815 if (m_actionViewToolTips->isChecked ()) {
1818 m_actionDigitizeSelect->setToolTip (m_actionDigitizeSelect->text());
1819 m_actionDigitizeAxis->setToolTip (m_actionDigitizeAxis->text());
1820 m_actionDigitizeCurve->setToolTip (m_actionDigitizeCurve->text());
1821 m_actionDigitizePointMatch->setToolTip (m_actionDigitizePointMatch->text());
1822 m_actionDigitizeColorPicker->setToolTip (m_actionDigitizeColorPicker->text());
1823 m_actionDigitizeSegment->setToolTip (m_actionDigitizeSegment->text());
1824 m_cmbBackground->setToolTip (tr (
"Background image."));
1825 m_cmbCurve->setToolTip (tr (
"Currently selected curve."));
1826 m_viewPointStyle->setToolTip (tr (
"Point style for currently selected curve."));
1827 m_viewSegmentFilter->setToolTip (tr (
"Segment Fill filter for currently selected curve."));
1832 m_actionDigitizeSelect->setToolTip (
"");
1833 m_actionDigitizeAxis->setToolTip (
"");
1834 m_actionDigitizeCurve->setToolTip (
"");
1835 m_actionDigitizePointMatch->setToolTip (
"");
1836 m_actionDigitizeColorPicker->setToolTip (
"");
1837 m_actionDigitizeSegment->setToolTip (
"");
1838 m_cmbBackground->setToolTip (
"");
1839 m_cmbCurve->setToolTip (
"");
1840 m_viewPointStyle->setToolTip (
"");
1841 m_viewSegmentFilter->setToolTip (
"");
1846 bool MainWindow::maybeSave()
1848 if (m_cmdMediator != 0) {
1850 QMessageBox::StandardButton ret = QMessageBox::warning (
this,
1851 engaugeWindowTitle(),
1852 tr(
"The document has been modified.\n"
1853 "Do you want to save your changes?"),
1854 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
1855 if (ret == QMessageBox::Save) {
1856 return slotFileSave();
1857 }
else if (ret == QMessageBox::Cancel) {
1868 const QString &fileName)
const
1876 QString csvExtension = QString (
".%1")
1878 QString tsvExtension = QString (
".%1")
1880 QString fileExtensionVersusCsv = fileName.right (csvExtension.size());
1881 QString fileExtensionVersusTsv = fileName.right (tsvExtension.size());
1885 if (csvExtension.compare (fileExtensionVersusCsv, Qt::CaseInsensitive) == 0) {
1886 modelExportFormatAfter.
setDelimiter (EXPORT_DELIMITER_COMMA);
1887 }
else if (tsvExtension.compare (fileExtensionVersusTsv, Qt::CaseInsensitive) == 0) {
1888 modelExportFormatAfter.
setDelimiter (EXPORT_DELIMITER_TAB);
1892 return modelExportFormatAfter;
1897 return m_modelMainWindow;
1900 void MainWindow::rebuildRecentFileListForCurrentFile(
const QString &filePath)
1902 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::rebuildRecentFileListForCurrentFile";
1904 setWindowFilePath (filePath);
1906 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
1907 QStringList recentFilePaths = settings.value (SETTINGS_RECENT_FILE_LIST).toStringList();
1908 recentFilePaths.removeAll (filePath);
1909 recentFilePaths.prepend (filePath);
1910 while (recentFilePaths.count () > (int) MAX_RECENT_FILE_LIST_SIZE) {
1911 recentFilePaths.removeLast ();
1913 settings.setValue (SETTINGS_RECENT_FILE_LIST, recentFilePaths);
1915 updateRecentFileList();
1920 LOG4CPP_DEBUG_S ((*mainCat)) <<
"MainWindow::resizeEvent";
1922 if (m_actionZoomFill->isChecked ()) {
1927 bool MainWindow::saveDocumentFile (
const QString &fileName)
1929 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::saveDocumentFile fileName=" << fileName.toLatin1 ().data ();
1931 QFile file(fileName);
1932 if (!file.open(QFile::WriteOnly)) {
1933 QMessageBox::warning (
this,
1934 engaugeWindowTitle(),
1935 QString (
"%1 %2: \n%3.")
1936 .arg(tr (
"Cannot write file"))
1938 .arg(file.errorString()));
1942 rebuildRecentFileListForCurrentFile (fileName);
1944 QApplication::setOverrideCursor (Qt::WaitCursor);
1945 QXmlStreamWriter writer(&file);
1946 writer.setAutoFormatting(
true);
1947 writer.writeStartDocument();
1948 writer.writeDTD(
"<!DOCTYPE engauge>");
1950 writer.writeEndDocument();
1951 QApplication::restoreOverrideCursor ();
1955 m_cmdMediator->setClean ();
1957 setCurrentFile(fileName);
1958 m_engaugeFile = fileName;
1968 const char *comment)
const
1972 if ((m_cmdMediator != 0) && !m_isRegressionTest) {
1974 QString report = saveErrorReportFileAndExitXml (context,
1981 if (dlg.exec() == QDialog::Accepted) {
1989 QString MainWindow::saveErrorReportFileAndExitXml (
const char *context,
1992 const char *comment)
const
1994 const bool DEEP_COPY =
true;
1996 QString xmlErrorReport;
1997 QXmlStreamWriter writer (&xmlErrorReport);
1998 writer.setAutoFormatting(
true);
2001 writer.writeStartElement(DOCUMENT_SERIALIZE_ERROR_REPORT);
2004 writer.writeStartElement(DOCUMENT_SERIALIZE_APPLICATION);
2005 writer.writeAttribute(DOCUMENT_SERIALIZE_APPLICATION_VERSION_NUMBER, VERSION_NUMBER);
2006 writer.writeEndElement();
2010 QXmlStreamReader reader (m_startingDocumentSnapshot);
2011 while (!reader.atEnd ()) {
2013 if (reader.tokenType() != QXmlStreamReader::StartDocument &&
2014 reader.tokenType() != QXmlStreamReader::EndDocument) {
2015 writer.writeCurrentToken (reader);
2020 writer.writeStartElement(DOCUMENT_SERIALIZE_OPERATING_SYSTEM);
2021 writer.writeAttribute(DOCUMENT_SERIALIZE_OPERATING_SYSTEM_ENDIAN, EndianToString (QSysInfo::ByteOrder));
2022 writer.writeAttribute(DOCUMENT_SERIALIZE_OPERATING_SYSTEM_WORD_SIZE, QString::number (QSysInfo::WordSize));
2023 writer.writeEndElement();
2026 writer.writeStartElement(DOCUMENT_SERIALIZE_FILE);
2027 writer.writeAttribute(DOCUMENT_SERIALIZE_FILE_IMPORTED,
2028 m_originalFileWasImported ? DOCUMENT_SERIALIZE_BOOL_TRUE : DOCUMENT_SERIALIZE_BOOL_FALSE);
2029 writer.writeEndElement();
2032 m_cmdMediator->
saveXml(writer);
2035 writer.writeStartElement(DOCUMENT_SERIALIZE_ERROR);
2036 writer.writeAttribute(DOCUMENT_SERIALIZE_ERROR_CONTEXT, context);
2037 writer.writeAttribute(DOCUMENT_SERIALIZE_ERROR_FILE, file);
2038 writer.writeAttribute(DOCUMENT_SERIALIZE_ERROR_LINE, QString::number (line));
2039 writer.writeAttribute(DOCUMENT_SERIALIZE_ERROR_COMMENT, comment);
2040 writer.writeEndElement();
2042 writer.writeEndElement();
2045 QDomDocument domErrorReport (
"ErrorReport");
2046 domErrorReport.setContent (xmlErrorReport);
2049 if (!m_originalFileWasImported) {
2053 QDomDocument domInputFile;
2054 loadInputFileForErrorReport (domInputFile);
2055 QDomDocumentFragment fragmentFileFrom = domErrorReport.createDocumentFragment();
2056 if (!domInputFile.isNull()) {
2057 fragmentFileFrom.appendChild (domErrorReport.importNode (domInputFile.documentElement(), DEEP_COPY));
2059 QDomNodeList nodesFileTo = domErrorReport.elementsByTagName (DOCUMENT_SERIALIZE_FILE);
2060 if (nodesFileTo.count () > 0) {
2061 QDomNode nodeFileTo = nodesFileTo.at (0);
2062 nodeFileTo.appendChild (fragmentFileFrom);
2069 QDomNodeList nodesDocument = domErrorReport.elementsByTagName (DOCUMENT_SERIALIZE_DOCUMENT);
2070 for (
int i = 0 ; i < nodesDocument.count(); i++) {
2071 QDomNode nodeDocument = nodesDocument.at (i);
2072 QDomElement elemImage = nodeDocument.firstChildElement(DOCUMENT_SERIALIZE_IMAGE);
2073 if (!elemImage.isNull()) {
2076 if (elemImage.hasAttribute (DOCUMENT_SERIALIZE_IMAGE_WIDTH) &&
2077 elemImage.hasAttribute (DOCUMENT_SERIALIZE_IMAGE_HEIGHT)) {
2079 int width = elemImage.attribute(DOCUMENT_SERIALIZE_IMAGE_WIDTH).toInt();
2080 int height = elemImage.attribute(DOCUMENT_SERIALIZE_IMAGE_HEIGHT).toInt();
2082 QDomNode nodeReplacement;
2083 QDomElement elemReplacement = nodeReplacement.toElement();
2084 elemReplacement.setAttribute (DOCUMENT_SERIALIZE_IMAGE_WIDTH, width);
2085 elemReplacement.setAttribute (DOCUMENT_SERIALIZE_IMAGE_HEIGHT, height);
2088 nodeDocument.insertBefore (nodeReplacement,
2090 nodeDocument.removeChild(elemImage);
2096 return domErrorReport.toString();
2099 void MainWindow::saveStartingDocumentSnapshot()
2101 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::saveStartingDocumentSnapshot";
2103 QXmlStreamWriter writer (&m_startingDocumentSnapshot);
2104 writer.setAutoFormatting (
true);
2110 ENGAUGE_CHECK_PTR (m_scene);
2116 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::selectBackgroundOriginal";
2118 BackgroundImage previousBackground = (BackgroundImage) m_cmbBackground->currentData().toInt();
2120 int index = m_cmbBackground->findData (backgroundImage);
2121 ENGAUGE_ASSERT (index >= 0);
2123 m_cmbBackground->setCurrentIndex(index);
2125 return previousBackground;
2130 return m_cmbCurve->currentText ();
2133 void MainWindow::setCurrentFile (
const QString &fileName)
2135 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::setCurrentFile";
2137 QString fileNameStripped;
2138 if (!fileName.isEmpty()) {
2141 QFileInfo fileInfo (fileName);
2142 fileNameStripped = fileInfo.baseName();
2145 m_currentFile = fileNameStripped;
2146 m_currentFileWithPathAndFileExtension = fileName;
2148 updateWindowTitle ();
2151 void MainWindow::setCurrentPathFromFile (
const QString &fileName)
2153 QDir dir = QFileInfo (fileName).absoluteDir();
2155 if (dir.exists ()) {
2157 bool success = QDir::setCurrent (dir.absolutePath ());
2158 ENGAUGE_ASSERT (success);
2166 void MainWindow::setPixmap (
const QPixmap &pixmap)
2168 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::setPixmap";
2172 m_backgroundStateContext->
setPixmap (m_transformation,
2176 m_cmbCurve->currentText());
2179 void MainWindow::settingsRead ()
2181 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
2183 settingsReadEnvironment (settings);
2184 settingsReadMainWindow (settings);
2187 void MainWindow::settingsReadEnvironment (QSettings &settings)
2189 settings.beginGroup (SETTINGS_GROUP_ENVIRONMENT);
2190 QDir::setCurrent (settings.value (SETTINGS_CURRENT_DIRECTORY,
2191 QDir::currentPath ()).toString ());
2192 settings.endGroup ();
2195 void MainWindow::settingsReadMainWindow (QSettings &settings)
2197 settings.beginGroup(SETTINGS_GROUP_MAIN_WINDOW);
2200 resize (settings.value (SETTINGS_SIZE,
2201 QSize (600, 600)).toSize ());
2202 move (settings.value (SETTINGS_POS,
2203 QPoint (200, 200)).toPoint ());
2206 QSize helpSize = settings.value (SETTINGS_HELP_SIZE,
2207 QSize (900, 600)).toSize();
2208 m_helpWindow->resize (helpSize);
2209 if (settings.contains (SETTINGS_HELP_POS)) {
2210 QPoint helpPos = settings.value (SETTINGS_HELP_POS).toPoint();
2211 m_helpWindow->move (helpPos);
2215 m_actionHelpChecklistGuideWizard->setChecked (settings.value (SETTINGS_CHECKLIST_GUIDE_WIZARD,
2219 bool viewBackgroundToolBar = settings.value (SETTINGS_VIEW_BACKGROUND_TOOLBAR,
2221 m_actionViewBackground->setChecked (viewBackgroundToolBar);
2222 m_toolBackground->setVisible (viewBackgroundToolBar);
2223 BackgroundImage backgroundImage = (BackgroundImage) settings.value (SETTINGS_BACKGROUND_IMAGE,
2224 BACKGROUND_IMAGE_FILTERED).toInt ();
2225 int indexBackground = m_cmbBackground->findData (QVariant (backgroundImage));
2226 m_cmbBackground->setCurrentIndex (indexBackground);
2229 bool viewDigitizeToolBar = settings.value (SETTINGS_VIEW_DIGITIZE_TOOLBAR,
2231 m_actionViewDigitize->setChecked (viewDigitizeToolBar);
2232 m_toolDigitize->setVisible (viewDigitizeToolBar);
2235 bool viewSettingsViewsToolBar = settings.value (SETTINGS_VIEW_SETTINGS_VIEWS_TOOLBAR,
2237 m_actionViewSettingsViews->setChecked (viewSettingsViewsToolBar);
2238 m_toolSettingsViews->setVisible (viewSettingsViewsToolBar);
2241 bool viewCoordSystemToolbar = settings.value (SETTINGS_VIEW_COORD_SYSTEM_TOOLBAR,
2243 m_actionViewCoordSystem->setChecked (viewCoordSystemToolbar);
2244 m_toolCoordSystem->setVisible (viewCoordSystemToolbar);
2247 bool viewToolTips = settings.value (SETTINGS_VIEW_TOOL_TIPS,
2249 m_actionViewToolTips->setChecked (viewToolTips);
2253 StatusBarMode statusBarMode = (StatusBarMode) settings.value (SETTINGS_VIEW_STATUS_BAR,
2256 m_actionStatusNever->setChecked (statusBarMode == STATUS_BAR_MODE_NEVER);
2257 m_actionStatusTemporary->setChecked (statusBarMode == STATUS_BAR_MODE_TEMPORARY);
2258 m_actionStatusAlways->setChecked (statusBarMode == STATUS_BAR_MODE_ALWAYS);
2263 const bool DOCKED_EQUALS_NOT_FLOATING =
false;
2264 Qt::DockWidgetArea area = (Qt::DockWidgetArea) settings.value (SETTINGS_CHECKLIST_GUIDE_DOCK_AREA,
2265 Qt::NoDockWidgetArea).toInt();
2267 if (area == Qt::NoDockWidgetArea) {
2269 addDockWidget (Qt::RightDockWidgetArea,
2270 m_dockChecklistGuide);
2271 m_dockChecklistGuide->setFloating(DOCKED_EQUALS_NOT_FLOATING);
2272 if (settings.contains (SETTINGS_CHECKLIST_GUIDE_DOCK_GEOMETRY)) {
2273 m_dockChecklistGuide->restoreGeometry (settings.value (SETTINGS_CHECKLIST_GUIDE_DOCK_GEOMETRY).toByteArray());
2278 addDockWidget (area,
2279 m_dockChecklistGuide);
2286 QLocale localeDefault;
2287 QLocale::Language language = (QLocale::Language) settings.value (SETTINGS_LOCALE_LANGUAGE,
2288 QVariant (localeDefault.language())).toInt();
2289 QLocale::Country country = (QLocale::Country) settings.value (SETTINGS_LOCALE_COUNTRY,
2290 QVariant (localeDefault.country())).toInt();
2291 QLocale locale (language,
2293 slotViewZoom ((ZoomFactor) settings.value (SETTINGS_ZOOM_FACTOR,
2294 QVariant (ZOOM_1_TO_1)).toInt());
2296 m_modelMainWindow.
setZoomFactorInitial((ZoomFactorInitial) settings.value (SETTINGS_ZOOM_FACTOR_INITIAL,
2297 QVariant (DEFAULT_ZOOM_FACTOR_INITIAL)).toInt());
2298 m_modelMainWindow.
setZoomControl ((ZoomControl) settings.value (SETTINGS_ZOOM_CONTROL,
2299 QVariant (ZOOM_CONTROL_MENU_WHEEL_PLUSMINUS)).toInt());
2300 m_modelMainWindow.
setMainTitleBarFormat ((MainTitleBarFormat) settings.value (SETTINGS_MAIN_TITLE_BAR_FORMAT,
2301 QVariant (MAIN_TITLE_BAR_FORMAT_PATH)).toInt());
2304 settings.endGroup();
2307 void MainWindow::settingsWrite ()
2309 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
2311 settings.beginGroup (SETTINGS_GROUP_ENVIRONMENT);
2312 settings.setValue (SETTINGS_CURRENT_DIRECTORY, QDir::currentPath ());
2313 settings.endGroup ();
2315 settings.beginGroup (SETTINGS_GROUP_MAIN_WINDOW);
2316 settings.setValue (SETTINGS_SIZE, size ());
2317 settings.setValue (SETTINGS_POS, pos ());
2318 settings.setValue (SETTINGS_HELP_SIZE, m_helpWindow->size());
2319 settings.setValue (SETTINGS_HELP_POS, m_helpWindow->pos ());
2320 if (m_dockChecklistGuide->isFloating()) {
2322 settings.setValue (SETTINGS_CHECKLIST_GUIDE_DOCK_AREA, Qt::NoDockWidgetArea);
2323 settings.setValue (SETTINGS_CHECKLIST_GUIDE_DOCK_GEOMETRY, m_dockChecklistGuide->saveGeometry ());
2327 settings.setValue (SETTINGS_CHECKLIST_GUIDE_DOCK_AREA, dockWidgetArea (m_dockChecklistGuide));
2330 settings.setValue (SETTINGS_CHECKLIST_GUIDE_WIZARD, m_actionHelpChecklistGuideWizard->isChecked ());
2331 settings.setValue (SETTINGS_LOCALE_LANGUAGE, m_modelMainWindow.
locale().language());
2332 settings.setValue (SETTINGS_LOCALE_COUNTRY, m_modelMainWindow.
locale().country());
2333 settings.setValue (SETTINGS_VIEW_BACKGROUND_TOOLBAR, m_actionViewBackground->isChecked());
2334 settings.setValue (SETTINGS_BACKGROUND_IMAGE, m_cmbBackground->currentData().toInt());
2335 settings.setValue (SETTINGS_VIEW_DIGITIZE_TOOLBAR, m_actionViewDigitize->isChecked ());
2336 settings.setValue (SETTINGS_VIEW_STATUS_BAR, m_statusBar->
statusBarMode ());
2337 settings.setValue (SETTINGS_VIEW_SETTINGS_VIEWS_TOOLBAR, m_actionViewSettingsViews->isChecked ());
2338 settings.setValue (SETTINGS_VIEW_COORD_SYSTEM_TOOLBAR, m_actionViewCoordSystem->isChecked ());
2339 settings.setValue (SETTINGS_VIEW_TOOL_TIPS, m_actionViewToolTips->isChecked ());
2340 settings.setValue (SETTINGS_ZOOM_CONTROL, m_modelMainWindow.
zoomControl());
2341 settings.setValue (SETTINGS_ZOOM_FACTOR, currentZoomFactor ());
2342 settings.setValue (SETTINGS_ZOOM_FACTOR_INITIAL, m_modelMainWindow.
zoomFactorInitial());
2343 settings.setValue (SETTINGS_MAIN_TITLE_BAR_FORMAT, m_modelMainWindow.
mainTitleBarFormat());
2344 settings.endGroup ();
2347 bool MainWindow::setupAfterLoad (
const QString &fileName,
2348 const QString &temporaryMessage ,
2349 ImportType importType)
2351 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::setupAfterLoad"
2352 <<
" file=" << fileName.toLatin1().data()
2353 <<
" message=" << temporaryMessage.toLatin1().data()
2354 <<
" importType=" << importType;
2356 const QString EMPTY_CURVE_NAME_TO_SKIP_BACKGROUND_PROCESSING;
2360 m_digitizeStateContext->
resetOnLoad (m_cmdMediator);
2364 EMPTY_CURVE_NAME_TO_SKIP_BACKGROUND_PROCESSING);
2365 setPixmap (m_cmdMediator->
pixmap ());
2369 if (importType == IMPORT_TYPE_ADVANCED) {
2371 applyZoomFactorAfterLoad();
2374 dlgImportAdvanced.exec();
2376 if (dlgImportAdvanced.result() == QDialog::Rejected) {
2380 int numberCoordSystem = dlgImportAdvanced.numberCoordSystem();
2389 connect (m_actionEditUndo, SIGNAL (triggered ()), m_cmdMediator, SLOT (undo ()));
2390 connect (m_actionEditUndo, SIGNAL (triggered ()), m_cmdStackShadow, SLOT (slotUndo ()));
2391 connect (m_actionEditRedo, SIGNAL (triggered ()), m_cmdMediator, SLOT (redo ()));
2392 connect (m_actionEditRedo, SIGNAL (triggered ()), m_cmdStackShadow, SLOT (slotRedo ()));
2393 connect (m_cmdMediator, SIGNAL (canRedoChanged(
bool)),
this, SLOT (slotCanRedoChanged (
bool)));
2394 connect (m_cmdMediator, SIGNAL (canUndoChanged(
bool)),
this, SLOT (slotCanUndoChanged (
bool)));
2395 connect (m_cmdMediator, SIGNAL (redoTextChanged (
const QString &)),
this, SLOT (slotRedoTextChanged (
const QString &)));
2396 connect (m_cmdMediator, SIGNAL (undoTextChanged (
const QString &)),
this, SLOT (slotUndoTextChanged (
const QString &)));
2397 loadCurveListFromCmdMediator ();
2398 loadCoordSystemListFromCmdMediator ();
2401 m_isDocumentExported =
false;
2410 m_cmbCurve->currentText ());
2411 m_backgroundStateContext->
setBackgroundImage ((BackgroundImage) m_cmbBackground->currentIndex ());
2413 applyZoomFactorAfterLoad();
2415 setCurrentFile(fileName);
2419 saveStartingDocumentSnapshot();
2428 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::showEvent"
2429 <<
" files=" << m_loadStartupFiles.join (
",").toLatin1().data();
2431 QMainWindow::showEvent (event);
2433 if (m_loadStartupFiles.count() > 0) {
2435 m_timerLoadStartupFiles =
new QTimer;
2436 m_timerLoadStartupFiles->setSingleShot (
true);
2437 connect (m_timerLoadStartupFiles, SIGNAL (timeout ()),
this, SLOT (slotLoadStartupFiles ()));
2438 m_timerLoadStartupFiles->start (0);
2448 void MainWindow::slotBtnPrintAll ()
2450 LOG4CPP_DEBUG_S ((*mainCat)) <<
"MainWindow::slotBtnPrintAll";
2454 QPrinter printer (QPrinter::HighResolution);
2455 QPrintDialog dlg (&printer,
this);
2456 if (dlg.exec() == QDialog::Accepted) {
2457 QPainter painter (&printer);
2458 m_view->render (&painter);
2465 void MainWindow::slotBtnShowAllPressed ()
2467 LOG4CPP_DEBUG_S ((*mainCat)) <<
"MainWindow::slotBtnShowAllPressed";
2473 void MainWindow::slotBtnShowAllReleased ()
2475 LOG4CPP_DEBUG_S ((*mainCat)) <<
"MainWindow::slotBtnShowAllReleased";
2481 void MainWindow::slotCanRedoChanged (
bool canRedo)
2483 LOG4CPP_DEBUG_S ((*mainCat)) <<
"MainWindow::slotCanRedoChanged";
2485 m_actionEditRedo->setEnabled (canRedo || m_cmdStackShadow->
canRedo());
2488 void MainWindow::slotCanUndoChanged (
bool canUndo)
2490 LOG4CPP_DEBUG_S ((*mainCat)) <<
"MainWindow::slotCanUndoChanged";
2492 m_actionEditUndo->setEnabled (canUndo);
2495 void MainWindow::slotChecklistClosed()
2497 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotChecklistClosed";
2499 m_actionViewChecklistGuide->setChecked (
false);
2502 void MainWindow::slotCleanChanged(
bool clean)
2504 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotCleanChanged";
2506 setWindowModified (!clean);
2509 void MainWindow::slotCmbBackground(
int currentIndex)
2511 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotCmbBackground";
2513 switch (currentIndex) {
2514 case BACKGROUND_IMAGE_NONE:
2515 if (!m_actionViewBackgroundNone->isChecked()) {
2516 m_actionViewBackgroundNone->toggle();
2520 case BACKGROUND_IMAGE_ORIGINAL:
2521 if (!m_actionViewBackgroundOriginal->isChecked ()) {
2522 m_actionViewBackgroundOriginal->toggle();
2526 case BACKGROUND_IMAGE_FILTERED:
2527 if (!m_actionViewBackgroundFiltered->isChecked ()) {
2528 m_actionViewBackgroundFiltered->toggle();
2536 void MainWindow::slotCmbCoordSystem(
int index)
2538 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotCmbCoordSystem";
2544 m_cmdMediator->push (cmd);
2547 void MainWindow::slotCmbCurve(
int )
2549 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotCmbCurve";
2554 m_cmbCurve->currentText ());
2558 updateViewedCurves();
2562 void MainWindow::slotContextMenuEvent (QString pointIdentifier)
2564 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotContextMenuEvent point=" << pointIdentifier.toLatin1 ().data ();
2570 void MainWindow::slotDigitizeAxis ()
2572 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotDigitizeAxis";
2575 DIGITIZE_STATE_AXIS);
2576 m_cmbCurve->setEnabled (
false);
2581 void MainWindow::slotDigitizeColorPicker ()
2583 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotDigitizeColorPicker";
2586 DIGITIZE_STATE_COLOR_PICKER);
2587 m_cmbCurve->setEnabled (
true);
2592 void MainWindow::slotDigitizeCurve ()
2594 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotDigitizeCurve";
2597 DIGITIZE_STATE_CURVE);
2598 m_cmbCurve->setEnabled (
true);
2603 void MainWindow::slotDigitizePointMatch ()
2605 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotDigitizePointMatch";
2608 DIGITIZE_STATE_POINT_MATCH);
2609 m_cmbCurve->setEnabled (
true);
2614 void MainWindow::slotDigitizeSegment ()
2616 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotDigitizeSegment";
2619 DIGITIZE_STATE_SEGMENT);
2620 m_cmbCurve->setEnabled (
true);
2625 void MainWindow::slotDigitizeSelect ()
2627 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotDigitizeSelect";
2630 DIGITIZE_STATE_SELECT);
2631 m_cmbCurve->setEnabled (
false);
2636 void MainWindow::slotEditCopy ()
2638 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotEditCopy";
2647 void MainWindow::slotEditCut ()
2649 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotEditCut";
2658 void MainWindow::slotEditDelete ()
2660 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotEditDelete";
2669 void MainWindow::slotEditMenu ()
2671 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotEditMenu";
2673 m_actionEditPasteAsNew->setEnabled (!QApplication::clipboard()->image().isNull());
2674 m_actionEditPasteAsNewAdvanced->setEnabled (!QApplication::clipboard()->image().isNull());
2677 void MainWindow::slotEditPaste ()
2679 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotEditPaste";
2682 void MainWindow::slotEditPasteAsNew ()
2684 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotEditPasteAsNew";
2686 filePaste (IMPORT_TYPE_SIMPLE);
2689 void MainWindow::slotEditPasteAsNewAdvanced ()
2691 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotEditPasteAsNewAdvanced";
2693 filePaste (IMPORT_TYPE_ADVANCED);
2696 void MainWindow::slotFileClose()
2698 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileClose";
2712 DIGITIZE_STATE_EMPTY);
2718 m_backgroundStateContext->
close ();
2721 m_scene->setSceneRect (QRectF (0, 0, 1, 1));
2724 delete m_cmdMediator;
2730 setWindowTitle (engaugeWindowTitle ());
2732 m_gridLines.
clear();
2737 void MainWindow::slotFileExport ()
2739 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileExport";
2744 QString filter = QString (
"%1;;%2;;All files (*.*)")
2749 QString defaultFileName = QString (
"%1/%2.%3")
2750 .arg (QDir::currentPath ())
2751 .arg (m_currentFile)
2754 QString filterCsv = exportStrategy.
filterCsv ();
2755 QString fileName = dlg.getSaveFileName (
this,
2760 if (!fileName.isEmpty ()) {
2762 fileExport(fileName,
2771 void MainWindow::slotFileImport ()
2773 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileImport";
2775 fileImportWithPrompts (IMPORT_TYPE_SIMPLE);
2778 void MainWindow::slotFileImportAdvanced ()
2780 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileImportAdvanced";
2782 fileImportWithPrompts (IMPORT_TYPE_ADVANCED);
2785 void MainWindow::slotFileImportDraggedImage(QImage image)
2787 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileImportDraggedImage";
2792 IMPORT_TYPE_SIMPLE);
2795 void MainWindow::slotFileImportDraggedImageUrl(QUrl url)
2797 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileImportDraggedImageUrl url=" << url.toString ().toLatin1 ().data ();
2802 void MainWindow::slotFileImportImage(QString fileName, QImage image)
2804 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileImportImage fileName=" << fileName.toLatin1 ().data ();
2807 loadImage (fileName,
2809 IMPORT_TYPE_SIMPLE);
2812 void MainWindow::slotFileOpen()
2814 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileOpen";
2820 QString filter = QString (
"%1 (*.%2);; All Files (*.*)")
2821 .arg (ENGAUGE_FILENAME_DESCRIPTION)
2822 .arg (ENGAUGE_FILENAME_EXTENSION);
2824 QString fileName = QFileDialog::getOpenFileName (
this,
2825 tr(
"Open Document"),
2826 QDir::currentPath (),
2828 if (!fileName.isEmpty ()) {
2830 loadDocumentFile (fileName);
2836 void MainWindow::slotFileOpenDraggedDigFile (QString fileName)
2838 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileOpenDraggedDigFile";
2840 loadDocumentFile (fileName);
2843 void MainWindow::slotFilePrint()
2845 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFilePrint";
2847 QPrinter printer (QPrinter::HighResolution);
2848 QPrintDialog dlg (&printer,
this);
2849 if (dlg.exec() == QDialog::Accepted) {
2850 QPainter painter (&printer);
2851 m_view->render (&painter);
2856 bool MainWindow::slotFileSave()
2858 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileSave";
2860 if (m_engaugeFile.isEmpty()) {
2861 return slotFileSaveAs();
2863 return saveDocumentFile (m_engaugeFile);
2867 bool MainWindow::slotFileSaveAs()
2869 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileSaveAs";
2872 QString filenameDefault = m_currentFile;
2873 if (!m_currentFile.endsWith (ENGAUGE_FILENAME_EXTENSION)) {
2874 filenameDefault = QString (
"%1.%2")
2875 .arg (m_currentFile)
2876 .arg (ENGAUGE_FILENAME_EXTENSION);
2879 if (!m_engaugeFile.isEmpty()) {
2880 filenameDefault = m_engaugeFile;
2883 QString filterDigitizer = QString (
"%1 (*.%2)")
2884 .arg (ENGAUGE_FILENAME_DESCRIPTION)
2885 .arg (ENGAUGE_FILENAME_EXTENSION);
2886 QString filterAll (
"All files (*. *)");
2888 QStringList filters;
2889 filters << filterDigitizer;
2890 filters << filterAll;
2892 QFileDialog dlg(
this);
2893 dlg.setFileMode (QFileDialog::AnyFile);
2894 dlg.selectNameFilter (filterDigitizer);
2895 dlg.setNameFilters (filters);
2898 dlg.setWindowModality(Qt::WindowModal);
2900 dlg.setAcceptMode(QFileDialog::AcceptSave);
2901 dlg.selectFile(filenameDefault);
2904 QStringList files = dlg.selectedFiles();
2905 return saveDocumentFile(files.at(0));
2911 void MainWindow::slotHelpAbout()
2913 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotHelpAbout";
2919 void MainWindow::slotHelpTutorial()
2921 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotHelpTutorial";
2923 m_tutorialDlg->show ();
2924 m_tutorialDlg->exec ();
2927 void MainWindow::slotKeyPress (Qt::Key key,
2928 bool atLeastOneSelectedItem)
2930 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotKeyPress"
2931 <<
" key=" << QKeySequence (key).toString().toLatin1 ().data ()
2932 <<
" atLeastOneSelectedItem=" << (atLeastOneSelectedItem ?
"true" :
"false");
2936 atLeastOneSelectedItem);
2939 void MainWindow::slotLeave ()
2941 LOG4CPP_DEBUG_S ((*mainCat)) <<
"MainWindow::slotLeave";
2943 m_digitizeStateContext->
handleLeave (m_cmdMediator);
2946 void MainWindow::slotLoadStartupFiles ()
2948 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotLoadStartupFiles";
2950 ENGAUGE_ASSERT (m_loadStartupFiles.count() > 0);
2952 QString fileName = m_loadStartupFiles.front();
2953 m_loadStartupFiles.pop_front();
2959 loadDocumentFile (fileName);
2963 fileImport (fileName,
2964 IMPORT_TYPE_SIMPLE);
2968 if (m_loadStartupFiles.count() > 0) {
2972 QProcess::startDetached (QCoreApplication::applicationFilePath(),
2973 m_loadStartupFiles);
2977 void MainWindow::slotMouseMove (QPointF pos)
2982 if (m_cmdMediator != 0) {
2985 QString coordsScreen, coordsGraph, resolutionGraph;
3004 void MainWindow::slotMousePress (QPointF pos)
3006 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotMousePress";
3014 void MainWindow::slotMouseRelease (QPointF pos)
3016 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotMouseRelease";
3018 if (pos.x() < 0 || pos.y() < 0) {
3032 void MainWindow::slotRecentFileAction ()
3034 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotRecentFileAction";
3036 QAction *action = qobject_cast<QAction*>(sender ());
3039 QString fileName = action->data().toString();
3040 loadDocumentFile (fileName);
3044 void MainWindow::slotRecentFileClear ()
3046 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotRecentFileClear";
3048 QStringList emptyList;
3050 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
3051 settings.setValue (SETTINGS_RECENT_FILE_LIST,
3054 updateRecentFileList();
3057 void MainWindow::slotRedoTextChanged (
const QString &text)
3059 LOG4CPP_DEBUG_S ((*mainCat)) <<
"MainWindow::slotRedoTextChanged";
3061 QString completeText (
"Redo");
3062 if (!text.isEmpty ()) {
3063 completeText += QString (
" \"%1\"").arg (text);
3065 m_actionEditRedo->setText (completeText);
3068 void MainWindow::slotSetOverrideCursor (QCursor cursor)
3070 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSetOverrideCursor";
3076 void MainWindow::slotSettingsAxesChecker ()
3078 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsAxesChecker";
3080 m_dlgSettingsAxesChecker->
load (*m_cmdMediator);
3081 m_dlgSettingsAxesChecker->show ();
3084 void MainWindow::slotSettingsColorFilter ()
3086 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsColorFilter";
3088 m_dlgSettingsColorFilter->
load (*m_cmdMediator);
3089 m_dlgSettingsColorFilter->show ();
3092 void MainWindow::slotSettingsCoords ()
3094 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsCoords";
3096 m_dlgSettingsCoords->
load (*m_cmdMediator);
3097 m_dlgSettingsCoords->show ();
3100 void MainWindow::slotSettingsCurveAddRemove ()
3102 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsCurveAddRemove";
3104 m_dlgSettingsCurveAddRemove->
load (*m_cmdMediator);
3105 m_dlgSettingsCurveAddRemove->show ();
3108 void MainWindow::slotSettingsCurveProperties ()
3110 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsCurveProperties";
3112 m_dlgSettingsCurveProperties->
load (*m_cmdMediator);
3114 m_dlgSettingsCurveProperties->show ();
3117 void MainWindow::slotSettingsDigitizeCurve ()
3119 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsDigitizeCurve";
3121 m_dlgSettingsDigitizeCurve->
load (*m_cmdMediator);
3122 m_dlgSettingsDigitizeCurve->show ();
3125 void MainWindow::slotSettingsExportFormat ()
3127 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsExportFormat";
3130 m_dlgSettingsExportFormat->
load (*m_cmdMediator);
3131 m_dlgSettingsExportFormat->show ();
3138 void MainWindow::slotSettingsGeneral ()
3140 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsGeneral";
3142 m_dlgSettingsGeneral->
load (*m_cmdMediator);
3143 m_dlgSettingsGeneral->show ();
3146 void MainWindow::slotSettingsGridDisplay()
3148 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsGridDisplay";
3150 m_dlgSettingsGridDisplay->
load (*m_cmdMediator);
3151 m_dlgSettingsGridDisplay->show ();
3154 void MainWindow::slotSettingsGridRemoval ()
3156 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsGridRemoval";
3158 m_dlgSettingsGridRemoval->
load (*m_cmdMediator);
3159 m_dlgSettingsGridRemoval->show ();
3162 void MainWindow::slotSettingsPointMatch ()
3164 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsPointMatch";
3166 m_dlgSettingsPointMatch->
load (*m_cmdMediator);
3167 m_dlgSettingsPointMatch->show ();
3170 void MainWindow::slotSettingsSegments ()
3172 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsSegments";
3174 m_dlgSettingsSegments->
load (*m_cmdMediator);
3175 m_dlgSettingsSegments->show ();
3178 void MainWindow::slotSettingsMainWindow ()
3180 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsMainWindow";
3184 m_dlgSettingsMainWindow->show ();
3187 void MainWindow::slotTimeoutRegressionErrorReport ()
3189 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotTimeoutRegressionErrorReport"
3190 <<
" cmdStackIndex=" << m_cmdMediator->index()
3191 <<
" cmdStackCount=" << m_cmdMediator->count();
3193 if (m_cmdStackShadow->
canRedo()) {
3200 exportAllCoordinateSystems ();
3204 m_cmdMediator->setClean();
3210 void MainWindow::slotTimeoutRegressionFileCmdScript ()
3212 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotTimeoutRegressionFileCmdScript";
3214 if (m_fileCmdScript->
canRedo()) {
3216 m_fileCmdScript->
redo(*
this);
3221 if (m_cmdMediator != 0) {
3224 exportAllCoordinateSystems ();
3228 m_cmdMediator->setClean();
3238 void MainWindow::slotUndoTextChanged (
const QString &text)
3240 LOG4CPP_DEBUG_S ((*mainCat)) <<
"MainWindow::slotUndoTextChanged";
3242 QString completeText (
"Undo");
3243 if (!text.isEmpty ()) {
3244 completeText += QString (
" \"%1\"").arg (text);
3246 m_actionEditUndo->setText (completeText);
3249 void MainWindow::slotViewGridLines ()
3251 LOG4CPP_DEBUG_S ((*mainCat)) <<
"MainWindow::slotViewGridLines";
3256 void MainWindow::slotViewGroupBackground(QAction *action)
3258 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewGroupBackground";
3261 BackgroundImage backgroundImage;
3262 int indexBackground;
3263 if (action == m_actionViewBackgroundNone) {
3264 indexBackground = m_cmbBackground->findData (QVariant (BACKGROUND_IMAGE_NONE));
3265 backgroundImage = BACKGROUND_IMAGE_NONE;
3266 }
else if (action == m_actionViewBackgroundOriginal) {
3267 indexBackground = m_cmbBackground->findData (QVariant (BACKGROUND_IMAGE_ORIGINAL));
3268 backgroundImage = BACKGROUND_IMAGE_ORIGINAL;
3269 }
else if (action == m_actionViewBackgroundFiltered) {
3270 indexBackground = m_cmbBackground->findData (QVariant (BACKGROUND_IMAGE_FILTERED));
3271 backgroundImage = BACKGROUND_IMAGE_FILTERED;
3273 ENGAUGE_ASSERT (
false);
3276 indexBackground = m_cmbBackground->findData (QVariant (BACKGROUND_IMAGE_ORIGINAL));
3277 backgroundImage = BACKGROUND_IMAGE_ORIGINAL;
3280 m_cmbBackground->setCurrentIndex (indexBackground);
3284 void MainWindow::slotViewGroupCurves(QAction * )
3286 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewGroupCurves";
3288 updateViewedCurves ();
3291 void MainWindow::slotViewGroupStatus(QAction *action)
3293 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewGroupStatus";
3295 ENGAUGE_CHECK_PTR (m_statusBar);
3297 if (action == m_actionStatusNever) {
3299 }
else if (action == m_actionStatusTemporary) {
3306 void MainWindow::slotViewToolBarBackground ()
3308 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewToolBarBackground";
3310 if (m_actionViewBackground->isChecked ()) {
3311 m_toolBackground->show();
3313 m_toolBackground->hide();
3317 void MainWindow::slotViewToolBarChecklistGuide ()
3319 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewToolBarChecklistGuide";
3321 if (m_actionViewChecklistGuide->isChecked ()) {
3322 m_dockChecklistGuide->show();
3324 m_dockChecklistGuide->hide();
3328 void MainWindow::slotViewToolBarCoordSystem ()
3330 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewToolBarCoordSystem";
3332 if (m_actionViewCoordSystem->isChecked ()) {
3333 m_toolCoordSystem->show();
3335 m_toolCoordSystem->hide();
3339 void MainWindow::slotViewToolBarDigitize ()
3341 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewToolBarDigitize";
3343 if (m_actionViewDigitize->isChecked ()) {
3344 m_toolDigitize->show();
3346 m_toolDigitize->hide();
3350 void MainWindow::slotViewToolBarSettingsViews ()
3352 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewToolBarSettingsViews";
3354 if (m_actionViewSettingsViews->isChecked ()) {
3355 m_toolSettingsViews->show();
3357 m_toolSettingsViews->hide();
3361 void MainWindow::slotViewToolTips ()
3363 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewToolTips";
3368 void MainWindow::slotViewZoom(
int zoom)
3370 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewZoom";
3373 switch ((ZoomFactor) zoom) {
3375 m_actionZoom16To1->setChecked(
true);
3376 slotViewZoom16To1 ();
3379 m_actionZoom8To1->setChecked(
true);
3380 slotViewZoom8To1 ();
3383 m_actionZoom4To1->setChecked(
true);
3384 slotViewZoom4To1 ();
3387 m_actionZoom2To1->setChecked(
true);
3388 slotViewZoom2To1 ();
3391 m_actionZoom1To1->setChecked(
true);
3392 slotViewZoom1To1 ();
3395 m_actionZoom1To2->setChecked(
true);
3396 slotViewZoom1To2 ();
3399 m_actionZoom1To4->setChecked(
true);
3400 slotViewZoom1To4 ();
3403 m_actionZoom1To8->setChecked(
true);
3404 slotViewZoom1To8 ();
3407 m_actionZoom1To16->setChecked(
true);
3408 slotViewZoom1To16 ();
3411 m_actionZoomFill->setChecked(
true);
3412 slotViewZoomFill ();
3417 void MainWindow::slotViewZoom16To1 ()
3419 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewZoom16To1";
3421 QTransform transform;
3422 transform.scale (16.0, 16.0);
3423 m_view->setTransform (transform);
3427 void MainWindow::slotViewZoom8To1 ()
3429 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewZoom8To1";
3431 QTransform transform;
3432 transform.scale (8.0, 8.0);
3433 m_view->setTransform (transform);
3437 void MainWindow::slotViewZoom4To1 ()
3439 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewZoom4To1";
3441 QTransform transform;
3442 transform.scale (4.0, 4.0);
3443 m_view->setTransform (transform);
3447 void MainWindow::slotViewZoom2To1 ()
3449 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotZoom2To1";
3451 QTransform transform;
3452 transform.scale (2.0, 2.0);
3453 m_view->setTransform (transform);
3457 void MainWindow::slotViewZoom1To1 ()
3459 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewZoom1To1";
3461 QTransform transform;
3462 transform.scale (1.0, 1.0);
3463 m_view->setTransform (transform);
3467 void MainWindow::slotViewZoom1To2 ()
3469 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotZoom1To2";
3471 QTransform transform;
3472 transform.scale (0.5, 0.5);
3473 m_view->setTransform (transform);
3477 void MainWindow::slotViewZoom1To4 ()
3479 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotZoom1To4";
3481 QTransform transform;
3482 transform.scale (0.25, 0.25);
3483 m_view->setTransform (transform);
3487 void MainWindow::slotViewZoom1To8 ()
3489 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotZoom1To8";
3491 QTransform transform;
3492 transform.scale (0.125, 0.125);
3493 m_view->setTransform (transform);
3497 void MainWindow::slotViewZoom1To16 ()
3499 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotZoom1To16";
3501 QTransform transform;
3502 transform.scale (0.0625, 0.0625);
3503 m_view->setTransform (transform);
3507 void MainWindow::slotViewZoomFill ()
3509 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewZoomFill";
3511 m_backgroundStateContext->
fitInView (*m_view);
3516 void MainWindow::slotViewZoomIn ()
3518 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewZoomIn";
3522 bool goto16To1 =
false, goto8To1 =
false, goto4To1 =
false, goto2To1 =
false;
3523 bool goto1To1 =
false;
3524 bool goto1To2 =
false, goto1To4 =
false, goto1To8 =
false, goto1To16 =
false;
3525 if (m_actionZoomFill->isChecked ()) {
3528 double xScale = m_view->transform().m11();
3529 double yScale = m_view->transform().m22();
3530 double scale = qMin(xScale, yScale);
3531 if (scale < 0.125) {
3533 }
else if (scale < 0.25) {
3535 }
else if (scale < 0.5) {
3537 }
else if (scale < 1) {
3539 }
else if (scale < 2) {
3541 }
else if (scale < 4) {
3543 }
else if (scale < 8) {
3549 goto16To1 = m_actionZoom8To1->isChecked ();
3550 goto8To1 = m_actionZoom4To1->isChecked ();
3551 goto4To1 = m_actionZoom2To1->isChecked ();
3552 goto2To1 = m_actionZoom1To1->isChecked ();
3553 goto1To1 = m_actionZoom1To2->isChecked ();
3554 goto1To2 = m_actionZoom1To4->isChecked ();
3555 goto1To4 = m_actionZoom1To8->isChecked ();
3556 goto1To8 = m_actionZoom1To16->isChecked ();
3561 m_actionZoom16To1->setChecked (
true);
3562 slotViewZoom16To1 ();
3563 }
else if (goto8To1) {
3564 m_actionZoom8To1->setChecked (
true);
3565 slotViewZoom8To1 ();
3566 }
else if (goto4To1) {
3567 m_actionZoom4To1->setChecked (
true);
3568 slotViewZoom4To1 ();
3569 }
else if (goto2To1) {
3570 m_actionZoom2To1->setChecked (
true);
3571 slotViewZoom2To1 ();
3572 }
else if (goto1To1) {
3573 m_actionZoom1To1->setChecked (
true);
3574 slotViewZoom1To1 ();
3575 }
else if (goto1To2) {
3576 m_actionZoom1To2->setChecked (
true);
3577 slotViewZoom1To2 ();
3578 }
else if (goto1To4) {
3579 m_actionZoom1To4->setChecked (
true);
3580 slotViewZoom1To4 ();
3581 }
else if (goto1To8) {
3582 m_actionZoom1To8->setChecked (
true);
3583 slotViewZoom1To8 ();
3584 }
else if (goto1To16) {
3585 m_actionZoom1To16->setChecked (
true);
3586 slotViewZoom1To16 ();
3590 void MainWindow::slotViewZoomInFromWheelEvent ()
3592 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewZoomInFromWheelEvent";
3594 if ((m_modelMainWindow.
zoomControl() == ZOOM_CONTROL_MENU_WHEEL) ||
3595 (m_modelMainWindow.
zoomControl() == ZOOM_CONTROL_MENU_WHEEL_PLUSMINUS)) {
3598 m_view->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
3603 m_view->setTransformationAnchor(QGraphicsView::NoAnchor);
3607 void MainWindow::slotViewZoomOut ()
3609 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewZoomOut";
3613 bool goto16To1 =
false, goto8To1 =
false, goto4To1 =
false, goto2To1 =
false;
3614 bool goto1To1 =
false;
3615 bool goto1To2 =
false, goto1To4 =
false, goto1To8 =
false, goto1To16 =
false;
3616 if (m_actionZoomFill->isChecked ()) {
3619 double xScale = m_view->transform().m11();
3620 double yScale = m_view->transform().m22();
3621 double scale = qMax(xScale, yScale);
3624 }
else if (scale > 4) {
3626 }
else if (scale > 2) {
3628 }
else if (scale > 1) {
3630 }
else if (scale > 0.5) {
3632 }
else if (scale > 0.25) {
3634 }
else if (scale > 0.125) {
3640 goto8To1 = m_actionZoom16To1->isChecked ();
3641 goto4To1 = m_actionZoom8To1->isChecked ();
3642 goto2To1 = m_actionZoom4To1->isChecked ();
3643 goto1To1 = m_actionZoom2To1->isChecked ();
3644 goto1To2 = m_actionZoom1To1->isChecked ();
3645 goto1To4 = m_actionZoom1To2->isChecked ();
3646 goto1To8 = m_actionZoom1To4->isChecked ();
3647 goto1To16 = m_actionZoom1To8->isChecked ();
3652 m_actionZoom1To16->setChecked (
true);
3653 slotViewZoom1To16 ();
3654 }
else if (goto1To8) {
3655 m_actionZoom1To8->setChecked (
true);
3656 slotViewZoom1To8 ();
3657 }
else if (goto1To4) {
3658 m_actionZoom1To4->setChecked (
true);
3659 slotViewZoom1To4 ();
3660 }
else if (goto1To2) {
3661 m_actionZoom1To2->setChecked (
true);
3662 slotViewZoom1To2 ();
3663 }
else if (goto1To1) {
3664 m_actionZoom1To1->setChecked (
true);
3665 slotViewZoom1To1 ();
3666 }
else if (goto2To1) {
3667 m_actionZoom2To1->setChecked (
true);
3668 slotViewZoom2To1 ();
3669 }
else if (goto4To1) {
3670 m_actionZoom4To1->setChecked (
true);
3671 slotViewZoom4To1 ();
3672 }
else if (goto8To1) {
3673 m_actionZoom8To1->setChecked (
true);
3674 slotViewZoom8To1 ();
3675 }
else if (goto16To1) {
3676 m_actionZoom16To1->setChecked (
true);
3677 slotViewZoom16To1 ();
3681 void MainWindow::slotViewZoomOutFromWheelEvent ()
3683 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewZoomOutFromWheelEvent";
3685 if ((m_modelMainWindow.
zoomControl() == ZOOM_CONTROL_MENU_WHEEL) ||
3686 (m_modelMainWindow.
zoomControl() == ZOOM_CONTROL_MENU_WHEEL_PLUSMINUS)) {
3689 m_view->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
3694 m_view->setTransformationAnchor(QGraphicsView::NoAnchor);
3698 void MainWindow::startRegressionTestErrorReport(
const QString &initialPath,
3699 const QString ®ressionInputFile)
3701 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::startRegressionTestErrorReport";
3711 QString absoluteRegressionInputFile = QString (
"%1/%2")
3713 .arg (regressionInputFile);
3716 m_regressionFile = exportFilenameFromInputFilename (absoluteRegressionInputFile);
3718 m_timerRegressionErrorReport =
new QTimer();
3719 m_timerRegressionErrorReport->setSingleShot(
false);
3720 connect (m_timerRegressionErrorReport, SIGNAL (timeout()),
this, SLOT (slotTimeoutRegressionErrorReport()));
3722 m_timerRegressionErrorReport->start(REGRESSION_INTERVAL);
3725 void MainWindow::startRegressionTestFileCmdScript()
3727 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::startRegressionTestFileCmdScript";
3729 m_timerRegressionFileCmdScript =
new QTimer();
3730 m_timerRegressionFileCmdScript->setSingleShot(
false);
3731 connect (m_timerRegressionFileCmdScript, SIGNAL (timeout()),
this, SLOT (slotTimeoutRegressionFileCmdScript()));
3733 m_timerRegressionFileCmdScript->start(REGRESSION_INTERVAL);
3738 return m_transformation;
3748 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateAfterCommand";
3750 ENGAUGE_CHECK_PTR (m_cmdMediator);
3754 updateAfterCommandStatusBarCoords ();
3763 m_dockChecklistGuide->
update (*m_cmdMediator,
3764 m_isDocumentExported);
3768 writeCheckpointToLogFile ();
3771 void MainWindow::updateAfterCommandStatusBarCoords ()
3773 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateAfterCommandStatusBarCoords";
3778 const QPoint HACK_SO_GRAPH_COORDINATE_MATCHES_INPUT (1, 1);
3782 updateTransformationAndItsDependencies();
3785 if (!m_transformationBefore.transformIsDefined() && m_transformation.
transformIsDefined()) {
3793 }
else if (m_transformationBefore.transformIsDefined() && !m_transformation.
transformIsDefined()) {
3801 }
else if (m_transformation.
transformIsDefined() && (m_transformationBefore != m_transformation)) {
3810 QPoint posLocal = m_view->mapFromGlobal (QCursor::pos ()) - HACK_SO_GRAPH_COORDINATE_MATCHES_INPUT;
3811 QPointF posScreen = m_view->mapToScene (posLocal);
3813 slotMouseMove (posScreen);
3818 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateAfterMouseRelease";
3823 void MainWindow::updateControls ()
3825 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateControls"
3826 <<
" selectedItems=" << m_scene->selectedItems().count();
3828 m_cmbBackground->setEnabled (!m_currentFile.isEmpty ());
3831 m_menuFileOpenRecent->setEnabled ((m_actionRecentFiles.count () > 0) &&
3832 (m_actionRecentFiles.at(0)->isVisible ()));
3834 m_actionClose->setEnabled (!m_currentFile.isEmpty ());
3835 m_actionSave->setEnabled (!m_currentFile.isEmpty ());
3836 m_actionSaveAs->setEnabled (!m_currentFile.isEmpty ());
3837 m_actionExport->setEnabled (!m_currentFile.isEmpty ());
3838 m_actionPrint->setEnabled (!m_currentFile.isEmpty ());
3840 if (m_cmdMediator == 0) {
3841 m_actionEditUndo->setEnabled (
false);
3842 m_actionEditRedo->setEnabled (
false);
3844 m_actionEditUndo->setEnabled (m_cmdMediator->canUndo ());
3845 m_actionEditRedo->setEnabled (m_cmdMediator->canRedo () || m_cmdStackShadow->
canRedo ());
3847 m_actionEditCut->setEnabled (m_scene->selectedItems().count () > 0);
3848 m_actionEditCopy->setEnabled (m_scene->selectedItems().count () > 0);
3849 m_actionEditPaste->setEnabled (
false);
3850 m_actionEditDelete->setEnabled (m_scene->selectedItems().count () > 0);
3853 m_actionDigitizeAxis->setEnabled (!m_currentFile.isEmpty ());
3854 m_actionDigitizeCurve ->setEnabled (!m_currentFile.isEmpty ());
3855 m_actionDigitizePointMatch->setEnabled (!m_currentFile.isEmpty ());
3856 m_actionDigitizeColorPicker->setEnabled (!m_currentFile.isEmpty ());
3857 m_actionDigitizeSegment->setEnabled (!m_currentFile.isEmpty ());
3858 m_actionDigitizeSelect->setEnabled (!m_currentFile.isEmpty ());
3860 m_actionViewGridLines->setEnabled (
true);
3862 m_actionViewGridLines->setEnabled (
false);
3863 m_actionViewGridLines->setChecked (
false);
3865 m_actionViewBackground->setEnabled (!m_currentFile.isEmpty());
3866 m_actionViewChecklistGuide->setEnabled (!m_dockChecklistGuide->
browserIsEmpty());
3867 m_actionViewDigitize->setEnabled (!m_currentFile.isEmpty ());
3868 m_actionViewSettingsViews->setEnabled (!m_currentFile.isEmpty ());
3870 m_actionSettingsCoords->setEnabled (!m_currentFile.isEmpty ());
3871 m_actionSettingsCurveAddRemove->setEnabled (!m_currentFile.isEmpty ());
3872 m_actionSettingsCurveProperties->setEnabled (!m_currentFile.isEmpty ());
3873 m_actionSettingsDigitizeCurve->setEnabled (!m_currentFile.isEmpty ());
3874 m_actionSettingsExport->setEnabled (!m_currentFile.isEmpty ());
3875 m_actionSettingsColorFilter->setEnabled (!m_currentFile.isEmpty ());
3876 m_actionSettingsAxesChecker->setEnabled (!m_currentFile.isEmpty ());
3877 m_actionSettingsGridDisplay->setEnabled (!m_currentFile.isEmpty () && m_transformation.
transformIsDefined());
3878 m_actionSettingsGridRemoval->setEnabled (!m_currentFile.isEmpty ());
3879 m_actionSettingsPointMatch->setEnabled (!m_currentFile.isEmpty ());
3880 m_actionSettingsSegments->setEnabled (!m_currentFile.isEmpty ());
3881 m_actionSettingsGeneral->setEnabled (!m_currentFile.isEmpty ());
3883 m_groupBackground->setEnabled (!m_currentFile.isEmpty ());
3884 m_groupCurves->setEnabled (!m_currentFile.isEmpty ());
3885 m_groupZoom->setEnabled (!m_currentFile.isEmpty ());
3887 m_actionZoomIn->setEnabled (!m_currentFile.isEmpty ());
3888 m_actionZoomOut->setEnabled (!m_currentFile.isEmpty ());
3893 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateCoordSystem";
3898 loadCurveListFromCmdMediator ();
3900 updateTransformationAndItsDependencies();
3912 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateDigitizeStateIfSoftwareTriggered";
3914 switch (digitizeState) {
3915 case DIGITIZE_STATE_AXIS:
3916 m_actionDigitizeAxis->setChecked(
true);
3920 case DIGITIZE_STATE_COLOR_PICKER:
3921 m_actionDigitizeColorPicker->setChecked(
true);
3922 slotDigitizeColorPicker();
3925 case DIGITIZE_STATE_CURVE:
3926 m_actionDigitizeCurve->setChecked(
true);
3927 slotDigitizeCurve();
3930 case DIGITIZE_STATE_EMPTY:
3933 case DIGITIZE_STATE_POINT_MATCH:
3934 m_actionDigitizePointMatch->setChecked(
true);
3935 slotDigitizePointMatch();
3938 case DIGITIZE_STATE_SEGMENT:
3939 m_actionDigitizeSegment->setChecked(
true);
3940 slotDigitizeSegment();
3943 case DIGITIZE_STATE_SELECT:
3944 m_actionDigitizeSelect->setChecked(
true);
3945 slotDigitizeSelect();
3949 LOG4CPP_ERROR_S ((*mainCat)) <<
"MainWindow::updateDigitizeStateIfSoftwareTriggered";
3956 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateGraphicsLinesToMatchGraphicsPoints";
3962 void MainWindow::updateGridLines ()
3964 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateGridLines";
3967 m_gridLines.
clear ();
3976 m_gridLines.
setVisible (m_actionViewGridLines->isChecked());
3979 void MainWindow::updateRecentFileList()
3981 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateRecentFileList";
3984 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
3985 QStringList recentFilePaths = settings.value(SETTINGS_RECENT_FILE_LIST).toStringList();
3988 unsigned int count = recentFilePaths.size();
3989 if (count > MAX_RECENT_FILE_LIST_SIZE) {
3990 count = MAX_RECENT_FILE_LIST_SIZE;
3995 for (i = 0; i < count; i++) {
3996 QString strippedName = QFileInfo (recentFilePaths.at(i)).fileName();
3997 m_actionRecentFiles.at (i)->setText (strippedName);
3998 m_actionRecentFiles.at (i)->setData (recentFilePaths.at (i));
3999 m_actionRecentFiles.at (i)->setVisible (
true);
4003 for (i = count; i < MAX_RECENT_FILE_LIST_SIZE; i++) {
4004 m_actionRecentFiles.at (i)->setVisible (
false);
4011 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsAxesChecker";
4018 m_cmbCurve->currentText());
4023 m_cmbCurve->currentText());
4029 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsColorFilter";
4035 m_cmbCurve->currentText());
4042 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsCoords";
4049 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsCurveAddRemove";
4052 loadCurveListFromCmdMediator();
4058 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsCurveStyles";
4067 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsDigitizeCurve";
4071 modelDigitizeCurve);
4076 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsExportFormat";
4083 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsGeneral";
4090 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsGridDisplay";
4097 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsGridRemoval";
4102 void MainWindow::updateSettingsMainWindow()
4104 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsMainWindow";
4106 if (m_modelMainWindow.
zoomControl() == ZOOM_CONTROL_MENU_ONLY ||
4107 m_modelMainWindow.
zoomControl() == ZOOM_CONTROL_MENU_WHEEL) {
4109 m_actionZoomIn->setShortcut (tr (
""));
4110 m_actionZoomOut->setShortcut (tr (
""));
4114 m_actionZoomIn->setShortcut (tr (
"+"));
4115 m_actionZoomOut->setShortcut (tr (
"-"));
4119 updateWindowTitle();
4124 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsMainWindow";
4132 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsPointMatch";
4139 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsSegments";
4145 void MainWindow::updateTransformationAndItsDependencies()
4147 m_transformation.
update (!m_currentFile.isEmpty (),
4155 m_cmbCurve->currentText ());
4162 void MainWindow::updateViewedCurves ()
4164 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateViewedCurves";
4166 if (m_actionViewCurvesAll->isChecked ()) {
4170 }
else if (m_actionViewCurvesSelected->isChecked ()) {
4174 }
else if (m_actionViewCurvesNone->isChecked ()) {
4179 ENGAUGE_ASSERT (
false);
4185 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateViewsOfSettings";
4187 QString activeCurve = m_digitizeStateContext->
activeCurve ();
4194 if (activeCurve.isEmpty ()) {
4207 m_cmdMediator->
pixmap ());
4212 void MainWindow::updateWindowTitle ()
4214 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateWindowTitle";
4216 const QString PLACEHOLDER (
"[*]");
4218 QString title = QString (tr (
"Engauge Digitizer %1")
4219 .arg (VERSION_NUMBER));
4221 QString fileNameMaybeStripped;
4222 if (!m_currentFileWithPathAndFileExtension.isEmpty()) {
4224 QFileInfo fileInfo (m_currentFileWithPathAndFileExtension);
4228 case MAIN_TITLE_BAR_FORMAT_NO_PATH:
4229 fileNameMaybeStripped = fileInfo.baseName();
4232 case MAIN_TITLE_BAR_FORMAT_PATH:
4233 fileNameMaybeStripped = m_currentFileWithPathAndFileExtension;
4237 title += QString (
": %1")
4238 .arg (fileNameMaybeStripped);
4243 title += PLACEHOLDER;
4245 setWindowTitle (title);
4250 ENGAUGE_CHECK_PTR (m_view);
4256 ENGAUGE_CHECK_PTR (m_view);
4260 void MainWindow::writeCheckpointToLogFile ()
4263 QString checkpointDoc;
4264 QTextStream strDoc (&checkpointDoc);
4269 QString checkpointScene;
4270 QTextStream strScene (&checkpointScene);
4275 if (mainCat->getPriority() == log4cpp::Priority::DEBUG) {
4277 LOG4CPP_DEBUG_S ((*mainCat)) <<
"MainWindow::writeCheckpointToLogFile\n"
4278 <<
"--------------DOCUMENT CHECKPOINT START----------" <<
"\n"
4279 << checkpointDoc.toLatin1().data()
4280 <<
"---------------DOCUMENT CHECKPOINT END-----------" <<
"\n"
4281 <<
"----------------SCENE CHECKPOINT START-----------" <<
"\n"
4282 << checkpointScene.toLatin1().data()
4283 <<
"-----------------SCENE CHECKPOINT END------------" ;
void addCoordSystems(unsigned int numberCoordSystemToAdd)
Add some number (0 or more) of additional coordinate systems.
Factory class for generating the points, composed of QGraphicsItem objects, along a GridLine...
void updateGraphicsLinesToMatchGraphicsPoints(const CurveStyles &modelCurveStyles, const Transformation &transformation)
A mouse move has just occurred so move the selected points, since they were dragged.
void updateCoordSystem(CoordSystemIndex coordSystemIndex)
Select a different CoordSystem.
Model for DlgSettingsGeneral and CmdSettingsGeneral.
void unsetPointStyle()
Apply no PointStyle.
void setPixmap(const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &modelColorFilter, const QPixmap &pixmapOriginal, const QString &curveSelected)
Update the images of all states, rather than just the current state.
void setColorFilterSettings(const ColorFilterSettings &colorFilterSettings, const QPixmap &pixmap)
Apply the color filter of the currently selected curve. The pixmap is included so the background colo...
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
unsigned int coordSystemCount() const
Number of CoordSystem.
void setCurveName(const QString &curveName)
Load information for the specified curve name. When called externally, the load method must have been...
void createGhosts(QGraphicsScene &scene)
Create ghosts from the path/rect/polygon lists.
void updateColorFilter(const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &colorFilter, const QString &curveSelected)
Apply color filter settings.
Model for DlgSettingsPointMatch and CmdSettingsPointMatch.
Returns information about files.
Color filter parameters for one curve. For a class, this is handled the same as LineStyle and PointSt...
void resetOnLoad(CmdMediator *cmdMediator)
Resetting makes re-initializes for documents after the first.
void updateSettingsMainWindow(const MainWindowModel &modelMainWindow)
Update with new main window properties.
void setStatusBarMode(StatusBarMode statusBarMode)
Set the status bar visibility mode.
Model for DlgSettingsGridDisplay and CmdSettingsGridDisplay.
DocumentModelColorFilter modelColorFilter() const
Get method for DocumentModelColorFilter.
Command for cutting all selected Points.
void setModelAxesChecker(const DocumentModelAxesChecker &modelAxesChecker)
Set method for DocumentModelAxesChecker.
void setModelGridRemoval(const DocumentModelGridRemoval &modelGridRemoval)
Set method for DocumentModelGridRemoval.
void updateAfterCommand(CmdMediator &cmdMediator)
Update the Points and their Curves after executing a command.
void clear()
Deallocate and remove all grid lines.
void updateDigitizeStateIfSoftwareTriggered(DigitizeState digitizeState)
After software-triggered state transition, this method manually triggers the action as if user had cl...
unsigned int coordSystemIndexToBeRestored() const
Coordinate system index that was active before the ghosts.
static void setIdentifierIndex(unsigned int identifierIndex)
Reset the current index while performing a Redo.
void printStream(QString indentation, QTextStream &str)
Debugging method that supports print method of this class and printStream method of some other class(...
Class that displays the current Segment Filter in a MainWindow toolbar.
Wrapper around OpenJPEG library, in C, for opening jpeg2000 files.
Dialog for editing Segments settings, for DigitizeStateSegment.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
void fitInView(GraphicsView &view)
Zoom so background fills the window.
void setModelPointMatch(const DocumentModelPointMatch &modelPointMatch)
Set method for DocumentModelPointMatch.
Dialog for editing point match settings, for DigitizeStatePointMatch.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
Transformation transformation() const
Return read-only copy of transformation.
void updateModelDigitizeCurve(CmdMediator *cmdMediator, const DocumentModelDigitizeCurve &modelDigitizeCurve)
Update the digitize curve settings.
void setModelGeneral(const DocumentModelGeneral &modelGeneral)
Set method for DocumentModelGeneral.
void setEnabled(bool enabled)
Show the style with semi-transparency or full-transparency to indicate if associated Curve is active ...
Context class for transformation state machine.
Model for DlgSettingsCurveProperties and CmdSettingsCurveProperties.
void updateSettingsCurveAddRemove(const CurvesGraphs &curvesGraphs)
Update with new curves.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
bool canRedo() const
Returns true if there is at least one command on the stack.
QString activeCurve() const
Curve name for active Curve. This can include AXIS_CURVE_NAME, and empty string.
void setModelSegments(const DocumentModelSegments &modelSegments)
Set method for DocumentModelSegments.
MainTitleBarFormat mainTitleBarFormat() const
Get method for MainWindow titlebar filename format.
void updateAfterMouseRelease()
Call MainWindow::updateControls (which is private) after the very specific case - a mouse press/relea...
void handleCurveChange(CmdMediator *cmdMediator)
See DigitizeStateAbstractBase::handleCurveChange.
void setCoordinates(const QString &coordsScreen, const QString &coordsGraph, const QString &resolutionGraph)
Populate the coordinates fields. Unavailable values are empty. Html-encoding to highlight with colors...
QStringList selectedPointIdentifiers() const
Return a list of identifiers for the currently selected points.
void cmdFileClose()
Close file. This is called from a file script command.
void setModelGridDisplay(const DocumentModelGridDisplay &modelGridDisplay)
Set method for DocumentModelGridDisplay.
void updateViewsOfSettings(const QString &activeCurve)
Update curve-specific view of settings. Private version gets active curve name from DigitizeStateCont...
QString selectedGraphCurve() const
Curve name that is currently selected in m_cmbCurve.
Class for showing points and lines for all coordinate systems simultaneously, even though the code no...
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
void slotRedo()
Move next command from list to CmdMediator. Noop if there are no more commands.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
void createGridLinesForEvenlySpacedGrid(const DocumentModelGridDisplay &modelGridDisplay, GridLines &gridLines)
Create a rectangular (cartesian) or annular (polar) grid of evenly spaced grid lines.
void setModelDigitizeCurve(const DocumentModelDigitizeCurve &modelDigitizeCurve)
Set method for DocumentModelDigitizeCurve.
PointStyle pointStyle() const
Get method for PointStyle.
void triggerStateTransition(TransformationState transformationState, CmdMediator &cmdMediator, const Transformation &transformation, const QString &selectedGraphCurve)
Trigger a state transition to be performed immediately.
void cmdFileOpen(const QString &fileName)
Open file. This is called from a file script command.
QString xmlToUpload() const
Xml to be uploaded. Includes document if user has approved.
CmdMediator * cmdMediator()
Accessor for commands to process the Document.
void setModelCoords(const DocumentModelCoords &modelCoords)
Set method for DocumentModelCoords.
void wakeUp()
Enable all widgets in the status bar. This is called just after a Document becomes active...
MainWindow(const QString &errorReportFile, const QString &fileCmdScriptFile, bool isRegressionTest, bool isGnuplot, QStringList loadStartupFiles, QWidget *parent=0)
Single constructor.
BackgroundImage selectOriginal(BackgroundImage backgroundImage)
Make original background visible, for DigitizeStateColorPicker.
static void bindToMainWindow(const MainWindow *mainWindow)
Bind to MainWindow so this class can access the command stack.
Dialog for editing grid removal settings.
void setLocale(QLocale::Language language, QLocale::Country country)
Set method for locale given attributes.
void handleKeyPress(CmdMediator *cmdMediator, Qt::Key key, bool atLeastOneSelectedItem)
See DigitizeStateAbstractBase::handleKeyPress.
void uploadErrorReport(const QString &report)
Upload the error report asynchronously.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
void showTemporaryMessage(const QString &temporaryMessage)
Show temporary message in status bar.
Dialog for editing curve names settings.
bool load(const QString &filename, QImage &image) const
Load image from jpeg2000 file.
void setImageIsLoaded(CmdMediator *cmdMediator, bool imageIsLoaded)
Set the image so QGraphicsView cursor and drag mode are accessible.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
void setCoordSystemIndex(CoordSystemIndex coordSystemIndex)
Set the index of current active CoordSystem.
void updateSettingsDigitizeCurve(const DocumentModelDigitizeCurve &modelDigitizeCurve)
Update with new curve digitization styles.
void loadMainWindowModel(CmdMediator &cmdMediator, const MainWindowModel &modelMainWindow)
Replaced load method since the main window settings are independent of document, unlike other DlgSett...
Tutorial using a strategy like a comic strip with decision points deciding which panels appear...
void cmdFileExport(const QString &fileName)
Export file. This is called from a file script command.
Strategy class for exporting to a file. This strategy is external to the Document class so that class...
CoordSystemIndex coordSystemIndex() const
Index of current active CoordSystem.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
Dockable text window containing checklist guide.
void setModelExport(const DocumentModelExportFormat &modelExport)
Set method for DocumentModelExportFormat.
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
GraphicsView & view()
View for the QImage and QGraphicsItems, without const.
Dialog for editing filtering settings.
StatusBarMode statusBarMode() const
Current mode for status bar visibility. This is tracked locally so this class knows when to hide/show...
ZoomControl zoomControl() const
Get method for zoom control.
QString fileExtensionTsv() const
File extension for tsv export files.
Details for a specific Point.
Container for all graph curves. The axes point curve is external to this class.
void setBackgroundImage(BackgroundImage backgroundImage)
Transition to the specified state. This method is used by classes outside of the state machine to tri...
Model for DlgSettingsColorFilter and CmdSettingsColorFilter.
Wrapper around QStatusBar to manage permanent widgets.
GraphicsScene & scene()
Scene container for the QImage and QGraphicsItems.
void updateSettingsGridDisplay(const DocumentModelGridDisplay &modelGridDisplay)
Update with new grid display properties.
void setEnabled(bool enabled)
Show the style with semi-transparency or full-transparency to indicate if associated Curve is active ...
void updateSettingsCurveStyles(const CurveStyles &modelCurveStyles)
Update with new curve styles.
Client for interacting with Engauge server.
void setModelCurveStyles(const CurveStyles &modelCurveStyles)
Set method for CurveStyles.
Context class that manages the background image state machine.
bool browserIsEmpty() const
When browser is empty, it is pointless to show it.
CurveStyles modelCurveStyles() const
Get method for CurveStyles.
QGraphicsView class with event handling added. Typically the events are sent to the active digitizing...
Container for all DigitizeStateAbstractBase subclasses. This functions as the context class in a stan...
Model for DlgSettingsMainWindow.
void appendNewCmd(CmdMediator *cmdMediator, QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
bool canRedo() const
Return true if there is a command available.
DocumentModelAxesChecker modelAxesChecker() const
Get method for DocumentModelAxesChecker.
void updateModelSegments(const DocumentModelSegments &modelSegments)
Update the segments given the new settings.
void resetOnLoad()
Reset, when loading a document after the first, to same state that first document was at when loaded...
Dialog for editing general settings.
void resetPositionHasChangedFlags()
Reset positionHasChanged flag for all items. Typically this is done as part of mousePressEvent.
void setModelColorFilter(const DocumentModelColorFilter &modelColorFilter)
Set method for DocumentModelColorFilter.
void close()
Open Document is being closed so remove the background.
QImage imageForCurveState() const
Image for the Curve state, even if the current state is different.
Model for DlgSettingsCoords and CmdSettingsCoords.
void setVisible(bool visible)
Make all grid lines visible or hidden.
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.
QString fileExtensionCsv() const
File extension for csv export files.
void updateSettingsColorFilter(const DocumentModelColorFilter &modelColorFilter)
Update with new color filter properties.
Dialog for editing grid display settings.
void setCurveSelected(const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &modelColorFilter, const QString &curveSelected)
Update the selected curve.
Command for deleting all selected Points.
Dialog for editing DigitizeStateCurve settings.
void updateSettingsAxesChecker(const DocumentModelAxesChecker &modelAxesChecker)
Update with new axes indicator properties.
void updateSettingsPointMatch(const DocumentModelPointMatch &modelPointMatch)
Update with new point match properties.
void updateSettingsGeneral(const DocumentModelGeneral &modelGeneral)
Update with new general properties.
void redo(MainWindow &mainWindow)
Apply the next command. Requires non-empty stack.
void setPointStyle(const PointStyle &pointStyle)
Apply the PointStyle of the currently selected curve.
QImage imageFiltered() const
Background image that has been filtered for the current curve. This asserts if a curve-specific image...
void updateSettingsGridRemoval(const DocumentModelGridRemoval &modelGridRemoval)
Update with new grid removal properties.
Class that displays a view of the current Curve's point style.
void showTemporaryMessage(const QString &message)
Show temporary message in status bar. After a short interval the message will disappear.
void exportToFile(const DocumentModelExportFormat &modelExport, const Document &document, const MainWindowModel &modelMainWindow, const Transformation &transformation, QTextStream &str) const
Export Document points according to the settings.
void updateCurveStyles(const CurveStyles &modelCurveStyles)
Update curve styles after settings changed.
void unsetColorFilterSettings()
Apply no color filter.
Dialog for setting the advanced parameters in a newly imported Document.
Wizard for setting up the checklist guide.
const ColorFilterSettings colorFilterSettings(const QString &curveName) const
Get method for copying one color filter. Cannot return just a reference or else there is a warning ab...
Dialog for editing main window settings, which are entirely independent of all documents.
void handleMouseMove(CmdMediator *cmdMediator, QPointF pos)
See DigitizeStateAbstractBase::handleMouseMove.
Model for DlgSettingsAxesChecker and CmdSettingsAxesChecker.
QString filterTsv() const
QFileDialog filter for TSV files.
Command stack that shadows the CmdMediator command stack at startup when reading commands from an err...
void updateSettingsExportFormat(const DocumentModelExportFormat &modelExport)
Update with new export properties.
Dialog for editing coordinates settings.
Load QImage from url. This is trivial for a file, but requires an asynchronous download step for http...
virtual bool eventFilter(QObject *, QEvent *)
Catch secret keypresses.
void startLoadImage(const QUrl &url)
Start the asynchronous loading of an image from the specified url.
void load(CmdMediator &cmdMediator)
Load settings from Document.
bool loadsAsDigFile(const QString &urlString) const
Returns true if specified file name can be loaded as a DIG file.
void resetOnLoad()
Reset, when loading a document after the first, to same state that first document was at when loaded...
bool isGnuplot() const
Get method for gnuplot flag.
CurveStyle curveStyle(const QString &curveName) const
CurveStyle in specified curve.
Dialog for editing curve properties settings.
void setZoomControl(ZoomControl zoomControl)
Set method for zoom control.
void setMainTitleBarFormat(MainTitleBarFormat mainTitleBarFormat)
Set method for MainWindow titlebar filename format.
void handleMouseRelease(CmdMediator *cmdMediator, QPointF pos)
See DigitizeStateAbstractBase::handleMouseRelease.
void captureGraphicsItems(QGraphicsScene &scene)
Take a snapshot of the graphics items.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
void setZoomFactorInitial(ZoomFactorInitial zoomFactorInitial)
Set method for initial zoom factor.
void saveErrorReportFileAndExit(const char *comment, const char *file, int line, const char *context) const
Save error report and exit.
void signalZoom(int)
Send zoom selection, picked from menu or keystroke, to StatusBar.
Model for DlgSettingsSegments and CmdSettingsSegments.
void destroyGhosts(QGraphicsScene &scene)
Destory ghosts. Called at end of algorithm.
void cmdFileImport(const QString &fileName)
Import file. This is called from a file script command.
void setCurvesGraphs(const CurvesGraphs &curvesGraphs)
Let CmdAbstract classes overwrite CurvesGraphs.
void updateAxesChecker(CmdMediator &cmdMediator, const Transformation &transformation)
Apply the new DocumentModelAxesChecker.
void resizeEvent(QResizeEvent *event)
Intercept resize event so graphics scene can be appropriately resized when in Fill mode...
QStringList supportedImageWildcards() const
List the supported jpeg2000 file extensions, for filtering import files.
void updateSettingsCoords(const DocumentModelCoords &modelCoords)
Update with new coordinate properties.
void loadCommands(MainWindow &mainWindow, Document &document, QXmlStreamReader &reader)
Load commands from serialized xml.
void update(const CmdMediator &cmdMediator, bool documentIsExported)
Update using current CmdMediator/Document state.
ZoomFactorInitial zoomFactorInitial() const
Get method for initial zoom factor.
File that manages a command stack for regression testing of file import/open/export/close.
void handleMousePress(CmdMediator *cmdMediator, QPointF pos)
See DigitizeStateAbstractBase::handleMousePress.
Add point and line handling to generic QGraphicsScene.
void handleSetOverrideCursor(CmdMediator *cmdMediator, const QCursor &cursor)
See DigitizeStateAbstractBase::handleSetOverrideCursor.
QString filterCsv() const
QFileDialog filter for CSV files.
void handleContextMenuEvent(CmdMediator *cmdMediator, const QString &pointIdentifier)
See DigitizeStateAbstractBase::handleContextMenuEvent.
Command for moving all selected Points by a specified translation.
DocumentModelGridDisplay modelGridDisplay() const
Get method for DocumentModelGridDisplay.
void saveXml(QXmlStreamWriter &writer) const
Save document to xml.
QLocale locale() const
Get method for locale.
Model for DlgSettingsGridRemoval and CmdSettingsGridRemoval. The settings are unstable until the user...
Dialog for sending error report.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
void updateSettingsSegments(const DocumentModelSegments &modelSegments)
Update with new segments properties.
Command for changing the currently selected CoordSystem.
void showCurves(bool show, bool showAll=false, const QString &curveName="")
Show or hide all Curves (if showAll is true) or just the selected Curve (if showAll is false);...
Dialog for editing axes checker settings.
void updateGraphicsLinesToMatchGraphicsPoints()
Update the graphics lines so they follow the graphics points, after a drag, addition, removal, and such.
void populateCurvesGraphs(CoordSystemIndex coordSystemIndex, CurvesGraphs &curvesGraphs)
Create entries in CurvesGraphs for each curve name that user provided.
DocumentModelGridRemoval modelGridRemoval() const
Get method for DocumentModelGridRemoval.
MainWindowModel modelMainWindow() const
Get method for main window model.
QString templateHtml(CoordSystemIndex coordSystemIndex) const
Template html comprising the checklist for display.
void setTemplateHtml(const QString &html, const QStringList &curveNames)
Populate the browser with template html.
DocumentModelExportFormat modelExport() const
Get method for DocumentModelExportFormat.
QStringList curveNames(CoordSystemIndex coordSystemIndex) const
Curve names to be placed into Document.
About Engauge dialog. This provides a hidden shortcut for triggering ENGAUGE_ASSERT.
void handleLeave(CmdMediator *cmdMediator)
See DigitizeStateAbstractBase::handleLeave.
virtual void showEvent(QShowEvent *)
Processing performed after gui becomes available.
bool transformIsDefined() const
Return true if all three axis points have been defined.
void requestImmediateStateTransition(CmdMediator *cmdMediator, DigitizeState digitizeState)
Perform immediate state transition. Called from outside state machine.