1 #include "BackgroundImage.h"
2 #include "BackgroundStateContext.h"
3 #include "img/bannerapp_16.xpm"
4 #include "img/bannerapp_32.xpm"
5 #include "img/bannerapp_64.xpm"
6 #include "img/bannerapp_128.xpm"
7 #include "img/bannerapp_256.xpm"
8 #include "ChecklistGuide.h"
9 #include "ChecklistGuideWizard.h"
12 #include "CmdDelete.h"
13 #include "CmdMediator.h"
14 #include "CmdStackShadow.h"
15 #include "ColorFilter.h"
18 #include "DigitizeStateContext.h"
19 #include "DigitAxis.xpm"
20 #include "DigitColorPicker.xpm"
21 #include "DigitCurve.xpm"
22 #include "DigitPointMatch.xpm"
23 #include "DigitSegment.xpm"
24 #include "DigitSelect.xpm"
26 #include "DlgErrorReport.h"
27 #include "DlgRequiresTransform.h"
28 #include "DlgSettingsAxesChecker.h"
29 #include "DlgSettingsColorFilter.h"
30 #include "DlgSettingsCoords.h"
31 #include "DlgSettingsCurveAddRemove.h"
32 #include "DlgSettingsCurveProperties.h"
33 #include "DlgSettingsDigitizeCurve.h"
34 #include "DlgSettingsExportFormat.h"
35 #include "DlgSettingsGeneral.h"
36 #include "DlgSettingsGridRemoval.h"
37 #include "DlgSettingsMainWindow.h"
38 #include "DlgSettingsPointMatch.h"
39 #include "DlgSettingsSegments.h"
40 #include "DocumentSerialize.h"
41 #include "EngaugeAssert.h"
42 #include "EnumsToQt.h"
43 #include "ExportToFile.h"
44 #include "GraphicsItemType.h"
45 #include "GraphicsScene.h"
46 #include "GraphicsView.h"
47 #include "HelpWindow.h"
48 #ifdef ENGAUGE_JPEG2000
50 #endif // ENGAUGE_JPEG2000
51 #include "LoadFileInfo.h"
52 #include "LoadImageFromUrl.h"
54 #include "MainWindow.h"
55 #include "NetworkClient.h"
57 #include <QApplication>
58 #include <QCloseEvent>
61 #include <QDesktopServices>
62 #include <QDockWidget>
63 #include <QDomDocument>
65 #include <QFileDialog>
67 #include <QGraphicsLineItem>
68 #include <QImageReader>
70 #include <QKeySequence>
74 #include <QMessageBox>
75 #include <QPrintDialog>
78 #include <QTextStream>
82 #include <QToolButton>
83 #include "QtToString.h"
84 #include <QVBoxLayout>
86 #include <QXmlStreamReader>
87 #include <QXmlStreamWriter>
89 #include "StatusBar.h"
90 #include "TransformationStateContext.h"
91 #include "TutorialDlg.h"
93 #include "ViewPointStyle.h"
94 #include "ViewSegmentFilter.h"
95 #include "ZoomFactor.h"
96 #include "ZoomFactorInitial.h"
99 const QString DIGITIZE_ACTION_AXIS_POINT (QObject::tr (
"Axis Point Tool"));
100 const QString DIGITIZE_ACTION_COLOR_PICKER (QObject::tr (
"Color Picker Tool"));
101 const QString DIGITIZE_ACTION_CURVE_POINT (QObject::tr (
"Curve Point Tool"));
102 const QString DIGITIZE_ACTION_POINT_MATCH (QObject::tr (
"Point Match Tool"));
103 const QString DIGITIZE_ACTION_SEGMENT_POINTS (QObject::tr (
"Segment Fill Tool"));
104 const QString DIGITIZE_ACTION_SELECT (QObject::tr (
"Select Tool"));
106 const QString EMPTY_FILENAME (
"");
107 const QString ENGAUGE_FILENAME_DESCRIPTION (
"Engauge Document");
108 const QString ENGAUGE_FILENAME_EXTENSION (
"dig");
110 const unsigned int MAX_RECENT_FILE_LIST_SIZE = 8;
114 QStringList loadStartupFiles,
117 m_isDocumentExported (false),
118 m_engaugeFile (EMPTY_FILENAME),
119 m_currentFile (EMPTY_FILENAME),
124 m_digitizeStateContext (0),
125 m_transformationStateContext (0),
126 m_backgroundStateContext (0),
127 m_isGnuplot (isGnuplot)
131 QString initialPath = QDir::currentPath();
135 setWindowFlags (Qt::WindowContextHelpButtonHint | windowFlags ());
136 setWindowTitle (engaugeWindowTitle ());
138 createCentralWidget();
147 createLoadImageFromUrl ();
148 createStateContextBackground ();
149 createStateContextDigitize ();
150 createStateContextTransformation ();
151 createSettingsDialogs ();
152 createCommandStackShadow ();
157 setUnifiedTitleAndToolBarOnMac(
true);
159 installEventFilter(
this);
160 if (!errorReportFile.isEmpty()) {
161 loadErrorReportFile(initialPath,
167 m_loadStartupFiles = loadStartupFiles;
171 MainWindow::~MainWindow()
175 void MainWindow::applyZoomFactorAfterLoad()
177 ZoomFactor zoomFactor;
181 case ZOOM_INITIAL_16_TO_1:
182 zoomFactor = ZOOM_16_TO_1;
185 case ZOOM_INITIAL_8_TO_1:
186 zoomFactor = ZOOM_8_TO_1;
189 case ZOOM_INITIAL_4_TO_1:
190 zoomFactor = ZOOM_4_TO_1;
193 case ZOOM_INITIAL_2_TO_1:
194 zoomFactor = ZOOM_2_TO_1;
197 case ZOOM_INITIAL_1_TO_1:
198 zoomFactor = ZOOM_1_TO_1;
201 case ZOOM_INITIAL_1_TO_2:
202 zoomFactor = ZOOM_1_TO_2;
205 case ZOOM_INITIAL_1_TO_4:
206 zoomFactor = ZOOM_1_TO_4;
209 case ZOOM_INITIAL_1_TO_8:
210 zoomFactor = ZOOM_1_TO_8;
213 case ZOOM_INITIAL_1_TO_16:
214 zoomFactor = ZOOM_1_TO_16;
217 case ZOOM_INITIAL_FILL:
218 zoomFactor = ZOOM_FILL;
221 case ZOOM_INITIAL_PREVIOUS:
222 zoomFactor = currentZoomFactor();
226 ENGAUGE_ASSERT (
false);
227 zoomFactor = currentZoomFactor();
231 slotViewZoom (zoomFactor);
234 void MainWindow::closeEvent(QCloseEvent *event)
246 ENGAUGE_CHECK_PTR (m_cmdMediator);
248 return *m_cmdMediator;
251 void MainWindow::createActions()
253 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createActions";
255 createActionsFile ();
256 createActionsEdit ();
257 createActionsDigitize ();
258 createActionsView ();
259 createActionsSettings ();
260 createActionsHelp ();
263 void MainWindow::createActionsDigitize ()
265 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createActionsDigitize";
267 QPixmap pixmapAxis (DigitAxis_xpm);
268 QPixmap pixmapCurve (DigitCurve_xpm);
269 QPixmap pixmapColorPicker (DigitColorPicker_xpm);
270 QPixmap pixmapPointMatch (DigitPointMatch_xpm);
271 QPixmap pixmapSegment (DigitSegment_xpm);
272 QPixmap pixmapSelect (DigitSelect_xpm);
274 QIcon iconAxis (pixmapAxis);
275 QIcon iconCurve (pixmapCurve);
276 QIcon iconColorPicker (pixmapColorPicker);
277 QIcon iconPointMatch (pixmapPointMatch);
278 QIcon iconSegment (pixmapSegment);
279 QIcon iconSelect (pixmapSelect);
281 m_actionDigitizeSelect =
new QAction (iconSelect, DIGITIZE_ACTION_SELECT,
this);
282 m_actionDigitizeSelect->setShortcut (QKeySequence (tr (
"Shift+F2")));
283 m_actionDigitizeSelect->setCheckable (
true);
284 m_actionDigitizeSelect->setStatusTip (tr (
"Select points on screen."));
285 m_actionDigitizeSelect->setWhatsThis (tr (
"Select\n\n"
286 "Select points on the screen."));
287 connect (m_actionDigitizeSelect, SIGNAL (triggered ()),
this, SLOT (slotDigitizeSelect ()));
289 m_actionDigitizeAxis =
new QAction (iconAxis, DIGITIZE_ACTION_AXIS_POINT,
this);
290 m_actionDigitizeAxis->setShortcut (QKeySequence (tr (
"Shift+F3")));
291 m_actionDigitizeAxis->setCheckable (
true);
292 m_actionDigitizeAxis->setStatusTip (tr (
"Digitize axis points."));
293 m_actionDigitizeAxis->setWhatsThis (tr (
"Digitize Axis Point\n\n"
294 "Digitizes an axis point by placing a new point at the cursor "
295 "after a mouse click. The coordinates of the axis point are then "
296 "entered. In a graph, three axis points are required to define "
297 "the graph coordinates."));
298 connect (m_actionDigitizeAxis, SIGNAL (triggered ()),
this, SLOT (slotDigitizeAxis ()));
300 m_actionDigitizeCurve =
new QAction (iconCurve, DIGITIZE_ACTION_CURVE_POINT,
this);
301 m_actionDigitizeCurve->setShortcut (QKeySequence (tr (
"Shift+F4")));
302 m_actionDigitizeCurve->setCheckable (
true);
303 m_actionDigitizeCurve->setStatusTip (tr (
"Digitize curve points."));
304 m_actionDigitizeCurve->setWhatsThis (tr (
"Digitize Curve Point\n\n"
305 "Digitizes a curve point by placing a new point at the cursor "
306 "after a mouse click. Use this mode to digitize points along curves "
308 "New points will be assigned to the currently selected curve."));
309 connect (m_actionDigitizeCurve, SIGNAL (triggered ()),
this, SLOT (slotDigitizeCurve ()));
311 m_actionDigitizePointMatch =
new QAction (iconPointMatch, DIGITIZE_ACTION_POINT_MATCH,
this);
312 m_actionDigitizePointMatch->setShortcut (QKeySequence (tr (
"Shift+F5")));
313 m_actionDigitizePointMatch->setCheckable (
true);
314 m_actionDigitizePointMatch->setStatusTip (tr (
"Digitize curve points in a point plot by matching a point."));
315 m_actionDigitizePointMatch->setWhatsThis (tr (
"Digitize Curve Points by Point Matching\n\n"
316 "Digitizes curve points in a point plot by finding points that match a sample point. The process "
317 "starts by selecting a representative sample point.\n\n"
318 "New points will be assigned to the currently selected curve."));
319 connect (m_actionDigitizePointMatch, SIGNAL (triggered ()),
this, SLOT (slotDigitizePointMatch ()));
321 m_actionDigitizeColorPicker =
new QAction (iconColorPicker, DIGITIZE_ACTION_COLOR_PICKER,
this);
322 m_actionDigitizeColorPicker->setShortcut (QKeySequence (tr (
"Shift+F6")));
323 m_actionDigitizeColorPicker->setCheckable (
true);
324 m_actionDigitizeColorPicker->setStatusTip (tr (
"Select color settings for filtering in Segment Fill mode."));
325 m_actionDigitizeColorPicker->setWhatsThis (tr (
"Select color settings for Segment Fill filtering\n\n"
326 "Select a pixel along the currently selected curve. That pixel and its neighbors will "
327 "define the filter settings (color, brightness, and so on) of the currently selected curve "
328 "while in Segment Fill mode."));
329 connect (m_actionDigitizeColorPicker, SIGNAL (triggered ()),
this, SLOT (slotDigitizeColorPicker ()));
331 m_actionDigitizeSegment =
new QAction (iconSegment, DIGITIZE_ACTION_SEGMENT_POINTS,
this);
332 m_actionDigitizeSegment->setShortcut (QKeySequence (tr (
"Shift+F7")));
333 m_actionDigitizeSegment->setCheckable (
true);
334 m_actionDigitizeSegment->setStatusTip (tr (
"Digitize curve points along a segment of a curve."));
335 m_actionDigitizeSegment->setWhatsThis (tr (
"Digitize Curve Points With Segment Fill\n\n"
336 "Digitizes curve points by placing new points along the highlighted "
337 "segment under the cursor. Use this mode to quickly digitize multiple points along a "
338 "curve with a single click.\n\n"
339 "New points will be assigned to the currently selected curve."));
340 connect (m_actionDigitizeSegment, SIGNAL (triggered ()),
this, SLOT (slotDigitizeSegment ()));
342 m_groupDigitize =
new QActionGroup (
this);
343 m_groupDigitize->addAction (m_actionDigitizeSelect);
344 m_groupDigitize->addAction (m_actionDigitizeAxis);
345 m_groupDigitize->addAction (m_actionDigitizeCurve);
346 m_groupDigitize->addAction (m_actionDigitizePointMatch);
347 m_groupDigitize->addAction (m_actionDigitizeColorPicker);
348 m_groupDigitize->addAction (m_actionDigitizeSegment);
351 void MainWindow::createActionsEdit ()
353 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createActionsEdit";
355 m_actionEditUndo =
new QAction(tr (
"&Undo"),
this);
356 m_actionEditUndo->setShortcut (QKeySequence::Undo);
357 m_actionEditUndo->setStatusTip (tr (
"Undo the last operation."));
358 m_actionEditUndo->setWhatsThis (tr (
"Undo\n\n"
359 "Undo the last operation."));
362 m_actionEditRedo =
new QAction(tr (
"&Redo"),
this);
363 m_actionEditRedo->setShortcut (QKeySequence::Redo);
364 m_actionEditRedo->setStatusTip (tr (
"Redo the last operation."));
365 m_actionEditRedo->setWhatsThis (tr (
"Redo\n\n"
366 "Redo the last operation."));
369 m_actionEditCut =
new QAction (tr (
"Cut"),
this);
370 m_actionEditCut->setShortcut (QKeySequence::Cut);
371 m_actionEditCut->setStatusTip (tr (
"Cuts the selected points and copies them to the clipboard."));
372 m_actionEditCut->setWhatsThis (tr (
"Cut\n\n"
373 "Cuts the selected points and copies them to the clipboard."));
374 connect (m_actionEditCut, SIGNAL (triggered ()),
this, SLOT (slotEditCut ()));
376 m_actionEditCopy =
new QAction (tr (
"Copy"),
this);
377 m_actionEditCopy->setShortcut (QKeySequence::Copy);
378 m_actionEditCopy->setStatusTip (tr (
"Copies the selected points to the clipboard."));
379 m_actionEditCopy->setWhatsThis (tr (
"Copy\n\n"
380 "Copies the selected points to the clipboard."));
381 connect (m_actionEditCopy, SIGNAL (triggered ()),
this, SLOT (slotEditCopy ()));
383 m_actionEditPaste =
new QAction (tr (
"Paste"),
this);
384 m_actionEditPaste->setShortcut (QKeySequence::Paste);
385 m_actionEditPaste->setStatusTip (tr (
"Pastes the selected points from the clipboard."));
386 m_actionEditPaste->setWhatsThis (tr (
"Paste\n\n"
387 "Pastes the selected points from the clipboard. They will be assigned to the current curve."));
388 connect (m_actionEditPaste, SIGNAL (triggered ()),
this, SLOT (slotEditPaste ()));
390 m_actionEditDelete =
new QAction (tr (
"Delete"),
this);
391 m_actionEditDelete->setShortcut (QKeySequence::Delete);
392 m_actionEditDelete->setStatusTip (tr (
"Deletes the selected points, after copying them to the clipboard."));
393 m_actionEditDelete->setWhatsThis (tr (
"Delete\n\n"
394 "Deletes the selected points, after copying them to the clipboard."));
395 connect (m_actionEditDelete, SIGNAL (triggered ()),
this, SLOT (slotEditDelete ()));
398 void MainWindow::createActionsFile ()
400 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createActionsFile";
402 m_actionImport =
new QAction(tr (
"&Import..."),
this);
403 m_actionImport->setShortcut (tr (
"Ctrl+I"));
404 m_actionImport->setStatusTip (tr (
"Creates a new document by importing an image."));
405 m_actionImport->setWhatsThis (tr (
"New Document\n\n"
406 "Creates a new document by importing an image."));
407 connect (m_actionImport, SIGNAL (triggered ()),
this, SLOT (slotFileImport ()));
409 m_actionOpen =
new QAction(tr (
"&Open..."),
this);
410 m_actionOpen->setShortcut (QKeySequence::Open);
411 m_actionOpen->setStatusTip (tr (
"Opens an existing document."));
412 m_actionOpen->setWhatsThis (tr (
"Open Document\n\n"
413 "Opens an existing document."));
414 connect (m_actionOpen, SIGNAL (triggered ()),
this, SLOT (slotFileOpen ()));
416 for (
unsigned int i = 0; i < MAX_RECENT_FILE_LIST_SIZE; i++) {
417 QAction *recentFileAction =
new QAction (
this);
418 recentFileAction->setVisible (
true);
419 connect (recentFileAction, SIGNAL (triggered ()),
this, SLOT (slotRecentFileAction ()));
420 m_actionRecentFiles.append (recentFileAction);
423 m_actionClose =
new QAction(tr (
"&Close"),
this);
424 m_actionClose->setShortcut (QKeySequence::Close);
425 m_actionClose->setStatusTip (tr (
"Closes the open document document."));
426 m_actionClose->setWhatsThis (tr (
"Close Document\n\n"
427 "Closes the open document."));
428 connect (m_actionClose, SIGNAL (triggered ()),
this, SLOT (slotFileClose ()));
430 m_actionSave =
new QAction(tr (
"&Save"),
this);
431 m_actionSave->setShortcut (QKeySequence::Save);
432 m_actionSave->setStatusTip (tr (
"Saves the current document."));
433 m_actionSave->setWhatsThis (tr (
"Save Document\n\n"
434 "Saves the current document."));
435 connect (m_actionSave, SIGNAL (triggered ()),
this, SLOT (slotFileSave ()));
437 m_actionSaveAs =
new QAction(tr (
"Save As..."),
this);
438 m_actionSaveAs->setShortcut (QKeySequence::SaveAs);
439 m_actionSaveAs->setStatusTip (tr (
"Saves the current document under a new filename."));
440 m_actionSaveAs->setWhatsThis (tr (
"Save Document As\n\n"
441 "Saves the current document under a new filename."));
442 connect (m_actionSaveAs, SIGNAL (triggered ()),
this, SLOT (slotFileSaveAs ()));
444 m_actionExport =
new QAction (tr (
"Export..."),
this);
445 m_actionExport->setShortcut (tr (
"Ctrl+E"));
446 m_actionExport->setStatusTip (tr (
"Exports the current document into a text file."));
447 m_actionExport->setWhatsThis (tr (
"Export Document\n\n"
448 "Exports the current document into a text file."));
449 connect (m_actionExport, SIGNAL (triggered ()),
this, SLOT (slotFileExport ()));
451 m_actionPrint =
new QAction (tr (
"&Print..."),
this);
452 m_actionPrint->setShortcut (QKeySequence::Print);
453 m_actionPrint->setStatusTip (tr (
"Print the current document."));
454 m_actionPrint->setWhatsThis (tr (
"Print Document\n\n"
455 "Print the current document to a printer or file."));
456 connect (m_actionPrint, SIGNAL (triggered ()),
this, SLOT (slotFilePrint ()));
458 m_actionExit =
new QAction(tr (
"&Exit"),
this);
459 m_actionExit->setShortcut (QKeySequence::Quit);
460 m_actionExit->setStatusTip (tr (
"Quits the application."));
461 m_actionExit->setWhatsThis (tr (
"Exit\n\n"
462 "Quits the application."));
463 connect (m_actionExit, SIGNAL (triggered ()),
this, SLOT (close ()));
466 void MainWindow::createActionsHelp ()
468 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createActionsHelp";
470 m_actionHelpChecklistGuideWizard =
new QAction (tr (
"Checklist Guide Wizard"),
this);
471 m_actionHelpChecklistGuideWizard->setCheckable (
true);
472 m_actionHelpChecklistGuideWizard->setStatusTip (tr (
"Open Checklist Guide Wizard during import to define digitizing steps"));
473 m_actionHelpChecklistGuideWizard->setWhatsThis (tr (
"Checklist Guide Wizard\n\n"
474 "Use Checklist Guide Wizard during import to generate a checklist of steps "
475 "for the imported document"));
477 m_actionHelpWhatsThis = QWhatsThis::createAction(
this);
478 m_actionHelpWhatsThis->setShortcut (QKeySequence::WhatsThis);
480 m_actionHelpTutorial =
new QAction (tr (
"Tutorial"),
this);
481 m_actionHelpTutorial->setStatusTip (tr (
"Play tutorial showing steps for digitizing curves"));
482 m_actionHelpTutorial->setWhatsThis (tr (
"Tutorial\n\n"
483 "Play tutorial showing steps for digitizing points from curves drawn with lines "
485 connect (m_actionHelpTutorial, SIGNAL (triggered ()),
this, SLOT (slotHelpTutorial()));
487 m_actionHelpHelp =
new QAction (tr (
"Help"),
this);
488 m_actionHelpHelp->setShortcut (QKeySequence::HelpContents);
489 m_actionHelpHelp->setStatusTip (tr (
"Help documentation"));
490 m_actionHelpHelp->setWhatsThis (tr (
"Help Documentation\n\n"
491 "Searchable help documentation"));
494 m_actionHelpAbout =
new QAction(tr (
"About Engauge"),
this);
495 m_actionHelpAbout->setStatusTip (tr (
"About the application."));
496 m_actionHelpAbout->setWhatsThis (tr (
"About Engauge\n\nAbout the application."));
497 connect (m_actionHelpAbout, SIGNAL (triggered ()),
this, SLOT (slotHelpAbout ()));
500 void MainWindow::createActionsSettings ()
502 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createActionsSettings";
504 m_actionSettingsCoords =
new QAction (tr (
"Coordinates..."),
this);
505 m_actionSettingsCoords->setStatusTip (tr (
"Edit Coordinate settings."));
506 m_actionSettingsCoords->setWhatsThis (tr (
"Coordinate Settings\n\n"
507 "Coordinate settings determine how the graph coordinates are mapped to the pixels in the image"));
508 connect (m_actionSettingsCoords, SIGNAL (triggered ()),
this, SLOT (slotSettingsCoords ()));
510 m_actionSettingsCurveAddRemove =
new QAction (tr (
"Add/Remove Curve..."),
this);
511 m_actionSettingsCurveAddRemove->setStatusTip (tr (
"Add or Remove Curves."));
512 m_actionSettingsCurveAddRemove->setWhatsThis (tr (
"Add/Remove Curve\n\n"
513 "Add/Remove Curve settings control which curves are included in the current document"));
514 connect (m_actionSettingsCurveAddRemove, SIGNAL (triggered ()),
this, SLOT (slotSettingsCurveAddRemove ()));
516 m_actionSettingsCurveProperties =
new QAction (tr (
"Curve Properties..."),
this);
517 m_actionSettingsCurveProperties->setStatusTip (tr (
"Edit Curve Properties settings."));
518 m_actionSettingsCurveProperties->setWhatsThis (tr (
"Curve Properties Settings\n\n"
519 "Curves properties settings determine how each curve appears"));
520 connect (m_actionSettingsCurveProperties, SIGNAL (triggered ()),
this, SLOT (slotSettingsCurveProperties ()));
522 m_actionSettingsDigitizeCurve =
new QAction (tr (
"Digitize Curve..."),
this);
523 m_actionSettingsDigitizeCurve->setStatusTip (tr (
"Edit Digitize Axis and Graph Curve settings."));
524 m_actionSettingsDigitizeCurve->setWhatsThis (tr (
"Digitize Axis and Graph Curve Settings\n\n"
525 "Digitize Curve settings determine how points are digitized in Digitize Axis Point and "
526 "Digitize Graph Point modes"));
527 connect (m_actionSettingsDigitizeCurve, SIGNAL (triggered ()),
this, SLOT (slotSettingsDigitizeCurve ()));
529 m_actionSettingsExport =
new QAction (tr (
"Export Format..."),
this);
530 m_actionSettingsExport->setStatusTip (tr (
"Edit Export Format settings."));
531 m_actionSettingsExport->setWhatsThis (tr (
"Export Format Settings\n\n"
532 "Export format settings affect how exported files are formatted"));
533 connect (m_actionSettingsExport, SIGNAL (triggered ()),
this, SLOT (slotSettingsExportFormat ()));
535 m_actionSettingsColorFilter =
new QAction (tr (
"Color Filter..."),
this);
536 m_actionSettingsColorFilter->setStatusTip (tr (
"Edit Color Filter settings."));
537 m_actionSettingsColorFilter->setWhatsThis (tr (
"Color Filter Settings\n\n"
538 "Color filtering simplifies the graphs for easier Point Matching and Segment Filling"));
539 connect (m_actionSettingsColorFilter, SIGNAL (triggered ()),
this, SLOT (slotSettingsColorFilter ()));
541 m_actionSettingsAxesChecker =
new QAction (tr (
"Axes Checker..."),
this);
542 m_actionSettingsAxesChecker->setStatusTip (tr (
"Edit Axes Checker settings."));
543 m_actionSettingsAxesChecker->setWhatsThis (tr (
"Axes Checker Settings\n\n"
544 "Axes checker can reveal any axis point mistakes, which are otherwise hard to find."));
545 connect (m_actionSettingsAxesChecker, SIGNAL (triggered ()),
this, SLOT (slotSettingsAxesChecker ()));
547 m_actionSettingsGridRemoval =
new QAction (tr (
"Grid Line Removal..."),
this);
548 m_actionSettingsGridRemoval->setStatusTip (tr (
"Edit Grid Line Removal settings."));
549 m_actionSettingsGridRemoval->setWhatsThis (tr (
"Grid Line Removal Settings\n\n"
550 "Grid line removal isolates curve lines for easier Point Matching and Segment Filling, when "
551 "Color Filtering is not able to separate grid lines from curve lines."));
552 connect (m_actionSettingsGridRemoval, SIGNAL (triggered ()),
this, SLOT (slotSettingsGridRemoval ()));
554 m_actionSettingsPointMatch =
new QAction (tr (
"Point Match..."),
this);
555 m_actionSettingsPointMatch->setStatusTip (tr (
"Edit Point Match settings."));
556 m_actionSettingsPointMatch->setWhatsThis (tr (
"Point Match Settings\n\n"
557 "Point match settings determine how points are matched while in Point Match mode"));
558 connect (m_actionSettingsPointMatch, SIGNAL (triggered ()),
this, SLOT (slotSettingsPointMatch ()));
560 m_actionSettingsSegments =
new QAction (tr (
"Segment Fill..."),
this);
561 m_actionSettingsSegments->setStatusTip (tr (
"Edit Segment Fill settings."));
562 m_actionSettingsSegments->setWhatsThis (tr (
"Segment Fill Settings\n\n"
563 "Segment fill settings determine how points are generated in the Segment Fill mode"));
564 connect (m_actionSettingsSegments, SIGNAL (triggered ()),
this, SLOT (slotSettingsSegments ()));
566 m_actionSettingsGeneral =
new QAction (tr (
"General..."),
this);
567 m_actionSettingsGeneral->setStatusTip (tr (
"Edit General settings."));
568 m_actionSettingsGeneral->setWhatsThis (tr (
"General Settings\n\n"
569 "General settings are document-specific settings that affect multiple modes. For example, the cursor size setting affects "
570 "both Color Picker and Point Match modes"));
571 connect (m_actionSettingsGeneral, SIGNAL (triggered ()),
this, SLOT (slotSettingsGeneral ()));
573 m_actionSettingsMainWindow =
new QAction (tr (
"Main Window..."),
this);
574 m_actionSettingsMainWindow->setStatusTip (tr (
"Edit Main Window settings."));
575 m_actionSettingsMainWindow->setWhatsThis (tr (
"Main Window Settings\n\n"
576 "Main window settings affect the user interface and are not specific to any document"));
577 connect (m_actionSettingsMainWindow, SIGNAL (triggered ()),
this, SLOT (slotSettingsMainWindow ()));
580 void MainWindow::createActionsView ()
582 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createActionsView";
584 m_actionViewBackground =
new QAction (tr (
"Background Toolbar"),
this);
585 m_actionViewBackground->setCheckable (
true);
586 m_actionViewBackground->setChecked (
true);
587 m_actionViewBackground->setStatusTip (tr (
"Show or hide the background toolbar."));
588 m_actionViewBackground->setWhatsThis (tr (
"View Background ToolBar\n\n"
589 "Show or hide the background toolbar"));
590 connect (m_actionViewBackground, SIGNAL (triggered ()),
this, SLOT (slotViewToolBarBackground ()));
592 m_actionViewChecklistGuide =
new QAction (tr (
"Checklist Guide Toolbar"),
this);
593 m_actionViewChecklistGuide->setCheckable (
true);
594 m_actionViewChecklistGuide->setChecked (
false);
595 m_actionViewChecklistGuide->setStatusTip (tr (
"Show or hide the checklist guide toolbar."));
596 m_actionViewChecklistGuide->setWhatsThis (tr (
"View Checklist Guide ToolBar\n\n"
597 "Show or hide the checklist guide toolbar"));
598 connect (m_actionViewChecklistGuide, SIGNAL (changed ()),
this, SLOT (slotViewToolBarChecklistGuide()));
600 m_actionViewDigitize =
new QAction (tr (
"Digitizing Tools Toolbar"),
this);
601 m_actionViewDigitize->setCheckable (
true);
602 m_actionViewDigitize->setChecked (
true);
603 m_actionViewDigitize->setStatusTip (tr (
"Show or hide the digitizing tools toolbar."));
604 m_actionViewDigitize->setWhatsThis (tr (
"View Digitizing Tools ToolBar\n\n"
605 "Show or hide the digitizing tools toolbar"));
606 connect (m_actionViewDigitize, SIGNAL (triggered ()),
this, SLOT (slotViewToolBarDigitize()));
608 m_actionViewSettingsViews =
new QAction (tr (
"Settings Views Toolbar"),
this);
609 m_actionViewSettingsViews->setCheckable (
true);
610 m_actionViewSettingsViews->setChecked (
true);
611 m_actionViewSettingsViews->setStatusTip (tr (
"Show or hide the settings views toolbar."));
612 m_actionViewSettingsViews->setWhatsThis (tr (
"View Settings Views ToolBar\n\n"
613 "Show or hide the settings views toolbar. These views graphically show the "
614 "most important settings."));
615 connect (m_actionViewSettingsViews, SIGNAL (triggered ()),
this, SLOT (slotViewToolBarSettingsViews()));
617 m_actionViewToolTips =
new QAction (tr (
"Tool Tips"),
this);
618 m_actionViewToolTips->setCheckable (
true);
619 m_actionViewToolTips->setChecked (
true);
620 m_actionViewToolTips->setStatusTip (tr (
"Show or hide the tool tips."));
621 m_actionViewToolTips->setWhatsThis (tr (
"View Tool Tips\n\n"
622 "Show or hide the tool tips"));
623 connect (m_actionViewToolTips, SIGNAL (triggered ()),
this, SLOT (slotViewToolTips()));
625 m_actionViewBackgroundNone =
new QAction (tr (
"No Background"),
this);
626 m_actionViewBackgroundNone->setCheckable (
true);
627 m_actionViewBackgroundNone->setStatusTip (tr (
"Do not show the image underneath the points."));
628 m_actionViewBackgroundNone->setWhatsThis (tr (
"No Background\n\n"
629 "No image is shown so points are easier to see"));
631 m_actionViewBackgroundOriginal =
new QAction (tr (
"Show Original Image"),
this);
632 m_actionViewBackgroundOriginal->setCheckable (
true);
633 m_actionViewBackgroundOriginal->setStatusTip (tr (
"Show the original image underneath the points."));
634 m_actionViewBackgroundOriginal->setWhatsThis (tr (
"Show Original Image\n\n"
635 "Show the original image underneath the points"));
637 m_actionViewBackgroundFiltered =
new QAction (tr (
"Show Filtered Image"),
this);
638 m_actionViewBackgroundFiltered->setCheckable (
true);
639 m_actionViewBackgroundFiltered->setChecked (
true);
640 m_actionViewBackgroundFiltered->setStatusTip (tr (
"Show the filtered image underneath the points."));
641 m_actionViewBackgroundFiltered->setWhatsThis (tr (
"Show Filtered Image\n\n"
642 "Show the filtered image underneath the points.\n\n"
643 "The filtered image is created from the original image according to the "
644 "Filter preferences so unimportant information is hidden and important "
645 "information is emphasized"));
647 m_actionViewCurvesNone =
new QAction (tr (
"Hide All Curves"),
this);
648 m_actionViewCurvesNone->setCheckable (
true);
649 m_actionViewCurvesNone->setStatusTip (tr (
"Hide all digitized curves."));
650 m_actionViewCurvesNone->setWhatsThis (tr (
"Hide All Curves\n\n"
651 "No axis points or digitized graph curves are shown so the image is easier to see."));
653 m_actionViewCurvesSelected =
new QAction (tr (
"Show Selected Curve"),
this);
654 m_actionViewCurvesSelected->setCheckable (
true);
655 m_actionViewCurvesSelected->setStatusTip (tr (
"Show only the currently selected curve."));
656 m_actionViewCurvesSelected->setWhatsThis (tr (
"Show Selected Curve\n\n"
657 "Show only the digitized points and line that belong to the currently selected curve."));
659 m_actionViewCurvesAll =
new QAction (tr (
"Show All Curves"),
this);
660 m_actionViewCurvesAll->setCheckable (
true);
661 m_actionViewCurvesAll->setChecked (
true);
662 m_actionViewCurvesAll->setStatusTip (tr (
"Show all curves."));
663 m_actionViewCurvesAll->setWhatsThis (tr (
"Show All Curves\n\n"
664 "Show all digitized axis points and graph curves"));
666 m_groupBackground =
new QActionGroup(
this);
667 m_groupBackground->addAction (m_actionViewBackgroundNone);
668 m_groupBackground->addAction (m_actionViewBackgroundOriginal);
669 m_groupBackground->addAction (m_actionViewBackgroundFiltered);
670 connect (m_groupBackground, SIGNAL(triggered (QAction*)),
this, SLOT (slotViewGroupBackground(QAction*)));
672 m_groupCurves =
new QActionGroup(
this);
673 m_groupCurves->addAction (m_actionViewCurvesNone);
674 m_groupCurves->addAction (m_actionViewCurvesSelected);
675 m_groupCurves->addAction (m_actionViewCurvesAll);
676 connect (m_groupCurves, SIGNAL(triggered (QAction*)),
this, SLOT (slotViewGroupCurves(QAction*)));
678 m_actionStatusNever =
new QAction (tr (
"Hide Always"),
this);
679 m_actionStatusNever->setCheckable(
true);
680 m_actionStatusNever->setStatusTip (tr (
"Always hide the status bar."));
681 m_actionStatusNever->setWhatsThis (tr (
"Hide the status bar. No temporary status or feedback messages will appear."));
683 m_actionStatusTemporary =
new QAction (tr (
"Show Temporary Messages"),
this);
684 m_actionStatusTemporary->setCheckable(
true);
685 m_actionStatusTemporary->setStatusTip (tr (
"Hide the status bar except when display temporary messages."));
686 m_actionStatusTemporary->setWhatsThis (tr (
"Hide the status bar, except when displaying temporary status and feedback messages."));
688 m_actionStatusAlways =
new QAction (tr (
"Show Always"),
this);
689 m_actionStatusAlways->setCheckable(
true);
690 m_actionStatusAlways->setStatusTip (tr (
"Always show the status bar."));
691 m_actionStatusAlways->setWhatsThis (tr (
"Show the status bar. Besides displaying temporary status and feedback messages, "
692 "the status bar also displays information about the cursor position."));
694 m_groupStatus =
new QActionGroup(
this);
695 m_groupStatus->addAction (m_actionStatusNever);
696 m_groupStatus->addAction (m_actionStatusTemporary);
697 m_groupStatus->addAction (m_actionStatusAlways);
698 connect (m_groupStatus, SIGNAL (triggered (QAction*)),
this, SLOT (slotViewGroupStatus(QAction*)));
700 m_actionZoomOut =
new QAction (tr (
"Zoom Out"),
this);
701 m_actionZoomOut->setStatusTip (tr (
"Zoom out"));
703 connect (m_actionZoomOut, SIGNAL (triggered ()),
this, SLOT (slotViewZoomOut ()));
705 m_actionZoomIn =
new QAction (tr (
"Zoom In"),
this);
706 m_actionZoomIn->setStatusTip (tr (
"Zoom in"));
708 connect (m_actionZoomIn, SIGNAL (triggered ()),
this, SLOT (slotViewZoomIn ()));
710 m_actionZoom16To1 =
new QAction (tr (
"16:1 (1600%)"),
this);
711 m_actionZoom16To1->setCheckable (
true);
712 m_actionZoom16To1->setStatusTip (tr (
"Zoom 16:1"));
713 connect (m_actionZoom16To1, SIGNAL (triggered ()),
this, SLOT (slotViewZoom16To1 ()));
715 m_actionZoom8To1 =
new QAction (tr (
"8:1 (800%)"),
this);
716 m_actionZoom8To1->setCheckable (
true);
717 m_actionZoom8To1->setStatusTip (tr (
"Zoom 8:1"));
718 connect (m_actionZoom8To1, SIGNAL (triggered ()),
this, SLOT (slotViewZoom8To1 ()));
720 m_actionZoom4To1 =
new QAction (tr (
"4:1 (400%)"),
this);
721 m_actionZoom4To1->setCheckable (
true);
722 m_actionZoom4To1->setStatusTip (tr (
"Zoom 4:1"));
723 connect (m_actionZoom4To1, SIGNAL (triggered ()),
this, SLOT (slotViewZoom4To1 ()));
725 m_actionZoom2To1 =
new QAction (tr (
"2:1 (200%)"),
this);
726 m_actionZoom2To1->setCheckable (
true);
727 m_actionZoom2To1->setStatusTip (tr (
"Zoom 2:1"));
728 connect (m_actionZoom2To1, SIGNAL (triggered ()),
this, SLOT (slotViewZoom2To1 ()));
730 m_actionZoom1To1 =
new QAction (tr (
"1:1 (100%)"),
this);
731 m_actionZoom1To1->setCheckable (
true);
732 m_actionZoom1To1->setChecked (
true);
733 m_actionZoom1To1->setStatusTip (tr (
"Zoom 6:1"));
734 connect (m_actionZoom1To1, SIGNAL (triggered ()),
this, SLOT (slotViewZoom1To1 ()));
736 m_actionZoom1To2 =
new QAction (tr (
"1:2 (50%)"),
this);
737 m_actionZoom1To2->setCheckable (
true);
738 m_actionZoom1To2->setStatusTip (tr (
"Zoom 1:2"));
739 connect (m_actionZoom1To2, SIGNAL (triggered ()),
this, SLOT (slotViewZoom1To2 ()));
741 m_actionZoom1To4 =
new QAction (tr (
"1:4 (25%)"),
this);
742 m_actionZoom1To4->setCheckable (
true);
743 m_actionZoom1To4->setStatusTip (tr (
"Zoom 1:4"));
744 connect (m_actionZoom1To4, SIGNAL (triggered ()),
this, SLOT (slotViewZoom1To4 ()));
746 m_actionZoom1To8 =
new QAction (tr (
"1:8 (12.5%)"),
this);
747 m_actionZoom1To8->setCheckable (
true);
748 m_actionZoom1To8->setStatusTip (tr (
"Zoom 1:8"));
749 connect (m_actionZoom1To8, SIGNAL (triggered ()),
this, SLOT (slotViewZoom1To8 ()));
751 m_actionZoom1To16 =
new QAction (tr (
"1:16 (6.25%)"),
this);
752 m_actionZoom1To16->setCheckable (
true);
753 m_actionZoom1To16->setStatusTip (tr (
"Zoom 1:16"));
754 connect (m_actionZoom1To16, SIGNAL (triggered ()),
this, SLOT (slotViewZoom1To16 ()));
756 m_actionZoomFill =
new QAction (tr (
"Fill"),
this);
757 m_actionZoomFill->setCheckable (
true);
758 m_actionZoomFill->setStatusTip (tr (
"Zoom with stretching to fill window"));
759 connect (m_actionZoomFill, SIGNAL (triggered ()),
this, SLOT (slotViewZoomFill ()));
761 m_groupZoom =
new QActionGroup (
this);
762 m_groupZoom->addAction (m_actionZoom16To1);
763 m_groupZoom->addAction (m_actionZoom8To1);
764 m_groupZoom->addAction (m_actionZoom4To1);
765 m_groupZoom->addAction (m_actionZoom2To1);
766 m_groupZoom->addAction (m_actionZoom1To1);
767 m_groupZoom->addAction (m_actionZoom1To2);
768 m_groupZoom->addAction (m_actionZoom1To4);
769 m_groupZoom->addAction (m_actionZoom1To8);
770 m_groupZoom->addAction (m_actionZoom1To16);
771 m_groupZoom->addAction (m_actionZoomFill);
774 void MainWindow::createCentralWidget ()
776 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createCentralWidget";
778 QWidget *widget =
new QWidget;
779 setCentralWidget (widget);
780 m_layout =
new QVBoxLayout;
781 widget->setLayout (m_layout);
784 void MainWindow::createCommandStackShadow ()
786 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createCommandStackShadow";
791 void MainWindow::createHelpWindow ()
793 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createHelpWindow";
796 m_helpWindow->hide ();
797 addDockWidget (Qt::RightDockWidgetArea,
799 m_helpWindow->setFloating (
true);
801 connect (m_actionHelpHelp, SIGNAL (triggered ()), m_helpWindow, SLOT (show ()));
804 void MainWindow::createIcons()
806 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createIcons";
809 QPixmap icon16 (bannerapp_16);
810 QPixmap icon32 (bannerapp_32);
811 QPixmap icon64 (bannerapp_64);
812 QPixmap icon128 (bannerapp_128);
813 QPixmap icon256 (bannerapp_256);
815 icon.addPixmap (icon16);
816 icon.addPixmap (icon32);
817 icon.addPixmap (icon64);
818 icon.addPixmap (icon128);
819 icon.addPixmap (icon256);
821 setWindowIcon (icon);
824 void MainWindow::createLoadImageFromUrl ()
829 void MainWindow::createMenus()
831 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createMenus";
833 m_menuFile = menuBar()->addMenu(tr(
"&File"));
834 m_menuFile->addAction (m_actionImport);
835 m_menuFile->addAction (m_actionOpen);
836 m_menuFileOpenRecent =
new QMenu (tr (
"Open &Recent"));
837 for (
unsigned int i = 0; i < MAX_RECENT_FILE_LIST_SIZE; i++) {
838 m_menuFileOpenRecent->addAction (m_actionRecentFiles.at (i));
840 m_menuFile->addMenu (m_menuFileOpenRecent);
841 m_menuFile->addAction (m_actionClose);
842 m_menuFile->insertSeparator (m_actionSave);
843 m_menuFile->addAction (m_actionSave);
844 m_menuFile->addAction (m_actionSaveAs);
845 m_menuFile->addAction (m_actionExport);
846 m_menuFile->insertSeparator (m_actionPrint);
847 m_menuFile->addAction (m_actionPrint);
848 m_menuFile->insertSeparator (m_actionExit);
849 m_menuFile->addAction (m_actionExit);
851 m_menuEdit = menuBar()->addMenu(tr(
"&Edit"));
852 m_menuEdit->addAction (m_actionEditUndo);
853 m_menuEdit->addAction (m_actionEditRedo);
854 m_menuEdit->insertSeparator (m_actionEditCut);
855 m_menuEdit->addAction (m_actionEditCut);
856 m_menuEdit->addAction (m_actionEditCopy);
857 m_menuEdit->addAction (m_actionEditPaste);
858 m_menuEdit->addAction (m_actionEditDelete);
860 m_menuDigitize = menuBar()->addMenu(tr(
"Digitize"));
861 m_menuDigitize->addAction (m_actionDigitizeSelect);
862 m_menuDigitize->addAction (m_actionDigitizeAxis);
863 m_menuDigitize->addAction (m_actionDigitizeCurve);
864 m_menuDigitize->addAction (m_actionDigitizePointMatch);
865 m_menuDigitize->addAction (m_actionDigitizeColorPicker);
866 m_menuDigitize->addAction (m_actionDigitizeSegment);
868 m_menuView = menuBar()->addMenu(tr(
"View"));
869 m_menuView->addAction (m_actionViewBackground);
870 m_menuView->addAction (m_actionViewDigitize);
871 m_menuView->addAction (m_actionViewChecklistGuide);
872 m_menuView->addAction (m_actionViewSettingsViews);
873 m_menuView->insertSeparator (m_actionViewToolTips);
874 m_menuView->addAction (m_actionViewToolTips);
875 m_menuView->insertSeparator (m_actionViewBackgroundNone);
876 m_menuViewBackground =
new QMenu (tr (
"Background"));
877 m_menuViewBackground->addAction (m_actionViewBackgroundNone);
878 m_menuViewBackground->addAction (m_actionViewBackgroundOriginal);
879 m_menuViewBackground->addAction (m_actionViewBackgroundFiltered);
880 m_menuView->addMenu (m_menuViewBackground);
881 m_menuViewCurves =
new QMenu (tr (
"Curves"));
882 m_menuViewCurves->addAction (m_actionViewCurvesNone);
883 m_menuViewCurves->addAction (m_actionViewCurvesSelected);
884 m_menuViewCurves->addAction (m_actionViewCurvesAll);
885 m_menuView->addMenu (m_menuViewCurves);
886 m_menuViewStatus =
new QMenu (tr (
"Status Bar"));
887 m_menuViewStatus->addAction (m_actionStatusNever);
888 m_menuViewStatus->addAction (m_actionStatusTemporary);
889 m_menuViewStatus->addAction (m_actionStatusAlways);
890 m_menuView->addMenu (m_menuViewStatus);
891 m_menuViewZoom =
new QMenu (tr (
"Zoom"));
892 m_menuViewZoom->addAction (m_actionZoomOut);
893 m_menuViewZoom->addAction (m_actionZoomIn);
894 m_menuViewZoom->insertSeparator (m_actionZoom16To1);
895 m_menuViewZoom->addAction (m_actionZoom16To1);
896 m_menuViewZoom->addAction (m_actionZoom8To1);
897 m_menuViewZoom->addAction (m_actionZoom4To1);
898 m_menuViewZoom->addAction (m_actionZoom2To1);
899 m_menuViewZoom->addAction (m_actionZoom1To1);
900 m_menuViewZoom->addAction (m_actionZoom1To2);
901 m_menuViewZoom->addAction (m_actionZoom1To4);
902 m_menuViewZoom->addAction (m_actionZoom1To8);
903 m_menuViewZoom->addAction (m_actionZoom1To16);
904 m_menuViewZoom->addAction (m_actionZoomFill);
905 m_menuView->addMenu (m_menuViewZoom);
907 m_menuSettings = menuBar()->addMenu(tr (
"Settings"));
908 m_menuSettings->addAction (m_actionSettingsCoords);
909 m_menuSettings->addAction (m_actionSettingsCurveAddRemove);
910 m_menuSettings->addAction (m_actionSettingsCurveProperties);
911 m_menuSettings->addAction (m_actionSettingsDigitizeCurve);
912 m_menuSettings->addAction (m_actionSettingsExport);
913 m_menuSettings->addAction (m_actionSettingsColorFilter);
914 m_menuSettings->addAction (m_actionSettingsAxesChecker);
915 m_menuSettings->addAction (m_actionSettingsGridRemoval);
916 m_menuSettings->addAction (m_actionSettingsPointMatch);
917 m_menuSettings->addAction (m_actionSettingsSegments);
918 m_menuSettings->insertSeparator (m_actionSettingsGeneral);
919 m_menuSettings->addAction (m_actionSettingsGeneral);
920 m_menuSettings->addAction (m_actionSettingsMainWindow);
922 m_menuHelp = menuBar()->addMenu(tr(
"&Help"));
923 m_menuHelp->addAction (m_actionHelpChecklistGuideWizard);
924 m_menuHelp->insertSeparator(m_actionHelpWhatsThis);
925 m_menuHelp->addAction (m_actionHelpWhatsThis);
926 m_menuHelp->addAction (m_actionHelpTutorial);
927 m_menuHelp->addAction (m_actionHelpHelp);
928 m_menuHelp->addAction (m_actionHelpAbout);
930 updateRecentFileList();
933 void MainWindow::createNetwork ()
935 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createNetwork";
940 void MainWindow::createSettingsDialogs ()
942 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createSettingsDialogs";
957 m_dlgSettingsCoords->setVisible (
false);
958 m_dlgSettingsCurveAddRemove->setVisible (
false);
959 m_dlgSettingsCurveProperties->setVisible (
false);
960 m_dlgSettingsDigitizeCurve->setVisible (
false);
961 m_dlgSettingsExportFormat->setVisible (
false);
962 m_dlgSettingsColorFilter->setVisible (
false);
963 m_dlgSettingsAxesChecker->setVisible (
false);
964 m_dlgSettingsGridRemoval->setVisible (
false);
965 m_dlgSettingsPointMatch->setVisible (
false);
966 m_dlgSettingsSegments->setVisible (
false);
967 m_dlgSettingsGeneral->setVisible (
false);
968 m_dlgSettingsMainWindow->setVisible (
false);
971 void MainWindow::createScene ()
973 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createScene";
977 m_layout->addWidget (m_view);
980 void MainWindow::createStateContextBackground ()
982 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createStateContextBackground";
987 void MainWindow::createStateContextDigitize ()
989 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createStateContextDigitize";
996 void MainWindow::createStateContextTransformation ()
998 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createStateContextTransformation";
1000 ENGAUGE_CHECK_PTR (m_scene);
1006 void MainWindow::createStatusBar ()
1008 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createStatusBar";
1010 m_statusBar =
new StatusBar (*statusBar ());
1011 connect (
this, SIGNAL (
signalZoom(
int)), m_statusBar, SLOT (slotZoom(
int)));
1012 connect (m_statusBar, SIGNAL (
signalZoom (
int)),
this, SLOT (slotViewZoom (
int)));
1015 void MainWindow::createToolBars ()
1017 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createToolBars";
1019 const int VIEW_SIZE = 22;
1022 m_cmbBackground =
new QComboBox ();
1023 m_cmbBackground->setEnabled (
false);
1024 m_cmbBackground->setStatusTip (tr (
"Select background image"));
1025 m_cmbBackground->setWhatsThis (tr (
"Selected Background\n\n"
1026 "Select background image:\n"
1027 "1) No background which highlights points\n"
1028 "2) Original image which shows everything\n"
1029 "3) Filtered image which highlights important details"));
1030 m_cmbBackground->addItem (
"No background", QVariant (BACKGROUND_IMAGE_NONE));
1031 m_cmbBackground->addItem (
"Original image", QVariant (BACKGROUND_IMAGE_ORIGINAL));
1032 m_cmbBackground->addItem (
"Filtered image", QVariant (BACKGROUND_IMAGE_FILTERED));
1034 connect (m_cmbBackground, SIGNAL (currentIndexChanged (
int)),
this, SLOT (slotCmbBackground (
int)));
1037 m_toolBackground =
new QToolBar (tr (
"Background"),
this);
1038 m_toolBackground->addWidget (m_cmbBackground);
1039 addToolBar (m_toolBackground);
1042 m_cmbCurve =
new QComboBox ();
1043 m_cmbCurve->setEnabled (
false);
1044 m_cmbCurve->setMinimumWidth (180);
1045 m_cmbCurve->setStatusTip (tr (
"Select curve for new points."));
1046 m_cmbCurve->setWhatsThis (tr (
"Selected Curve Name\n\n"
1047 "Select curve for any new points. Every point belongs to one curve."));
1048 connect (m_cmbCurve, SIGNAL (activated (
int)),
this, SLOT (slotCmbCurve (
int)));
1051 m_toolDigitize =
new QToolBar (tr (
"Drawing"),
this);
1052 m_toolDigitize->addAction (m_actionDigitizeSelect);
1053 m_toolDigitize->insertSeparator (m_actionDigitizeAxis);
1054 m_toolDigitize->addAction (m_actionDigitizeAxis);
1055 m_toolDigitize->insertSeparator (m_actionDigitizeCurve);
1056 m_toolDigitize->addAction (m_actionDigitizeCurve);
1057 m_toolDigitize->addAction (m_actionDigitizePointMatch);
1058 m_toolDigitize->addAction (m_actionDigitizeColorPicker);
1059 m_toolDigitize->addAction (m_actionDigitizeSegment);
1060 m_toolDigitize->addWidget (m_cmbCurve);
1061 addToolBar (m_toolDigitize);
1065 m_viewPointStyle->setMinimumSize(VIEW_SIZE, VIEW_SIZE);
1066 m_viewPointStyle->setMaximumSize(VIEW_SIZE, VIEW_SIZE);
1067 m_viewPointStyle->setStatusTip (tr (
"Points style for the currently selected curve"));
1068 m_viewPointStyle->setWhatsThis (tr (
"Points Style\n\n"
1069 "Points style for the currently selected curve. The points style is only "
1070 "displayed in this toolbar. To change the points style, "
1071 "use the Curve Properties dialog."));
1074 m_viewSegmentFilter->setMinimumSize(VIEW_SIZE, VIEW_SIZE);
1075 m_viewSegmentFilter->setMaximumSize(VIEW_SIZE, VIEW_SIZE);
1076 m_viewSegmentFilter->setStatusTip (tr (
"View of filter for current curve in Segment Fill mode"));
1077 m_viewSegmentFilter->setWhatsThis (tr (
"Segment Fill Filter\n\n"
1078 "View of filter for the current curve in Segment Fill mode. The filter settings are only "
1079 "displayed in this toolbar. To changed the filter settings, "
1080 "use the Color Picker mode or the Filter Settings dialog."));
1083 m_toolSettingsViews =
new QToolBar (tr (
"Views"),
this);
1084 m_toolSettingsViews->addWidget (m_viewPointStyle);
1085 m_toolSettingsViews->addWidget (
new QLabel (
" "));
1086 m_toolSettingsViews->addWidget (m_viewSegmentFilter);
1087 addToolBar (m_toolSettingsViews);
1091 connect (m_dockChecklistGuide, SIGNAL (signalChecklistClosed()),
this, SLOT (slotChecklistClosed()));
1094 void MainWindow::createTutorial ()
1096 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::createTutorial";
1099 m_tutorialDlg->setModal (
true);
1100 m_tutorialDlg->setMinimumSize (500, 400);
1101 m_tutorialDlg->hide();
1104 ZoomFactor MainWindow::currentZoomFactor ()
const
1106 if (m_actionZoom1To1->isChecked()) {
1108 }
else if (m_actionZoom1To2->isChecked()) {
1110 }
else if (m_actionZoom1To4->isChecked()) {
1112 }
else if (m_actionZoom1To8->isChecked()) {
1114 }
else if (m_actionZoom1To16->isChecked()) {
1115 return ZOOM_1_TO_16;
1116 }
else if (m_actionZoom2To1->isChecked()) {
1118 }
else if (m_actionZoom4To1->isChecked()) {
1120 }
else if (m_actionZoom8To1->isChecked()) {
1122 }
else if (m_actionZoom16To1->isChecked()) {
1123 return ZOOM_16_TO_1;
1124 }
else if (m_actionZoomFill->isChecked()) {
1127 ENGAUGE_ASSERT (
false);
1133 if (event->type () == QEvent::KeyPress) {
1135 QKeyEvent *eventKeyPress = (QKeyEvent *) event;
1137 if ((eventKeyPress->key() == Qt::Key_E) &&
1138 ((eventKeyPress->modifiers() & Qt::ShiftModifier) != 0) &&
1139 ((eventKeyPress->modifiers() & Qt::ControlModifier) != 0)) {
1148 return QObject::eventFilter (target, event);
1151 void MainWindow::fileImport (
const QString &fileName)
1153 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::fileImport"
1154 <<
" fileName=" << fileName.toLatin1 ().data ()
1155 <<
" curDir=" << QDir::currentPath().toLatin1().data();
1157 QString originalFileOld = m_originalFile;
1158 bool originalFileWasImported = m_originalFileWasImported;
1160 m_originalFile = fileName;
1161 m_originalFileWasImported =
true;
1164 bool loaded =
false;
1165 #ifdef ENGAUGE_JPEG2000
1167 loaded = jpeg2000.
load (fileName,
1169 #endif // ENGAUGE_JPEG2000
1171 loaded = image.load (fileName);
1175 QMessageBox::warning (
this,
1176 engaugeWindowTitle(),
1177 tr(
"Cannot read file %1.").
1181 m_originalFile = originalFileOld;
1182 m_originalFileWasImported = originalFileWasImported;
1187 loadImage (fileName,
1201 void MainWindow::loadCurveListFromCmdMediator ()
1203 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::loadCurveListFromCmdMediator";
1205 m_cmbCurve->clear ();
1207 QStringList::iterator itr;
1208 for (itr = curvesGraphsNames.begin (); itr != curvesGraphsNames.end (); itr++) {
1210 QString curvesGraphName = *itr;
1211 m_cmbCurve->addItem (curvesGraphName);
1215 m_cmbCurve->setCurrentIndex (0);
1218 void MainWindow::loadDocumentFile (
const QString &fileName)
1220 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::loadDocumentFile fileName=" << fileName.toLatin1 ().data ();
1222 QApplication::setOverrideCursor(Qt::WaitCursor);
1225 QApplication::restoreOverrideCursor();
1229 setCurrentPathFromFile (fileName);
1230 rebuildRecentFileListForCurrentFile(fileName);
1231 m_currentFile = fileName;
1233 if (m_cmdMediator != 0) {
1234 delete m_cmdMediator;
1239 setupAfterLoad(fileName,
1243 m_actionDigitizeSelect->setChecked (
true);
1244 slotDigitizeSelect();
1246 m_engaugeFile = fileName;
1247 m_originalFile = fileName;
1248 m_originalFileWasImported =
false;
1254 QMessageBox::warning (
this,
1255 engaugeWindowTitle(),
1256 tr(
"Cannot read file %1:\n%2.").
1264 void MainWindow::loadErrorReportFile(
const QString &initialPath,
1265 const QString &errorReportFile)
1267 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::loadErrorReportFile"
1268 <<
" path=" << initialPath.toLatin1().data()
1269 <<
" file=" << errorReportFile.toLatin1().data();
1275 QString originalPath = QDir::currentPath();
1276 QDir::setCurrent(initialPath);
1278 QFile file (errorReportFile);
1279 if (!file.exists()) {
1281 QFileInfo fileInfo (errorReportFile);
1283 QMessageBox::critical (
this,
1284 engaugeWindowTitle(),
1285 tr (
"File not found: ") + fileInfo.absoluteFilePath());
1290 QXmlStreamReader reader (&file);
1291 file.open(QIODevice::ReadOnly | QIODevice::Text);
1302 QDir::setCurrent(originalPath);
1304 setupAfterLoad(errorReportFile,
1305 "Error report opened");
1308 m_actionDigitizeSelect->setChecked (
true);
1309 slotDigitizeSelect();
1314 void MainWindow::loadImage (
const QString &fileName,
1315 const QImage &image)
1317 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::loadImage fileName=" << fileName.toLatin1 ().data ();
1319 QApplication::setOverrideCursor(Qt::WaitCursor);
1322 QApplication::restoreOverrideCursor();
1324 setCurrentPathFromFile (fileName);
1326 m_engaugeFile = EMPTY_FILENAME;
1328 if (m_cmdMediator != 0) {
1329 delete m_cmdMediator;
1334 setupAfterLoad(fileName,
1337 if (m_actionHelpChecklistGuideWizard->isChecked ()) {
1341 if (wizard->exec() == QDialog::Accepted) {
1348 m_actionViewChecklistGuide->setChecked (
true);
1356 loadCurveListFromCmdMediator();
1362 m_actionDigitizeAxis->setChecked (
true);
1363 slotDigitizeAxis ();
1368 void MainWindow::loadInputFileForErrorReport(QDomDocument &domInputFile)
const
1370 QFile file (m_originalFile);
1374 if (!file.open (QIODevice::ReadOnly)) {
1378 domInputFile.setContent (&file);
1382 void MainWindow::loadToolTips()
1384 if (m_actionViewToolTips->isChecked ()) {
1387 m_actionDigitizeSelect->setToolTip (DIGITIZE_ACTION_SELECT);
1388 m_actionDigitizeAxis->setToolTip (DIGITIZE_ACTION_AXIS_POINT);
1389 m_actionDigitizeCurve->setToolTip (DIGITIZE_ACTION_CURVE_POINT);
1390 m_actionDigitizePointMatch->setToolTip (DIGITIZE_ACTION_POINT_MATCH);
1391 m_actionDigitizeColorPicker->setToolTip (DIGITIZE_ACTION_COLOR_PICKER);
1392 m_actionDigitizeSegment->setToolTip (DIGITIZE_ACTION_SEGMENT_POINTS);
1393 m_cmbBackground->setToolTip (tr (
"Background image."));
1394 m_cmbCurve->setToolTip (tr (
"Currently selected curve."));
1395 m_viewPointStyle->setToolTip (tr (
"Point style for currently selected curve."));
1396 m_viewSegmentFilter->setToolTip (tr (
"Segment Fill filter for currently selected curve."));
1401 m_actionDigitizeSelect->setToolTip (
"");
1402 m_actionDigitizeAxis->setToolTip (
"");
1403 m_actionDigitizeCurve->setToolTip (
"");
1404 m_actionDigitizePointMatch->setToolTip (
"");
1405 m_actionDigitizeColorPicker->setToolTip (
"");
1406 m_actionDigitizeSegment->setToolTip (
"");
1407 m_cmbBackground->setToolTip (
"");
1408 m_cmbCurve->setToolTip (
"");
1409 m_viewPointStyle->setToolTip (
"");
1410 m_viewSegmentFilter->setToolTip (
"");
1415 bool MainWindow::maybeSave()
1417 if (m_cmdMediator != 0) {
1419 QMessageBox::StandardButton ret = QMessageBox::warning (
this,
1420 engaugeWindowTitle(),
1421 tr(
"The document has been modified.\n"
1422 "Do you want to save your changes?"),
1423 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
1424 if (ret == QMessageBox::Save) {
1425 return slotFileSave();
1426 }
else if (ret == QMessageBox::Cancel) {
1437 const QString &fileName)
const
1442 QString csvExtension = QString (
".%1")
1444 QString tsvExtension = QString (
".%1")
1446 QString fileExtensionVersusCsv = fileName.right (csvExtension.size());
1447 QString fileExtensionVersusTsv = fileName.right (tsvExtension.size());
1451 if (csvExtension.compare (fileExtensionVersusCsv, Qt::CaseInsensitive) == 0) {
1452 modelExportFormatAfter.
setDelimiter (EXPORT_DELIMITER_COMMA);
1453 }
else if (tsvExtension.compare (fileExtensionVersusTsv, Qt::CaseInsensitive) == 0) {
1454 modelExportFormatAfter.
setDelimiter (EXPORT_DELIMITER_TAB);
1457 return modelExportFormatAfter;
1462 return m_modelMainWindow;
1465 void MainWindow::rebuildRecentFileListForCurrentFile(
const QString &filePath)
1467 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::rebuildRecentFileListForCurrentFile";
1469 setWindowFilePath (filePath);
1471 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
1472 QStringList recentFilePaths = settings.value (SETTINGS_RECENT_FILE_LIST).toStringList();
1473 recentFilePaths.removeAll (filePath);
1474 recentFilePaths.prepend (filePath);
1475 while (recentFilePaths.count () > (int) MAX_RECENT_FILE_LIST_SIZE) {
1476 recentFilePaths.removeLast ();
1478 settings.setValue (SETTINGS_RECENT_FILE_LIST, recentFilePaths);
1480 updateRecentFileList();
1485 LOG4CPP_DEBUG_S ((*mainCat)) <<
"MainWindow::resizeEvent";
1487 if (m_actionZoomFill->isChecked ()) {
1492 bool MainWindow::saveDocumentFile (
const QString &fileName)
1494 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::saveDocumentFile fileName=" << fileName.toLatin1 ().data ();
1496 QFile file(fileName);
1497 if (!file.open(QFile::WriteOnly)) {
1498 QMessageBox::warning (
this,
1499 engaugeWindowTitle(),
1500 tr (
"Cannot write file %1: \n%2.").
1502 arg(file.errorString()));
1506 rebuildRecentFileListForCurrentFile (fileName);
1508 QApplication::setOverrideCursor (Qt::WaitCursor);
1509 QXmlStreamWriter writer(&file);
1510 writer.setAutoFormatting(
true);
1511 writer.writeStartDocument();
1512 writer.writeDTD(
"<!DOCTYPE engauge>");
1514 writer.writeEndDocument();
1515 QApplication::restoreOverrideCursor ();
1519 m_cmdMediator->setClean ();
1521 setCurrentFile(fileName);
1522 m_engaugeFile = fileName;
1532 const char *comment)
const
1534 if (m_cmdMediator != 0) {
1536 QString reportWithoutDocument = saveErrorReportFileAndExitXml (context,
1541 QString reportWithDocument = saveErrorReportFileAndExitXml (context,
1547 reportWithDocument);
1550 if (dlg.exec() == QDialog::Accepted) {
1558 QString MainWindow::saveErrorReportFileAndExitXml (
const char *context,
1561 const char *comment,
1562 bool includeDocument)
const
1564 const bool DEEP_COPY =
true;
1566 QString xmlErrorReport;
1567 QXmlStreamWriter writer (&xmlErrorReport);
1568 writer.setAutoFormatting(
true);
1571 writer.writeStartElement(DOCUMENT_SERIALIZE_ERROR_REPORT);
1574 writer.writeStartElement(DOCUMENT_SERIALIZE_APPLICATION);
1575 writer.writeAttribute(DOCUMENT_SERIALIZE_APPLICATION_VERSION_NUMBER, VERSION_NUMBER);
1576 writer.writeEndElement();
1579 if (includeDocument) {
1581 QXmlStreamReader reader (m_startingDocumentSnapshot);
1582 while (!reader.atEnd ()) {
1584 if (reader.tokenType() != QXmlStreamReader::StartDocument &&
1585 reader.tokenType() != QXmlStreamReader::EndDocument) {
1586 writer.writeCurrentToken (reader);
1592 writer.writeStartElement(DOCUMENT_SERIALIZE_OPERATING_SYSTEM);
1593 writer.writeAttribute(DOCUMENT_SERIALIZE_OPERATING_SYSTEM_ENDIAN, EndianToString (QSysInfo::ByteOrder));
1594 writer.writeAttribute(DOCUMENT_SERIALIZE_OPERATING_SYSTEM_WORD_SIZE, QString::number (QSysInfo::WordSize));
1595 writer.writeEndElement();
1598 writer.writeStartElement(DOCUMENT_SERIALIZE_IMAGE);
1599 writer.writeAttribute(DOCUMENT_SERIALIZE_IMAGE_WIDTH, QString::number (m_cmdMediator->
pixmap().width ()));
1600 writer.writeAttribute(DOCUMENT_SERIALIZE_IMAGE_HEIGHT, QString::number (m_cmdMediator->
pixmap().height ()));
1601 writer.writeEndElement();
1604 writer.writeStartElement(DOCUMENT_SERIALIZE_FILE);
1605 writer.writeAttribute(DOCUMENT_SERIALIZE_FILE_IMPORTED,
1606 m_originalFileWasImported ? DOCUMENT_SERIALIZE_BOOL_TRUE : DOCUMENT_SERIALIZE_BOOL_FALSE);
1607 writer.writeEndElement();
1610 m_cmdMediator->
saveXml(writer);
1613 writer.writeStartElement(DOCUMENT_SERIALIZE_ERROR);
1614 writer.writeAttribute(DOCUMENT_SERIALIZE_ERROR_CONTEXT, context);
1615 writer.writeAttribute(DOCUMENT_SERIALIZE_ERROR_FILE, file);
1616 writer.writeAttribute(DOCUMENT_SERIALIZE_ERROR_LINE, QString::number (line));
1617 writer.writeAttribute(DOCUMENT_SERIALIZE_ERROR_COMMENT, comment);
1618 writer.writeEndElement();
1620 writer.writeEndElement();
1623 QDomDocument domErrorReport (
"ErrorReport");
1624 domErrorReport.setContent (xmlErrorReport);
1627 if (!m_originalFileWasImported) {
1631 QDomDocument domInputFile;
1632 loadInputFileForErrorReport (domInputFile);
1633 QDomDocumentFragment fragmentFileFrom = domErrorReport.createDocumentFragment();
1634 if (!domInputFile.isNull()) {
1635 fragmentFileFrom.appendChild (domErrorReport.importNode (domInputFile.documentElement(), DEEP_COPY));
1637 QDomNodeList nodesFileTo = domErrorReport.elementsByTagName (DOCUMENT_SERIALIZE_FILE);
1638 if (nodesFileTo.count () > 0) {
1639 QDomNode nodeFileTo = nodesFileTo.at (0);
1640 nodeFileTo.appendChild (fragmentFileFrom);
1647 QDomNodeList nodesDocument = domErrorReport.elementsByTagName (DOCUMENT_SERIALIZE_DOCUMENT);
1648 for (
int i = 0 ; i < nodesDocument.count(); i++) {
1649 QDomNode nodeDocument = nodesDocument.at (i);
1650 QDomElement elemImage = nodeDocument.firstChildElement(DOCUMENT_SERIALIZE_IMAGE);
1651 if (!elemImage.isNull()) {
1654 if (elemImage.hasAttribute (DOCUMENT_SERIALIZE_IMAGE_WIDTH) &&
1655 elemImage.hasAttribute (DOCUMENT_SERIALIZE_IMAGE_HEIGHT)) {
1657 int width = elemImage.attribute(DOCUMENT_SERIALIZE_IMAGE_WIDTH).toInt();
1658 int height = elemImage.attribute(DOCUMENT_SERIALIZE_IMAGE_HEIGHT).toInt();
1660 QDomNode nodeReplacement;
1661 QDomElement elemReplacement = nodeReplacement.toElement();
1662 elemReplacement.setAttribute (DOCUMENT_SERIALIZE_IMAGE_WIDTH, width);
1663 elemReplacement.setAttribute (DOCUMENT_SERIALIZE_IMAGE_HEIGHT, height);
1666 nodeDocument.insertBefore (nodeReplacement,
1668 nodeDocument.removeChild(elemImage);
1674 return domErrorReport.toString();
1677 void MainWindow::saveStartingDocumentSnapshot()
1679 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::saveStartingDocumentSnapshot";
1681 QXmlStreamWriter writer (&m_startingDocumentSnapshot);
1682 writer.setAutoFormatting (
true);
1688 ENGAUGE_CHECK_PTR (m_scene);
1694 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::selectBackgroundOriginal";
1696 BackgroundImage previousBackground = (BackgroundImage) m_cmbBackground->currentData().toInt();
1698 int index = m_cmbBackground->findData (backgroundImage);
1699 ENGAUGE_ASSERT (index >= 0);
1701 m_cmbBackground->setCurrentIndex(index);
1703 return previousBackground;
1708 return m_cmbCurve->currentText ();
1711 void MainWindow::setCurrentFile (
const QString &fileName)
1713 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::setCurrentFile";
1715 const QString PLACEHOLDER (
"[*]");
1717 QString title = QString (tr (
"Engauge Digitizer %1")
1718 .arg (VERSION_NUMBER));
1720 QString fileNameStripped = fileName;
1721 if (!fileName.isEmpty()) {
1724 QFileInfo fileInfo (fileName);
1725 fileNameStripped = fileInfo.baseName();
1727 title += QString (
": %1")
1728 .arg (fileNameStripped);
1731 m_currentFile = fileNameStripped;
1735 title += PLACEHOLDER;
1737 setWindowTitle (title);
1740 void MainWindow::setCurrentPathFromFile (
const QString &fileName)
1742 QDir dir = QFileInfo (fileName).absoluteDir();
1744 if (dir.exists ()) {
1746 bool success = QDir::setCurrent (dir.absolutePath ());
1747 ENGAUGE_ASSERT (success);
1755 void MainWindow::setPixmap (
const QPixmap &pixmap)
1757 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::setPixmap";
1760 m_backgroundStateContext->
setPixmap (m_transformation,
1766 void MainWindow::settingsRead ()
1768 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
1770 settingsReadEnvironment (settings);
1771 settingsReadMainWindow (settings);
1774 void MainWindow::settingsReadEnvironment (QSettings &settings)
1776 settings.beginGroup (SETTINGS_GROUP_ENVIRONMENT);
1777 QDir::setCurrent (settings.value (SETTINGS_CURRENT_DIRECTORY,
1778 QDir::currentPath ()).toString ());
1779 settings.endGroup ();
1782 void MainWindow::settingsReadMainWindow (QSettings &settings)
1784 settings.beginGroup(SETTINGS_GROUP_MAIN_WINDOW);
1787 resize (settings.value (SETTINGS_SIZE,
1788 QSize (400, 400)).toSize ());
1789 move (settings.value (SETTINGS_POS,
1790 QPoint (200, 200)).toPoint ());
1793 QSize helpSize = settings.value (SETTINGS_HELP_SIZE,
1794 QSize (900, 600)).toSize();
1795 m_helpWindow->resize (helpSize);
1796 if (settings.contains (SETTINGS_HELP_POS)) {
1797 QPoint helpPos = settings.value (SETTINGS_HELP_POS).toPoint();
1798 m_helpWindow->move (helpPos);
1802 m_actionHelpChecklistGuideWizard->setChecked (settings.value (SETTINGS_CHECKLIST_GUIDE_WIZARD,
1806 bool viewBackgroundToolBar = settings.value (SETTINGS_VIEW_BACKGROUND_TOOLBAR,
1808 m_actionViewBackground->setChecked (viewBackgroundToolBar);
1809 m_toolBackground->setVisible (viewBackgroundToolBar);
1810 BackgroundImage backgroundImage = (BackgroundImage) settings.value (SETTINGS_BACKGROUND_IMAGE,
1811 BACKGROUND_IMAGE_FILTERED).toInt ();
1812 int indexBackground = m_cmbBackground->findData (QVariant (backgroundImage));
1813 m_cmbBackground->setCurrentIndex (indexBackground);
1816 bool viewDigitizeToolBar = settings.value (SETTINGS_VIEW_DIGITIZE_TOOLBAR,
1818 m_actionViewDigitize->setChecked (viewDigitizeToolBar);
1819 m_toolDigitize->setVisible (viewDigitizeToolBar);
1822 bool viewSettingsViewsToolBar = settings.value (SETTINGS_VIEW_SETTINGS_VIEWS_TOOLBAR,
1824 m_actionViewSettingsViews->setChecked (viewSettingsViewsToolBar);
1825 m_toolSettingsViews->setVisible (viewSettingsViewsToolBar);
1828 bool viewToolTips = settings.value (SETTINGS_VIEW_TOOL_TIPS,
1830 m_actionViewToolTips->setChecked (viewToolTips);
1834 StatusBarMode statusBarMode = (StatusBarMode) settings.value (SETTINGS_VIEW_STATUS_BAR,
1837 m_actionStatusNever->setChecked (statusBarMode == STATUS_BAR_MODE_NEVER);
1838 m_actionStatusTemporary->setChecked (statusBarMode == STATUS_BAR_MODE_TEMPORARY);
1839 m_actionStatusAlways->setChecked (statusBarMode == STATUS_BAR_MODE_ALWAYS);
1842 Qt::DockWidgetArea area = (Qt::DockWidgetArea) settings.value (SETTINGS_CHECKLIST_GUIDE_DOCK_AREA,
1843 Qt::NoDockWidgetArea).toInt();
1845 if (area == Qt::NoDockWidgetArea) {
1847 addDockWidget (Qt::RightDockWidgetArea,
1848 m_dockChecklistGuide);
1849 m_dockChecklistGuide->setFloating(
true);
1850 if (settings.contains (SETTINGS_CHECKLIST_GUIDE_DOCK_GEOMETRY)) {
1851 m_dockChecklistGuide->restoreGeometry (settings.value (SETTINGS_CHECKLIST_GUIDE_DOCK_GEOMETRY).toByteArray());
1856 addDockWidget (area,
1857 m_dockChecklistGuide);
1863 QLocale localeDefault;
1864 QLocale::Language language = (QLocale::Language) settings.value (SETTINGS_LOCALE_LANGUAGE,
1865 QVariant (localeDefault.language())).toInt();
1866 QLocale::Country country = (QLocale::Country) settings.value (SETTINGS_LOCALE_COUNTRY,
1867 QVariant (localeDefault.country())).toInt();
1868 QLocale locale (language,
1870 slotViewZoom ((ZoomFactor) settings.value (SETTINGS_ZOOM_FACTOR,
1871 QVariant (ZOOM_1_TO_1)).toInt());
1874 m_modelMainWindow.
setZoomFactorInitial((ZoomFactorInitial) settings.value (SETTINGS_ZOOM_FACTOR_INITIAL,
1875 QVariant (DEFAULT_ZOOM_FACTOR_INITIAL)).toInt());
1876 m_modelMainWindow.
setZoomControl ((ZoomControl) settings.value (SETTINGS_ZOOM_CONTROL,
1877 QVariant (ZOOM_CONTROL_MENU_WHEEL_PLUSMINUS)).toInt());
1880 settings.endGroup();
1883 void MainWindow::settingsWrite ()
1885 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
1887 settings.beginGroup (SETTINGS_GROUP_ENVIRONMENT);
1888 settings.setValue (SETTINGS_CURRENT_DIRECTORY, QDir::currentPath ());
1889 settings.endGroup ();
1891 settings.beginGroup (SETTINGS_GROUP_MAIN_WINDOW);
1892 settings.setValue (SETTINGS_SIZE, size ());
1893 settings.setValue (SETTINGS_POS, pos ());
1894 settings.setValue (SETTINGS_HELP_SIZE, m_helpWindow->size());
1895 settings.setValue (SETTINGS_HELP_POS, m_helpWindow->pos ());
1896 if (m_dockChecklistGuide->isFloating()) {
1898 settings.setValue (SETTINGS_CHECKLIST_GUIDE_DOCK_AREA, Qt::NoDockWidgetArea);
1899 settings.setValue (SETTINGS_CHECKLIST_GUIDE_DOCK_GEOMETRY, m_dockChecklistGuide->saveGeometry ());
1903 settings.setValue (SETTINGS_CHECKLIST_GUIDE_DOCK_AREA, dockWidgetArea (m_dockChecklistGuide));
1906 settings.setValue (SETTINGS_CHECKLIST_GUIDE_WIZARD, m_actionHelpChecklistGuideWizard->isChecked ());
1907 settings.setValue (SETTINGS_LOCALE_LANGUAGE, m_modelMainWindow.
locale().language());
1908 settings.setValue (SETTINGS_LOCALE_COUNTRY, m_modelMainWindow.
locale().country());
1909 settings.setValue (SETTINGS_VIEW_BACKGROUND_TOOLBAR, m_actionViewBackground->isChecked());
1910 settings.setValue (SETTINGS_BACKGROUND_IMAGE, m_cmbBackground->currentData().toInt());
1911 settings.setValue (SETTINGS_VIEW_DIGITIZE_TOOLBAR, m_actionViewDigitize->isChecked ());
1912 settings.setValue (SETTINGS_VIEW_STATUS_BAR, m_statusBar->
statusBarMode ());
1913 settings.setValue (SETTINGS_VIEW_SETTINGS_VIEWS_TOOLBAR, m_actionViewSettingsViews->isChecked ());
1914 settings.setValue (SETTINGS_VIEW_TOOL_TIPS, m_actionViewToolTips->isChecked ());
1915 settings.setValue (SETTINGS_ZOOM_CONTROL, m_modelMainWindow.
zoomControl());
1916 settings.setValue (SETTINGS_ZOOM_FACTOR, currentZoomFactor ());
1917 settings.setValue (SETTINGS_ZOOM_FACTOR_INITIAL, m_modelMainWindow.
zoomFactorInitial());
1918 settings.endGroup ();
1921 void MainWindow::setupAfterLoad (
const QString &fileName,
1922 const QString &temporaryMessage)
1924 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::setupAfterLoad"
1925 <<
" file=" << fileName.toLatin1().data()
1926 <<
" message=" << temporaryMessage.toLatin1().data();
1935 connect (m_actionEditUndo, SIGNAL (triggered ()), m_cmdMediator, SLOT (undo ()));
1936 connect (m_actionEditUndo, SIGNAL (triggered ()), m_cmdStackShadow, SLOT (slotUndo ()));
1937 connect (m_actionEditRedo, SIGNAL (triggered ()), m_cmdMediator, SLOT (redo ()));
1938 connect (m_actionEditRedo, SIGNAL (triggered ()), m_cmdStackShadow, SLOT (slotRedo ()));
1939 connect (m_cmdMediator, SIGNAL (canRedoChanged(
bool)),
this, SLOT (slotCanRedoChanged (
bool)));
1940 connect (m_cmdMediator, SIGNAL (canUndoChanged(
bool)),
this, SLOT (slotCanUndoChanged (
bool)));
1941 connect (m_cmdMediator, SIGNAL (redoTextChanged (
const QString &)),
this, SLOT (slotRedoTextChanged (
const QString &)));
1942 connect (m_cmdMediator, SIGNAL (undoTextChanged (
const QString &)),
this, SLOT (slotUndoTextChanged (
const QString &)));
1943 loadCurveListFromCmdMediator ();
1946 m_isDocumentExported =
false;
1951 setPixmap (m_cmdMediator->
pixmap ());
1955 m_cmbCurve->currentText ());
1956 m_backgroundStateContext->
setBackgroundImage ((BackgroundImage) m_cmbBackground->currentIndex ());
1958 applyZoomFactorAfterLoad();
1960 setCurrentFile(fileName);
1964 saveStartingDocumentSnapshot();
1971 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::showEvent"
1972 <<
" files=" << m_loadStartupFiles.join (
",").toLatin1().data();
1974 QMainWindow::showEvent (event);
1976 if (m_loadStartupFiles.count() > 0) {
1978 m_timerLoadStartupFiles =
new QTimer;
1979 m_timerLoadStartupFiles->setSingleShot (
true);
1980 connect (m_timerLoadStartupFiles, SIGNAL (timeout ()),
this, SLOT (slotLoadStartupFiles ()));
1981 m_timerLoadStartupFiles->start (0);
1991 void MainWindow::slotCanRedoChanged (
bool canRedo)
1993 LOG4CPP_DEBUG_S ((*mainCat)) <<
"MainWindow::slotCanRedoChanged";
1995 m_actionEditRedo->setEnabled (canRedo || m_cmdStackShadow->
canRedo());
1998 void MainWindow::slotCanUndoChanged (
bool canUndo)
2000 LOG4CPP_DEBUG_S ((*mainCat)) <<
"MainWindow::slotCanUndoChanged";
2002 m_actionEditUndo->setEnabled (canUndo);
2005 void MainWindow::slotChecklistClosed()
2007 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotChecklistClosed";
2009 m_actionViewChecklistGuide->setChecked (
false);
2012 void MainWindow::slotCleanChanged(
bool clean)
2014 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotCleanChanged";
2016 setWindowModified (!clean);
2019 void MainWindow::slotCmbBackground(
int currentIndex)
2021 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotCmbBackground";
2023 switch (currentIndex) {
2024 case BACKGROUND_IMAGE_NONE:
2025 if (!m_actionViewBackgroundNone->isChecked()) {
2026 m_actionViewBackgroundNone->toggle();
2030 case BACKGROUND_IMAGE_ORIGINAL:
2031 if (!m_actionViewBackgroundOriginal->isChecked ()) {
2032 m_actionViewBackgroundOriginal->toggle();
2036 case BACKGROUND_IMAGE_FILTERED:
2037 if (!m_actionViewBackgroundFiltered->isChecked ()) {
2038 m_actionViewBackgroundFiltered->toggle();
2046 void MainWindow::slotCmbCurve(
int )
2048 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotCmbCurve";
2053 m_cmbCurve->currentText ());
2056 updateViewedCurves();
2060 void MainWindow::slotContextMenuEvent (QString pointIdentifier)
2062 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotContextMenuEvent point=" << pointIdentifier.toLatin1 ().data ();
2067 void MainWindow::slotDigitizeAxis ()
2069 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotDigitizeAxis";
2072 m_cmbCurve->setEnabled (
false);
2077 void MainWindow::slotDigitizeColorPicker ()
2079 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotDigitizeColorPicker";
2082 m_cmbCurve->setEnabled (
true);
2087 void MainWindow::slotDigitizeCurve ()
2089 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotDigitizeCurve";
2092 m_cmbCurve->setEnabled (
true);
2097 void MainWindow::slotDigitizePointMatch ()
2099 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotDigitizePointMatch";
2102 m_cmbCurve->setEnabled (
true);
2107 void MainWindow::slotDigitizeSegment ()
2109 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotDigitizeSegment";
2112 m_cmbCurve->setEnabled (
true);
2117 void MainWindow::slotDigitizeSelect ()
2119 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotDigitizeSelect";
2122 m_cmbCurve->setEnabled (
false);
2127 void MainWindow::slotEditCopy ()
2129 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotEditCopy";
2137 void MainWindow::slotEditCut ()
2139 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotEditCut";
2147 void MainWindow::slotEditDelete ()
2149 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotEditDelete";
2157 void MainWindow::slotEditPaste ()
2159 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotEditPaste";
2162 void MainWindow::slotFileClose()
2164 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileClose";
2183 m_backgroundStateContext->
close ();
2186 m_scene->setSceneRect (QRectF (0, 0, 1, 1));
2189 delete m_cmdMediator;
2198 void MainWindow::slotFileExport ()
2200 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileExport";
2205 QString filter = QString (
"%1;;%2;;All files (*.*)")
2208 QString defaultFileName = QString (
"%1/%2.%3")
2209 .arg (QDir::currentPath ())
2210 .arg (m_currentFile)
2213 QString filterCsv = exportStrategy.
filterCsv ();
2214 QString fileName = dlg.getSaveFileName (
this,
2219 if (!fileName.isEmpty ()) {
2221 QFile file (fileName);
2222 if (file.open(QIODevice::WriteOnly)) {
2224 QTextStream str (&file);
2236 m_isDocumentExported =
true;
2237 m_dockChecklistGuide->
update (*m_cmdMediator,
2238 m_isDocumentExported);
2242 QMessageBox::critical (0,
2243 engaugeWindowTitle(),
2244 tr (
"Unable to export to file ") + fileName);
2253 void MainWindow::slotFileImport ()
2255 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileImport";
2260 QTextStream str (&filter);
2263 QList<QByteArray>::const_iterator itr;
2264 QList<QByteArray> supportedImageFormats = QImageReader::supportedImageFormats();
2265 QStringList supportedImageFormatStrings;
2266 for (itr = supportedImageFormats.begin (); itr != supportedImageFormats.end (); itr++) {
2267 QByteArray arr = *itr;
2268 QString extensionAsWildcard = QString (
"*.%1").arg (QString (arr));
2269 supportedImageFormatStrings << extensionAsWildcard;
2271 #ifdef ENGAUGE_JPEG2000
2274 #endif // ENGAUGE_JPEG2000
2276 supportedImageFormatStrings.sort();
2278 str <<
"Image Files (" << supportedImageFormatStrings.join (
" ") <<
")";
2282 str <<
";; All Files (*.*)";
2284 QString fileName = QFileDialog::getOpenFileName (
this,
2286 QDir::currentPath (),
2288 if (!fileName.isEmpty ()) {
2290 fileImport (fileName);
2296 void MainWindow::slotFileImportDraggedImage(QImage image)
2298 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileImportDraggedImage";
2304 void MainWindow::slotFileImportDraggedImageUrl(QUrl url)
2306 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileImportDraggedImageUrl url=" << url.toString ().toLatin1 ().data ();
2311 void MainWindow::slotFileImportImage(QString fileName, QImage image)
2313 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileImportImage fileName=" << fileName.toLatin1 ().data ();
2315 loadImage (fileName,
2319 void MainWindow::slotFileOpen()
2321 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileOpen";
2327 QString filter = QString (
"%1 (*.%2);; All Files (*.*)")
2328 .arg (ENGAUGE_FILENAME_DESCRIPTION)
2329 .arg (ENGAUGE_FILENAME_EXTENSION);
2331 QString fileName = QFileDialog::getOpenFileName (
this,
2332 tr(
"Open Document"),
2333 QDir::currentPath (),
2335 if (!fileName.isEmpty ()) {
2337 loadDocumentFile (fileName);
2343 void MainWindow::slotFileOpenDraggedDigFile (QString fileName)
2345 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileOpenDraggedDigFile";
2347 loadDocumentFile (fileName);
2350 void MainWindow::slotFilePrint()
2352 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFilePrint";
2354 QPrinter printer (QPrinter::HighResolution);
2355 QPrintDialog dlg (&printer,
this);
2356 if (dlg.exec() == QDialog::Accepted) {
2357 QPainter painter (&printer);
2358 m_view->render (&painter);
2363 bool MainWindow::slotFileSave()
2365 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileSave";
2367 if (m_engaugeFile.isEmpty()) {
2368 return slotFileSaveAs();
2370 return saveDocumentFile (m_engaugeFile);
2374 bool MainWindow::slotFileSaveAs()
2376 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotFileSaveAs";
2379 QString filenameDefault = m_currentFile;
2380 if (!m_currentFile.endsWith (ENGAUGE_FILENAME_EXTENSION)) {
2381 filenameDefault = QString (
"%1.%2")
2382 .arg (m_currentFile)
2383 .arg (ENGAUGE_FILENAME_EXTENSION);
2386 if (!m_engaugeFile.isEmpty()) {
2387 filenameDefault = m_engaugeFile;
2390 QString filterDigitizer = QString (
"%1 (*.%2)")
2391 .arg (ENGAUGE_FILENAME_DESCRIPTION)
2392 .arg (ENGAUGE_FILENAME_EXTENSION);
2393 QString filterAll (
"All files (*. *)");
2395 QStringList filters;
2396 filters << filterDigitizer;
2397 filters << filterAll;
2399 QFileDialog dlg(
this);
2400 dlg.selectNameFilter (filterDigitizer);
2401 dlg.setNameFilters (filters);
2402 dlg.setWindowModality(Qt::WindowModal);
2403 dlg.setAcceptMode(QFileDialog::AcceptSave);
2404 dlg.selectFile(filenameDefault);
2407 QStringList files = dlg.selectedFiles();
2408 return saveDocumentFile(files.at(0));
2414 void MainWindow::slotHelpAbout()
2416 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotHelpAbout";
2422 void MainWindow::slotHelpTutorial()
2424 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotHelpTutorial";
2426 m_tutorialDlg->show ();
2427 m_tutorialDlg->exec ();
2430 void MainWindow::slotKeyPress (Qt::Key key,
2431 bool atLeastOneSelectedItem)
2433 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotKeyPress"
2434 <<
" key=" << QKeySequence (key).toString().toLatin1 ().data ()
2435 <<
" atLeastOneSelectedItem=" << (atLeastOneSelectedItem ?
"true" :
"false");
2438 atLeastOneSelectedItem);
2441 void MainWindow::slotLeave ()
2443 LOG4CPP_DEBUG_S ((*mainCat)) <<
"MainWindow::slotLeave";
2448 void MainWindow::slotLoadStartupFiles ()
2450 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotLoadStartupFiles";
2452 ENGAUGE_ASSERT (m_loadStartupFiles.count() > 0);
2454 QString fileName = m_loadStartupFiles.front();
2455 m_loadStartupFiles.pop_front();
2461 loadDocumentFile (fileName);
2465 fileImport (fileName);
2469 if (m_loadStartupFiles.count() > 0) {
2473 QProcess *process =
new QProcess (
this);
2474 process->startDetached (QCoreApplication::applicationFilePath(),
2475 m_loadStartupFiles);
2479 void MainWindow::slotMouseMove (QPointF pos)
2484 if (m_cmdMediator != 0) {
2487 QString coordsScreen, coordsGraph, resolutionGraph;
2505 void MainWindow::slotMousePress (QPointF pos)
2507 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotMousePress";
2514 void MainWindow::slotMouseRelease (QPointF pos)
2516 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotMouseRelease";
2518 if (pos.x() < 0 || pos.y() < 0) {
2531 void MainWindow::slotRecentFileAction ()
2533 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotRecentFileAction";
2535 QAction *action = qobject_cast<QAction*>(sender ());
2538 QString fileName = action->data().toString();
2539 loadDocumentFile (fileName);
2543 void MainWindow::slotRedoTextChanged (
const QString &text)
2545 LOG4CPP_DEBUG_S ((*mainCat)) <<
"MainWindow::slotRedoTextChanged";
2547 QString completeText (
"Redo");
2548 if (!text.isEmpty ()) {
2549 completeText += QString (
" \"%1\"").arg (text);
2551 m_actionEditRedo->setText (completeText);
2554 void MainWindow::slotSetOverrideCursor (QCursor cursor)
2556 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSetOverrideCursor";
2561 void MainWindow::slotSettingsAxesChecker ()
2563 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsAxesChecker";
2565 m_dlgSettingsAxesChecker->
load (*m_cmdMediator);
2566 m_dlgSettingsAxesChecker->show ();
2569 void MainWindow::slotSettingsColorFilter ()
2571 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsColorFilter";
2573 m_dlgSettingsColorFilter->
load (*m_cmdMediator);
2574 m_dlgSettingsColorFilter->show ();
2577 void MainWindow::slotSettingsCoords ()
2579 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsCoords";
2581 m_dlgSettingsCoords->
load (*m_cmdMediator);
2582 m_dlgSettingsCoords->show ();
2585 void MainWindow::slotSettingsCurveAddRemove ()
2587 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsCurveAddRemove";
2589 m_dlgSettingsCurveAddRemove->
load (*m_cmdMediator);
2590 m_dlgSettingsCurveAddRemove->show ();
2593 void MainWindow::slotSettingsCurveProperties ()
2595 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsCurveProperties";
2597 m_dlgSettingsCurveProperties->
load (*m_cmdMediator);
2599 m_dlgSettingsCurveProperties->show ();
2602 void MainWindow::slotSettingsDigitizeCurve ()
2604 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsDigitizeCurve";
2606 m_dlgSettingsDigitizeCurve->
load (*m_cmdMediator);
2607 m_dlgSettingsDigitizeCurve->show ();
2610 void MainWindow::slotSettingsExportFormat ()
2612 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsExportFormat";
2615 m_dlgSettingsExportFormat->
load (*m_cmdMediator);
2616 m_dlgSettingsExportFormat->show ();
2623 void MainWindow::slotSettingsGeneral ()
2625 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsGeneral";
2627 m_dlgSettingsGeneral->
load (*m_cmdMediator);
2628 m_dlgSettingsGeneral->show ();
2631 void MainWindow::slotSettingsGridRemoval ()
2633 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsGridRemoval";
2635 m_dlgSettingsGridRemoval->
load (*m_cmdMediator);
2636 m_dlgSettingsGridRemoval->show ();
2639 void MainWindow::slotSettingsPointMatch ()
2641 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsPointMatch";
2643 m_dlgSettingsPointMatch->
load (*m_cmdMediator);
2644 m_dlgSettingsPointMatch->show ();
2647 void MainWindow::slotSettingsSegments ()
2649 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsSegments";
2651 m_dlgSettingsSegments->
load (*m_cmdMediator);
2652 m_dlgSettingsSegments->show ();
2655 void MainWindow::slotSettingsMainWindow ()
2657 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotSettingsMainWindow";
2661 m_dlgSettingsMainWindow->show ();
2664 void MainWindow::slotUndoTextChanged (
const QString &text)
2666 LOG4CPP_DEBUG_S ((*mainCat)) <<
"MainWindow::slotUndoTextChanged";
2668 QString completeText (
"Undo");
2669 if (!text.isEmpty ()) {
2670 completeText += QString (
" \"%1\"").arg (text);
2672 m_actionEditUndo->setText (completeText);
2675 void MainWindow::slotViewGroupBackground(QAction *action)
2677 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewGroupBackground";
2680 BackgroundImage backgroundImage;
2681 int indexBackground;
2682 if (action == m_actionViewBackgroundNone) {
2683 indexBackground = m_cmbBackground->findData (QVariant (BACKGROUND_IMAGE_NONE));
2684 backgroundImage = BACKGROUND_IMAGE_NONE;
2685 }
else if (action == m_actionViewBackgroundOriginal) {
2686 indexBackground = m_cmbBackground->findData (QVariant (BACKGROUND_IMAGE_ORIGINAL));
2687 backgroundImage = BACKGROUND_IMAGE_ORIGINAL;
2688 }
else if (action == m_actionViewBackgroundFiltered) {
2689 indexBackground = m_cmbBackground->findData (QVariant (BACKGROUND_IMAGE_FILTERED));
2690 backgroundImage = BACKGROUND_IMAGE_FILTERED;
2692 ENGAUGE_ASSERT (
false);
2695 indexBackground = m_cmbBackground->findData (QVariant (BACKGROUND_IMAGE_ORIGINAL));
2696 backgroundImage = BACKGROUND_IMAGE_ORIGINAL;
2699 m_cmbBackground->setCurrentIndex (indexBackground);
2703 void MainWindow::slotViewGroupCurves(QAction * )
2705 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewGroupCurves";
2707 updateViewedCurves ();
2710 void MainWindow::slotViewGroupStatus(QAction *action)
2712 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewGroupStatus";
2714 ENGAUGE_CHECK_PTR (m_statusBar);
2716 if (action == m_actionStatusNever) {
2718 }
else if (action == m_actionStatusTemporary) {
2725 void MainWindow::slotViewToolBarBackground ()
2727 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewToolBarBackground";
2729 if (m_actionViewBackground->isChecked ()) {
2730 m_toolBackground->show();
2732 m_toolBackground->hide();
2736 void MainWindow::slotViewToolBarChecklistGuide ()
2738 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewToolBarChecklistGuide";
2740 if (m_actionViewChecklistGuide->isChecked ()) {
2741 m_dockChecklistGuide->show();
2743 m_dockChecklistGuide->hide();
2747 void MainWindow::slotViewToolBarDigitize ()
2749 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewToolBarDigitize";
2751 if (m_actionViewDigitize->isChecked ()) {
2752 m_toolDigitize->show();
2754 m_toolDigitize->hide();
2758 void MainWindow::slotViewToolBarSettingsViews ()
2760 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewToolBarSettingsViews";
2762 if (m_actionViewSettingsViews->isChecked ()) {
2763 m_toolSettingsViews->show();
2765 m_toolSettingsViews->hide();
2769 void MainWindow::slotViewToolTips ()
2771 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewToolTips";
2776 void MainWindow::slotViewZoom(
int zoom)
2778 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewZoom";
2781 switch ((ZoomFactor) zoom) {
2783 m_actionZoom16To1->setChecked(
true);
2784 slotViewZoom16To1 ();
2787 m_actionZoom8To1->setChecked(
true);
2788 slotViewZoom8To1 ();
2791 m_actionZoom4To1->setChecked(
true);
2792 slotViewZoom4To1 ();
2795 m_actionZoom2To1->setChecked(
true);
2796 slotViewZoom2To1 ();
2799 m_actionZoom1To1->setChecked(
true);
2800 slotViewZoom1To1 ();
2803 m_actionZoom1To2->setChecked(
true);
2804 slotViewZoom1To2 ();
2807 m_actionZoom1To4->setChecked(
true);
2808 slotViewZoom1To4 ();
2811 m_actionZoom1To8->setChecked(
true);
2812 slotViewZoom1To8 ();
2815 m_actionZoom1To16->setChecked(
true);
2816 slotViewZoom1To16 ();
2819 m_actionZoomFill->setChecked(
true);
2820 slotViewZoomFill ();
2825 void MainWindow::slotViewZoom16To1 ()
2827 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewZoom16To1";
2829 QTransform transform;
2830 transform.scale (16.0, 16.0);
2831 m_view->setTransform (transform);
2835 void MainWindow::slotViewZoom8To1 ()
2837 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewZoom8To1";
2839 QTransform transform;
2840 transform.scale (8.0, 8.0);
2841 m_view->setTransform (transform);
2845 void MainWindow::slotViewZoom4To1 ()
2847 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewZoom4To1";
2849 QTransform transform;
2850 transform.scale (4.0, 4.0);
2851 m_view->setTransform (transform);
2855 void MainWindow::slotViewZoom2To1 ()
2857 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotZoom2To1";
2859 QTransform transform;
2860 transform.scale (2.0, 2.0);
2861 m_view->setTransform (transform);
2865 void MainWindow::slotViewZoom1To1 ()
2867 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewZoom1To1";
2869 QTransform transform;
2870 transform.scale (1.0, 1.0);
2871 m_view->setTransform (transform);
2875 void MainWindow::slotViewZoom1To2 ()
2877 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotZoom1To2";
2879 QTransform transform;
2880 transform.scale (0.5, 0.5);
2881 m_view->setTransform (transform);
2885 void MainWindow::slotViewZoom1To4 ()
2887 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotZoom1To4";
2889 QTransform transform;
2890 transform.scale (0.25, 0.25);
2891 m_view->setTransform (transform);
2895 void MainWindow::slotViewZoom1To8 ()
2897 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotZoom1To8";
2899 QTransform transform;
2900 transform.scale (0.125, 0.125);
2901 m_view->setTransform (transform);
2905 void MainWindow::slotViewZoom1To16 ()
2907 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotZoom1To16";
2909 QTransform transform;
2910 transform.scale (0.0625, 0.0625);
2911 m_view->setTransform (transform);
2915 void MainWindow::slotViewZoomFill ()
2917 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewZoomFill";
2919 m_backgroundStateContext->
fitInView (*m_view);
2924 void MainWindow::slotViewZoomIn ()
2926 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewZoomIn";
2930 bool goto16To1 =
false, goto8To1 =
false, goto4To1 =
false, goto2To1 =
false;
2931 bool goto1To1 =
false;
2932 bool goto1To2 =
false, goto1To4 =
false, goto1To8 =
false, goto1To16 =
false;
2933 if (m_actionZoomFill->isChecked ()) {
2936 double xScale = m_view->transform().m11();
2937 double yScale = m_view->transform().m22();
2938 double scale = qMin(xScale, yScale);
2939 if (scale < 0.125) {
2941 }
else if (scale < 0.25) {
2943 }
else if (scale < 0.5) {
2945 }
else if (scale < 1) {
2947 }
else if (scale < 2) {
2949 }
else if (scale < 4) {
2951 }
else if (scale < 8) {
2957 goto16To1 = m_actionZoom8To1->isChecked ();
2958 goto8To1 = m_actionZoom4To1->isChecked ();
2959 goto4To1 = m_actionZoom2To1->isChecked ();
2960 goto2To1 = m_actionZoom1To1->isChecked ();
2961 goto1To1 = m_actionZoom1To2->isChecked ();
2962 goto1To2 = m_actionZoom1To4->isChecked ();
2963 goto1To4 = m_actionZoom1To8->isChecked ();
2964 goto1To8 = m_actionZoom1To16->isChecked ();
2969 m_actionZoom16To1->setChecked (
true);
2970 slotViewZoom16To1 ();
2971 }
else if (goto8To1) {
2972 m_actionZoom8To1->setChecked (
true);
2973 slotViewZoom8To1 ();
2974 }
else if (goto4To1) {
2975 m_actionZoom4To1->setChecked (
true);
2976 slotViewZoom4To1 ();
2977 }
else if (goto2To1) {
2978 m_actionZoom2To1->setChecked (
true);
2979 slotViewZoom2To1 ();
2980 }
else if (goto1To1) {
2981 m_actionZoom1To1->setChecked (
true);
2982 slotViewZoom1To1 ();
2983 }
else if (goto1To2) {
2984 m_actionZoom1To2->setChecked (
true);
2985 slotViewZoom1To2 ();
2986 }
else if (goto1To4) {
2987 m_actionZoom1To4->setChecked (
true);
2988 slotViewZoom1To4 ();
2989 }
else if (goto1To8) {
2990 m_actionZoom1To8->setChecked (
true);
2991 slotViewZoom1To8 ();
2992 }
else if (goto1To16) {
2993 m_actionZoom1To16->setChecked (
true);
2994 slotViewZoom1To16 ();
2998 void MainWindow::slotViewZoomOut ()
3000 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::slotViewZoomOut";
3004 bool goto16To1 =
false, goto8To1 =
false, goto4To1 =
false, goto2To1 =
false;
3005 bool goto1To1 =
false;
3006 bool goto1To2 =
false, goto1To4 =
false, goto1To8 =
false, goto1To16 =
false;
3007 if (m_actionZoomFill->isChecked ()) {
3010 double xScale = m_view->transform().m11();
3011 double yScale = m_view->transform().m22();
3012 double scale = qMax(xScale, yScale);
3015 }
else if (scale > 4) {
3017 }
else if (scale > 2) {
3019 }
else if (scale > 1) {
3021 }
else if (scale > 0.5) {
3023 }
else if (scale > 0.25) {
3025 }
else if (scale > 0.125) {
3031 goto8To1 = m_actionZoom16To1->isChecked ();
3032 goto4To1 = m_actionZoom8To1->isChecked ();
3033 goto2To1 = m_actionZoom4To1->isChecked ();
3034 goto1To1 = m_actionZoom2To1->isChecked ();
3035 goto1To2 = m_actionZoom1To1->isChecked ();
3036 goto1To4 = m_actionZoom1To2->isChecked ();
3037 goto1To8 = m_actionZoom1To4->isChecked ();
3038 goto1To16 = m_actionZoom1To8->isChecked ();
3043 m_actionZoom1To16->setChecked (
true);
3044 slotViewZoom1To16 ();
3045 }
else if (goto1To8) {
3046 m_actionZoom1To8->setChecked (
true);
3047 slotViewZoom1To8 ();
3048 }
else if (goto1To4) {
3049 m_actionZoom1To4->setChecked (
true);
3050 slotViewZoom1To4 ();
3051 }
else if (goto1To2) {
3052 m_actionZoom1To2->setChecked (
true);
3053 slotViewZoom1To2 ();
3054 }
else if (goto1To1) {
3055 m_actionZoom1To1->setChecked (
true);
3056 slotViewZoom1To1 ();
3057 }
else if (goto2To1) {
3058 m_actionZoom2To1->setChecked (
true);
3059 slotViewZoom2To1 ();
3060 }
else if (goto4To1) {
3061 m_actionZoom4To1->setChecked (
true);
3062 slotViewZoom4To1 ();
3063 }
else if (goto8To1) {
3064 m_actionZoom8To1->setChecked (
true);
3065 slotViewZoom8To1 ();
3066 }
else if (goto16To1) {
3067 m_actionZoom16To1->setChecked (
true);
3068 slotViewZoom16To1 ();
3074 return m_transformation;
3084 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateAfterCommand";
3086 ENGAUGE_CHECK_PTR (m_cmdMediator);
3090 updateAfterCommandStatusBarCoords ();
3099 m_dockChecklistGuide->
update (*m_cmdMediator,
3100 m_isDocumentExported);
3104 writeCheckpointToLogFile ();
3107 void MainWindow::updateAfterCommandStatusBarCoords ()
3109 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateAfterCommandStatusBarCoords";
3114 const QPoint HACK_SO_GRAPH_COORDINATE_MATCHES_INPUT (1, 1);
3118 updateTransformationAndItsDependencies();
3121 if (!m_transformationBefore.transformIsDefined() && m_transformation.
transformIsDefined()) {
3129 }
else if (m_transformationBefore.transformIsDefined() && !m_transformation.
transformIsDefined()) {
3137 }
else if (m_transformation.
transformIsDefined() && (m_transformationBefore != m_transformation)) {
3146 QPoint posLocal = m_view->mapFromGlobal (QCursor::pos ()) - HACK_SO_GRAPH_COORDINATE_MATCHES_INPUT;
3147 QPointF posScreen = m_view->mapToScene (posLocal);
3149 slotMouseMove (posScreen);
3154 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateAfterMouseRelease";
3159 void MainWindow::updateControls ()
3161 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateControls"
3162 <<
" selectedItems=" << m_scene->selectedItems().count();
3164 m_cmbBackground->setEnabled (!m_currentFile.isEmpty ());
3166 m_menuFileOpenRecent->setEnabled ((m_actionRecentFiles.count () > 0) &&
3167 (m_actionRecentFiles.at(0)->isVisible ()));
3168 m_actionClose->setEnabled (!m_currentFile.isEmpty ());
3169 m_actionSave->setEnabled (!m_currentFile.isEmpty ());
3170 m_actionSaveAs->setEnabled (!m_currentFile.isEmpty ());
3171 m_actionExport->setEnabled (!m_currentFile.isEmpty ());
3172 m_actionPrint->setEnabled (!m_currentFile.isEmpty ());
3174 if (m_cmdMediator == 0) {
3175 m_actionEditUndo->setEnabled (
false);
3176 m_actionEditRedo->setEnabled (
false);
3178 m_actionEditUndo->setEnabled (m_cmdMediator->canUndo ());
3179 m_actionEditRedo->setEnabled (m_cmdMediator->canRedo () || m_cmdStackShadow->
canRedo ());
3181 m_actionEditCut->setEnabled (m_scene->selectedItems().count () > 0);
3182 m_actionEditCopy->setEnabled (m_scene->selectedItems().count () > 0);
3183 m_actionEditPaste->setEnabled (
false);
3184 m_actionEditDelete->setEnabled (m_scene->selectedItems().count () > 0);
3186 m_actionDigitizeAxis->setEnabled (!m_currentFile.isEmpty ());
3187 m_actionDigitizeCurve ->setEnabled (!m_currentFile.isEmpty ());
3188 m_actionDigitizePointMatch->setEnabled (!m_currentFile.isEmpty ());
3189 m_actionDigitizeColorPicker->setEnabled (!m_currentFile.isEmpty ());
3190 m_actionDigitizeSegment->setEnabled (!m_currentFile.isEmpty ());
3191 m_actionDigitizeSelect->setEnabled (!m_currentFile.isEmpty ());
3193 m_actionViewBackground->setEnabled (!m_currentFile.isEmpty());
3194 m_actionViewChecklistGuide->setEnabled (!m_dockChecklistGuide->
browserIsEmpty());
3195 m_actionViewDigitize->setEnabled (!m_currentFile.isEmpty ());
3196 m_actionViewSettingsViews->setEnabled (!m_currentFile.isEmpty ());
3198 m_actionSettingsCoords->setEnabled (!m_currentFile.isEmpty ());
3199 m_actionSettingsCurveAddRemove->setEnabled (!m_currentFile.isEmpty ());
3200 m_actionSettingsCurveProperties->setEnabled (!m_currentFile.isEmpty ());
3201 m_actionSettingsDigitizeCurve->setEnabled (!m_currentFile.isEmpty ());
3202 m_actionSettingsExport->setEnabled (!m_currentFile.isEmpty ());
3203 m_actionSettingsColorFilter->setEnabled (!m_currentFile.isEmpty ());
3204 m_actionSettingsAxesChecker->setEnabled (!m_currentFile.isEmpty ());
3205 m_actionSettingsGridRemoval->setEnabled (!m_currentFile.isEmpty ());
3206 m_actionSettingsPointMatch->setEnabled (!m_currentFile.isEmpty ());
3207 m_actionSettingsSegments->setEnabled (!m_currentFile.isEmpty ());
3208 m_actionSettingsGeneral->setEnabled (!m_currentFile.isEmpty ());
3209 m_actionSettingsMainWindow->setEnabled (!m_currentFile.isEmpty ());
3211 m_groupBackground->setEnabled (!m_currentFile.isEmpty ());
3212 m_groupCurves->setEnabled (!m_currentFile.isEmpty ());
3213 m_groupZoom->setEnabled (!m_currentFile.isEmpty ());
3215 m_actionZoomIn->setEnabled (!m_currentFile.isEmpty ());
3216 m_actionZoomOut->setEnabled (!m_currentFile.isEmpty ());
3221 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateDigitizeStateIfSoftwareTriggered";
3223 switch (digitizeState) {
3224 case DIGITIZE_STATE_AXIS:
3225 m_actionDigitizeAxis->setChecked(
true);
3229 case DIGITIZE_STATE_COLOR_PICKER:
3230 m_actionDigitizeColorPicker->setChecked(
true);
3231 slotDigitizeColorPicker();
3234 case DIGITIZE_STATE_CURVE:
3235 m_actionDigitizeCurve->setChecked(
true);
3236 slotDigitizeCurve();
3239 case DIGITIZE_STATE_EMPTY:
3242 case DIGITIZE_STATE_POINT_MATCH:
3243 m_actionDigitizePointMatch->setChecked(
true);
3244 slotDigitizePointMatch();
3247 case DIGITIZE_STATE_SEGMENT:
3248 m_actionDigitizeSegment->setChecked(
true);
3249 slotDigitizeSegment();
3252 case DIGITIZE_STATE_SELECT:
3253 m_actionDigitizeSelect->setChecked(
true);
3254 slotDigitizeSelect();
3258 LOG4CPP_ERROR_S ((*mainCat)) <<
"MainWindow::updateDigitizeStateIfSoftwareTriggered";
3265 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateGraphicsLinesToMatchGraphicsPoints";
3271 void MainWindow::updateRecentFileList()
3273 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateRecentFileList";
3275 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
3276 QStringList recentFilePaths = settings.value(SETTINGS_RECENT_FILE_LIST).toStringList();
3279 unsigned int count = recentFilePaths.size();
3280 if (count > MAX_RECENT_FILE_LIST_SIZE) {
3281 count = MAX_RECENT_FILE_LIST_SIZE;
3286 for (i = 0; i < count; i++) {
3287 QString strippedName = QFileInfo (recentFilePaths.at(i)).fileName();
3288 m_actionRecentFiles.at (i)->setText (strippedName);
3289 m_actionRecentFiles.at (i)->setData (recentFilePaths.at (i));
3290 m_actionRecentFiles.at (i)->setVisible (
true);
3294 for (i = count; i < MAX_RECENT_FILE_LIST_SIZE; i++) {
3295 m_actionRecentFiles.at (i)->setVisible (
false);
3301 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsAxesChecker";
3308 m_cmbCurve->currentText());
3313 m_cmbCurve->currentText());
3319 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsColorFilter";
3331 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsCoords";
3338 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsCurveAddRemove";
3341 loadCurveListFromCmdMediator();
3347 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsCurveStyles";
3356 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsDigitizeCurve";
3364 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsExportFormat";
3371 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsGeneral";
3378 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsGridRemoval";
3383 void MainWindow::updateSettingsMainWindow()
3385 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsMainWindow";
3387 if (m_modelMainWindow.
zoomControl() == ZOOM_CONTROL_MENU_ONLY ||
3388 m_modelMainWindow.
zoomControl() == ZOOM_CONTROL_MENU_WHEEL) {
3390 m_actionZoomIn->setShortcut (tr (
""));
3391 m_actionZoomOut->setShortcut (tr (
""));
3395 m_actionZoomIn->setShortcut (tr (
"+"));
3396 m_actionZoomOut->setShortcut (tr (
"-"));
3403 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsMainWindow";
3411 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsPointMatch";
3418 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateSettingsSegments";
3424 void MainWindow::updateTransformationAndItsDependencies()
3426 m_transformation.
update (!m_currentFile.isEmpty (),
3434 m_cmbCurve->currentText ());
3437 void MainWindow::updateViewedCurves ()
3439 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateViewedCurves";
3441 if (m_actionViewCurvesAll->isChecked ()) {
3445 }
else if (m_actionViewCurvesSelected->isChecked ()) {
3449 }
else if (m_actionViewCurvesNone->isChecked ()) {
3454 ENGAUGE_ASSERT (
false);
3460 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::updateViewsOfSettings";
3462 QString activeCurve = m_digitizeStateContext->
activeCurve ();
3469 if (activeCurve.isEmpty ()) {
3482 m_cmdMediator->
pixmap ());
3489 ENGAUGE_CHECK_PTR (m_view);
3495 ENGAUGE_CHECK_PTR (m_view);
3501 const int ANGLE_THRESHOLD = 15;
3502 const int DELTAS_PER_DEGREE = 8;
3504 QPoint numDegrees =
event->angleDelta() / DELTAS_PER_DEGREE;
3506 LOG4CPP_INFO_S ((*mainCat)) <<
"MainWindow::wheelEvent"
3507 <<
" degrees=" << numDegrees.y()
3508 <<
" phase=" <<
event->phase();
3510 if (m_modelMainWindow.
zoomControl() == ZOOM_CONTROL_MENU_WHEEL ||
3511 m_modelMainWindow.
zoomControl() == ZOOM_CONTROL_MENU_WHEEL_PLUSMINUS) {
3513 if (numDegrees.y() >= ANGLE_THRESHOLD) {
3517 }
else if (numDegrees.y() <= -ANGLE_THRESHOLD) {
3525 void MainWindow::writeCheckpointToLogFile ()
3528 QString checkpointDoc;
3529 QTextStream strDoc (&checkpointDoc);
3534 QString checkpointScene;
3535 QTextStream strScene (&checkpointScene);
3540 if (mainCat->getPriority() == log4cpp::Priority::DEBUG) {
3542 LOG4CPP_DEBUG_S ((*mainCat)) <<
"MainWindow::writeCheckpointToLogFile\n"
3543 <<
"--------------DOCUMENT CHECKPOINT START----------" <<
"\n"
3544 << checkpointDoc.toLatin1().data()
3545 <<
"---------------DOCUMENT CHECKPOINT END-----------" <<
"\n"
3546 <<
"----------------SCENE CHECKPOINT START-----------" <<
"\n"
3547 << checkpointScene.toLatin1().data()
3548 <<
"-----------------SCENE CHECKPOINT END------------" ;
void updateGraphicsLinesToMatchGraphicsPoints(const CurveStyles &modelCurveStyles, const Transformation &transformation)
A mouse move has just occurred so move the selected points, since they were dragged.
Model for DlgSettingsGeneral and CmdSettingsGeneral.
void unsetPointStyle()
Apply no PointStyle.
void handleMouseMove(QPointF pos)
See DigitizeStateAbstractBase::handleMouseMove.
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(...
void setCurveName(const QString &curveName)
Load information for the specified curve name. When called externally, the load method must have been...
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 updateSettingsMainWindow(const MainWindowModel &modelMainWindow)
Update with new main window properties.
void setStatusBarMode(StatusBarMode statusBarMode)
Set the status bar visibility mode.
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 updateDigitizeStateIfSoftwareTriggered(DigitizeState digitizeState)
After software-triggered state transition, this method manually triggers the action as if user had cl...
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.
QString templateHtml() const
Template html comprising the checklist for display.
Transformation transformation() const
Return read-only copy of transformation.
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 ...
void setImageIsLoaded(bool imageIsLoaded)
Set the image so QGraphicsView cursor and drag mode are accessible.
Context class for transformation state machine.
Model for DlgSettingsCurveProperties and CmdSettingsCurveProperties.
void updateSettingsCurveAddRemove(const CurvesGraphs &curvesGraphs)
Update with new curves.
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.
void bindToCmdMediatorAndResetOnLoad(CmdMediator *cmdMediator)
Bind to CmdMediator class.
void updateAfterMouseRelease()
Call MainWindow::updateControls (which is private) after the very specific case - a mouse press/relea...
void updateModelDigitizeCurve(const DocumentModelDigitizeCurve &modelDigitizeCurve)
Update the digitize curve settings.
virtual void wheelEvent(QWheelEvent *event)
Convert wheel events into zoom in/out.
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 handleContextMenuEvent(const QString &pointIdentifier)
See DigitizeStateAbstractBase::handleContextMenuEvent.
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.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
void setModelDigitizeCurve(const DocumentModelDigitizeCurve &modelDigitizeCurve)
Set method for DocumentModelDigitizeCurve.
CmdMediator & cmdMediator()
Accessor for commands to process the Document.
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.
QString xmlToUpload() const
Xml to be uploaded. Includes document if user has approved.
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...
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 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.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
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...
Strategy class for exporting to a file. This strategy is external to the Document class so that class...
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...
void setPixmap(const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &modelColorFilter, const QPixmap &pixmapOriginal)
Update the images of all states, rather than just the current state.
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 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 and CmdSettingsMainWindow.
bool canRedo() const
Return true if there is a command available.
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 updateAfterCommand()
See GraphicsScene::updateAfterCommand.
QString fileExtensionCsv() const
File extension for csv export files.
void updateSettingsColorFilter(const DocumentModelColorFilter &modelColorFilter)
Update with new color filter properties.
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 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 requestImmediateStateTransition(DigitizeState digitizeState)
Perform immediate state transition. Called from outside state machine.
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.
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 handleLeave()
See DigitizeStateAbstractBase::handleLeave.
void appendNewCmd(QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
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...
QStringList curveNames() const
Curve names to be placed into Document.
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 populateCurvesGraphs(CurvesGraphs &curvesGraphs)
Create entries in CurvesGraphs for each curve name that user provided.
void setZoomControl(ZoomControl zoomControl)
Set method for zoom control.
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 handleSetOverrideCursor(const QCursor &cursor)
See DigitizeStateAbstractBase::handleSetOverrideCursor.
MainWindow(const QString &errorReportFile, bool isGnuplot, QStringList loadStartupFiles, QWidget *parent=0)
Single constructor.
void updateColorFilter(const Transformation &transformation, const DocumentModelGridRemoval &modelGridRemoval, const DocumentModelColorFilter &colorFilter)
Apply color filter settings.
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.
void handleCurveChange()
See DigitizeStateAbstractBase::handleCurveChange.
Add point and line handling to generic QGraphicsScene.
QString filterCsv() const
QFileDialog filter for CSV files.
Command for moving all selected Points by a specified translation.
void handleMouseRelease(QPointF pos)
See DigitizeStateAbstractBase::handleMouseRelease.
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...
void handleKeyPress(Qt::Key key, bool atLeastOneSelectedItem)
See DigitizeStateAbstractBase::handleKeyPress.
Dialog for sending error report.
virtual void load(CmdMediator &cmdMediator)
Load settings from Document.
void updateSettingsSegments(const DocumentModelSegments &modelSegments)
Update with new segments properties.
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.
DocumentModelGridRemoval modelGridRemoval() const
Get method for DocumentModelGridRemoval.
MainWindowModel modelMainWindow() const
Get method for main window model.
void setTemplateHtml(const QString &html, const QStringList &curveNames)
Populate the browser with template html.
About Engauge dialog. This provides a hidden shortcut for triggering ENGAUGE_ASSERT.
virtual void showEvent(QShowEvent *)
Processing performed after gui becomes available.
bool transformIsDefined() const
Return true if all three axis points have been defined.
void handleMousePress(QPointF pos)
See DigitizeStateAbstractBase::handleMousePress.