00001
00002
00003
00004
00005
00006
00007 #include "BackgroundImage.h"
00008 #include "BackgroundStateContext.h"
00009 #include "img/bannerapp_16.xpm"
00010 #include "img/bannerapp_32.xpm"
00011 #include "img/bannerapp_64.xpm"
00012 #include "img/bannerapp_128.xpm"
00013 #include "img/bannerapp_256.xpm"
00014 #include "ChecklistGuide.h"
00015 #include "ChecklistGuideWizard.h"
00016 #include "CmdCopy.h"
00017 #include "CmdCut.h"
00018 #include "CmdDelete.h"
00019 #include "CmdMediator.h"
00020 #include "CmdSelectCoordSystem.h"
00021 #include "CmdStackShadow.h"
00022 #include "ColorFilter.h"
00023 #include "Curve.h"
00024 #include "DataKey.h"
00025 #include "DigitizeStateContext.h"
00026 #include "DigitAxis.xpm"
00027 #include "DigitColorPicker.xpm"
00028 #include "DigitCurve.xpm"
00029 #include "DigitPointMatch.xpm"
00030 #include "DigitSegment.xpm"
00031 #include "DigitSelect.xpm"
00032 #include "DlgAbout.h"
00033 #include "DlgErrorReport.h"
00034 #include "DlgImportAdvanced.h"
00035 #include "DlgRequiresTransform.h"
00036 #include "DlgSettingsAxesChecker.h"
00037 #include "DlgSettingsColorFilter.h"
00038 #include "DlgSettingsCoords.h"
00039 #include "DlgSettingsCurveAddRemove.h"
00040 #include "DlgSettingsCurveProperties.h"
00041 #include "DlgSettingsDigitizeCurve.h"
00042 #include "DlgSettingsExportFormat.h"
00043 #include "DlgSettingsGeneral.h"
00044 #include "DlgSettingsGridDisplay.h"
00045 #include "DlgSettingsGridRemoval.h"
00046 #include "DlgSettingsMainWindow.h"
00047 #include "DlgSettingsPointMatch.h"
00048 #include "DlgSettingsSegments.h"
00049 #include "DocumentSerialize.h"
00050 #include "EngaugeAssert.h"
00051 #include "EnumsToQt.h"
00052 #include "ExportToFile.h"
00053 #include "FileCmdScript.h"
00054 #include "Ghosts.h"
00055 #include "GraphicsItemType.h"
00056 #include "GraphicsScene.h"
00057 #include "GraphicsView.h"
00058 #include "GridLineFactory.h"
00059 #include "HelpWindow.h"
00060 #ifdef ENGAUGE_JPEG2000
00061 #include "Jpeg2000.h"
00062 #endif // ENGAUGE_JPEG2000
00063 #include "LoadFileInfo.h"
00064 #include "LoadImageFromUrl.h"
00065 #include "Logger.h"
00066 #include "MainTitleBarFormat.h"
00067 #include "MainWindow.h"
00068 #include "NetworkClient.h"
00069 #include <QAction>
00070 #include <QApplication>
00071 #include <QCloseEvent>
00072 #include <QComboBox>
00073 #include <QDebug>
00074 #include <QDesktopServices>
00075 #include <QDockWidget>
00076 #include <QDomDocument>
00077 #include <QKeyEvent>
00078 #include <QFileDialog>
00079 #include <QFileInfo>
00080 #include <QGraphicsLineItem>
00081 #include <QImageReader>
00082 #include <QKeyEvent>
00083 #include <QKeySequence>
00084 #include <QLabel>
00085 #include <QMenu>
00086 #include <QMenuBar>
00087 #include <QMessageBox>
00088 #include <QMouseEvent>
00089 #include <QPrintDialog>
00090 #include <QPrinter>
00091 #include <QSettings>
00092 #include <QTextStream>
00093 #include <QtHelp>
00094 #include <QTimer>
00095 #include <QToolBar>
00096 #include <QToolButton>
00097 #include "QtToString.h"
00098 #include <QVBoxLayout>
00099 #include <QWhatsThis>
00100 #include <QXmlStreamReader>
00101 #include <QXmlStreamWriter>
00102 #include "Settings.h"
00103 #include "StatusBar.h"
00104 #include "TransformationStateContext.h"
00105 #include "TutorialDlg.h"
00106 #include "Version.h"
00107 #include "ViewPointStyle.h"
00108 #include "ViewSegmentFilter.h"
00109 #include "ZoomFactor.h"
00110 #include "ZoomFactorInitial.h"
00111
00112 const QString EMPTY_FILENAME ("");
00113 const char *ENGAUGE_FILENAME_DESCRIPTION = "Engauge Document";
00114 const QString ENGAUGE_FILENAME_EXTENSION ("dig");
00115 const int REGRESSION_INTERVAL = 400;
00116 const unsigned int MAX_RECENT_FILE_LIST_SIZE = 8;
00117
00118 MainWindow::MainWindow(const QString &errorReportFile,
00119 const QString &fileCmdScriptFile,
00120 bool isRegressionTest,
00121 bool isGnuplot,
00122 QStringList loadStartupFiles,
00123 QWidget *parent) :
00124 QMainWindow(parent),
00125 m_isDocumentExported (false),
00126 m_engaugeFile (EMPTY_FILENAME),
00127 m_currentFile (EMPTY_FILENAME),
00128 m_layout (0),
00129 m_scene (0),
00130 m_view (0),
00131 m_cmdMediator (0),
00132 m_digitizeStateContext (0),
00133 m_transformationStateContext (0),
00134 m_backgroundStateContext (0),
00135 m_isGnuplot (isGnuplot),
00136 m_ghosts (0),
00137 m_timerRegressionErrorReport(0),
00138 m_fileCmdScript (0),
00139 m_isRegressionTest (isRegressionTest),
00140 m_timerRegressionFileCmdScript(0)
00141 {
00142 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::MainWindow"
00143 << " curDir=" << QDir::currentPath().toLatin1().data();
00144
00145 #ifdef OSX
00146 qApp->setApplicationName ("Engauge Digitizer");
00147 qApp->setOrganizationDomain ("Mark Mitchell");
00148 #endif
00149
00150 LoggerUpload::bindToMainWindow(this);
00151
00152 QString initialPath = QDir::currentPath();
00153
00154 setCurrentFile ("");
00155 createIcons();
00156 setWindowFlags (Qt::WindowContextHelpButtonHint | windowFlags ());
00157 setWindowTitle (engaugeWindowTitle ());
00158
00159 createCentralWidget();
00160 createActions ();
00161 createStatusBar ();
00162 createMenus ();
00163 createToolBars ();
00164 createHelpWindow ();
00165 createTutorial ();
00166 createScene ();
00167 createNetwork ();
00168 createLoadImageFromUrl ();
00169 createStateContextBackground ();
00170 createStateContextDigitize ();
00171 createStateContextTransformation ();
00172 createSettingsDialogs ();
00173 createCommandStackShadow ();
00174 createZoomMap ();
00175 updateControls ();
00176
00177 settingsRead ();
00178 setCurrentFile ("");
00179 setUnifiedTitleAndToolBarOnMac(true);
00180
00181 installEventFilter(this);
00182 if (!errorReportFile.isEmpty()) {
00183 loadErrorReportFile(initialPath,
00184 errorReportFile);
00185 if (m_isRegressionTest) {
00186 startRegressionTestErrorReport(initialPath,
00187 errorReportFile);
00188 }
00189 } else if (!fileCmdScriptFile.isEmpty()) {
00190 m_fileCmdScript = new FileCmdScript (fileCmdScriptFile);
00191 startRegressionTestFileCmdScript();
00192 } else {
00193
00194
00195
00196 m_loadStartupFiles = loadStartupFiles;
00197 }
00198 }
00199
00200 MainWindow::~MainWindow()
00201 {
00202 }
00203
00204 void MainWindow::applyZoomFactorAfterLoad()
00205 {
00206 ZoomFactor zoomFactor;
00207 ZoomFactorInitial zoomFactorInitial = m_modelMainWindow.zoomFactorInitial();
00208
00209 if (m_zoomMap.contains (zoomFactorInitial)) {
00210 zoomFactor = m_zoomMap [zoomFactorInitial];
00211 } else if (zoomFactorInitial == ZOOM_INITIAL_PREVIOUS) {
00212 zoomFactor = currentZoomFactor ();
00213 } else {
00214 ENGAUGE_ASSERT (false);
00215 zoomFactor = currentZoomFactor();
00216 }
00217
00218 slotViewZoom (zoomFactor);
00219 }
00220
00221 void MainWindow::closeEvent(QCloseEvent *event)
00222 {
00223 if (maybeSave()) {
00224 settingsWrite ();
00225 event->accept ();
00226 } else {
00227 event->ignore ();
00228 }
00229 }
00230
00231 void MainWindow::cmdFileClose()
00232 {
00233 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::cmdFileClose";
00234
00235 setWindowModified (false);
00236 slotFileClose();
00237 }
00238
00239 void MainWindow::cmdFileExport(const QString &fileName)
00240 {
00241 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::cmdFileExport";
00242
00243 ExportToFile exportStrategy;
00244 fileExport(fileName,
00245 exportStrategy);
00246 }
00247
00248 void MainWindow::cmdFileImport(const QString &fileName)
00249 {
00250 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::cmdFileImport";
00251
00252 m_regressionFile = exportFilenameFromInputFilename (fileName);
00253 fileImport (fileName,
00254 IMPORT_TYPE_SIMPLE);
00255 }
00256
00257 void MainWindow::cmdFileOpen(const QString &fileName)
00258 {
00259 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::cmdFileOpen";
00260
00261 m_regressionFile = exportFilenameFromInputFilename (fileName);
00262 loadDocumentFile(fileName);
00263 }
00264
00265 CmdMediator *MainWindow::cmdMediator ()
00266 {
00267
00268 return m_cmdMediator;
00269 }
00270
00271 void MainWindow::createActions()
00272 {
00273 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createActions";
00274
00275 createActionsFile ();
00276 createActionsEdit ();
00277 createActionsDigitize ();
00278 createActionsView ();
00279 createActionsSettings ();
00280 createActionsHelp ();
00281 }
00282
00283 void MainWindow::createActionsDigitize ()
00284 {
00285 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createActionsDigitize";
00286
00287 QPixmap pixmapAxis (DigitAxis_xpm);
00288 QPixmap pixmapCurve (DigitCurve_xpm);
00289 QPixmap pixmapColorPicker (DigitColorPicker_xpm);
00290 QPixmap pixmapPointMatch (DigitPointMatch_xpm);
00291 QPixmap pixmapSegment (DigitSegment_xpm);
00292 QPixmap pixmapSelect (DigitSelect_xpm);
00293
00294 QIcon iconAxis (pixmapAxis);
00295 QIcon iconCurve (pixmapCurve);
00296 QIcon iconColorPicker (pixmapColorPicker);
00297 QIcon iconPointMatch (pixmapPointMatch);
00298 QIcon iconSegment (pixmapSegment);
00299 QIcon iconSelect (pixmapSelect);
00300
00301 m_actionDigitizeSelect = new QAction (iconSelect, tr ("Select Tool"), this);
00302 m_actionDigitizeSelect->setShortcut (QKeySequence (tr ("Shift+F2")));
00303 m_actionDigitizeSelect->setCheckable (true);
00304 m_actionDigitizeSelect->setStatusTip (tr ("Select points on screen."));
00305 m_actionDigitizeSelect->setWhatsThis (tr ("Select\n\n"
00306 "Select points on the screen."));
00307 connect (m_actionDigitizeSelect, SIGNAL (triggered ()), this, SLOT (slotDigitizeSelect ()));
00308
00309 m_actionDigitizeAxis = new QAction (iconAxis, tr ("Axis Point Tool"), this);
00310 m_actionDigitizeAxis->setShortcut (QKeySequence (tr ("Shift+F3")));
00311 m_actionDigitizeAxis->setCheckable (true);
00312 m_actionDigitizeAxis->setStatusTip (tr ("Digitize axis points."));
00313 m_actionDigitizeAxis->setWhatsThis (tr ("Digitize Axis Point\n\n"
00314 "Digitizes an axis point by placing a new point at the cursor "
00315 "after a mouse click. The coordinates of the axis point are then "
00316 "entered. In a graph, three axis points are required to define "
00317 "the graph coordinates."));
00318 connect (m_actionDigitizeAxis, SIGNAL (triggered ()), this, SLOT (slotDigitizeAxis ()));
00319
00320 m_actionDigitizeCurve = new QAction (iconCurve, tr ("Curve Point Tool"), this);
00321 m_actionDigitizeCurve->setShortcut (QKeySequence (tr ("Shift+F4")));
00322 m_actionDigitizeCurve->setCheckable (true);
00323 m_actionDigitizeCurve->setStatusTip (tr ("Digitize curve points."));
00324 m_actionDigitizeCurve->setWhatsThis (tr ("Digitize Curve Point\n\n"
00325 "Digitizes a curve point by placing a new point at the cursor "
00326 "after a mouse click. Use this mode to digitize points along curves "
00327 "one by one.\n\n"
00328 "New points will be assigned to the currently selected curve."));
00329 connect (m_actionDigitizeCurve, SIGNAL (triggered ()), this, SLOT (slotDigitizeCurve ()));
00330
00331 m_actionDigitizePointMatch = new QAction (iconPointMatch, tr ("Point Match Tool"), this);
00332 m_actionDigitizePointMatch->setShortcut (QKeySequence (tr ("Shift+F5")));
00333 m_actionDigitizePointMatch->setCheckable (true);
00334 m_actionDigitizePointMatch->setStatusTip (tr ("Digitize curve points in a point plot by matching a point."));
00335 m_actionDigitizePointMatch->setWhatsThis (tr ("Digitize Curve Points by Point Matching\n\n"
00336 "Digitizes curve points in a point plot by finding points that match a sample point. The process "
00337 "starts by selecting a representative sample point.\n\n"
00338 "New points will be assigned to the currently selected curve."));
00339 connect (m_actionDigitizePointMatch, SIGNAL (triggered ()), this, SLOT (slotDigitizePointMatch ()));
00340
00341 m_actionDigitizeColorPicker = new QAction (iconColorPicker, tr ("Color Picker Tool"), this);
00342 m_actionDigitizeColorPicker->setShortcut (QKeySequence (tr ("Shift+F6")));
00343 m_actionDigitizeColorPicker->setCheckable (true);
00344 m_actionDigitizeColorPicker->setStatusTip (tr ("Select color settings for filtering in Segment Fill mode."));
00345 m_actionDigitizeColorPicker->setWhatsThis (tr ("Select color settings for Segment Fill filtering\n\n"
00346 "Select a pixel along the currently selected curve. That pixel and its neighbors will "
00347 "define the filter settings (color, brightness, and so on) of the currently selected curve "
00348 "while in Segment Fill mode."));
00349 connect (m_actionDigitizeColorPicker, SIGNAL (triggered ()), this, SLOT (slotDigitizeColorPicker ()));
00350
00351 m_actionDigitizeSegment = new QAction (iconSegment, tr ("Segment Fill Tool"), this);
00352 m_actionDigitizeSegment->setShortcut (QKeySequence (tr ("Shift+F7")));
00353 m_actionDigitizeSegment->setCheckable (true);
00354 m_actionDigitizeSegment->setStatusTip (tr ("Digitize curve points along a segment of a curve."));
00355 m_actionDigitizeSegment->setWhatsThis (tr ("Digitize Curve Points With Segment Fill\n\n"
00356 "Digitizes curve points by placing new points along the highlighted "
00357 "segment under the cursor. Use this mode to quickly digitize multiple points along a "
00358 "curve with a single click.\n\n"
00359 "New points will be assigned to the currently selected curve."));
00360 connect (m_actionDigitizeSegment, SIGNAL (triggered ()), this, SLOT (slotDigitizeSegment ()));
00361
00362 m_groupDigitize = new QActionGroup (this);
00363 m_groupDigitize->addAction (m_actionDigitizeSelect);
00364 m_groupDigitize->addAction (m_actionDigitizeAxis);
00365 m_groupDigitize->addAction (m_actionDigitizeCurve);
00366 m_groupDigitize->addAction (m_actionDigitizePointMatch);
00367 m_groupDigitize->addAction (m_actionDigitizeColorPicker);
00368 m_groupDigitize->addAction (m_actionDigitizeSegment);
00369 }
00370
00371 void MainWindow::createActionsEdit ()
00372 {
00373 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createActionsEdit";
00374
00375 m_actionEditUndo = new QAction(tr ("&Undo"), this);
00376 m_actionEditUndo->setShortcut (QKeySequence::Undo);
00377 m_actionEditUndo->setStatusTip (tr ("Undo the last operation."));
00378 m_actionEditUndo->setWhatsThis (tr ("Undo\n\n"
00379 "Undo the last operation."));
00380
00381
00382 m_actionEditRedo = new QAction(tr ("&Redo"), this);
00383 m_actionEditRedo->setShortcut (QKeySequence::Redo);
00384 m_actionEditRedo->setStatusTip (tr ("Redo the last operation."));
00385 m_actionEditRedo->setWhatsThis (tr ("Redo\n\n"
00386 "Redo the last operation."));
00387
00388
00389 m_actionEditCut = new QAction (tr ("Cut"), this);
00390 m_actionEditCut->setShortcut (QKeySequence::Cut);
00391 m_actionEditCut->setStatusTip (tr ("Cuts the selected points and copies them to the clipboard."));
00392 m_actionEditCut->setWhatsThis (tr ("Cut\n\n"
00393 "Cuts the selected points and copies them to the clipboard."));
00394 connect (m_actionEditCut, SIGNAL (triggered ()), this, SLOT (slotEditCut ()));
00395
00396 m_actionEditCopy = new QAction (tr ("Copy"), this);
00397 m_actionEditCopy->setShortcut (QKeySequence::Copy);
00398 m_actionEditCopy->setStatusTip (tr ("Copies the selected points to the clipboard."));
00399 m_actionEditCopy->setWhatsThis (tr ("Copy\n\n"
00400 "Copies the selected points to the clipboard."));
00401 connect (m_actionEditCopy, SIGNAL (triggered ()), this, SLOT (slotEditCopy ()));
00402
00403 m_actionEditPaste = new QAction (tr ("Paste"), this);
00404 m_actionEditPaste->setShortcut (QKeySequence::Paste);
00405 m_actionEditPaste->setStatusTip (tr ("Pastes the selected points from the clipboard."));
00406 m_actionEditPaste->setWhatsThis (tr ("Paste\n\n"
00407 "Pastes the selected points from the clipboard. They will be assigned to the current curve."));
00408 connect (m_actionEditPaste, SIGNAL (triggered ()), this, SLOT (slotEditPaste ()));
00409
00410 m_actionEditDelete = new QAction (tr ("Delete"), this);
00411 m_actionEditDelete->setShortcut (QKeySequence::Delete);
00412 m_actionEditDelete->setStatusTip (tr ("Deletes the selected points, after copying them to the clipboard."));
00413 m_actionEditDelete->setWhatsThis (tr ("Delete\n\n"
00414 "Deletes the selected points, after copying them to the clipboard."));
00415 connect (m_actionEditDelete, SIGNAL (triggered ()), this, SLOT (slotEditDelete ()));
00416
00417 m_actionEditPasteAsNew = new QAction (tr ("Paste As New"), this);
00418 m_actionEditPasteAsNew->setStatusTip (tr ("Pastes an image from the clipboard."));
00419 m_actionEditPasteAsNew->setWhatsThis (tr ("Paste as New\n\n"
00420 "Creates a new document by pasting an image from the clipboard."));
00421 connect (m_actionEditPasteAsNew, SIGNAL (triggered ()), this, SLOT (slotEditPasteAsNew ()));
00422
00423 m_actionEditPasteAsNewAdvanced = new QAction (tr ("Paste As New (Advanced)..."), this);
00424 m_actionEditPasteAsNewAdvanced->setStatusTip (tr ("Pastes an image from the clipboard, in advanced mode."));
00425 m_actionEditPasteAsNewAdvanced->setWhatsThis (tr ("Paste as New (Advanced)\n\n"
00426 "Creates a new document by pasting an image from the clipboard, in advanced mode."));
00427 connect (m_actionEditPasteAsNewAdvanced, SIGNAL (triggered ()), this, SLOT (slotEditPasteAsNewAdvanced ()));
00428 }
00429
00430 void MainWindow::createActionsFile ()
00431 {
00432 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createActionsFile";
00433
00434 m_actionImport = new QAction(tr ("&Import..."), this);
00435 m_actionImport->setShortcut (tr ("Ctrl+I"));
00436 m_actionImport->setStatusTip (tr ("Creates a new document by importing an simple image."));
00437 m_actionImport->setWhatsThis (tr ("Import Image\n\n"
00438 "Creates a new document by importing an image with a single coordinate system, "
00439 "and axes both coordinates known.\n\n"
00440 "For more complicated images with multiple coordinate systems, "
00441 "and/or floating axes, Import (Advanced) is used instead."));
00442 connect (m_actionImport, SIGNAL (triggered ()), this, SLOT (slotFileImport ()));
00443
00444 m_actionImportAdvanced = new QAction(tr ("Import (Advanced)..."), this);
00445 m_actionImportAdvanced->setStatusTip (tr ("Creates a new document by importing an image with support for advanced feaures."));
00446 m_actionImportAdvanced->setWhatsThis (tr ("Import (Advanced)\n\n"
00447 "Creates a new document by importing an image with support for advanced feaures. In "
00448 "advanced mode, there can be multiple coordinate systems and/or floating axes."));
00449 connect (m_actionImportAdvanced, SIGNAL (triggered ()), this, SLOT (slotFileImportAdvanced ()));
00450
00451 m_actionOpen = new QAction(tr ("&Open..."), this);
00452 m_actionOpen->setShortcut (QKeySequence::Open);
00453 m_actionOpen->setStatusTip (tr ("Opens an existing document."));
00454 m_actionOpen->setWhatsThis (tr ("Open Document\n\n"
00455 "Opens an existing document."));
00456 connect (m_actionOpen, SIGNAL (triggered ()), this, SLOT (slotFileOpen ()));
00457
00458 #ifndef OSX
00459 for (unsigned int i = 0; i < MAX_RECENT_FILE_LIST_SIZE; i++) {
00460 QAction *recentFileAction = new QAction (this);
00461 recentFileAction->setVisible (true);
00462 connect (recentFileAction, SIGNAL (triggered ()), this, SLOT (slotRecentFileAction ()));
00463 m_actionRecentFiles.append (recentFileAction);
00464 }
00465 #endif
00466
00467 m_actionClose = new QAction(tr ("&Close"), this);
00468 m_actionClose->setShortcut (QKeySequence::Close);
00469 m_actionClose->setStatusTip (tr ("Closes the open document document."));
00470 m_actionClose->setWhatsThis (tr ("Close Document\n\n"
00471 "Closes the open document."));
00472 connect (m_actionClose, SIGNAL (triggered ()), this, SLOT (slotFileClose ()));
00473
00474 m_actionSave = new QAction(tr ("&Save"), this);
00475 m_actionSave->setShortcut (QKeySequence::Save);
00476 m_actionSave->setStatusTip (tr ("Saves the current document."));
00477 m_actionSave->setWhatsThis (tr ("Save Document\n\n"
00478 "Saves the current document."));
00479 connect (m_actionSave, SIGNAL (triggered ()), this, SLOT (slotFileSave ()));
00480
00481 m_actionSaveAs = new QAction(tr ("Save As..."), this);
00482 m_actionSaveAs->setShortcut (QKeySequence::SaveAs);
00483 m_actionSaveAs->setStatusTip (tr ("Saves the current document under a new filename."));
00484 m_actionSaveAs->setWhatsThis (tr ("Save Document As\n\n"
00485 "Saves the current document under a new filename."));
00486 connect (m_actionSaveAs, SIGNAL (triggered ()), this, SLOT (slotFileSaveAs ()));
00487
00488 m_actionExport = new QAction (tr ("Export..."), this);
00489 m_actionExport->setShortcut (tr ("Ctrl+E"));
00490 m_actionExport->setStatusTip (tr ("Exports the current document into a text file."));
00491 m_actionExport->setWhatsThis (tr ("Export Document\n\n"
00492 "Exports the current document into a text file."));
00493 connect (m_actionExport, SIGNAL (triggered ()), this, SLOT (slotFileExport ()));
00494
00495 m_actionPrint = new QAction (tr ("&Print..."), this);
00496 m_actionPrint->setShortcut (QKeySequence::Print);
00497 m_actionPrint->setStatusTip (tr ("Print the current document."));
00498 m_actionPrint->setWhatsThis (tr ("Print Document\n\n"
00499 "Print the current document to a printer or file."));
00500 connect (m_actionPrint, SIGNAL (triggered ()), this, SLOT (slotFilePrint ()));
00501
00502 m_actionExit = new QAction(tr ("&Exit"), this);
00503 m_actionExit->setShortcut (QKeySequence::Quit);
00504 m_actionExit->setStatusTip (tr ("Quits the application."));
00505 m_actionExit->setWhatsThis (tr ("Exit\n\n"
00506 "Quits the application."));
00507 connect (m_actionExit, SIGNAL (triggered ()), this, SLOT (close ()));
00508 }
00509
00510 void MainWindow::createActionsHelp ()
00511 {
00512 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createActionsHelp";
00513
00514 m_actionHelpChecklistGuideWizard = new QAction (tr ("Checklist Guide Wizard"), this);
00515 m_actionHelpChecklistGuideWizard->setCheckable (true);
00516 m_actionHelpChecklistGuideWizard->setStatusTip (tr ("Open Checklist Guide Wizard during import to define digitizing steps"));
00517 m_actionHelpChecklistGuideWizard->setWhatsThis (tr ("Checklist Guide Wizard\n\n"
00518 "Use Checklist Guide Wizard during import to generate a checklist of steps "
00519 "for the imported document"));
00520
00521 m_actionHelpWhatsThis = QWhatsThis::createAction(this);
00522 m_actionHelpWhatsThis->setShortcut (QKeySequence::WhatsThis);
00523
00524 m_actionHelpTutorial = new QAction (tr ("Tutorial"), this);
00525 m_actionHelpTutorial->setStatusTip (tr ("Play tutorial showing steps for digitizing curves"));
00526 m_actionHelpTutorial->setWhatsThis (tr ("Tutorial\n\n"
00527 "Play tutorial showing steps for digitizing points from curves drawn with lines "
00528 "and/or point"));
00529 connect (m_actionHelpTutorial, SIGNAL (triggered ()), this, SLOT (slotHelpTutorial()));
00530
00531 m_actionHelpHelp = new QAction (tr ("Help"), this);
00532 m_actionHelpHelp->setShortcut (QKeySequence::HelpContents);
00533 m_actionHelpHelp->setStatusTip (tr ("Help documentation"));
00534 m_actionHelpHelp->setWhatsThis (tr ("Help Documentation\n\n"
00535 "Searchable help documentation"));
00536
00537
00538 m_actionHelpAbout = new QAction(tr ("About Engauge"), this);
00539 m_actionHelpAbout->setStatusTip (tr ("About the application."));
00540 m_actionHelpAbout->setWhatsThis (tr ("About Engauge\n\nAbout the application."));
00541 connect (m_actionHelpAbout, SIGNAL (triggered ()), this, SLOT (slotHelpAbout ()));
00542 }
00543
00544 void MainWindow::createActionsSettings ()
00545 {
00546 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createActionsSettings";
00547
00548 m_actionSettingsCoords = new QAction (tr ("Coordinates..."), this);
00549 m_actionSettingsCoords->setStatusTip (tr ("Edit Coordinate settings."));
00550 m_actionSettingsCoords->setWhatsThis (tr ("Coordinate Settings\n\n"
00551 "Coordinate settings determine how the graph coordinates are mapped to the pixels in the image"));
00552 connect (m_actionSettingsCoords, SIGNAL (triggered ()), this, SLOT (slotSettingsCoords ()));
00553
00554 m_actionSettingsCurveAddRemove = new QAction (tr ("Add/Remove Curve..."), this);
00555 m_actionSettingsCurveAddRemove->setStatusTip (tr ("Add or Remove Curves."));
00556 m_actionSettingsCurveAddRemove->setWhatsThis (tr ("Add/Remove Curve\n\n"
00557 "Add/Remove Curve settings control which curves are included in the current document"));
00558 connect (m_actionSettingsCurveAddRemove, SIGNAL (triggered ()), this, SLOT (slotSettingsCurveAddRemove ()));
00559
00560 m_actionSettingsCurveProperties = new QAction (tr ("Curve Properties..."), this);
00561 m_actionSettingsCurveProperties->setStatusTip (tr ("Edit Curve Properties settings."));
00562 m_actionSettingsCurveProperties->setWhatsThis (tr ("Curve Properties Settings\n\n"
00563 "Curves properties settings determine how each curve appears"));
00564 connect (m_actionSettingsCurveProperties, SIGNAL (triggered ()), this, SLOT (slotSettingsCurveProperties ()));
00565
00566 m_actionSettingsDigitizeCurve = new QAction (tr ("Digitize Curve..."), this);
00567 m_actionSettingsDigitizeCurve->setStatusTip (tr ("Edit Digitize Axis and Graph Curve settings."));
00568 m_actionSettingsDigitizeCurve->setWhatsThis (tr ("Digitize Axis and Graph Curve Settings\n\n"
00569 "Digitize Curve settings determine how points are digitized in Digitize Axis Point and "
00570 "Digitize Graph Point modes"));
00571 connect (m_actionSettingsDigitizeCurve, SIGNAL (triggered ()), this, SLOT (slotSettingsDigitizeCurve ()));
00572
00573 m_actionSettingsExport = new QAction (tr ("Export Format..."), this);
00574 m_actionSettingsExport->setStatusTip (tr ("Edit Export Format settings."));
00575 m_actionSettingsExport->setWhatsThis (tr ("Export Format Settings\n\n"
00576 "Export format settings affect how exported files are formatted"));
00577 connect (m_actionSettingsExport, SIGNAL (triggered ()), this, SLOT (slotSettingsExportFormat ()));
00578
00579 m_actionSettingsColorFilter = new QAction (tr ("Color Filter..."), this);
00580 m_actionSettingsColorFilter->setStatusTip (tr ("Edit Color Filter settings."));
00581 m_actionSettingsColorFilter->setWhatsThis (tr ("Color Filter Settings\n\n"
00582 "Color filtering simplifies the graphs for easier Point Matching and Segment Filling"));
00583 connect (m_actionSettingsColorFilter, SIGNAL (triggered ()), this, SLOT (slotSettingsColorFilter ()));
00584
00585 m_actionSettingsAxesChecker = new QAction (tr ("Axes Checker..."), this);
00586 m_actionSettingsAxesChecker->setStatusTip (tr ("Edit Axes Checker settings."));
00587 m_actionSettingsAxesChecker->setWhatsThis (tr ("Axes Checker Settings\n\n"
00588 "Axes checker can reveal any axis point mistakes, which are otherwise hard to find."));
00589 connect (m_actionSettingsAxesChecker, SIGNAL (triggered ()), this, SLOT (slotSettingsAxesChecker ()));
00590
00591 m_actionSettingsGridDisplay = new QAction (tr ("Grid Line Display..."), this);
00592 m_actionSettingsGridDisplay->setStatusTip (tr ("Edit Grid Line Display settings."));
00593 m_actionSettingsGridDisplay->setWhatsThis (tr ("Grid Line Display Settings\n\n"
00594 "Grid lines displayed on the graph can provide more accuracy than the Axis Checker, for distorted graphs. "
00595 "In a distorted graph, the grid lines can be used to adjust the axis points for more accuracy in different regions."));
00596 connect (m_actionSettingsGridDisplay, SIGNAL (triggered ()), this, SLOT (slotSettingsGridDisplay ()));
00597
00598 m_actionSettingsGridRemoval = new QAction (tr ("Grid Line Removal..."), this);
00599 m_actionSettingsGridRemoval->setStatusTip (tr ("Edit Grid Line Removal settings."));
00600 m_actionSettingsGridRemoval->setWhatsThis (tr ("Grid Line Removal Settings\n\n"
00601 "Grid line removal isolates curve lines for easier Point Matching and Segment Filling, when "
00602 "Color Filtering is not able to separate grid lines from curve lines."));
00603 connect (m_actionSettingsGridRemoval, SIGNAL (triggered ()), this, SLOT (slotSettingsGridRemoval ()));
00604
00605 m_actionSettingsPointMatch = new QAction (tr ("Point Match..."), this);
00606 m_actionSettingsPointMatch->setStatusTip (tr ("Edit Point Match settings."));
00607 m_actionSettingsPointMatch->setWhatsThis (tr ("Point Match Settings\n\n"
00608 "Point match settings determine how points are matched while in Point Match mode"));
00609 connect (m_actionSettingsPointMatch, SIGNAL (triggered ()), this, SLOT (slotSettingsPointMatch ()));
00610
00611 m_actionSettingsSegments = new QAction (tr ("Segment Fill..."), this);
00612 m_actionSettingsSegments->setStatusTip (tr ("Edit Segment Fill settings."));
00613 m_actionSettingsSegments->setWhatsThis (tr ("Segment Fill Settings\n\n"
00614 "Segment fill settings determine how points are generated in the Segment Fill mode"));
00615 connect (m_actionSettingsSegments, SIGNAL (triggered ()), this, SLOT (slotSettingsSegments ()));
00616
00617 m_actionSettingsGeneral = new QAction (tr ("General..."), this);
00618 m_actionSettingsGeneral->setStatusTip (tr ("Edit General settings."));
00619 m_actionSettingsGeneral->setWhatsThis (tr ("General Settings\n\n"
00620 "General settings are document-specific settings that affect multiple modes. For example, the cursor size setting affects "
00621 "both Color Picker and Point Match modes"));
00622 connect (m_actionSettingsGeneral, SIGNAL (triggered ()), this, SLOT (slotSettingsGeneral ()));
00623
00624 m_actionSettingsMainWindow = new QAction (tr ("Main Window..."), this);
00625 m_actionSettingsMainWindow->setEnabled (true);
00626 m_actionSettingsMainWindow->setStatusTip (tr ("Edit Main Window settings."));
00627 m_actionSettingsMainWindow->setWhatsThis (tr ("Main Window Settings\n\n"
00628 "Main window settings affect the user interface and are not specific to any document"));
00629 connect (m_actionSettingsMainWindow, SIGNAL (triggered ()), this, SLOT (slotSettingsMainWindow ()));
00630 }
00631
00632 void MainWindow::createActionsView ()
00633 {
00634 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createActionsView";
00635
00636 m_actionViewBackground = new QAction (tr ("Background Toolbar"), this);
00637 m_actionViewBackground->setCheckable (true);
00638 m_actionViewBackground->setChecked (true);
00639 m_actionViewBackground->setStatusTip (tr ("Show or hide the background toolbar."));
00640 m_actionViewBackground->setWhatsThis (tr ("View Background ToolBar\n\n"
00641 "Show or hide the background toolbar"));
00642 connect (m_actionViewBackground, SIGNAL (triggered ()), this, SLOT (slotViewToolBarBackground ()));
00643
00644 m_actionViewChecklistGuide = new QAction (tr ("Checklist Guide Toolbar"), this);
00645 m_actionViewChecklistGuide->setCheckable (true);
00646 m_actionViewChecklistGuide->setChecked (false);
00647 m_actionViewChecklistGuide->setStatusTip (tr ("Show or hide the checklist guide toolbar."));
00648 m_actionViewChecklistGuide->setWhatsThis (tr ("View Checklist Guide ToolBar\n\n"
00649 "Show or hide the checklist guide toolbar"));
00650 connect (m_actionViewChecklistGuide, SIGNAL (changed ()), this, SLOT (slotViewToolBarChecklistGuide()));
00651
00652 m_actionViewDigitize = new QAction (tr ("Digitizing Tools Toolbar"), this);
00653 m_actionViewDigitize->setCheckable (true);
00654 m_actionViewDigitize->setChecked (true);
00655 m_actionViewDigitize->setStatusTip (tr ("Show or hide the digitizing tools toolbar."));
00656 m_actionViewDigitize->setWhatsThis (tr ("View Digitizing Tools ToolBar\n\n"
00657 "Show or hide the digitizing tools toolbar"));
00658 connect (m_actionViewDigitize, SIGNAL (triggered ()), this, SLOT (slotViewToolBarDigitize()));
00659
00660 m_actionViewSettingsViews = new QAction (tr ("Settings Views Toolbar"), this);
00661 m_actionViewSettingsViews->setCheckable (true);
00662 m_actionViewSettingsViews->setChecked (true);
00663 m_actionViewSettingsViews->setStatusTip (tr ("Show or hide the settings views toolbar."));
00664 m_actionViewSettingsViews->setWhatsThis (tr ("View Settings Views ToolBar\n\n"
00665 "Show or hide the settings views toolbar. These views graphically show the "
00666 "most important settings."));
00667 connect (m_actionViewSettingsViews, SIGNAL (triggered ()), this, SLOT (slotViewToolBarSettingsViews()));
00668
00669 m_actionViewCoordSystem = new QAction (tr ("Coordinate System Toolbar"), this);
00670 m_actionViewCoordSystem->setCheckable (true);
00671 m_actionViewCoordSystem->setChecked (false);
00672 m_actionViewCoordSystem->setStatusTip (tr ("Show or hide the coordinate system toolbar."));
00673 m_actionViewCoordSystem->setWhatsThis (tr ("View Coordinate Systems ToolBar\n\n"
00674 "Show or hide the coordinate system selection toolbar. This toolbar is used "
00675 "to select the current coordinate system when the document has multiple "
00676 "coordinate systems. This toolbar is also used to view and print all coordinate "
00677 "systems.\n\n"
00678 "This toolbar is disabled when there is only one coordinate system."));
00679 connect (m_actionViewCoordSystem, SIGNAL (triggered ()), this, SLOT (slotViewToolBarCoordSystem()));
00680
00681 m_actionViewToolTips = new QAction (tr ("Tool Tips"), this);
00682 m_actionViewToolTips->setCheckable (true);
00683 m_actionViewToolTips->setChecked (true);
00684 m_actionViewToolTips->setStatusTip (tr ("Show or hide the tool tips."));
00685 m_actionViewToolTips->setWhatsThis (tr ("View Tool Tips\n\n"
00686 "Show or hide the tool tips"));
00687 connect (m_actionViewToolTips, SIGNAL (triggered ()), this, SLOT (slotViewToolTips()));
00688
00689 m_actionViewGridLines = new QAction (tr ("Grid Lines"), this);
00690 m_actionViewGridLines->setCheckable (true);
00691 m_actionViewGridLines->setChecked (false);
00692 m_actionViewGridLines->setStatusTip (tr ("Show or hide grid lines."));
00693 m_actionViewGridLines->setWhatsThis (tr ("View Grid Lines\n\n"
00694 "Show or hide grid lines that are added for accurate adjustments of the axes points, "
00695 "which can improve accuracy in distorted graphs"));
00696 connect (m_actionViewGridLines, SIGNAL (triggered ()), this, SLOT (slotViewGridLines()));
00697
00698 m_actionViewBackgroundNone = new QAction (tr ("No Background"), this);
00699 m_actionViewBackgroundNone->setCheckable (true);
00700 m_actionViewBackgroundNone->setStatusTip (tr ("Do not show the image underneath the points."));
00701 m_actionViewBackgroundNone->setWhatsThis (tr ("No Background\n\n"
00702 "No image is shown so points are easier to see"));
00703
00704 m_actionViewBackgroundOriginal = new QAction (tr ("Show Original Image"), this);
00705 m_actionViewBackgroundOriginal->setCheckable (true);
00706 m_actionViewBackgroundOriginal->setStatusTip (tr ("Show the original image underneath the points."));
00707 m_actionViewBackgroundOriginal->setWhatsThis (tr ("Show Original Image\n\n"
00708 "Show the original image underneath the points"));
00709
00710 m_actionViewBackgroundFiltered = new QAction (tr ("Show Filtered Image"), this);
00711 m_actionViewBackgroundFiltered->setCheckable (true);
00712 m_actionViewBackgroundFiltered->setChecked (true);
00713 m_actionViewBackgroundFiltered->setStatusTip (tr ("Show the filtered image underneath the points."));
00714 m_actionViewBackgroundFiltered->setWhatsThis (tr ("Show Filtered Image\n\n"
00715 "Show the filtered image underneath the points.\n\n"
00716 "The filtered image is created from the original image according to the "
00717 "Filter preferences so unimportant information is hidden and important "
00718 "information is emphasized"));
00719
00720 m_actionViewCurvesNone = new QAction (tr ("Hide All Curves"), this);
00721 m_actionViewCurvesNone->setCheckable (true);
00722 m_actionViewCurvesNone->setStatusTip (tr ("Hide all digitized curves."));
00723 m_actionViewCurvesNone->setWhatsThis (tr ("Hide All Curves\n\n"
00724 "No axis points or digitized graph curves are shown so the image is easier to see."));
00725
00726 m_actionViewCurvesSelected = new QAction (tr ("Show Selected Curve"), this);
00727 m_actionViewCurvesSelected->setCheckable (true);
00728 m_actionViewCurvesSelected->setStatusTip (tr ("Show only the currently selected curve."));
00729 m_actionViewCurvesSelected->setWhatsThis (tr ("Show Selected Curve\n\n"
00730 "Show only the digitized points and line that belong to the currently selected curve."));
00731
00732 m_actionViewCurvesAll = new QAction (tr ("Show All Curves"), this);
00733 m_actionViewCurvesAll->setCheckable (true);
00734 m_actionViewCurvesAll->setChecked (true);
00735 m_actionViewCurvesAll->setStatusTip (tr ("Show all curves."));
00736 m_actionViewCurvesAll->setWhatsThis (tr ("Show All Curves\n\n"
00737 "Show all digitized axis points and graph curves"));
00738
00739 m_groupBackground = new QActionGroup(this);
00740 m_groupBackground->addAction (m_actionViewBackgroundNone);
00741 m_groupBackground->addAction (m_actionViewBackgroundOriginal);
00742 m_groupBackground->addAction (m_actionViewBackgroundFiltered);
00743 connect (m_groupBackground, SIGNAL(triggered (QAction*)), this, SLOT (slotViewGroupBackground(QAction*)));
00744
00745 m_groupCurves = new QActionGroup(this);
00746 m_groupCurves->addAction (m_actionViewCurvesNone);
00747 m_groupCurves->addAction (m_actionViewCurvesSelected);
00748 m_groupCurves->addAction (m_actionViewCurvesAll);
00749 connect (m_groupCurves, SIGNAL(triggered (QAction*)), this, SLOT (slotViewGroupCurves(QAction*)));
00750
00751 m_actionStatusNever = new QAction (tr ("Hide Always"), this);
00752 m_actionStatusNever->setCheckable(true);
00753 m_actionStatusNever->setStatusTip (tr ("Always hide the status bar."));
00754 m_actionStatusNever->setWhatsThis (tr ("Hide the status bar. No temporary status or feedback messages will appear."));
00755
00756 m_actionStatusTemporary = new QAction (tr ("Show Temporary Messages"), this);
00757 m_actionStatusTemporary->setCheckable(true);
00758 m_actionStatusTemporary->setStatusTip (tr ("Hide the status bar except when display temporary messages."));
00759 m_actionStatusTemporary->setWhatsThis (tr ("Hide the status bar, except when displaying temporary status and feedback messages."));
00760
00761 m_actionStatusAlways = new QAction (tr ("Show Always"), this);
00762 m_actionStatusAlways->setCheckable(true);
00763 m_actionStatusAlways->setStatusTip (tr ("Always show the status bar."));
00764 m_actionStatusAlways->setWhatsThis (tr ("Show the status bar. Besides displaying temporary status and feedback messages, "
00765 "the status bar also displays information about the cursor position."));
00766
00767 m_groupStatus = new QActionGroup(this);
00768 m_groupStatus->addAction (m_actionStatusNever);
00769 m_groupStatus->addAction (m_actionStatusTemporary);
00770 m_groupStatus->addAction (m_actionStatusAlways);
00771 connect (m_groupStatus, SIGNAL (triggered (QAction*)), this, SLOT (slotViewGroupStatus(QAction*)));
00772
00773 m_actionZoomOut = new QAction (tr ("Zoom Out"), this);
00774 m_actionZoomOut->setStatusTip (tr ("Zoom out"));
00775
00776 connect (m_actionZoomOut, SIGNAL (triggered ()), this, SLOT (slotViewZoomOut ()));
00777
00778 m_actionZoomIn = new QAction (tr ("Zoom In"), this);
00779 m_actionZoomIn->setStatusTip (tr ("Zoom in"));
00780
00781 connect (m_actionZoomIn, SIGNAL (triggered ()), this, SLOT (slotViewZoomIn ()));
00782
00783 m_actionZoom16To1 = new QAction (tr ("16:1 (1600%)"), this);
00784 m_actionZoom16To1->setCheckable (true);
00785 m_actionZoom16To1->setStatusTip (tr ("Zoom 16:1"));
00786 connect (m_actionZoom16To1, SIGNAL (triggered ()), this, SLOT (slotViewZoom16To1 ()));
00787
00788 m_actionZoom8To1 = new QAction (tr ("8:1 (800%)"), this);
00789 m_actionZoom8To1->setCheckable (true);
00790 m_actionZoom8To1->setStatusTip (tr ("Zoom 8:1"));
00791 connect (m_actionZoom8To1, SIGNAL (triggered ()), this, SLOT (slotViewZoom8To1 ()));
00792
00793 m_actionZoom4To1 = new QAction (tr ("4:1 (400%)"), this);
00794 m_actionZoom4To1->setCheckable (true);
00795 m_actionZoom4To1->setStatusTip (tr ("Zoom 4:1"));
00796 connect (m_actionZoom4To1, SIGNAL (triggered ()), this, SLOT (slotViewZoom4To1 ()));
00797
00798 m_actionZoom2To1 = new QAction (tr ("2:1 (200%)"), this);
00799 m_actionZoom2To1->setCheckable (true);
00800 m_actionZoom2To1->setStatusTip (tr ("Zoom 2:1"));
00801 connect (m_actionZoom2To1, SIGNAL (triggered ()), this, SLOT (slotViewZoom2To1 ()));
00802
00803 m_actionZoom1To1 = new QAction (tr ("1:1 (100%)"), this);
00804 m_actionZoom1To1->setCheckable (true);
00805 m_actionZoom1To1->setChecked (true);
00806 m_actionZoom1To1->setStatusTip (tr ("Zoom 6:1"));
00807 connect (m_actionZoom1To1, SIGNAL (triggered ()), this, SLOT (slotViewZoom1To1 ()));
00808
00809 m_actionZoom1To2 = new QAction (tr ("1:2 (50%)"), this);
00810 m_actionZoom1To2->setCheckable (true);
00811 m_actionZoom1To2->setStatusTip (tr ("Zoom 1:2"));
00812 connect (m_actionZoom1To2, SIGNAL (triggered ()), this, SLOT (slotViewZoom1To2 ()));
00813
00814 m_actionZoom1To4 = new QAction (tr ("1:4 (25%)"), this);
00815 m_actionZoom1To4->setCheckable (true);
00816 m_actionZoom1To4->setStatusTip (tr ("Zoom 1:4"));
00817 connect (m_actionZoom1To4, SIGNAL (triggered ()), this, SLOT (slotViewZoom1To4 ()));
00818
00819 m_actionZoom1To8 = new QAction (tr ("1:8 (12.5%)"), this);
00820 m_actionZoom1To8->setCheckable (true);
00821 m_actionZoom1To8->setStatusTip (tr ("Zoom 1:8"));
00822 connect (m_actionZoom1To8, SIGNAL (triggered ()), this, SLOT (slotViewZoom1To8 ()));
00823
00824 m_actionZoom1To16 = new QAction (tr ("1:16 (6.25%)"), this);
00825 m_actionZoom1To16->setCheckable (true);
00826 m_actionZoom1To16->setStatusTip (tr ("Zoom 1:16"));
00827 connect (m_actionZoom1To16, SIGNAL (triggered ()), this, SLOT (slotViewZoom1To16 ()));
00828
00829 m_actionZoomFill = new QAction (tr ("Fill"), this);
00830 m_actionZoomFill->setCheckable (true);
00831 m_actionZoomFill->setStatusTip (tr ("Zoom with stretching to fill window"));
00832 connect (m_actionZoomFill, SIGNAL (triggered ()), this, SLOT (slotViewZoomFill ()));
00833
00834 m_groupZoom = new QActionGroup (this);
00835 m_groupZoom->addAction (m_actionZoom16To1);
00836 m_groupZoom->addAction (m_actionZoom8To1);
00837 m_groupZoom->addAction (m_actionZoom4To1);
00838 m_groupZoom->addAction (m_actionZoom2To1);
00839 m_groupZoom->addAction (m_actionZoom1To1);
00840 m_groupZoom->addAction (m_actionZoom1To2);
00841 m_groupZoom->addAction (m_actionZoom1To4);
00842 m_groupZoom->addAction (m_actionZoom1To8);
00843 m_groupZoom->addAction (m_actionZoom1To16);
00844 m_groupZoom->addAction (m_actionZoomFill);
00845 }
00846
00847 void MainWindow::createCentralWidget ()
00848 {
00849 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createCentralWidget";
00850
00851 QWidget *widget = new QWidget;
00852 setCentralWidget (widget);
00853 m_layout = new QVBoxLayout;
00854 widget->setLayout (m_layout);
00855 }
00856
00857 void MainWindow::createCommandStackShadow ()
00858 {
00859 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createCommandStackShadow";
00860
00861 m_cmdStackShadow = new CmdStackShadow;
00862 }
00863
00864 void MainWindow::createHelpWindow ()
00865 {
00866 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createHelpWindow";
00867
00868 m_helpWindow = new HelpWindow (this);
00869 m_helpWindow->hide ();
00870 addDockWidget (Qt::RightDockWidgetArea,
00871 m_helpWindow);
00872 m_helpWindow->setFloating (true);
00873
00874 connect (m_actionHelpHelp, SIGNAL (triggered ()), m_helpWindow, SLOT (show ()));
00875 }
00876
00877 void MainWindow::createIcons()
00878 {
00879 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createIcons";
00880
00881 QIcon icon;
00882 QPixmap icon16 (bannerapp_16);
00883 QPixmap icon32 (bannerapp_32);
00884 QPixmap icon64 (bannerapp_64);
00885 QPixmap icon128 (bannerapp_128);
00886 QPixmap icon256 (bannerapp_256);
00887
00888 icon.addPixmap (icon16);
00889 icon.addPixmap (icon32);
00890 icon.addPixmap (icon64);
00891 icon.addPixmap (icon128);
00892 icon.addPixmap (icon256);
00893
00894 setWindowIcon (icon);
00895 }
00896
00897 void MainWindow::createLoadImageFromUrl ()
00898 {
00899 m_loadImageFromUrl = new LoadImageFromUrl (*this);
00900 }
00901
00902 void MainWindow::createMenus()
00903 {
00904 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createMenus";
00905
00906 m_menuFile = menuBar()->addMenu(tr("&File"));
00907 m_menuFile->addAction (m_actionImport);
00908 m_menuFile->addAction (m_actionImportAdvanced);
00909 m_menuFile->addAction (m_actionOpen);
00910 #ifndef OSX
00911 m_menuFileOpenRecent = new QMenu (tr ("Open &Recent"));
00912 for (unsigned int i = 0; i < MAX_RECENT_FILE_LIST_SIZE; i++) {
00913 m_menuFileOpenRecent->addAction (m_actionRecentFiles.at (i));
00914 }
00915 m_menuFile->addMenu (m_menuFileOpenRecent);
00916 #endif
00917 m_menuFile->addAction (m_actionClose);
00918 m_menuFile->insertSeparator (m_actionSave);
00919 m_menuFile->addAction (m_actionSave);
00920 m_menuFile->addAction (m_actionSaveAs);
00921 m_menuFile->addAction (m_actionExport);
00922 m_menuFile->insertSeparator (m_actionPrint);
00923 m_menuFile->addAction (m_actionPrint);
00924 m_menuFile->insertSeparator (m_actionExit);
00925 m_menuFile->addAction (m_actionExit);
00926
00927 m_menuEdit = menuBar()->addMenu(tr("&Edit"));
00928 connect (m_menuEdit, SIGNAL (aboutToShow ()), this, SLOT (slotEditMenu ()));
00929 m_menuEdit->addAction (m_actionEditUndo);
00930 m_menuEdit->addAction (m_actionEditRedo);
00931 m_menuEdit->insertSeparator (m_actionEditCut);
00932 m_menuEdit->addAction (m_actionEditCut);
00933 m_menuEdit->addAction (m_actionEditCopy);
00934 m_menuEdit->addAction (m_actionEditPaste);
00935 m_menuEdit->addAction (m_actionEditDelete);
00936 m_menuEdit->insertSeparator (m_actionEditPasteAsNew);
00937 m_menuEdit->addAction (m_actionEditPasteAsNew);
00938 m_menuEdit->addAction (m_actionEditPasteAsNewAdvanced);
00939
00940 m_menuDigitize = menuBar()->addMenu(tr("Digitize"));
00941 m_menuDigitize->addAction (m_actionDigitizeSelect);
00942 m_menuDigitize->addAction (m_actionDigitizeAxis);
00943 m_menuDigitize->addAction (m_actionDigitizeCurve);
00944 m_menuDigitize->addAction (m_actionDigitizePointMatch);
00945 m_menuDigitize->addAction (m_actionDigitizeColorPicker);
00946 m_menuDigitize->addAction (m_actionDigitizeSegment);
00947
00948 m_menuView = menuBar()->addMenu(tr("View"));
00949 m_menuView->addAction (m_actionViewBackground);
00950 m_menuView->addAction (m_actionViewDigitize);
00951 m_menuView->addAction (m_actionViewChecklistGuide);
00952 m_menuView->addAction (m_actionViewSettingsViews);
00953 m_menuView->addAction (m_actionViewCoordSystem);
00954 m_menuView->insertSeparator (m_actionViewToolTips);
00955 m_menuView->addAction (m_actionViewToolTips);
00956 m_menuView->addAction (m_actionViewGridLines);
00957 m_menuView->insertSeparator (m_actionViewBackgroundNone);
00958 m_menuViewBackground = new QMenu (tr ("Background"));
00959 m_menuViewBackground->addAction (m_actionViewBackgroundNone);
00960 m_menuViewBackground->addAction (m_actionViewBackgroundOriginal);
00961 m_menuViewBackground->addAction (m_actionViewBackgroundFiltered);
00962 m_menuView->addMenu (m_menuViewBackground);
00963 m_menuViewCurves = new QMenu (tr ("Curves"));
00964 m_menuViewCurves->addAction (m_actionViewCurvesNone);
00965 m_menuViewCurves->addAction (m_actionViewCurvesSelected);
00966 m_menuViewCurves->addAction (m_actionViewCurvesAll);
00967 m_menuView->addMenu (m_menuViewCurves);
00968 m_menuViewStatus = new QMenu (tr ("Status Bar"));
00969 m_menuViewStatus->addAction (m_actionStatusNever);
00970 m_menuViewStatus->addAction (m_actionStatusTemporary);
00971 m_menuViewStatus->addAction (m_actionStatusAlways);
00972 m_menuView->addMenu (m_menuViewStatus);
00973 m_menuViewZoom = new QMenu (tr ("Zoom"));
00974 m_menuViewZoom->addAction (m_actionZoomOut);
00975 m_menuViewZoom->addAction (m_actionZoomIn);
00976 m_menuViewZoom->insertSeparator (m_actionZoom16To1);
00977 m_menuViewZoom->addAction (m_actionZoom16To1);
00978 m_menuViewZoom->addAction (m_actionZoom8To1);
00979 m_menuViewZoom->addAction (m_actionZoom4To1);
00980 m_menuViewZoom->addAction (m_actionZoom2To1);
00981 m_menuViewZoom->addAction (m_actionZoom1To1);
00982 m_menuViewZoom->addAction (m_actionZoom1To2);
00983 m_menuViewZoom->addAction (m_actionZoom1To4);
00984 m_menuViewZoom->addAction (m_actionZoom1To8);
00985 m_menuViewZoom->addAction (m_actionZoom1To16);
00986 m_menuViewZoom->addAction (m_actionZoomFill);
00987 m_menuView->addMenu (m_menuViewZoom);
00988
00989 m_menuSettings = menuBar()->addMenu(tr ("Settings"));
00990 m_menuSettings->addAction (m_actionSettingsCoords);
00991 m_menuSettings->addAction (m_actionSettingsCurveAddRemove);
00992 m_menuSettings->addAction (m_actionSettingsCurveProperties);
00993 m_menuSettings->addAction (m_actionSettingsDigitizeCurve);
00994 m_menuSettings->addAction (m_actionSettingsExport);
00995 m_menuSettings->addAction (m_actionSettingsColorFilter);
00996 m_menuSettings->addAction (m_actionSettingsAxesChecker);
00997 m_menuSettings->addAction (m_actionSettingsGridDisplay);
00998 m_menuSettings->addAction (m_actionSettingsGridRemoval);
00999 m_menuSettings->addAction (m_actionSettingsPointMatch);
01000 m_menuSettings->addAction (m_actionSettingsSegments);
01001 m_menuSettings->insertSeparator (m_actionSettingsGeneral);
01002 m_menuSettings->addAction (m_actionSettingsGeneral);
01003 m_menuSettings->addAction (m_actionSettingsMainWindow);
01004
01005 m_menuHelp = menuBar()->addMenu(tr("&Help"));
01006 m_menuHelp->addAction (m_actionHelpChecklistGuideWizard);
01007 m_menuHelp->insertSeparator(m_actionHelpWhatsThis);
01008 m_menuHelp->addAction (m_actionHelpWhatsThis);
01009 m_menuHelp->addAction (m_actionHelpTutorial);
01010 m_menuHelp->addAction (m_actionHelpHelp);
01011 m_menuHelp->addAction (m_actionHelpAbout);
01012
01013 updateRecentFileList();
01014 }
01015
01016 void MainWindow::createNetwork ()
01017 {
01018 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createNetwork";
01019
01020 m_networkClient = new NetworkClient (this);
01021 }
01022
01023 void MainWindow::createSettingsDialogs ()
01024 {
01025 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createSettingsDialogs";
01026
01027 m_dlgSettingsCoords = new DlgSettingsCoords (*this);
01028 m_dlgSettingsCurveAddRemove = new DlgSettingsCurveAddRemove (*this);
01029 m_dlgSettingsCurveProperties = new DlgSettingsCurveProperties (*this);
01030 m_dlgSettingsDigitizeCurve = new DlgSettingsDigitizeCurve (*this);
01031 m_dlgSettingsExportFormat = new DlgSettingsExportFormat (*this);
01032 m_dlgSettingsColorFilter = new DlgSettingsColorFilter (*this);
01033 m_dlgSettingsAxesChecker = new DlgSettingsAxesChecker (*this);
01034 m_dlgSettingsGridDisplay = new DlgSettingsGridDisplay (*this);
01035 m_dlgSettingsGridRemoval = new DlgSettingsGridRemoval (*this);
01036 m_dlgSettingsPointMatch = new DlgSettingsPointMatch (*this);
01037 m_dlgSettingsSegments = new DlgSettingsSegments (*this);
01038 m_dlgSettingsGeneral = new DlgSettingsGeneral (*this);
01039 m_dlgSettingsMainWindow = new DlgSettingsMainWindow (*this);
01040
01041 m_dlgSettingsCoords->setVisible (false);
01042 m_dlgSettingsCurveAddRemove->setVisible (false);
01043 m_dlgSettingsCurveProperties->setVisible (false);
01044 m_dlgSettingsDigitizeCurve->setVisible (false);
01045 m_dlgSettingsExportFormat->setVisible (false);
01046 m_dlgSettingsColorFilter->setVisible (false);
01047 m_dlgSettingsAxesChecker->setVisible (false);
01048 m_dlgSettingsGridDisplay->setVisible (false);
01049 m_dlgSettingsGridRemoval->setVisible (false);
01050 m_dlgSettingsPointMatch->setVisible (false);
01051 m_dlgSettingsSegments->setVisible (false);
01052 m_dlgSettingsGeneral->setVisible (false);
01053 m_dlgSettingsMainWindow->setVisible (false);
01054 }
01055
01056 void MainWindow::createScene ()
01057 {
01058 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createScene";
01059
01060 m_scene = new GraphicsScene (this);
01061 m_view = new GraphicsView (m_scene, *this);
01062 m_layout->addWidget (m_view);
01063 }
01064
01065 void MainWindow::createStateContextBackground ()
01066 {
01067 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createStateContextBackground";
01068
01069 m_backgroundStateContext = new BackgroundStateContext (*this);
01070 }
01071
01072 void MainWindow::createStateContextDigitize ()
01073 {
01074 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createStateContextDigitize";
01075
01076 m_digitizeStateContext = new DigitizeStateContext (*this,
01077 *m_view,
01078 m_isGnuplot);
01079 }
01080
01081 void MainWindow::createStateContextTransformation ()
01082 {
01083 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createStateContextTransformation";
01084
01085 ENGAUGE_CHECK_PTR (m_scene);
01086
01087 m_transformationStateContext = new TransformationStateContext (*m_scene,
01088 m_isGnuplot);
01089 }
01090
01091 void MainWindow::createStatusBar ()
01092 {
01093 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createStatusBar";
01094
01095 m_statusBar = new StatusBar (*statusBar ());
01096 connect (this, SIGNAL (signalZoom(int)), m_statusBar, SLOT (slotZoom(int)));
01097 connect (m_statusBar, SIGNAL (signalZoom (int)), this, SLOT (slotViewZoom (int)));
01098 }
01099
01100 void MainWindow::createToolBars ()
01101 {
01102 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createToolBars";
01103
01104 const int VIEW_SIZE = 22;
01105
01106
01107 m_cmbBackground = new QComboBox ();
01108 m_cmbBackground->setEnabled (false);
01109 m_cmbBackground->setStatusTip (tr ("Select background image"));
01110 m_cmbBackground->setWhatsThis (tr ("Selected Background\n\n"
01111 "Select background image:\n"
01112 "1) No background which highlights points\n"
01113 "2) Original image which shows everything\n"
01114 "3) Filtered image which highlights important details"));
01115 m_cmbBackground->addItem (tr ("No background"), QVariant (BACKGROUND_IMAGE_NONE));
01116 m_cmbBackground->addItem (tr ("Original image"), QVariant (BACKGROUND_IMAGE_ORIGINAL));
01117 m_cmbBackground->addItem (tr ("Filtered image"), QVariant (BACKGROUND_IMAGE_FILTERED));
01118
01119 connect (m_cmbBackground, SIGNAL (currentIndexChanged (int)), this, SLOT (slotCmbBackground (int)));
01120
01121
01122 m_toolBackground = new QToolBar (tr ("Background"), this);
01123 m_toolBackground->addWidget (m_cmbBackground);
01124 addToolBar (m_toolBackground);
01125
01126
01127 m_cmbCurve = new QComboBox ();
01128 m_cmbCurve->setEnabled (false);
01129 m_cmbCurve->setMinimumWidth (180);
01130 m_cmbCurve->setStatusTip (tr ("Select curve for new points."));
01131 m_cmbCurve->setWhatsThis (tr ("Selected Curve Name\n\n"
01132 "Select curve for any new points. Every point belongs to one curve."));
01133 connect (m_cmbCurve, SIGNAL (activated (int)), this, SLOT (slotCmbCurve (int)));
01134
01135
01136 m_toolDigitize = new QToolBar (tr ("Drawing"), this);
01137 m_toolDigitize->addAction (m_actionDigitizeSelect);
01138 m_toolDigitize->insertSeparator (m_actionDigitizeAxis);
01139 m_toolDigitize->addAction (m_actionDigitizeAxis);
01140 m_toolDigitize->insertSeparator (m_actionDigitizeCurve);
01141 m_toolDigitize->addAction (m_actionDigitizeCurve);
01142 m_toolDigitize->addAction (m_actionDigitizePointMatch);
01143 m_toolDigitize->addAction (m_actionDigitizeColorPicker);
01144 m_toolDigitize->addAction (m_actionDigitizeSegment);
01145 m_toolDigitize->addWidget (m_cmbCurve);
01146 addToolBar (m_toolDigitize);
01147
01148
01149 m_viewPointStyle = new ViewPointStyle();
01150 m_viewPointStyle->setMinimumSize(VIEW_SIZE, VIEW_SIZE);
01151 m_viewPointStyle->setMaximumSize(VIEW_SIZE, VIEW_SIZE);
01152 m_viewPointStyle->setStatusTip (tr ("Points style for the currently selected curve"));
01153 m_viewPointStyle->setWhatsThis (tr ("Points Style\n\n"
01154 "Points style for the currently selected curve. The points style is only "
01155 "displayed in this toolbar. To change the points style, "
01156 "use the Curve Properties dialog."));
01157
01158 m_viewSegmentFilter = new ViewSegmentFilter();
01159 m_viewSegmentFilter->setMinimumSize(VIEW_SIZE, VIEW_SIZE);
01160 m_viewSegmentFilter->setMaximumSize(VIEW_SIZE, VIEW_SIZE);
01161 m_viewSegmentFilter->setStatusTip (tr ("View of filter for current curve in Segment Fill mode"));
01162 m_viewSegmentFilter->setWhatsThis (tr ("Segment Fill Filter\n\n"
01163 "View of filter for the current curve in Segment Fill mode. The filter settings are only "
01164 "displayed in this toolbar. To changed the filter settings, "
01165 "use the Color Picker mode or the Filter Settings dialog."));
01166
01167
01168 m_toolSettingsViews = new QToolBar (tr ("Views"), this);
01169 m_toolSettingsViews->addWidget (m_viewPointStyle);
01170 m_toolSettingsViews->addWidget (new QLabel (" "));
01171 m_toolSettingsViews->addWidget (m_viewSegmentFilter);
01172 addToolBar (m_toolSettingsViews);
01173
01174
01175 m_cmbCoordSystem = new QComboBox;
01176 m_cmbCoordSystem->setEnabled (false);
01177 m_cmbCoordSystem->setStatusTip (tr ("Currently selected coordinate system"));
01178 m_cmbCoordSystem->setWhatsThis (tr ("Selected Coordinate System\n\n"
01179 "Currently selected coordinate system. This is used to switch between coordinate systems "
01180 "in documents with multiple coordinate systems"));
01181 connect (m_cmbCoordSystem, SIGNAL (activated (int)), this, SLOT (slotCmbCoordSystem (int)));
01182
01183 m_btnShowAll = new QPushButton(QIcon(":/engauge/img/icon_show_all.png"), "");
01184 m_btnShowAll->setEnabled (false);
01185 m_btnShowAll->setAcceptDrops(false);
01186 m_btnShowAll->setStatusTip (tr ("Show all coordinate systems"));
01187 m_btnShowAll->setWhatsThis (tr ("Show All Coordinate Systems\n\n"
01188 "When pressed and held, this button shows all digitized points and lines for all coordinate systems."));
01189 connect (m_btnShowAll, SIGNAL (pressed ()), this, SLOT (slotBtnShowAllPressed ()));
01190 connect (m_btnShowAll, SIGNAL (released ()), this, SLOT (slotBtnShowAllReleased ()));
01191
01192 m_btnPrintAll = new QPushButton(QIcon(":/engauge/img/icon_print_all.png"), "");
01193 m_btnPrintAll->setEnabled (false);
01194 m_btnPrintAll->setAcceptDrops(false);
01195 m_btnPrintAll->setStatusTip (tr ("Print all coordinate systems"));
01196 m_btnPrintAll->setWhatsThis (tr ("Print All Coordinate Systems\n\n"
01197 "When pressed, this button Prints all digitized points and lines for all coordinate systems."));
01198 connect (m_btnPrintAll, SIGNAL (pressed ()), this, SLOT (slotBtnPrintAll ()));
01199
01200 m_toolCoordSystem = new QToolBar (tr ("Coordinate System"), this);
01201 m_toolCoordSystem->addWidget (m_cmbCoordSystem);
01202 m_toolCoordSystem->addWidget (m_btnShowAll);
01203 m_toolCoordSystem->addWidget (m_btnPrintAll);
01204 addToolBar (m_toolCoordSystem);
01205
01206
01207 m_dockChecklistGuide = new ChecklistGuide (this);
01208 connect (m_dockChecklistGuide, SIGNAL (signalChecklistClosed()), this, SLOT (slotChecklistClosed()));
01209 }
01210
01211 void MainWindow::createTutorial ()
01212 {
01213 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createTutorial";
01214
01215 m_tutorialDlg = new TutorialDlg (this);
01216 m_tutorialDlg->setModal (true);
01217 m_tutorialDlg->setMinimumSize (500, 400);
01218 m_tutorialDlg->hide();
01219 }
01220
01221 void MainWindow::createZoomMap ()
01222 {
01223 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::createZoomMap";
01224
01225 m_zoomMap [ZOOM_INITIAL_16_TO_1] = ZOOM_16_TO_1;
01226 m_zoomMap [ZOOM_INITIAL_8_TO_1] = ZOOM_8_TO_1;
01227 m_zoomMap [ZOOM_INITIAL_4_TO_1] = ZOOM_4_TO_1;
01228 m_zoomMap [ZOOM_INITIAL_2_TO_1] = ZOOM_2_TO_1;
01229 m_zoomMap [ZOOM_INITIAL_1_TO_1] = ZOOM_1_TO_1;
01230 m_zoomMap [ZOOM_INITIAL_1_TO_2] = ZOOM_1_TO_2;
01231 m_zoomMap [ZOOM_INITIAL_1_TO_4] = ZOOM_1_TO_4;
01232 m_zoomMap [ZOOM_INITIAL_1_TO_8] = ZOOM_1_TO_8;
01233 m_zoomMap [ZOOM_INITIAL_1_TO_16] = ZOOM_1_TO_16;
01234 m_zoomMap [ZOOM_INITIAL_FILL] = ZOOM_FILL;
01235 }
01236
01237 ZoomFactor MainWindow::currentZoomFactor () const
01238 {
01239 if (m_actionZoom1To1->isChecked()) {
01240 return ZOOM_1_TO_1;
01241 } else if (m_actionZoom1To2->isChecked()) {
01242 return ZOOM_1_TO_2;
01243 } else if (m_actionZoom1To4->isChecked()) {
01244 return ZOOM_1_TO_4;
01245 } else if (m_actionZoom1To8->isChecked()) {
01246 return ZOOM_1_TO_8;
01247 } else if (m_actionZoom1To16->isChecked()) {
01248 return ZOOM_1_TO_16;
01249 } else if (m_actionZoom2To1->isChecked()) {
01250 return ZOOM_2_TO_1;
01251 } else if (m_actionZoom4To1->isChecked()) {
01252 return ZOOM_4_TO_1;
01253 } else if (m_actionZoom8To1->isChecked()) {
01254 return ZOOM_8_TO_1;
01255 } else if (m_actionZoom16To1->isChecked()) {
01256 return ZOOM_16_TO_1;
01257 } else if (m_actionZoomFill->isChecked()) {
01258 return ZOOM_FILL;
01259 } else {
01260 ENGAUGE_ASSERT (false);
01261 return ZOOM_1_TO_1;
01262 }
01263 }
01264 bool MainWindow::eventFilter(QObject *target, QEvent *event)
01265 {
01266 if (event->type () == QEvent::KeyPress) {
01267
01268 QKeyEvent *eventKeyPress = (QKeyEvent *) event;
01269
01270
01271 if ((eventKeyPress->key() == Qt::Key_E) &&
01272 ((eventKeyPress->modifiers() & Qt::ShiftModifier) != 0) &&
01273 ((eventKeyPress->modifiers() & Qt::ControlModifier) != 0)) {
01274
01275 saveErrorReportFileAndExit ("Shift+Control+E",
01276 __FILE__,
01277 __LINE__,
01278 "userTriggered");
01279
01280 }
01281 }
01282
01283 return QObject::eventFilter (target, event);
01284 }
01285
01286 #ifndef OSX
01287 void MainWindow::exportAllCoordinateSystems()
01288 {
01289 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::exportAllCoordinateSystems";
01290
01291 ExportToFile exportStrategy;
01292
01293
01294 for (CoordSystemIndex index = 0; index < m_cmdMediator->document().coordSystemCount(); index++) {
01295
01296 updateCoordSystem (index);
01297
01298 QString regressionFile = QString ("%1_%2")
01299 .arg (m_regressionFile)
01300 .arg (index + 1);
01301 fileExport (regressionFile,
01302 exportStrategy);
01303 }
01304 }
01305 #endif
01306
01307 QString MainWindow::exportFilenameFromInputFilename (const QString &fileName) const
01308 {
01309 QString outFileName = fileName;
01310
01311 outFileName = outFileName.replace (".xml", ".csv_actual");
01312 outFileName = outFileName.replace (".dig", ".csv_actual");
01313
01314 return outFileName;
01315 }
01316
01317 void MainWindow::fileExport(const QString &fileName,
01318 ExportToFile exportStrategy)
01319 {
01320 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::fileExport"
01321 << " fileName=" << fileName.toLatin1().data();
01322
01323 QFile file (fileName);
01324 if (file.open(QIODevice::WriteOnly)) {
01325
01326 QTextStream str (&file);
01327
01328 DocumentModelExportFormat modelExportFormat = modelExportOverride (m_cmdMediator->document().modelExport(),
01329 exportStrategy,
01330 fileName);
01331 exportStrategy.exportToFile (modelExportFormat,
01332 m_cmdMediator->document(),
01333 m_modelMainWindow,
01334 transformation (),
01335 str);
01336
01337
01338 m_isDocumentExported = true;
01339 m_dockChecklistGuide->update (*m_cmdMediator,
01340 m_isDocumentExported);
01341
01342 } else {
01343
01344 LOG4CPP_ERROR_S ((*mainCat)) << "MainWindow::fileExport"
01345 << " file=" << fileName.toLatin1().data()
01346 << " curDir=" << QDir::currentPath().toLatin1().data();
01347 QMessageBox::critical (0,
01348 engaugeWindowTitle(),
01349 tr ("Unable to export to file ") + fileName);
01350 }
01351 }
01352
01353 void MainWindow::fileImport (const QString &fileName,
01354 ImportType importType)
01355 {
01356 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::fileImport"
01357 << " fileName=" << fileName.toLatin1 ().data ()
01358 << " curDir=" << QDir::currentPath().toLatin1().data()
01359 << " importType=" << importType;
01360
01361 QString originalFileOld = m_originalFile;
01362 bool originalFileWasImported = m_originalFileWasImported;
01363
01364 m_originalFile = fileName;
01365 m_originalFileWasImported = true;
01366
01367 if (importType == IMPORT_TYPE_ADVANCED) {
01368
01369
01370
01371 slotFileClose();
01372
01373
01374 m_backgroundStateContext->setBackgroundImage(BACKGROUND_IMAGE_ORIGINAL);
01375 }
01376
01377 QImage image;
01378 bool loaded = false;
01379 #ifdef ENGAUGE_JPEG2000
01380 Jpeg2000 jpeg2000;
01381 loaded = jpeg2000.load (fileName,
01382 image);
01383 #endif // ENGAUGE_JPEG2000
01384 if (!loaded) {
01385 loaded = image.load (fileName);
01386 }
01387
01388 if (!loaded) {
01389 QMessageBox::warning (this,
01390 engaugeWindowTitle(),
01391 QString("%1 %2.")
01392 .arg (tr ("Cannot read file"))
01393 .arg(fileName));
01394
01395
01396 m_originalFile = originalFileOld;
01397 m_originalFileWasImported = originalFileWasImported;
01398
01399 } else {
01400
01401 loaded = loadImage (fileName,
01402 image,
01403 importType);
01404
01405 if (!loaded) {
01406
01407
01408 if (importType == IMPORT_TYPE_ADVANCED) {
01409
01410
01411
01412
01413 slotFileClose();
01414
01415 } else {
01416
01417
01418 m_originalFile = originalFileOld;
01419 m_originalFileWasImported = originalFileWasImported;
01420 }
01421 }
01422 }
01423 }
01424
01425 void MainWindow::fileImportWithPrompts (ImportType importType)
01426 {
01427 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::fileImportWithPrompts"
01428 << " importType=" << importType;
01429
01430 if (maybeSave ()) {
01431
01432 QString filter;
01433 QTextStream str (&filter);
01434
01435
01436 QList<QByteArray>::const_iterator itr;
01437 QList<QByteArray> supportedImageFormats = QImageReader::supportedImageFormats();
01438 QStringList supportedImageFormatStrings;
01439 for (itr = supportedImageFormats.begin (); itr != supportedImageFormats.end (); itr++) {
01440 QByteArray arr = *itr;
01441 QString extensionAsWildcard = QString ("*.%1").arg (QString (arr));
01442 supportedImageFormatStrings << extensionAsWildcard;
01443 }
01444 #ifdef ENGAUGE_JPEG2000
01445 Jpeg2000 jpeg2000;
01446 supportedImageFormatStrings << jpeg2000.supportedImageWildcards();
01447 #endif // ENGAUGE_JPEG2000
01448
01449 supportedImageFormatStrings.sort();
01450
01451 str << "Image Files (" << supportedImageFormatStrings.join (" ") << ")";
01452
01453
01454
01455 str << ";; All Files (*.*)";
01456
01457 QString fileName = QFileDialog::getOpenFileName (this,
01458 tr("Import Image"),
01459 QDir::currentPath (),
01460 filter);
01461 if (!fileName.isEmpty ()) {
01462
01463
01464 fileImport (fileName,
01465 importType);
01466 }
01467 }
01468 }
01469
01470 void MainWindow::filePaste (ImportType importType)
01471 {
01472 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::filePaste"
01473 << " importType=" << importType;
01474
01475 QString originalFileOld = m_originalFile;
01476 bool originalFileWasImported = m_originalFileWasImported;
01477
01478 QString fileName ("clipboard");
01479 m_originalFile = fileName;
01480 m_originalFileWasImported = true;
01481
01482 if (importType == IMPORT_TYPE_ADVANCED) {
01483
01484
01485
01486 slotFileClose();
01487
01488
01489 m_backgroundStateContext->setBackgroundImage(BACKGROUND_IMAGE_ORIGINAL);
01490 }
01491
01492
01493 QImage image = QApplication::clipboard()->image();
01494
01495 bool loaded = false;
01496 if (!loaded) {
01497 loaded = !image.isNull();
01498 }
01499
01500 if (!loaded) {
01501 QMessageBox::warning (this,
01502 engaugeWindowTitle(),
01503 QString("%1 %2.")
01504 .arg (tr ("Cannot read file"))
01505 .arg(fileName));
01506
01507
01508 m_originalFile = originalFileOld;
01509 m_originalFileWasImported = originalFileWasImported;
01510
01511 } else {
01512
01513 loaded = loadImage (fileName,
01514 image,
01515 importType);
01516
01517 if (!loaded) {
01518
01519
01520 if (importType == IMPORT_TYPE_ADVANCED) {
01521
01522
01523
01524
01525 slotFileClose();
01526
01527 } else {
01528
01529
01530 m_originalFile = originalFileOld;
01531 m_originalFileWasImported = originalFileWasImported;
01532 }
01533 }
01534 }
01535 }
01536
01537 void MainWindow::ghostsCreate ()
01538 {
01539 LOG4CPP_DEBUG_S ((*mainCat)) << "MainWindow::ghostsCreate";
01540
01541 ENGAUGE_ASSERT (m_ghosts == 0);
01542 m_ghosts = new Ghosts (m_cmdMediator->document().coordSystemIndex());
01543
01544 for (unsigned int index = 0; index < m_cmdMediator->document().coordSystemCount(); index++) {
01545
01546
01547 if (index != m_ghosts->coordSystemIndexToBeRestored ()) {
01548
01549 updateCoordSystem (index);
01550
01551
01552 m_ghosts->captureGraphicsItems (*m_scene);
01553 }
01554 }
01555
01556
01557 updateCoordSystem (m_ghosts->coordSystemIndexToBeRestored ());
01558
01559
01560 m_ghosts->createGhosts (*m_scene);
01561 }
01562
01563 void MainWindow::ghostsDestroy ()
01564 {
01565 LOG4CPP_DEBUG_S ((*mainCat)) << "MainWindow::ghostsDestroy";
01566
01567 ENGAUGE_CHECK_PTR (m_ghosts);
01568
01569 m_ghosts->destroyGhosts(*m_scene);
01570
01571 delete m_ghosts;
01572 m_ghosts = 0;
01573 }
01574
01575 QImage MainWindow::imageFiltered () const
01576 {
01577 return m_backgroundStateContext->imageForCurveState();
01578 }
01579
01580 bool MainWindow::isGnuplot() const
01581 {
01582 return m_isGnuplot;
01583 }
01584
01585 void MainWindow::loadCoordSystemListFromCmdMediator ()
01586 {
01587 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::loadCoordSystemListFromCmdMediator";
01588
01589 m_cmbCoordSystem->clear();
01590
01591 unsigned int numberCoordSystem = m_cmdMediator->document().coordSystemCount();
01592
01593 for (unsigned int i = 0; i < numberCoordSystem; i++) {
01594 int index1Based = i + 1;
01595 m_cmbCoordSystem->addItem (QString::number (index1Based),
01596 QVariant (i));
01597 }
01598
01599
01600 m_cmbCoordSystem->setCurrentIndex (0);
01601
01602
01603 bool enable = (m_cmbCoordSystem->count() > 1);
01604 m_cmbCoordSystem->setEnabled (enable);
01605 m_btnShowAll->setEnabled (enable);
01606 m_btnPrintAll->setEnabled (enable);
01607 }
01608
01609 void MainWindow::loadCurveListFromCmdMediator ()
01610 {
01611 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::loadCurveListFromCmdMediator";
01612
01613 m_cmbCurve->clear ();
01614 QStringList curvesGraphsNames = m_cmdMediator->curvesGraphsNames ();
01615 QStringList::iterator itr;
01616 for (itr = curvesGraphsNames.begin (); itr != curvesGraphsNames.end (); itr++) {
01617
01618 QString curvesGraphName = *itr;
01619 m_cmbCurve->addItem (curvesGraphName);
01620 }
01621
01622
01623 m_cmbCurve->setCurrentText (m_cmdMediator->selectedCurveName ());
01624 }
01625
01626 void MainWindow::loadDocumentFile (const QString &fileName)
01627 {
01628 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::loadDocumentFile fileName=" << fileName.toLatin1 ().data ();
01629
01630 QApplication::setOverrideCursor(Qt::WaitCursor);
01631 CmdMediator *cmdMediator = new CmdMediator (*this,
01632 fileName);
01633 QApplication::restoreOverrideCursor();
01634
01635 if (cmdMediator->successfulRead ()) {
01636
01637 setCurrentPathFromFile (fileName);
01638 rebuildRecentFileListForCurrentFile(fileName);
01639 m_currentFile = fileName;
01640
01641 if (m_cmdMediator != 0) {
01642 delete m_cmdMediator;
01643 m_cmdMediator = 0;
01644 }
01645
01646 m_cmdMediator = cmdMediator;
01647 setupAfterLoad(fileName,
01648 "File opened",
01649 IMPORT_TYPE_SIMPLE);
01650
01651
01652 m_actionDigitizeSelect->setChecked (true);
01653 slotDigitizeSelect();
01654
01655 m_engaugeFile = fileName;
01656 m_originalFile = fileName;
01657 m_originalFileWasImported = false;
01658
01659 updateGridLines ();
01660 updateAfterCommand ();
01661
01662 } else {
01663
01664 QMessageBox::warning (this,
01665 engaugeWindowTitle(),
01666 QString("%1 %2:\n%3.")
01667 .arg (tr ("Cannot read file"))
01668 .arg(fileName)
01669 .arg(cmdMediator->reasonForUnsuccessfulRead ()));
01670 delete cmdMediator;
01671
01672 }
01673 }
01674
01675 void MainWindow::loadErrorReportFile(const QString &initialPath,
01676 const QString &errorReportFile)
01677 {
01678 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::loadErrorReportFile"
01679 << " path=" << initialPath.toLatin1().data()
01680 << " file=" << errorReportFile.toLatin1().data();
01681
01682
01683
01684
01685
01686 QString originalPath = QDir::currentPath();
01687 QDir::setCurrent(initialPath);
01688
01689 QFile file (errorReportFile);
01690 if (!file.exists()) {
01691
01692 QFileInfo fileInfo (errorReportFile);
01693
01694 QMessageBox::critical (this,
01695 engaugeWindowTitle(),
01696 tr ("File not found:") + " " + fileInfo.absoluteFilePath());
01697 exit (-1);
01698 }
01699
01700
01701 QXmlStreamReader reader (&file);
01702 file.open(QIODevice::ReadOnly | QIODevice::Text);
01703 m_cmdMediator = new CmdMediator(*this,
01704 errorReportFile);
01705
01706
01707 m_cmdStackShadow->loadCommands (*this,
01708 m_cmdMediator->document(),
01709 reader);
01710 file.close();
01711
01712
01713 QDir::setCurrent(originalPath);
01714
01715 setupAfterLoad(errorReportFile,
01716 "Error report opened",
01717 IMPORT_TYPE_SIMPLE);
01718
01719
01720 m_actionDigitizeSelect->setChecked (true);
01721 slotDigitizeSelect();
01722
01723 updateAfterCommand ();
01724 }
01725
01726 bool MainWindow::loadImage (const QString &fileName,
01727 const QImage &image,
01728 ImportType importType)
01729 {
01730 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::loadImage"
01731 << " fileName=" << fileName.toLatin1 ().data ()
01732 << " importType=" << importType;
01733
01734 QApplication::setOverrideCursor(Qt::WaitCursor);
01735 CmdMediator *cmdMediator = new CmdMediator (*this,
01736 image);
01737 QApplication::restoreOverrideCursor();
01738
01739 setCurrentPathFromFile (fileName);
01740
01741 m_engaugeFile = EMPTY_FILENAME;
01742
01743 if (m_cmdMediator != 0) {
01744 delete m_cmdMediator;
01745 m_cmdMediator = 0;
01746 }
01747
01748 m_cmdMediator = cmdMediator;
01749 bool accepted = setupAfterLoad(fileName,
01750 tr ("File imported"),
01751 importType);
01752
01753 if (accepted) {
01754
01755
01756 if (m_actionHelpChecklistGuideWizard->isChecked () &&
01757 (m_fileCmdScript == 0)) {
01758
01759
01760 ChecklistGuideWizard *wizard = new ChecklistGuideWizard (*this,
01761 m_cmdMediator->document().coordSystemCount());
01762 if (wizard->exec() == QDialog::Accepted) {
01763
01764 for (CoordSystemIndex coordSystemIndex = 0; coordSystemIndex < m_cmdMediator->document().coordSystemCount(); coordSystemIndex++) {
01765
01766
01767 m_dockChecklistGuide->setTemplateHtml (wizard->templateHtml(coordSystemIndex),
01768 wizard->curveNames(coordSystemIndex));
01769
01770
01771 CurvesGraphs curvesGraphs;
01772 wizard->populateCurvesGraphs (coordSystemIndex,
01773 curvesGraphs);
01774 m_cmdMediator->document().setCurvesGraphs(curvesGraphs);
01775 }
01776
01777
01778 m_actionViewChecklistGuide->setChecked (true);
01779
01780
01781 loadCurveListFromCmdMediator();
01782
01783
01784 loadCoordSystemListFromCmdMediator();
01785 }
01786 delete wizard;
01787 }
01788
01789
01790 m_actionDigitizeAxis->setChecked (true);
01791 slotDigitizeAxis ();
01792
01793 updateControls ();
01794 }
01795
01796 return accepted;
01797 }
01798
01799 void MainWindow::loadInputFileForErrorReport(QDomDocument &domInputFile) const
01800 {
01801 QFile file (m_originalFile);
01802
01803
01804
01805 if (!file.open (QIODevice::ReadOnly)) {
01806 return;
01807 }
01808
01809 domInputFile.setContent (&file);
01810 file.close();
01811 }
01812
01813 void MainWindow::loadToolTips()
01814 {
01815 if (m_actionViewToolTips->isChecked ()) {
01816
01817
01818 m_actionDigitizeSelect->setToolTip (m_actionDigitizeSelect->text());
01819 m_actionDigitizeAxis->setToolTip (m_actionDigitizeAxis->text());
01820 m_actionDigitizeCurve->setToolTip (m_actionDigitizeCurve->text());
01821 m_actionDigitizePointMatch->setToolTip (m_actionDigitizePointMatch->text());
01822 m_actionDigitizeColorPicker->setToolTip (m_actionDigitizeColorPicker->text());
01823 m_actionDigitizeSegment->setToolTip (m_actionDigitizeSegment->text());
01824 m_cmbBackground->setToolTip (tr ("Background image."));
01825 m_cmbCurve->setToolTip (tr ("Currently selected curve."));
01826 m_viewPointStyle->setToolTip (tr ("Point style for currently selected curve."));
01827 m_viewSegmentFilter->setToolTip (tr ("Segment Fill filter for currently selected curve."));
01828
01829 } else {
01830
01831
01832 m_actionDigitizeSelect->setToolTip ("");
01833 m_actionDigitizeAxis->setToolTip ("");
01834 m_actionDigitizeCurve->setToolTip ("");
01835 m_actionDigitizePointMatch->setToolTip ("");
01836 m_actionDigitizeColorPicker->setToolTip ("");
01837 m_actionDigitizeSegment->setToolTip ("");
01838 m_cmbBackground->setToolTip ("");
01839 m_cmbCurve->setToolTip ("");
01840 m_viewPointStyle->setToolTip ("");
01841 m_viewSegmentFilter->setToolTip ("");
01842
01843 }
01844 }
01845
01846 bool MainWindow::maybeSave()
01847 {
01848 if (m_cmdMediator != 0) {
01849 if (m_cmdMediator->isModified()) {
01850 QMessageBox::StandardButton ret = QMessageBox::warning (this,
01851 engaugeWindowTitle(),
01852 tr("The document has been modified.\n"
01853 "Do you want to save your changes?"),
01854 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
01855 if (ret == QMessageBox::Save) {
01856 return slotFileSave();
01857 } else if (ret == QMessageBox::Cancel) {
01858 return false;
01859 }
01860 }
01861 }
01862
01863 return true;
01864 }
01865
01866 DocumentModelExportFormat MainWindow::modelExportOverride (const DocumentModelExportFormat &modelExportFormatBefore,
01867 const ExportToFile &exportStrategy,
01868 const QString &fileName) const
01869 {
01870 DocumentModelExportFormat modelExportFormatAfter = modelExportFormatBefore;
01871
01872
01873 if (!modelExportFormatAfter.overrideCsvTsv()) {
01874
01875
01876 QString csvExtension = QString (".%1")
01877 .arg (exportStrategy.fileExtensionCsv());
01878 QString tsvExtension = QString (".%1")
01879 .arg (exportStrategy.fileExtensionTsv());
01880 QString fileExtensionVersusCsv = fileName.right (csvExtension.size());
01881 QString fileExtensionVersusTsv = fileName.right (tsvExtension.size());
01882
01883
01884
01885 if (csvExtension.compare (fileExtensionVersusCsv, Qt::CaseInsensitive) == 0) {
01886 modelExportFormatAfter.setDelimiter (EXPORT_DELIMITER_COMMA);
01887 } else if (tsvExtension.compare (fileExtensionVersusTsv, Qt::CaseInsensitive) == 0) {
01888 modelExportFormatAfter.setDelimiter (EXPORT_DELIMITER_TAB);
01889 }
01890 }
01891
01892 return modelExportFormatAfter;
01893 }
01894
01895 MainWindowModel MainWindow::modelMainWindow () const
01896 {
01897 return m_modelMainWindow;
01898 }
01899
01900 void MainWindow::rebuildRecentFileListForCurrentFile(const QString &filePath)
01901 {
01902 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::rebuildRecentFileListForCurrentFile";
01903
01904 setWindowFilePath (filePath);
01905
01906 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
01907 QStringList recentFilePaths = settings.value (SETTINGS_RECENT_FILE_LIST).toStringList();
01908 recentFilePaths.removeAll (filePath);
01909 recentFilePaths.prepend (filePath);
01910 while (recentFilePaths.count () > (int) MAX_RECENT_FILE_LIST_SIZE) {
01911 recentFilePaths.removeLast ();
01912 }
01913 settings.setValue (SETTINGS_RECENT_FILE_LIST, recentFilePaths);
01914
01915 updateRecentFileList();
01916 }
01917
01918 void MainWindow::resizeEvent(QResizeEvent * )
01919 {
01920 LOG4CPP_DEBUG_S ((*mainCat)) << "MainWindow::resizeEvent";
01921
01922 if (m_actionZoomFill->isChecked ()) {
01923 slotViewZoomFill();
01924 }
01925 }
01926
01927 bool MainWindow::saveDocumentFile (const QString &fileName)
01928 {
01929 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::saveDocumentFile fileName=" << fileName.toLatin1 ().data ();
01930
01931 QFile file(fileName);
01932 if (!file.open(QFile::WriteOnly)) {
01933 QMessageBox::warning (this,
01934 engaugeWindowTitle(),
01935 QString ("%1 %2: \n%3.")
01936 .arg(tr ("Cannot write file"))
01937 .arg(fileName)
01938 .arg(file.errorString()));
01939 return false;
01940 }
01941
01942 rebuildRecentFileListForCurrentFile (fileName);
01943
01944 QApplication::setOverrideCursor (Qt::WaitCursor);
01945 QXmlStreamWriter writer(&file);
01946 writer.setAutoFormatting(true);
01947 writer.writeStartDocument();
01948 writer.writeDTD("<!DOCTYPE engauge>");
01949 m_cmdMediator->document().saveXml(writer);
01950 writer.writeEndDocument();
01951 QApplication::restoreOverrideCursor ();
01952
01953
01954
01955 m_cmdMediator->setClean ();
01956
01957 setCurrentFile(fileName);
01958 m_engaugeFile = fileName;
01959 updateAfterCommand ();
01960 m_statusBar->showTemporaryMessage("File saved");
01961
01962 return true;
01963 }
01964
01965 void MainWindow::saveErrorReportFileAndExit (const char *context,
01966 const char *file,
01967 int line,
01968 const char *comment) const
01969 {
01970
01971
01972 if ((m_cmdMediator != 0) && !m_isRegressionTest) {
01973
01974 QString report = saveErrorReportFileAndExitXml (context,
01975 file,
01976 line,
01977 comment);
01978 DlgErrorReport dlg (report);
01979
01980
01981 if (dlg.exec() == QDialog::Accepted) {
01982
01983
01984 m_networkClient->uploadErrorReport (dlg.xmlToUpload());
01985 }
01986 }
01987 }
01988
01989 QString MainWindow::saveErrorReportFileAndExitXml (const char *context,
01990 const char *file,
01991 int line,
01992 const char *comment) const
01993 {
01994 const bool DEEP_COPY = true;
01995
01996 QString xmlErrorReport;
01997 QXmlStreamWriter writer (&xmlErrorReport);
01998 writer.setAutoFormatting(true);
01999
02000
02001 writer.writeStartElement(DOCUMENT_SERIALIZE_ERROR_REPORT);
02002
02003
02004 writer.writeStartElement(DOCUMENT_SERIALIZE_APPLICATION);
02005 writer.writeAttribute(DOCUMENT_SERIALIZE_APPLICATION_VERSION_NUMBER, VERSION_NUMBER);
02006 writer.writeEndElement();
02007
02008
02009
02010 QXmlStreamReader reader (m_startingDocumentSnapshot);
02011 while (!reader.atEnd ()) {
02012 reader.readNext ();
02013 if (reader.tokenType() != QXmlStreamReader::StartDocument &&
02014 reader.tokenType() != QXmlStreamReader::EndDocument) {
02015 writer.writeCurrentToken (reader);
02016 }
02017 }
02018
02019
02020 writer.writeStartElement(DOCUMENT_SERIALIZE_OPERATING_SYSTEM);
02021 writer.writeAttribute(DOCUMENT_SERIALIZE_OPERATING_SYSTEM_ENDIAN, EndianToString (QSysInfo::ByteOrder));
02022 writer.writeAttribute(DOCUMENT_SERIALIZE_OPERATING_SYSTEM_WORD_SIZE, QString::number (QSysInfo::WordSize));
02023 writer.writeEndElement();
02024
02025
02026 writer.writeStartElement(DOCUMENT_SERIALIZE_FILE);
02027 writer.writeAttribute(DOCUMENT_SERIALIZE_FILE_IMPORTED,
02028 m_originalFileWasImported ? DOCUMENT_SERIALIZE_BOOL_TRUE : DOCUMENT_SERIALIZE_BOOL_FALSE);
02029 writer.writeEndElement();
02030
02031
02032 m_cmdMediator->saveXml(writer);
02033
02034
02035 writer.writeStartElement(DOCUMENT_SERIALIZE_ERROR);
02036 writer.writeAttribute(DOCUMENT_SERIALIZE_ERROR_CONTEXT, context);
02037 writer.writeAttribute(DOCUMENT_SERIALIZE_ERROR_FILE, file);
02038 writer.writeAttribute(DOCUMENT_SERIALIZE_ERROR_LINE, QString::number (line));
02039 writer.writeAttribute(DOCUMENT_SERIALIZE_ERROR_COMMENT, comment);
02040 writer.writeEndElement();
02041
02042 writer.writeEndElement();
02043
02044
02045 QDomDocument domErrorReport ("ErrorReport");
02046 domErrorReport.setContent (xmlErrorReport);
02047
02048
02049 if (!m_originalFileWasImported) {
02050
02051
02052
02053 QDomDocument domInputFile;
02054 loadInputFileForErrorReport (domInputFile);
02055 QDomDocumentFragment fragmentFileFrom = domErrorReport.createDocumentFragment();
02056 if (!domInputFile.isNull()) {
02057 fragmentFileFrom.appendChild (domErrorReport.importNode (domInputFile.documentElement(), DEEP_COPY));
02058 }
02059 QDomNodeList nodesFileTo = domErrorReport.elementsByTagName (DOCUMENT_SERIALIZE_FILE);
02060 if (nodesFileTo.count () > 0) {
02061 QDomNode nodeFileTo = nodesFileTo.at (0);
02062 nodeFileTo.appendChild (fragmentFileFrom);
02063 }
02064
02065
02066
02067
02068
02069 QDomNodeList nodesDocument = domErrorReport.elementsByTagName (DOCUMENT_SERIALIZE_DOCUMENT);
02070 for (int i = 0 ; i < nodesDocument.count(); i++) {
02071 QDomNode nodeDocument = nodesDocument.at (i);
02072 QDomElement elemImage = nodeDocument.firstChildElement(DOCUMENT_SERIALIZE_IMAGE);
02073 if (!elemImage.isNull()) {
02074
02075
02076 if (elemImage.hasAttribute (DOCUMENT_SERIALIZE_IMAGE_WIDTH) &&
02077 elemImage.hasAttribute (DOCUMENT_SERIALIZE_IMAGE_HEIGHT)) {
02078
02079 int width = elemImage.attribute(DOCUMENT_SERIALIZE_IMAGE_WIDTH).toInt();
02080 int height = elemImage.attribute(DOCUMENT_SERIALIZE_IMAGE_HEIGHT).toInt();
02081
02082 QDomNode nodeReplacement;
02083 QDomElement elemReplacement = nodeReplacement.toElement();
02084 elemReplacement.setAttribute (DOCUMENT_SERIALIZE_IMAGE_WIDTH, width);
02085 elemReplacement.setAttribute (DOCUMENT_SERIALIZE_IMAGE_HEIGHT, height);
02086
02087
02088 nodeDocument.insertBefore (nodeReplacement,
02089 elemImage);
02090 nodeDocument.removeChild(elemImage);
02091 }
02092 }
02093 }
02094 }
02095
02096 return domErrorReport.toString();
02097 }
02098
02099 void MainWindow::saveStartingDocumentSnapshot()
02100 {
02101 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::saveStartingDocumentSnapshot";
02102
02103 QXmlStreamWriter writer (&m_startingDocumentSnapshot);
02104 writer.setAutoFormatting (true);
02105 m_cmdMediator->document().saveXml (writer);
02106 }
02107
02108 GraphicsScene &MainWindow::scene ()
02109 {
02110 ENGAUGE_CHECK_PTR (m_scene);
02111 return *m_scene;
02112 }
02113
02114 BackgroundImage MainWindow::selectOriginal(BackgroundImage backgroundImage)
02115 {
02116 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::selectBackgroundOriginal";
02117
02118 BackgroundImage previousBackground = (BackgroundImage) m_cmbBackground->currentData().toInt();
02119
02120 int index = m_cmbBackground->findData (backgroundImage);
02121 ENGAUGE_ASSERT (index >= 0);
02122
02123 m_cmbBackground->setCurrentIndex(index);
02124
02125 return previousBackground;
02126 }
02127
02128 QString MainWindow::selectedGraphCurve () const
02129 {
02130 return m_cmbCurve->currentText ();
02131 }
02132
02133 void MainWindow::setCurrentFile (const QString &fileName)
02134 {
02135 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::setCurrentFile";
02136
02137 QString fileNameStripped;
02138 if (!fileName.isEmpty()) {
02139
02140
02141 QFileInfo fileInfo (fileName);
02142 fileNameStripped = fileInfo.baseName();
02143 }
02144
02145 m_currentFile = fileNameStripped;
02146 m_currentFileWithPathAndFileExtension = fileName;
02147
02148 updateWindowTitle ();
02149 }
02150
02151 void MainWindow::setCurrentPathFromFile (const QString &fileName)
02152 {
02153 QDir dir = QFileInfo (fileName).absoluteDir();
02154
02155 if (dir.exists ()) {
02156
02157 bool success = QDir::setCurrent (dir.absolutePath ());
02158 ENGAUGE_ASSERT (success);
02159
02160 } else {
02161
02162
02163 }
02164 }
02165
02166 void MainWindow::setPixmap (const QPixmap &pixmap)
02167 {
02168 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::setPixmap";
02169
02170 m_digitizeStateContext->setImageIsLoaded (m_cmdMediator,
02171 true);
02172 m_backgroundStateContext->setPixmap (m_transformation,
02173 m_cmdMediator->document().modelGridRemoval(),
02174 m_cmdMediator->document().modelColorFilter(),
02175 pixmap,
02176 m_cmbCurve->currentText());
02177 }
02178
02179 void MainWindow::settingsRead ()
02180 {
02181 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
02182
02183 settingsReadEnvironment (settings);
02184 settingsReadMainWindow (settings);
02185 }
02186
02187 void MainWindow::settingsReadEnvironment (QSettings &settings)
02188 {
02189 settings.beginGroup (SETTINGS_GROUP_ENVIRONMENT);
02190 QDir::setCurrent (settings.value (SETTINGS_CURRENT_DIRECTORY,
02191 QDir::currentPath ()).toString ());
02192 settings.endGroup ();
02193 }
02194
02195 void MainWindow::settingsReadMainWindow (QSettings &settings)
02196 {
02197 settings.beginGroup(SETTINGS_GROUP_MAIN_WINDOW);
02198
02199
02200 resize (settings.value (SETTINGS_SIZE,
02201 QSize (600, 600)).toSize ());
02202 move (settings.value (SETTINGS_POS,
02203 QPoint (200, 200)).toPoint ());
02204
02205
02206 QSize helpSize = settings.value (SETTINGS_HELP_SIZE,
02207 QSize (900, 600)).toSize();
02208 m_helpWindow->resize (helpSize);
02209 if (settings.contains (SETTINGS_HELP_POS)) {
02210 QPoint helpPos = settings.value (SETTINGS_HELP_POS).toPoint();
02211 m_helpWindow->move (helpPos);
02212 }
02213
02214
02215 m_actionHelpChecklistGuideWizard->setChecked (settings.value (SETTINGS_CHECKLIST_GUIDE_WIZARD,
02216 true).toBool ());
02217
02218
02219 bool viewBackgroundToolBar = settings.value (SETTINGS_VIEW_BACKGROUND_TOOLBAR,
02220 true).toBool ();
02221 m_actionViewBackground->setChecked (viewBackgroundToolBar);
02222 m_toolBackground->setVisible (viewBackgroundToolBar);
02223 BackgroundImage backgroundImage = (BackgroundImage) settings.value (SETTINGS_BACKGROUND_IMAGE,
02224 BACKGROUND_IMAGE_FILTERED).toInt ();
02225 int indexBackground = m_cmbBackground->findData (QVariant (backgroundImage));
02226 m_cmbBackground->setCurrentIndex (indexBackground);
02227
02228
02229 bool viewDigitizeToolBar = settings.value (SETTINGS_VIEW_DIGITIZE_TOOLBAR,
02230 true).toBool ();
02231 m_actionViewDigitize->setChecked (viewDigitizeToolBar);
02232 m_toolDigitize->setVisible (viewDigitizeToolBar);
02233
02234
02235 bool viewSettingsViewsToolBar = settings.value (SETTINGS_VIEW_SETTINGS_VIEWS_TOOLBAR,
02236 true).toBool ();
02237 m_actionViewSettingsViews->setChecked (viewSettingsViewsToolBar);
02238 m_toolSettingsViews->setVisible (viewSettingsViewsToolBar);
02239
02240
02241 bool viewCoordSystemToolbar = settings.value (SETTINGS_VIEW_COORD_SYSTEM_TOOLBAR,
02242 false).toBool ();
02243 m_actionViewCoordSystem->setChecked (viewCoordSystemToolbar);
02244 m_toolCoordSystem->setVisible (viewCoordSystemToolbar);
02245
02246
02247 bool viewToolTips = settings.value (SETTINGS_VIEW_TOOL_TIPS,
02248 true).toBool ();
02249 m_actionViewToolTips->setChecked (viewToolTips);
02250 loadToolTips ();
02251
02252
02253 StatusBarMode statusBarMode = (StatusBarMode) settings.value (SETTINGS_VIEW_STATUS_BAR,
02254 false).toInt ();
02255 m_statusBar->setStatusBarMode (statusBarMode);
02256 m_actionStatusNever->setChecked (statusBarMode == STATUS_BAR_MODE_NEVER);
02257 m_actionStatusTemporary->setChecked (statusBarMode == STATUS_BAR_MODE_TEMPORARY);
02258 m_actionStatusAlways->setChecked (statusBarMode == STATUS_BAR_MODE_ALWAYS);
02259
02260
02261
02262
02263 const bool DOCKED_EQUALS_NOT_FLOATING = false;
02264 Qt::DockWidgetArea area = (Qt::DockWidgetArea) settings.value (SETTINGS_CHECKLIST_GUIDE_DOCK_AREA,
02265 Qt::NoDockWidgetArea).toInt();
02266
02267 if (area == Qt::NoDockWidgetArea) {
02268
02269 addDockWidget (Qt::RightDockWidgetArea,
02270 m_dockChecklistGuide);
02271 m_dockChecklistGuide->setFloating(DOCKED_EQUALS_NOT_FLOATING);
02272 if (settings.contains (SETTINGS_CHECKLIST_GUIDE_DOCK_GEOMETRY)) {
02273 m_dockChecklistGuide->restoreGeometry (settings.value (SETTINGS_CHECKLIST_GUIDE_DOCK_GEOMETRY).toByteArray());
02274 }
02275
02276 } else {
02277
02278 addDockWidget (area,
02279 m_dockChecklistGuide);
02280
02281 }
02282
02283
02284
02285
02286 QLocale localeDefault;
02287 QLocale::Language language = (QLocale::Language) settings.value (SETTINGS_LOCALE_LANGUAGE,
02288 QVariant (localeDefault.language())).toInt();
02289 QLocale::Country country = (QLocale::Country) settings.value (SETTINGS_LOCALE_COUNTRY,
02290 QVariant (localeDefault.country())).toInt();
02291 QLocale locale (language,
02292 country);
02293 slotViewZoom ((ZoomFactor) settings.value (SETTINGS_ZOOM_FACTOR,
02294 QVariant (ZOOM_1_TO_1)).toInt());
02295 m_modelMainWindow.setLocale (locale);
02296 m_modelMainWindow.setZoomFactorInitial((ZoomFactorInitial) settings.value (SETTINGS_ZOOM_FACTOR_INITIAL,
02297 QVariant (DEFAULT_ZOOM_FACTOR_INITIAL)).toInt());
02298 m_modelMainWindow.setZoomControl ((ZoomControl) settings.value (SETTINGS_ZOOM_CONTROL,
02299 QVariant (ZOOM_CONTROL_MENU_WHEEL_PLUSMINUS)).toInt());
02300 m_modelMainWindow.setMainTitleBarFormat ((MainTitleBarFormat) settings.value (SETTINGS_MAIN_TITLE_BAR_FORMAT,
02301 QVariant (MAIN_TITLE_BAR_FORMAT_PATH)).toInt());
02302 updateSettingsMainWindow();
02303
02304 settings.endGroup();
02305 }
02306
02307 void MainWindow::settingsWrite ()
02308 {
02309 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
02310
02311 settings.beginGroup (SETTINGS_GROUP_ENVIRONMENT);
02312 settings.setValue (SETTINGS_CURRENT_DIRECTORY, QDir::currentPath ());
02313 settings.endGroup ();
02314
02315 settings.beginGroup (SETTINGS_GROUP_MAIN_WINDOW);
02316 settings.setValue (SETTINGS_SIZE, size ());
02317 settings.setValue (SETTINGS_POS, pos ());
02318 settings.setValue (SETTINGS_HELP_SIZE, m_helpWindow->size());
02319 settings.setValue (SETTINGS_HELP_POS, m_helpWindow->pos ());
02320 if (m_dockChecklistGuide->isFloating()) {
02321
02322 settings.setValue (SETTINGS_CHECKLIST_GUIDE_DOCK_AREA, Qt::NoDockWidgetArea);
02323 settings.setValue (SETTINGS_CHECKLIST_GUIDE_DOCK_GEOMETRY, m_dockChecklistGuide->saveGeometry ());
02324
02325 } else {
02326
02327 settings.setValue (SETTINGS_CHECKLIST_GUIDE_DOCK_AREA, dockWidgetArea (m_dockChecklistGuide));
02328
02329 }
02330 settings.setValue (SETTINGS_CHECKLIST_GUIDE_WIZARD, m_actionHelpChecklistGuideWizard->isChecked ());
02331 settings.setValue (SETTINGS_LOCALE_LANGUAGE, m_modelMainWindow.locale().language());
02332 settings.setValue (SETTINGS_LOCALE_COUNTRY, m_modelMainWindow.locale().country());
02333 settings.setValue (SETTINGS_VIEW_BACKGROUND_TOOLBAR, m_actionViewBackground->isChecked());
02334 settings.setValue (SETTINGS_BACKGROUND_IMAGE, m_cmbBackground->currentData().toInt());
02335 settings.setValue (SETTINGS_VIEW_DIGITIZE_TOOLBAR, m_actionViewDigitize->isChecked ());
02336 settings.setValue (SETTINGS_VIEW_STATUS_BAR, m_statusBar->statusBarMode ());
02337 settings.setValue (SETTINGS_VIEW_SETTINGS_VIEWS_TOOLBAR, m_actionViewSettingsViews->isChecked ());
02338 settings.setValue (SETTINGS_VIEW_COORD_SYSTEM_TOOLBAR, m_actionViewCoordSystem->isChecked ());
02339 settings.setValue (SETTINGS_VIEW_TOOL_TIPS, m_actionViewToolTips->isChecked ());
02340 settings.setValue (SETTINGS_ZOOM_CONTROL, m_modelMainWindow.zoomControl());
02341 settings.setValue (SETTINGS_ZOOM_FACTOR, currentZoomFactor ());
02342 settings.setValue (SETTINGS_ZOOM_FACTOR_INITIAL, m_modelMainWindow.zoomFactorInitial());
02343 settings.setValue (SETTINGS_MAIN_TITLE_BAR_FORMAT, m_modelMainWindow.mainTitleBarFormat());
02344 settings.endGroup ();
02345 }
02346
02347 bool MainWindow::setupAfterLoad (const QString &fileName,
02348 const QString &temporaryMessage ,
02349 ImportType importType)
02350 {
02351 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::setupAfterLoad"
02352 << " file=" << fileName.toLatin1().data()
02353 << " message=" << temporaryMessage.toLatin1().data()
02354 << " importType=" << importType;
02355
02356 const QString EMPTY_CURVE_NAME_TO_SKIP_BACKGROUND_PROCESSING;
02357
02358
02359
02360 m_digitizeStateContext->resetOnLoad (m_cmdMediator);
02361 m_backgroundStateContext->setCurveSelected (m_transformation,
02362 m_cmdMediator->document().modelGridRemoval(),
02363 m_cmdMediator->document().modelColorFilter(),
02364 EMPTY_CURVE_NAME_TO_SKIP_BACKGROUND_PROCESSING);
02365 setPixmap (m_cmdMediator->pixmap ());
02366
02367
02368
02369 if (importType == IMPORT_TYPE_ADVANCED) {
02370
02371 applyZoomFactorAfterLoad();
02372
02373 DlgImportAdvanced dlgImportAdvanced (*this);
02374 dlgImportAdvanced.exec();
02375
02376 if (dlgImportAdvanced.result() == QDialog::Rejected) {
02377 return false;
02378 }
02379
02380 int numberCoordSystem = dlgImportAdvanced.numberCoordSystem();
02381 m_cmdMediator->document().addCoordSystems (numberCoordSystem - 1);
02382 m_cmdMediator->setDocumentAxesPointsRequired (dlgImportAdvanced.documentAxesPointsRequired());
02383 }
02384
02385 m_transformation.resetOnLoad();
02386 m_transformationStateContext->resetOnLoad();
02387 m_scene->resetOnLoad();
02388
02389 connect (m_actionEditUndo, SIGNAL (triggered ()), m_cmdMediator, SLOT (undo ()));
02390 connect (m_actionEditUndo, SIGNAL (triggered ()), m_cmdStackShadow, SLOT (slotUndo ()));
02391 connect (m_actionEditRedo, SIGNAL (triggered ()), m_cmdMediator, SLOT (redo ()));
02392 connect (m_actionEditRedo, SIGNAL (triggered ()), m_cmdStackShadow, SLOT (slotRedo ()));
02393 connect (m_cmdMediator, SIGNAL (canRedoChanged(bool)), this, SLOT (slotCanRedoChanged (bool)));
02394 connect (m_cmdMediator, SIGNAL (canUndoChanged(bool)), this, SLOT (slotCanUndoChanged (bool)));
02395 connect (m_cmdMediator, SIGNAL (redoTextChanged (const QString &)), this, SLOT (slotRedoTextChanged (const QString &)));
02396 connect (m_cmdMediator, SIGNAL (undoTextChanged (const QString &)), this, SLOT (slotUndoTextChanged (const QString &)));
02397 loadCurveListFromCmdMediator ();
02398 loadCoordSystemListFromCmdMediator ();
02399 updateViewsOfSettings ();
02400
02401 m_isDocumentExported = false;
02402
02403
02404
02405
02406
02407 m_backgroundStateContext->setCurveSelected (m_transformation,
02408 m_cmdMediator->document().modelGridRemoval(),
02409 m_cmdMediator->document().modelColorFilter(),
02410 m_cmbCurve->currentText ());
02411 m_backgroundStateContext->setBackgroundImage ((BackgroundImage) m_cmbBackground->currentIndex ());
02412
02413 applyZoomFactorAfterLoad();
02414
02415 setCurrentFile(fileName);
02416 m_statusBar->showTemporaryMessage (temporaryMessage);
02417 m_statusBar->wakeUp ();
02418
02419 saveStartingDocumentSnapshot();
02420
02421 updateAfterCommand();
02422
02423 return true;
02424 }
02425
02426 void MainWindow::showEvent (QShowEvent *event)
02427 {
02428 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::showEvent"
02429 << " files=" << m_loadStartupFiles.join (",").toLatin1().data();
02430
02431 QMainWindow::showEvent (event);
02432
02433 if (m_loadStartupFiles.count() > 0) {
02434
02435 m_timerLoadStartupFiles = new QTimer;
02436 m_timerLoadStartupFiles->setSingleShot (true);
02437 connect (m_timerLoadStartupFiles, SIGNAL (timeout ()), this, SLOT (slotLoadStartupFiles ()));
02438 m_timerLoadStartupFiles->start (0);
02439
02440 }
02441 }
02442
02443 void MainWindow::showTemporaryMessage (const QString &temporaryMessage)
02444 {
02445 m_statusBar->showTemporaryMessage (temporaryMessage);
02446 }
02447
02448 void MainWindow::slotBtnPrintAll ()
02449 {
02450 LOG4CPP_DEBUG_S ((*mainCat)) << "MainWindow::slotBtnPrintAll";
02451
02452 ghostsCreate ();
02453
02454 QPrinter printer (QPrinter::HighResolution);
02455 QPrintDialog dlg (&printer, this);
02456 if (dlg.exec() == QDialog::Accepted) {
02457 QPainter painter (&printer);
02458 m_view->render (&painter);
02459 painter.end();
02460 }
02461
02462 ghostsDestroy ();
02463 }
02464
02465 void MainWindow::slotBtnShowAllPressed ()
02466 {
02467 LOG4CPP_DEBUG_S ((*mainCat)) << "MainWindow::slotBtnShowAllPressed";
02468
02469
02470 ghostsCreate ();
02471 }
02472
02473 void MainWindow::slotBtnShowAllReleased ()
02474 {
02475 LOG4CPP_DEBUG_S ((*mainCat)) << "MainWindow::slotBtnShowAllReleased";
02476
02477
02478 ghostsDestroy ();
02479 }
02480
02481 void MainWindow::slotCanRedoChanged (bool canRedo)
02482 {
02483 LOG4CPP_DEBUG_S ((*mainCat)) << "MainWindow::slotCanRedoChanged";
02484
02485 m_actionEditRedo->setEnabled (canRedo || m_cmdStackShadow->canRedo());
02486 }
02487
02488 void MainWindow::slotCanUndoChanged (bool canUndo)
02489 {
02490 LOG4CPP_DEBUG_S ((*mainCat)) << "MainWindow::slotCanUndoChanged";
02491
02492 m_actionEditUndo->setEnabled (canUndo);
02493 }
02494
02495 void MainWindow::slotChecklistClosed()
02496 {
02497 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotChecklistClosed";
02498
02499 m_actionViewChecklistGuide->setChecked (false);
02500 }
02501
02502 void MainWindow::slotCleanChanged(bool clean)
02503 {
02504 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotCleanChanged";
02505
02506 setWindowModified (!clean);
02507 }
02508
02509 void MainWindow::slotCmbBackground(int currentIndex)
02510 {
02511 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotCmbBackground";
02512
02513 switch (currentIndex) {
02514 case BACKGROUND_IMAGE_NONE:
02515 if (!m_actionViewBackgroundNone->isChecked()) {
02516 m_actionViewBackgroundNone->toggle();
02517 }
02518 break;
02519
02520 case BACKGROUND_IMAGE_ORIGINAL:
02521 if (!m_actionViewBackgroundOriginal->isChecked ()) {
02522 m_actionViewBackgroundOriginal->toggle();
02523 }
02524 break;
02525
02526 case BACKGROUND_IMAGE_FILTERED:
02527 if (!m_actionViewBackgroundFiltered->isChecked ()) {
02528 m_actionViewBackgroundFiltered->toggle();
02529 }
02530 break;
02531 }
02532
02533 m_backgroundStateContext->setBackgroundImage ((BackgroundImage) currentIndex);
02534 }
02535
02536 void MainWindow::slotCmbCoordSystem(int index)
02537 {
02538 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotCmbCoordSystem";
02539
02540 CmdSelectCoordSystem *cmd = new CmdSelectCoordSystem (*this,
02541 m_cmdMediator->document(),
02542 index);
02543
02544 m_cmdMediator->push (cmd);
02545 }
02546
02547 void MainWindow::slotCmbCurve(int )
02548 {
02549 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotCmbCurve";
02550
02551 m_backgroundStateContext->setCurveSelected (m_transformation,
02552 m_cmdMediator->document().modelGridRemoval(),
02553 m_cmdMediator->document().modelColorFilter(),
02554 m_cmbCurve->currentText ());
02555 m_digitizeStateContext->handleCurveChange (m_cmdMediator);
02556 m_cmdMediator->setSelectedCurveName (m_cmbCurve->currentText ());
02557
02558 updateViewedCurves();
02559 updateViewsOfSettings();
02560 }
02561
02562 void MainWindow::slotContextMenuEvent (QString pointIdentifier)
02563 {
02564 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotContextMenuEvent point=" << pointIdentifier.toLatin1 ().data ();
02565
02566 m_digitizeStateContext->handleContextMenuEvent (m_cmdMediator,
02567 pointIdentifier);
02568 }
02569
02570 void MainWindow::slotDigitizeAxis ()
02571 {
02572 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotDigitizeAxis";
02573
02574 m_digitizeStateContext->requestImmediateStateTransition (m_cmdMediator,
02575 DIGITIZE_STATE_AXIS);
02576 m_cmbCurve->setEnabled (false);
02577 m_viewPointStyle->setEnabled (true);
02578 m_viewSegmentFilter->setEnabled (true);
02579 }
02580
02581 void MainWindow::slotDigitizeColorPicker ()
02582 {
02583 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotDigitizeColorPicker";
02584
02585 m_digitizeStateContext->requestImmediateStateTransition (m_cmdMediator,
02586 DIGITIZE_STATE_COLOR_PICKER);
02587 m_cmbCurve->setEnabled (true);
02588 m_viewPointStyle->setEnabled (true);
02589 m_viewSegmentFilter->setEnabled (true);
02590 }
02591
02592 void MainWindow::slotDigitizeCurve ()
02593 {
02594 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotDigitizeCurve";
02595
02596 m_digitizeStateContext->requestImmediateStateTransition (m_cmdMediator,
02597 DIGITIZE_STATE_CURVE);
02598 m_cmbCurve->setEnabled (true);
02599 m_viewPointStyle->setEnabled (true);
02600 m_viewSegmentFilter->setEnabled (true);
02601 }
02602
02603 void MainWindow::slotDigitizePointMatch ()
02604 {
02605 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotDigitizePointMatch";
02606
02607 m_digitizeStateContext->requestImmediateStateTransition (m_cmdMediator,
02608 DIGITIZE_STATE_POINT_MATCH);
02609 m_cmbCurve->setEnabled (true);
02610 m_viewPointStyle->setEnabled (true);
02611 m_viewSegmentFilter->setEnabled (true);
02612 }
02613
02614 void MainWindow::slotDigitizeSegment ()
02615 {
02616 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotDigitizeSegment";
02617
02618 m_digitizeStateContext->requestImmediateStateTransition (m_cmdMediator,
02619 DIGITIZE_STATE_SEGMENT);
02620 m_cmbCurve->setEnabled (true);
02621 m_viewPointStyle->setEnabled (true);
02622 m_viewSegmentFilter->setEnabled (true);
02623 }
02624
02625 void MainWindow::slotDigitizeSelect ()
02626 {
02627 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotDigitizeSelect";
02628
02629 m_digitizeStateContext->requestImmediateStateTransition (m_cmdMediator,
02630 DIGITIZE_STATE_SELECT);
02631 m_cmbCurve->setEnabled (false);
02632 m_viewPointStyle->setEnabled (false);
02633 m_viewSegmentFilter->setEnabled (false);
02634 }
02635
02636 void MainWindow::slotEditCopy ()
02637 {
02638 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotEditCopy";
02639
02640 CmdCopy *cmd = new CmdCopy (*this,
02641 m_cmdMediator->document(),
02642 m_scene->selectedPointIdentifiers ());
02643 m_digitizeStateContext->appendNewCmd (m_cmdMediator,
02644 cmd);
02645 }
02646
02647 void MainWindow::slotEditCut ()
02648 {
02649 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotEditCut";
02650
02651 CmdCut *cmd = new CmdCut (*this,
02652 m_cmdMediator->document(),
02653 m_scene->selectedPointIdentifiers ());
02654 m_digitizeStateContext->appendNewCmd (m_cmdMediator,
02655 cmd);
02656 }
02657
02658 void MainWindow::slotEditDelete ()
02659 {
02660 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotEditDelete";
02661
02662 CmdDelete *cmd = new CmdDelete (*this,
02663 m_cmdMediator->document(),
02664 m_scene->selectedPointIdentifiers ());
02665 m_digitizeStateContext->appendNewCmd (m_cmdMediator,
02666 cmd);
02667 }
02668
02669 void MainWindow::slotEditMenu ()
02670 {
02671 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotEditMenu";
02672
02673 m_actionEditPasteAsNew->setEnabled (!QApplication::clipboard()->image().isNull());
02674 m_actionEditPasteAsNewAdvanced->setEnabled (!QApplication::clipboard()->image().isNull());
02675 }
02676
02677 void MainWindow::slotEditPaste ()
02678 {
02679 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotEditPaste";
02680 }
02681
02682 void MainWindow::slotEditPasteAsNew ()
02683 {
02684 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotEditPasteAsNew";
02685
02686 filePaste (IMPORT_TYPE_SIMPLE);
02687 }
02688
02689 void MainWindow::slotEditPasteAsNewAdvanced ()
02690 {
02691 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotEditPasteAsNewAdvanced";
02692
02693 filePaste (IMPORT_TYPE_ADVANCED);
02694 }
02695
02696 void MainWindow::slotFileClose()
02697 {
02698 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotFileClose";
02699
02700 if (maybeSave ()) {
02701
02702
02703
02704 m_transformationStateContext->triggerStateTransition(TRANSFORMATION_STATE_UNDEFINED,
02705 *m_cmdMediator,
02706 m_transformation,
02707 selectedGraphCurve());
02708
02709
02710
02711 m_digitizeStateContext->requestImmediateStateTransition (m_cmdMediator,
02712 DIGITIZE_STATE_EMPTY);
02713
02714
02715 m_scene->resetOnLoad ();
02716
02717
02718 m_backgroundStateContext->close ();
02719
02720
02721 m_scene->setSceneRect (QRectF (0, 0, 1, 1));
02722
02723
02724 delete m_cmdMediator;
02725
02726
02727 m_cmdMediator = 0;
02728 m_currentFile = "";
02729 m_engaugeFile = "";
02730 setWindowTitle (engaugeWindowTitle ());
02731
02732 m_gridLines.clear();
02733 updateControls();
02734 }
02735 }
02736
02737 void MainWindow::slotFileExport ()
02738 {
02739 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotFileExport";
02740
02741 if (m_transformation.transformIsDefined()) {
02742
02743 ExportToFile exportStrategy;
02744 QString filter = QString ("%1;;%2;;All files (*.*)")
02745 .arg (exportStrategy.filterCsv ())
02746 .arg (exportStrategy.filterTsv ());
02747
02748
02749 QString defaultFileName = QString ("%1/%2.%3")
02750 .arg (QDir::currentPath ())
02751 .arg (m_currentFile)
02752 .arg (exportStrategy.fileExtensionCsv ());
02753 QFileDialog dlg;
02754 QString filterCsv = exportStrategy.filterCsv ();
02755 QString fileName = dlg.getSaveFileName (this,
02756 tr("Export"),
02757 defaultFileName,
02758 filter,
02759 &filterCsv);
02760 if (!fileName.isEmpty ()) {
02761
02762 fileExport(fileName,
02763 exportStrategy);
02764 }
02765 } else {
02766 DlgRequiresTransform dlg ("Export");
02767 dlg.exec ();
02768 }
02769 }
02770
02771 void MainWindow::slotFileImport ()
02772 {
02773 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotFileImport";
02774
02775 fileImportWithPrompts (IMPORT_TYPE_SIMPLE);
02776 }
02777
02778 void MainWindow::slotFileImportAdvanced ()
02779 {
02780 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotFileImportAdvanced";
02781
02782 fileImportWithPrompts (IMPORT_TYPE_ADVANCED);
02783 }
02784
02785 void MainWindow::slotFileImportDraggedImage(QImage image)
02786 {
02787 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotFileImportDraggedImage";
02788
02789
02790 loadImage ("",
02791 image,
02792 IMPORT_TYPE_SIMPLE);
02793 }
02794
02795 void MainWindow::slotFileImportDraggedImageUrl(QUrl url)
02796 {
02797 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotFileImportDraggedImageUrl url=" << url.toString ().toLatin1 ().data ();
02798
02799 m_loadImageFromUrl->startLoadImage (url);
02800 }
02801
02802 void MainWindow::slotFileImportImage(QString fileName, QImage image)
02803 {
02804 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotFileImportImage fileName=" << fileName.toLatin1 ().data ();
02805
02806
02807 loadImage (fileName,
02808 image,
02809 IMPORT_TYPE_SIMPLE);
02810 }
02811
02812 void MainWindow::slotFileOpen()
02813 {
02814 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotFileOpen";
02815
02816 if (maybeSave ()) {
02817
02818
02819
02820 QString filter = QString ("%1 (*.%2);; All Files (*.*)")
02821 .arg (ENGAUGE_FILENAME_DESCRIPTION)
02822 .arg (ENGAUGE_FILENAME_EXTENSION);
02823
02824 QString fileName = QFileDialog::getOpenFileName (this,
02825 tr("Open Document"),
02826 QDir::currentPath (),
02827 filter);
02828 if (!fileName.isEmpty ()) {
02829
02830 loadDocumentFile (fileName);
02831
02832 }
02833 }
02834 }
02835
02836 void MainWindow::slotFileOpenDraggedDigFile (QString fileName)
02837 {
02838 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotFileOpenDraggedDigFile";
02839
02840 loadDocumentFile (fileName);
02841 }
02842
02843 void MainWindow::slotFilePrint()
02844 {
02845 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotFilePrint";
02846
02847 QPrinter printer (QPrinter::HighResolution);
02848 QPrintDialog dlg (&printer, this);
02849 if (dlg.exec() == QDialog::Accepted) {
02850 QPainter painter (&printer);
02851 m_view->render (&painter);
02852 painter.end();
02853 }
02854 }
02855
02856 bool MainWindow::slotFileSave()
02857 {
02858 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotFileSave";
02859
02860 if (m_engaugeFile.isEmpty()) {
02861 return slotFileSaveAs();
02862 } else {
02863 return saveDocumentFile (m_engaugeFile);
02864 }
02865 }
02866
02867 bool MainWindow::slotFileSaveAs()
02868 {
02869 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotFileSaveAs";
02870
02871
02872 QString filenameDefault = m_currentFile;
02873 if (!m_currentFile.endsWith (ENGAUGE_FILENAME_EXTENSION)) {
02874 filenameDefault = QString ("%1.%2")
02875 .arg (m_currentFile)
02876 .arg (ENGAUGE_FILENAME_EXTENSION);
02877 }
02878
02879 if (!m_engaugeFile.isEmpty()) {
02880 filenameDefault = m_engaugeFile;
02881 }
02882
02883 QString filterDigitizer = QString ("%1 (*.%2)")
02884 .arg (ENGAUGE_FILENAME_DESCRIPTION)
02885 .arg (ENGAUGE_FILENAME_EXTENSION);
02886 QString filterAll ("All files (*. *)");
02887
02888 QStringList filters;
02889 filters << filterDigitizer;
02890 filters << filterAll;
02891
02892 QFileDialog dlg(this);
02893 dlg.setFileMode (QFileDialog::AnyFile);
02894 dlg.selectNameFilter (filterDigitizer);
02895 dlg.setNameFilters (filters);
02896 #ifndef OSX
02897
02898 dlg.setWindowModality(Qt::WindowModal);
02899 #endif
02900 dlg.setAcceptMode(QFileDialog::AcceptSave);
02901 dlg.selectFile(filenameDefault);
02902 if (dlg.exec()) {
02903
02904 QStringList files = dlg.selectedFiles();
02905 return saveDocumentFile(files.at(0));
02906 }
02907
02908 return false;
02909 }
02910
02911 void MainWindow::slotHelpAbout()
02912 {
02913 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotHelpAbout";
02914
02915 DlgAbout dlg (*this);
02916 dlg.exec ();
02917 }
02918
02919 void MainWindow::slotHelpTutorial()
02920 {
02921 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotHelpTutorial";
02922
02923 m_tutorialDlg->show ();
02924 m_tutorialDlg->exec ();
02925 }
02926
02927 void MainWindow::slotKeyPress (Qt::Key key,
02928 bool atLeastOneSelectedItem)
02929 {
02930 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotKeyPress"
02931 << " key=" << QKeySequence (key).toString().toLatin1 ().data ()
02932 << " atLeastOneSelectedItem=" << (atLeastOneSelectedItem ? "true" : "false");
02933
02934 m_digitizeStateContext->handleKeyPress (m_cmdMediator,
02935 key,
02936 atLeastOneSelectedItem);
02937 }
02938
02939 void MainWindow::slotLeave ()
02940 {
02941 LOG4CPP_DEBUG_S ((*mainCat)) << "MainWindow::slotLeave";
02942
02943 m_digitizeStateContext->handleLeave (m_cmdMediator);
02944 }
02945
02946 void MainWindow::slotLoadStartupFiles ()
02947 {
02948 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotLoadStartupFiles";
02949
02950 ENGAUGE_ASSERT (m_loadStartupFiles.count() > 0);
02951
02952 QString fileName = m_loadStartupFiles.front();
02953 m_loadStartupFiles.pop_front();
02954
02955
02956 LoadFileInfo loadFileInfo;
02957 if (loadFileInfo.loadsAsDigFile(fileName)) {
02958
02959 loadDocumentFile (fileName);
02960
02961 } else {
02962
02963 fileImport (fileName,
02964 IMPORT_TYPE_SIMPLE);
02965
02966 }
02967
02968 if (m_loadStartupFiles.count() > 0) {
02969
02970
02971
02972 QProcess::startDetached (QCoreApplication::applicationFilePath(),
02973 m_loadStartupFiles);
02974 }
02975 }
02976
02977 void MainWindow::slotMouseMove (QPointF pos)
02978 {
02979
02980
02981
02982 if (m_cmdMediator != 0) {
02983
02984
02985 QString coordsScreen, coordsGraph, resolutionGraph;
02986 m_transformation.coordTextForStatusBar (pos,
02987 coordsScreen,
02988 coordsGraph,
02989 resolutionGraph);
02990
02991
02992 m_statusBar->setCoordinates (coordsScreen,
02993 coordsGraph,
02994 resolutionGraph);
02995
02996
02997
02998
02999 m_digitizeStateContext->handleMouseMove (m_cmdMediator,
03000 pos);
03001 }
03002 }
03003
03004 void MainWindow::slotMousePress (QPointF pos)
03005 {
03006 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotMousePress";
03007
03008 m_scene->resetPositionHasChangedFlags();
03009
03010 m_digitizeStateContext->handleMousePress (m_cmdMediator,
03011 pos);
03012 }
03013
03014 void MainWindow::slotMouseRelease (QPointF pos)
03015 {
03016 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotMouseRelease";
03017
03018 if (pos.x() < 0 || pos.y() < 0) {
03019
03020
03021
03022 updateControls ();
03023
03024 } else {
03025
03026
03027 m_digitizeStateContext->handleMouseRelease (m_cmdMediator,
03028 pos);
03029 }
03030 }
03031
03032 void MainWindow::slotRecentFileAction ()
03033 {
03034 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotRecentFileAction";
03035
03036 QAction *action = qobject_cast<QAction*>(sender ());
03037
03038 if (action) {
03039 QString fileName = action->data().toString();
03040 loadDocumentFile (fileName);
03041 }
03042 }
03043
03044 void MainWindow::slotRecentFileClear ()
03045 {
03046 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotRecentFileClear";
03047
03048 QStringList emptyList;
03049
03050 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
03051 settings.setValue (SETTINGS_RECENT_FILE_LIST,
03052 emptyList);
03053
03054 updateRecentFileList();
03055 }
03056
03057 void MainWindow::slotRedoTextChanged (const QString &text)
03058 {
03059 LOG4CPP_DEBUG_S ((*mainCat)) << "MainWindow::slotRedoTextChanged";
03060
03061 QString completeText ("Redo");
03062 if (!text.isEmpty ()) {
03063 completeText += QString (" \"%1\"").arg (text);
03064 }
03065 m_actionEditRedo->setText (completeText);
03066 }
03067
03068 void MainWindow::slotSetOverrideCursor (QCursor cursor)
03069 {
03070 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotSetOverrideCursor";
03071
03072 m_digitizeStateContext->handleSetOverrideCursor (m_cmdMediator,
03073 cursor);
03074 }
03075
03076 void MainWindow::slotSettingsAxesChecker ()
03077 {
03078 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotSettingsAxesChecker";
03079
03080 m_dlgSettingsAxesChecker->load (*m_cmdMediator);
03081 m_dlgSettingsAxesChecker->show ();
03082 }
03083
03084 void MainWindow::slotSettingsColorFilter ()
03085 {
03086 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotSettingsColorFilter";
03087
03088 m_dlgSettingsColorFilter->load (*m_cmdMediator);
03089 m_dlgSettingsColorFilter->show ();
03090 }
03091
03092 void MainWindow::slotSettingsCoords ()
03093 {
03094 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotSettingsCoords";
03095
03096 m_dlgSettingsCoords->load (*m_cmdMediator);
03097 m_dlgSettingsCoords->show ();
03098 }
03099
03100 void MainWindow::slotSettingsCurveAddRemove ()
03101 {
03102 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotSettingsCurveAddRemove";
03103
03104 m_dlgSettingsCurveAddRemove->load (*m_cmdMediator);
03105 m_dlgSettingsCurveAddRemove->show ();
03106 }
03107
03108 void MainWindow::slotSettingsCurveProperties ()
03109 {
03110 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotSettingsCurveProperties";
03111
03112 m_dlgSettingsCurveProperties->load (*m_cmdMediator);
03113 m_dlgSettingsCurveProperties->setCurveName (selectedGraphCurve ());
03114 m_dlgSettingsCurveProperties->show ();
03115 }
03116
03117 void MainWindow::slotSettingsDigitizeCurve ()
03118 {
03119 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotSettingsDigitizeCurve";
03120
03121 m_dlgSettingsDigitizeCurve->load (*m_cmdMediator);
03122 m_dlgSettingsDigitizeCurve->show ();
03123 }
03124
03125 void MainWindow::slotSettingsExportFormat ()
03126 {
03127 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotSettingsExportFormat";
03128
03129 if (transformIsDefined()) {
03130 m_dlgSettingsExportFormat->load (*m_cmdMediator);
03131 m_dlgSettingsExportFormat->show ();
03132 } else {
03133 DlgRequiresTransform dlg ("Export settings");
03134 dlg.exec();
03135 }
03136 }
03137
03138 void MainWindow::slotSettingsGeneral ()
03139 {
03140 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotSettingsGeneral";
03141
03142 m_dlgSettingsGeneral->load (*m_cmdMediator);
03143 m_dlgSettingsGeneral->show ();
03144 }
03145
03146 void MainWindow::slotSettingsGridDisplay()
03147 {
03148 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotSettingsGridDisplay";
03149
03150 m_dlgSettingsGridDisplay->load (*m_cmdMediator);
03151 m_dlgSettingsGridDisplay->show ();
03152 }
03153
03154 void MainWindow::slotSettingsGridRemoval ()
03155 {
03156 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotSettingsGridRemoval";
03157
03158 m_dlgSettingsGridRemoval->load (*m_cmdMediator);
03159 m_dlgSettingsGridRemoval->show ();
03160 }
03161
03162 void MainWindow::slotSettingsPointMatch ()
03163 {
03164 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotSettingsPointMatch";
03165
03166 m_dlgSettingsPointMatch->load (*m_cmdMediator);
03167 m_dlgSettingsPointMatch->show ();
03168 }
03169
03170 void MainWindow::slotSettingsSegments ()
03171 {
03172 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotSettingsSegments";
03173
03174 m_dlgSettingsSegments->load (*m_cmdMediator);
03175 m_dlgSettingsSegments->show ();
03176 }
03177
03178 void MainWindow::slotSettingsMainWindow ()
03179 {
03180 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotSettingsMainWindow";
03181
03182 m_dlgSettingsMainWindow->loadMainWindowModel (*m_cmdMediator,
03183 m_modelMainWindow);
03184 m_dlgSettingsMainWindow->show ();
03185 }
03186
03187 void MainWindow::slotTimeoutRegressionErrorReport ()
03188 {
03189 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotTimeoutRegressionErrorReport"
03190 << " cmdStackIndex=" << m_cmdMediator->index()
03191 << " cmdStackCount=" << m_cmdMediator->count();
03192
03193 if (m_cmdStackShadow->canRedo()) {
03194
03195 m_cmdStackShadow->slotRedo();
03196
03197 } else {
03198
03199 #ifndef OSX
03200 exportAllCoordinateSystems ();
03201 #endif
03202
03203
03204 m_cmdMediator->setClean();
03205 close();
03206
03207 }
03208 }
03209
03210 void MainWindow::slotTimeoutRegressionFileCmdScript ()
03211 {
03212 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotTimeoutRegressionFileCmdScript";
03213
03214 if (m_fileCmdScript->canRedo()) {
03215
03216 m_fileCmdScript->redo(*this);
03217
03218 } else {
03219
03220
03221 if (m_cmdMediator != 0) {
03222
03223 #ifndef OSX
03224 exportAllCoordinateSystems ();
03225 #endif
03226
03227
03228 m_cmdMediator->setClean();
03229
03230 }
03231
03232
03233 close();
03234
03235 }
03236 }
03237
03238 void MainWindow::slotUndoTextChanged (const QString &text)
03239 {
03240 LOG4CPP_DEBUG_S ((*mainCat)) << "MainWindow::slotUndoTextChanged";
03241
03242 QString completeText ("Undo");
03243 if (!text.isEmpty ()) {
03244 completeText += QString (" \"%1\"").arg (text);
03245 }
03246 m_actionEditUndo->setText (completeText);
03247 }
03248
03249 void MainWindow::slotViewGridLines ()
03250 {
03251 LOG4CPP_DEBUG_S ((*mainCat)) << "MainWindow::slotViewGridLines";
03252
03253 updateGridLines ();
03254 }
03255
03256 void MainWindow::slotViewGroupBackground(QAction *action)
03257 {
03258 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotViewGroupBackground";
03259
03260
03261 BackgroundImage backgroundImage;
03262 int indexBackground;
03263 if (action == m_actionViewBackgroundNone) {
03264 indexBackground = m_cmbBackground->findData (QVariant (BACKGROUND_IMAGE_NONE));
03265 backgroundImage = BACKGROUND_IMAGE_NONE;
03266 } else if (action == m_actionViewBackgroundOriginal) {
03267 indexBackground = m_cmbBackground->findData (QVariant (BACKGROUND_IMAGE_ORIGINAL));
03268 backgroundImage = BACKGROUND_IMAGE_ORIGINAL;
03269 } else if (action == m_actionViewBackgroundFiltered) {
03270 indexBackground = m_cmbBackground->findData (QVariant (BACKGROUND_IMAGE_FILTERED));
03271 backgroundImage = BACKGROUND_IMAGE_FILTERED;
03272 } else {
03273 ENGAUGE_ASSERT (false);
03274
03275
03276 indexBackground = m_cmbBackground->findData (QVariant (BACKGROUND_IMAGE_ORIGINAL));
03277 backgroundImage = BACKGROUND_IMAGE_ORIGINAL;
03278 }
03279
03280 m_cmbBackground->setCurrentIndex (indexBackground);
03281 m_backgroundStateContext->setBackgroundImage (backgroundImage);
03282 }
03283
03284 void MainWindow::slotViewGroupCurves(QAction * )
03285 {
03286 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotViewGroupCurves";
03287
03288 updateViewedCurves ();
03289 }
03290
03291 void MainWindow::slotViewGroupStatus(QAction *action)
03292 {
03293 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotViewGroupStatus";
03294
03295 ENGAUGE_CHECK_PTR (m_statusBar);
03296
03297 if (action == m_actionStatusNever) {
03298 m_statusBar->setStatusBarMode(STATUS_BAR_MODE_NEVER);
03299 } else if (action == m_actionStatusTemporary) {
03300 m_statusBar->setStatusBarMode(STATUS_BAR_MODE_TEMPORARY);
03301 } else {
03302 m_statusBar->setStatusBarMode(STATUS_BAR_MODE_ALWAYS);
03303 }
03304 }
03305
03306 void MainWindow::slotViewToolBarBackground ()
03307 {
03308 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotViewToolBarBackground";
03309
03310 if (m_actionViewBackground->isChecked ()) {
03311 m_toolBackground->show();
03312 } else {
03313 m_toolBackground->hide();
03314 }
03315 }
03316
03317 void MainWindow::slotViewToolBarChecklistGuide ()
03318 {
03319 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotViewToolBarChecklistGuide";
03320
03321 if (m_actionViewChecklistGuide->isChecked ()) {
03322 m_dockChecklistGuide->show();
03323 } else {
03324 m_dockChecklistGuide->hide();
03325 }
03326 }
03327
03328 void MainWindow::slotViewToolBarCoordSystem ()
03329 {
03330 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotViewToolBarCoordSystem";
03331
03332 if (m_actionViewCoordSystem->isChecked ()) {
03333 m_toolCoordSystem->show();
03334 } else {
03335 m_toolCoordSystem->hide();
03336 }
03337 }
03338
03339 void MainWindow::slotViewToolBarDigitize ()
03340 {
03341 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotViewToolBarDigitize";
03342
03343 if (m_actionViewDigitize->isChecked ()) {
03344 m_toolDigitize->show();
03345 } else {
03346 m_toolDigitize->hide();
03347 }
03348 }
03349
03350 void MainWindow::slotViewToolBarSettingsViews ()
03351 {
03352 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotViewToolBarSettingsViews";
03353
03354 if (m_actionViewSettingsViews->isChecked ()) {
03355 m_toolSettingsViews->show();
03356 } else {
03357 m_toolSettingsViews->hide();
03358 }
03359 }
03360
03361 void MainWindow::slotViewToolTips ()
03362 {
03363 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotViewToolTips";
03364
03365 loadToolTips();
03366 }
03367
03368 void MainWindow::slotViewZoom(int zoom)
03369 {
03370 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotViewZoom";
03371
03372
03373 switch ((ZoomFactor) zoom) {
03374 case ZOOM_16_TO_1:
03375 m_actionZoom16To1->setChecked(true);
03376 slotViewZoom16To1 ();
03377 break;
03378 case ZOOM_8_TO_1:
03379 m_actionZoom8To1->setChecked(true);
03380 slotViewZoom8To1 ();
03381 break;
03382 case ZOOM_4_TO_1:
03383 m_actionZoom4To1->setChecked(true);
03384 slotViewZoom4To1 ();
03385 break;
03386 case ZOOM_2_TO_1:
03387 m_actionZoom2To1->setChecked(true);
03388 slotViewZoom2To1 ();
03389 break;
03390 case ZOOM_1_TO_1:
03391 m_actionZoom1To1->setChecked(true);
03392 slotViewZoom1To1 ();
03393 break;
03394 case ZOOM_1_TO_2:
03395 m_actionZoom1To2->setChecked(true);
03396 slotViewZoom1To2 ();
03397 break;
03398 case ZOOM_1_TO_4:
03399 m_actionZoom1To4->setChecked(true);
03400 slotViewZoom1To4 ();
03401 break;
03402 case ZOOM_1_TO_8:
03403 m_actionZoom1To8->setChecked(true);
03404 slotViewZoom1To8 ();
03405 break;
03406 case ZOOM_1_TO_16:
03407 m_actionZoom1To16->setChecked(true);
03408 slotViewZoom1To16 ();
03409 break;
03410 case ZOOM_FILL:
03411 m_actionZoomFill->setChecked(true);
03412 slotViewZoomFill ();
03413 break;
03414 }
03415 }
03416
03417 void MainWindow::slotViewZoom16To1 ()
03418 {
03419 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotViewZoom16To1";
03420
03421 QTransform transform;
03422 transform.scale (16.0, 16.0);
03423 m_view->setTransform (transform);
03424 emit signalZoom(ZOOM_16_TO_1);
03425 }
03426
03427 void MainWindow::slotViewZoom8To1 ()
03428 {
03429 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotViewZoom8To1";
03430
03431 QTransform transform;
03432 transform.scale (8.0, 8.0);
03433 m_view->setTransform (transform);
03434 emit signalZoom(ZOOM_8_TO_1);
03435 }
03436
03437 void MainWindow::slotViewZoom4To1 ()
03438 {
03439 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotViewZoom4To1";
03440
03441 QTransform transform;
03442 transform.scale (4.0, 4.0);
03443 m_view->setTransform (transform);
03444 emit signalZoom(ZOOM_4_TO_1);
03445 }
03446
03447 void MainWindow::slotViewZoom2To1 ()
03448 {
03449 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotZoom2To1";
03450
03451 QTransform transform;
03452 transform.scale (2.0, 2.0);
03453 m_view->setTransform (transform);
03454 emit signalZoom(ZOOM_2_TO_1);
03455 }
03456
03457 void MainWindow::slotViewZoom1To1 ()
03458 {
03459 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotViewZoom1To1";
03460
03461 QTransform transform;
03462 transform.scale (1.0, 1.0);
03463 m_view->setTransform (transform);
03464 emit signalZoom(ZOOM_1_TO_1);
03465 }
03466
03467 void MainWindow::slotViewZoom1To2 ()
03468 {
03469 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotZoom1To2";
03470
03471 QTransform transform;
03472 transform.scale (0.5, 0.5);
03473 m_view->setTransform (transform);
03474 emit signalZoom(ZOOM_1_TO_2);
03475 }
03476
03477 void MainWindow::slotViewZoom1To4 ()
03478 {
03479 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotZoom1To4";
03480
03481 QTransform transform;
03482 transform.scale (0.25, 0.25);
03483 m_view->setTransform (transform);
03484 emit signalZoom(ZOOM_1_TO_4);
03485 }
03486
03487 void MainWindow::slotViewZoom1To8 ()
03488 {
03489 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotZoom1To8";
03490
03491 QTransform transform;
03492 transform.scale (0.125, 0.125);
03493 m_view->setTransform (transform);
03494 emit signalZoom(ZOOM_1_TO_8);
03495 }
03496
03497 void MainWindow::slotViewZoom1To16 ()
03498 {
03499 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotZoom1To16";
03500
03501 QTransform transform;
03502 transform.scale (0.0625, 0.0625);
03503 m_view->setTransform (transform);
03504 emit signalZoom(ZOOM_1_TO_16);
03505 }
03506
03507 void MainWindow::slotViewZoomFill ()
03508 {
03509 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotViewZoomFill";
03510
03511 m_backgroundStateContext->fitInView (*m_view);
03512
03513 emit signalZoom(ZOOM_FILL);
03514 }
03515
03516 void MainWindow::slotViewZoomIn ()
03517 {
03518 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotViewZoomIn";
03519
03520
03521
03522 bool goto16To1 = false, goto8To1 = false, goto4To1 = false, goto2To1 = false;
03523 bool goto1To1 = false;
03524 bool goto1To2 = false, goto1To4 = false, goto1To8 = false, goto1To16 = false;
03525 if (m_actionZoomFill->isChecked ()) {
03526
03527
03528 double xScale = m_view->transform().m11();
03529 double yScale = m_view->transform().m22();
03530 double scale = qMin(xScale, yScale);
03531 if (scale < 0.125) {
03532 goto1To8 = true;
03533 } else if (scale < 0.25) {
03534 goto1To4 = true;
03535 } else if (scale < 0.5) {
03536 goto1To2 = true;
03537 } else if (scale < 1) {
03538 goto1To1 = true;
03539 } else if (scale < 2) {
03540 goto2To1 = true;
03541 } else if (scale < 4) {
03542 goto4To1 = true;
03543 } else if (scale < 8) {
03544 goto8To1 = true;
03545 } else {
03546 goto1To16 = true;
03547 }
03548 } else {
03549 goto16To1 = m_actionZoom8To1->isChecked ();
03550 goto8To1 = m_actionZoom4To1->isChecked ();
03551 goto4To1 = m_actionZoom2To1->isChecked ();
03552 goto2To1 = m_actionZoom1To1->isChecked ();
03553 goto1To1 = m_actionZoom1To2->isChecked ();
03554 goto1To2 = m_actionZoom1To4->isChecked ();
03555 goto1To4 = m_actionZoom1To8->isChecked ();
03556 goto1To8 = m_actionZoom1To16->isChecked ();
03557 }
03558
03559
03560 if (goto16To1) {
03561 m_actionZoom16To1->setChecked (true);
03562 slotViewZoom16To1 ();
03563 } else if (goto8To1) {
03564 m_actionZoom8To1->setChecked (true);
03565 slotViewZoom8To1 ();
03566 } else if (goto4To1) {
03567 m_actionZoom4To1->setChecked (true);
03568 slotViewZoom4To1 ();
03569 } else if (goto2To1) {
03570 m_actionZoom2To1->setChecked (true);
03571 slotViewZoom2To1 ();
03572 } else if (goto1To1) {
03573 m_actionZoom1To1->setChecked (true);
03574 slotViewZoom1To1 ();
03575 } else if (goto1To2) {
03576 m_actionZoom1To2->setChecked (true);
03577 slotViewZoom1To2 ();
03578 } else if (goto1To4) {
03579 m_actionZoom1To4->setChecked (true);
03580 slotViewZoom1To4 ();
03581 } else if (goto1To8) {
03582 m_actionZoom1To8->setChecked (true);
03583 slotViewZoom1To8 ();
03584 } else if (goto1To16) {
03585 m_actionZoom1To16->setChecked (true);
03586 slotViewZoom1To16 ();
03587 }
03588 }
03589
03590 void MainWindow::slotViewZoomInFromWheelEvent ()
03591 {
03592 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotViewZoomInFromWheelEvent";
03593
03594 if ((m_modelMainWindow.zoomControl() == ZOOM_CONTROL_MENU_WHEEL) ||
03595 (m_modelMainWindow.zoomControl() == ZOOM_CONTROL_MENU_WHEEL_PLUSMINUS)) {
03596
03597
03598 m_view->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
03599
03600
03601 slotViewZoomIn ();
03602
03603 m_view->setTransformationAnchor(QGraphicsView::NoAnchor);
03604 }
03605 }
03606
03607 void MainWindow::slotViewZoomOut ()
03608 {
03609 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotViewZoomOut";
03610
03611
03612
03613 bool goto16To1 = false, goto8To1 = false, goto4To1 = false, goto2To1 = false;
03614 bool goto1To1 = false;
03615 bool goto1To2 = false, goto1To4 = false, goto1To8 = false, goto1To16 = false;
03616 if (m_actionZoomFill->isChecked ()) {
03617
03618
03619 double xScale = m_view->transform().m11();
03620 double yScale = m_view->transform().m22();
03621 double scale = qMax(xScale, yScale);
03622 if (scale > 8) {
03623 goto8To1 = true;
03624 } else if (scale > 4) {
03625 goto4To1 = true;
03626 } else if (scale > 2) {
03627 goto2To1 = true;
03628 } else if (scale > 1) {
03629 goto1To1 = true;
03630 } else if (scale > 0.5) {
03631 goto1To2 = true;
03632 } else if (scale > 0.25) {
03633 goto1To4 = true;
03634 } else if (scale > 0.125) {
03635 goto1To8 = true;
03636 } else {
03637 goto1To16 = true;
03638 }
03639 } else {
03640 goto8To1 = m_actionZoom16To1->isChecked ();
03641 goto4To1 = m_actionZoom8To1->isChecked ();
03642 goto2To1 = m_actionZoom4To1->isChecked ();
03643 goto1To1 = m_actionZoom2To1->isChecked ();
03644 goto1To2 = m_actionZoom1To1->isChecked ();
03645 goto1To4 = m_actionZoom1To2->isChecked ();
03646 goto1To8 = m_actionZoom1To4->isChecked ();
03647 goto1To16 = m_actionZoom1To8->isChecked ();
03648 }
03649
03650
03651 if (goto1To16) {
03652 m_actionZoom1To16->setChecked (true);
03653 slotViewZoom1To16 ();
03654 } else if (goto1To8) {
03655 m_actionZoom1To8->setChecked (true);
03656 slotViewZoom1To8 ();
03657 } else if (goto1To4) {
03658 m_actionZoom1To4->setChecked (true);
03659 slotViewZoom1To4 ();
03660 } else if (goto1To2) {
03661 m_actionZoom1To2->setChecked (true);
03662 slotViewZoom1To2 ();
03663 } else if (goto1To1) {
03664 m_actionZoom1To1->setChecked (true);
03665 slotViewZoom1To1 ();
03666 } else if (goto2To1) {
03667 m_actionZoom2To1->setChecked (true);
03668 slotViewZoom2To1 ();
03669 } else if (goto4To1) {
03670 m_actionZoom4To1->setChecked (true);
03671 slotViewZoom4To1 ();
03672 } else if (goto8To1) {
03673 m_actionZoom8To1->setChecked (true);
03674 slotViewZoom8To1 ();
03675 } else if (goto16To1) {
03676 m_actionZoom16To1->setChecked (true);
03677 slotViewZoom16To1 ();
03678 }
03679 }
03680
03681 void MainWindow::slotViewZoomOutFromWheelEvent ()
03682 {
03683 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::slotViewZoomOutFromWheelEvent";
03684
03685 if ((m_modelMainWindow.zoomControl() == ZOOM_CONTROL_MENU_WHEEL) ||
03686 (m_modelMainWindow.zoomControl() == ZOOM_CONTROL_MENU_WHEEL_PLUSMINUS)) {
03687
03688
03689 m_view->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
03690
03691
03692 slotViewZoomOut ();
03693
03694 m_view->setTransformationAnchor(QGraphicsView::NoAnchor);
03695 }
03696 }
03697
03698 void MainWindow::startRegressionTestErrorReport(const QString &initialPath,
03699 const QString ®ressionInputFile)
03700 {
03701 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::startRegressionTestErrorReport";
03702
03703
03704
03705
03706
03707 Point::setIdentifierIndex(0);
03708
03709
03710
03711 QString absoluteRegressionInputFile = QString ("%1/%2")
03712 .arg (initialPath)
03713 .arg (regressionInputFile);
03714
03715
03716 m_regressionFile = exportFilenameFromInputFilename (absoluteRegressionInputFile);
03717
03718 m_timerRegressionErrorReport = new QTimer();
03719 m_timerRegressionErrorReport->setSingleShot(false);
03720 connect (m_timerRegressionErrorReport, SIGNAL (timeout()), this, SLOT (slotTimeoutRegressionErrorReport()));
03721
03722 m_timerRegressionErrorReport->start(REGRESSION_INTERVAL);
03723 }
03724
03725 void MainWindow::startRegressionTestFileCmdScript()
03726 {
03727 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::startRegressionTestFileCmdScript";
03728
03729 m_timerRegressionFileCmdScript = new QTimer();
03730 m_timerRegressionFileCmdScript->setSingleShot(false);
03731 connect (m_timerRegressionFileCmdScript, SIGNAL (timeout()), this, SLOT (slotTimeoutRegressionFileCmdScript()));
03732
03733 m_timerRegressionFileCmdScript->start(REGRESSION_INTERVAL);
03734 }
03735
03736 Transformation MainWindow::transformation() const
03737 {
03738 return m_transformation;
03739 }
03740
03741 bool MainWindow::transformIsDefined() const
03742 {
03743 return m_transformation.transformIsDefined();
03744 }
03745
03746 void MainWindow::updateAfterCommand ()
03747 {
03748 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateAfterCommand";
03749
03750 ENGAUGE_CHECK_PTR (m_cmdMediator);
03751
03752
03753
03754 updateAfterCommandStatusBarCoords ();
03755
03756
03757
03758 m_scene->updateAfterCommand (*m_cmdMediator);
03759
03760 updateControls ();
03761
03762
03763 m_dockChecklistGuide->update (*m_cmdMediator,
03764 m_isDocumentExported);
03765
03766
03767
03768 writeCheckpointToLogFile ();
03769 }
03770
03771 void MainWindow::updateAfterCommandStatusBarCoords ()
03772 {
03773 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateAfterCommandStatusBarCoords";
03774
03775
03776
03777
03778 const QPoint HACK_SO_GRAPH_COORDINATE_MATCHES_INPUT (1, 1);
03779
03780 Transformation m_transformationBefore (m_transformation);
03781
03782 updateTransformationAndItsDependencies();
03783
03784
03785 if (!m_transformationBefore.transformIsDefined() && m_transformation.transformIsDefined()) {
03786
03787
03788 m_transformationStateContext->triggerStateTransition(TRANSFORMATION_STATE_DEFINED,
03789 *m_cmdMediator,
03790 m_transformation,
03791 selectedGraphCurve());
03792
03793 } else if (m_transformationBefore.transformIsDefined() && !m_transformation.transformIsDefined()) {
03794
03795
03796 m_transformationStateContext->triggerStateTransition(TRANSFORMATION_STATE_UNDEFINED,
03797 *m_cmdMediator,
03798 m_transformation,
03799 selectedGraphCurve());
03800
03801 } else if (m_transformation.transformIsDefined() && (m_transformationBefore != m_transformation)) {
03802
03803
03804
03805 m_transformationStateContext->updateAxesChecker(*m_cmdMediator,
03806 m_transformation);
03807
03808 }
03809
03810 QPoint posLocal = m_view->mapFromGlobal (QCursor::pos ()) - HACK_SO_GRAPH_COORDINATE_MATCHES_INPUT;
03811 QPointF posScreen = m_view->mapToScene (posLocal);
03812
03813 slotMouseMove (posScreen);
03814 }
03815
03816 void MainWindow::updateAfterMouseRelease ()
03817 {
03818 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateAfterMouseRelease";
03819
03820 updateControls ();
03821 }
03822
03823 void MainWindow::updateControls ()
03824 {
03825 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateControls"
03826 << " selectedItems=" << m_scene->selectedItems().count();
03827
03828 m_cmbBackground->setEnabled (!m_currentFile.isEmpty ());
03829
03830 #ifndef OSX
03831 m_menuFileOpenRecent->setEnabled ((m_actionRecentFiles.count () > 0) &&
03832 (m_actionRecentFiles.at(0)->isVisible ()));
03833 #endif
03834 m_actionClose->setEnabled (!m_currentFile.isEmpty ());
03835 m_actionSave->setEnabled (!m_currentFile.isEmpty ());
03836 m_actionSaveAs->setEnabled (!m_currentFile.isEmpty ());
03837 m_actionExport->setEnabled (!m_currentFile.isEmpty ());
03838 m_actionPrint->setEnabled (!m_currentFile.isEmpty ());
03839
03840 if (m_cmdMediator == 0) {
03841 m_actionEditUndo->setEnabled (false);
03842 m_actionEditRedo->setEnabled (false);
03843 } else {
03844 m_actionEditUndo->setEnabled (m_cmdMediator->canUndo ());
03845 m_actionEditRedo->setEnabled (m_cmdMediator->canRedo () || m_cmdStackShadow->canRedo ());
03846 }
03847 m_actionEditCut->setEnabled (m_scene->selectedItems().count () > 0);
03848 m_actionEditCopy->setEnabled (m_scene->selectedItems().count () > 0);
03849 m_actionEditPaste->setEnabled (false);
03850 m_actionEditDelete->setEnabled (m_scene->selectedItems().count () > 0);
03851
03852
03853 m_actionDigitizeAxis->setEnabled (!m_currentFile.isEmpty ());
03854 m_actionDigitizeCurve ->setEnabled (!m_currentFile.isEmpty ());
03855 m_actionDigitizePointMatch->setEnabled (!m_currentFile.isEmpty ());
03856 m_actionDigitizeColorPicker->setEnabled (!m_currentFile.isEmpty ());
03857 m_actionDigitizeSegment->setEnabled (!m_currentFile.isEmpty ());
03858 m_actionDigitizeSelect->setEnabled (!m_currentFile.isEmpty ());
03859 if (m_transformation.transformIsDefined()) {
03860 m_actionViewGridLines->setEnabled (true);
03861 } else {
03862 m_actionViewGridLines->setEnabled (false);
03863 m_actionViewGridLines->setChecked (false);
03864 }
03865 m_actionViewBackground->setEnabled (!m_currentFile.isEmpty());
03866 m_actionViewChecklistGuide->setEnabled (!m_dockChecklistGuide->browserIsEmpty());
03867 m_actionViewDigitize->setEnabled (!m_currentFile.isEmpty ());
03868 m_actionViewSettingsViews->setEnabled (!m_currentFile.isEmpty ());
03869
03870 m_actionSettingsCoords->setEnabled (!m_currentFile.isEmpty ());
03871 m_actionSettingsCurveAddRemove->setEnabled (!m_currentFile.isEmpty ());
03872 m_actionSettingsCurveProperties->setEnabled (!m_currentFile.isEmpty ());
03873 m_actionSettingsDigitizeCurve->setEnabled (!m_currentFile.isEmpty ());
03874 m_actionSettingsExport->setEnabled (!m_currentFile.isEmpty ());
03875 m_actionSettingsColorFilter->setEnabled (!m_currentFile.isEmpty ());
03876 m_actionSettingsAxesChecker->setEnabled (!m_currentFile.isEmpty ());
03877 m_actionSettingsGridDisplay->setEnabled (!m_currentFile.isEmpty () && m_transformation.transformIsDefined());
03878 m_actionSettingsGridRemoval->setEnabled (!m_currentFile.isEmpty ());
03879 m_actionSettingsPointMatch->setEnabled (!m_currentFile.isEmpty ());
03880 m_actionSettingsSegments->setEnabled (!m_currentFile.isEmpty ());
03881 m_actionSettingsGeneral->setEnabled (!m_currentFile.isEmpty ());
03882
03883 m_groupBackground->setEnabled (!m_currentFile.isEmpty ());
03884 m_groupCurves->setEnabled (!m_currentFile.isEmpty ());
03885 m_groupZoom->setEnabled (!m_currentFile.isEmpty ());
03886
03887 m_actionZoomIn->setEnabled (!m_currentFile.isEmpty ());
03888 m_actionZoomOut->setEnabled (!m_currentFile.isEmpty ());
03889 }
03890
03891 void MainWindow::updateCoordSystem(CoordSystemIndex coordSystemIndex)
03892 {
03893 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateCoordSystem";
03894
03895
03896
03897 m_cmdMediator->document().setCoordSystemIndex (coordSystemIndex);
03898 loadCurveListFromCmdMediator ();
03899
03900 updateTransformationAndItsDependencies();
03901 updateSettingsAxesChecker(m_cmdMediator->document().modelAxesChecker());
03902
03903
03904 m_transformationStateContext->updateAxesChecker (*m_cmdMediator,
03905 m_transformation);
03906
03907 updateAfterCommand();
03908 }
03909
03910 void MainWindow::updateDigitizeStateIfSoftwareTriggered (DigitizeState digitizeState)
03911 {
03912 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateDigitizeStateIfSoftwareTriggered";
03913
03914 switch (digitizeState) {
03915 case DIGITIZE_STATE_AXIS:
03916 m_actionDigitizeAxis->setChecked(true);
03917 slotDigitizeAxis();
03918 break;
03919
03920 case DIGITIZE_STATE_COLOR_PICKER:
03921 m_actionDigitizeColorPicker->setChecked(true);
03922 slotDigitizeColorPicker();
03923 break;
03924
03925 case DIGITIZE_STATE_CURVE:
03926 m_actionDigitizeCurve->setChecked(true);
03927 slotDigitizeCurve();
03928 break;
03929
03930 case DIGITIZE_STATE_EMPTY:
03931 break;
03932
03933 case DIGITIZE_STATE_POINT_MATCH:
03934 m_actionDigitizePointMatch->setChecked(true);
03935 slotDigitizePointMatch();
03936 break;
03937
03938 case DIGITIZE_STATE_SEGMENT:
03939 m_actionDigitizeSegment->setChecked(true);
03940 slotDigitizeSegment();
03941 break;
03942
03943 case DIGITIZE_STATE_SELECT:
03944 m_actionDigitizeSelect->setChecked(true);
03945 slotDigitizeSelect();
03946 break;
03947
03948 default:
03949 LOG4CPP_ERROR_S ((*mainCat)) << "MainWindow::updateDigitizeStateIfSoftwareTriggered";
03950 break;
03951 }
03952 }
03953
03954 void MainWindow::updateGraphicsLinesToMatchGraphicsPoints()
03955 {
03956 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateGraphicsLinesToMatchGraphicsPoints";
03957
03958 m_scene->updateGraphicsLinesToMatchGraphicsPoints(m_cmdMediator->document().modelCurveStyles(),
03959 m_transformation);
03960 }
03961
03962 void MainWindow::updateGridLines ()
03963 {
03964 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateGridLines";
03965
03966
03967 m_gridLines.clear ();
03968
03969
03970 GridLineFactory factory (*m_scene,
03971 m_cmdMediator->document().modelCoords(),
03972 m_transformation);
03973 factory.createGridLinesForEvenlySpacedGrid (m_cmdMediator->document().modelGridDisplay(),
03974 m_gridLines);
03975
03976 m_gridLines.setVisible (m_actionViewGridLines->isChecked());
03977 }
03978
03979 void MainWindow::updateRecentFileList()
03980 {
03981 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateRecentFileList";
03982
03983 #ifndef OSX
03984 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
03985 QStringList recentFilePaths = settings.value(SETTINGS_RECENT_FILE_LIST).toStringList();
03986
03987
03988 unsigned int count = recentFilePaths.size();
03989 if (count > MAX_RECENT_FILE_LIST_SIZE) {
03990 count = MAX_RECENT_FILE_LIST_SIZE;
03991 }
03992
03993
03994 unsigned int i;
03995 for (i = 0; i < count; i++) {
03996 QString strippedName = QFileInfo (recentFilePaths.at(i)).fileName();
03997 m_actionRecentFiles.at (i)->setText (strippedName);
03998 m_actionRecentFiles.at (i)->setData (recentFilePaths.at (i));
03999 m_actionRecentFiles.at (i)->setVisible (true);
04000 }
04001
04002
04003 for (i = count; i < MAX_RECENT_FILE_LIST_SIZE; i++) {
04004 m_actionRecentFiles.at (i)->setVisible (false);
04005 }
04006 #endif
04007 }
04008
04009 void MainWindow::updateSettingsAxesChecker(const DocumentModelAxesChecker &modelAxesChecker)
04010 {
04011 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateSettingsAxesChecker";
04012
04013 m_cmdMediator->document().setModelAxesChecker(modelAxesChecker);
04014 if (m_transformation.transformIsDefined()) {
04015 m_transformationStateContext->triggerStateTransition(TRANSFORMATION_STATE_DEFINED,
04016 *m_cmdMediator,
04017 m_transformation,
04018 m_cmbCurve->currentText());
04019 } else {
04020 m_transformationStateContext->triggerStateTransition(TRANSFORMATION_STATE_UNDEFINED,
04021 *m_cmdMediator,
04022 m_transformation,
04023 m_cmbCurve->currentText());
04024 }
04025 }
04026
04027 void MainWindow::updateSettingsColorFilter(const DocumentModelColorFilter &modelColorFilter)
04028 {
04029 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateSettingsColorFilter";
04030
04031 m_cmdMediator->document().setModelColorFilter(modelColorFilter);
04032 m_backgroundStateContext->updateColorFilter (m_transformation,
04033 m_cmdMediator->document().modelGridRemoval(),
04034 modelColorFilter,
04035 m_cmbCurve->currentText());
04036 m_digitizeStateContext->handleCurveChange (m_cmdMediator);
04037 updateViewsOfSettings();
04038 }
04039
04040 void MainWindow::updateSettingsCoords(const DocumentModelCoords &modelCoords)
04041 {
04042 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateSettingsCoords";
04043
04044 m_cmdMediator->document().setModelCoords(modelCoords);
04045 }
04046
04047 void MainWindow::updateSettingsCurveAddRemove (const CurvesGraphs &curvesGraphs)
04048 {
04049 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateSettingsCurveAddRemove";
04050
04051 m_cmdMediator->document().setCurvesGraphs (curvesGraphs);
04052 loadCurveListFromCmdMediator();
04053 updateViewsOfSettings();
04054 }
04055
04056 void MainWindow::updateSettingsCurveStyles(const CurveStyles &modelCurveStyles)
04057 {
04058 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateSettingsCurveStyles";
04059
04060 m_scene->updateCurveStyles(modelCurveStyles);
04061 m_cmdMediator->document().setModelCurveStyles(modelCurveStyles);
04062 updateViewsOfSettings();
04063 }
04064
04065 void MainWindow::updateSettingsDigitizeCurve(const DocumentModelDigitizeCurve &modelDigitizeCurve)
04066 {
04067 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateSettingsDigitizeCurve";
04068
04069 m_cmdMediator->document().setModelDigitizeCurve(modelDigitizeCurve);
04070 m_digitizeStateContext->updateModelDigitizeCurve (m_cmdMediator,
04071 modelDigitizeCurve);
04072 }
04073
04074 void MainWindow::updateSettingsExportFormat(const DocumentModelExportFormat &modelExport)
04075 {
04076 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateSettingsExportFormat";
04077
04078 m_cmdMediator->document().setModelExport (modelExport);
04079 }
04080
04081 void MainWindow::updateSettingsGeneral(const DocumentModelGeneral &modelGeneral)
04082 {
04083 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateSettingsGeneral";
04084
04085 m_cmdMediator->document().setModelGeneral(modelGeneral);
04086 }
04087
04088 void MainWindow::updateSettingsGridDisplay(const DocumentModelGridDisplay &modelGridDisplay)
04089 {
04090 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateSettingsGridDisplay";
04091
04092 m_cmdMediator->document().setModelGridDisplay(modelGridDisplay);
04093 }
04094
04095 void MainWindow::updateSettingsGridRemoval(const DocumentModelGridRemoval &modelGridRemoval)
04096 {
04097 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateSettingsGridRemoval";
04098
04099 m_cmdMediator->document().setModelGridRemoval(modelGridRemoval);
04100 }
04101
04102 void MainWindow::updateSettingsMainWindow()
04103 {
04104 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateSettingsMainWindow";
04105
04106 if (m_modelMainWindow.zoomControl() == ZOOM_CONTROL_MENU_ONLY ||
04107 m_modelMainWindow.zoomControl() == ZOOM_CONTROL_MENU_WHEEL) {
04108
04109 m_actionZoomIn->setShortcut (tr (""));
04110 m_actionZoomOut->setShortcut (tr (""));
04111
04112 } else {
04113
04114 m_actionZoomIn->setShortcut (tr ("+"));
04115 m_actionZoomOut->setShortcut (tr ("-"));
04116
04117 }
04118
04119 updateWindowTitle();
04120 }
04121
04122 void MainWindow::updateSettingsMainWindow(const MainWindowModel &modelMainWindow)
04123 {
04124 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateSettingsMainWindow";
04125
04126 m_modelMainWindow = modelMainWindow;
04127 updateSettingsMainWindow();
04128 }
04129
04130 void MainWindow::updateSettingsPointMatch(const DocumentModelPointMatch &modelPointMatch)
04131 {
04132 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateSettingsPointMatch";
04133
04134 m_cmdMediator->document().setModelPointMatch(modelPointMatch);
04135 }
04136
04137 void MainWindow::updateSettingsSegments(const DocumentModelSegments &modelSegments)
04138 {
04139 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateSettingsSegments";
04140
04141 m_cmdMediator->document().setModelSegments(modelSegments);
04142 m_digitizeStateContext->updateModelSegments(modelSegments);
04143 }
04144
04145 void MainWindow::updateTransformationAndItsDependencies()
04146 {
04147 m_transformation.update (!m_currentFile.isEmpty (),
04148 *m_cmdMediator,
04149 m_modelMainWindow);
04150
04151
04152 m_backgroundStateContext->setCurveSelected (m_transformation,
04153 m_cmdMediator->document().modelGridRemoval(),
04154 m_cmdMediator->document().modelColorFilter(),
04155 m_cmbCurve->currentText ());
04156
04157
04158
04159 updateGridLines();
04160 }
04161
04162 void MainWindow::updateViewedCurves ()
04163 {
04164 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateViewedCurves";
04165
04166 if (m_actionViewCurvesAll->isChecked ()) {
04167
04168 m_scene->showCurves (true, true);
04169
04170 } else if (m_actionViewCurvesSelected->isChecked ()) {
04171
04172 m_scene->showCurves (true, false, selectedGraphCurve ());
04173
04174 } else if (m_actionViewCurvesNone->isChecked ()) {
04175
04176 m_scene->showCurves (false);
04177
04178 } else {
04179 ENGAUGE_ASSERT (false);
04180 }
04181 }
04182
04183 void MainWindow::updateViewsOfSettings ()
04184 {
04185 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateViewsOfSettings";
04186
04187 QString activeCurve = m_digitizeStateContext->activeCurve ();
04188
04189 updateViewsOfSettings (activeCurve);
04190 }
04191
04192 void MainWindow::updateViewsOfSettings (const QString &activeCurve)
04193 {
04194 if (activeCurve.isEmpty ()) {
04195
04196 m_viewPointStyle->unsetPointStyle ();
04197 m_viewSegmentFilter->unsetColorFilterSettings ();
04198
04199
04200 } else {
04201
04202 PointStyle pointStyle = m_cmdMediator->document().modelCurveStyles().curveStyle(activeCurve).pointStyle();
04203 m_viewPointStyle->setPointStyle (pointStyle);
04204
04205 ColorFilterSettings colorFilterSettings = m_cmdMediator->document().modelColorFilter().colorFilterSettings(activeCurve);
04206 m_viewSegmentFilter->setColorFilterSettings (colorFilterSettings,
04207 m_cmdMediator->pixmap ());
04208
04209 }
04210 }
04211
04212 void MainWindow::updateWindowTitle ()
04213 {
04214 LOG4CPP_INFO_S ((*mainCat)) << "MainWindow::updateWindowTitle";
04215
04216 const QString PLACEHOLDER ("[*]");
04217
04218 QString title = QString (tr ("Engauge Digitizer %1")
04219 .arg (VERSION_NUMBER));
04220
04221 QString fileNameMaybeStripped;
04222 if (!m_currentFileWithPathAndFileExtension.isEmpty()) {
04223
04224 QFileInfo fileInfo (m_currentFileWithPathAndFileExtension);
04225
04226 switch (m_modelMainWindow.mainTitleBarFormat())
04227 {
04228 case MAIN_TITLE_BAR_FORMAT_NO_PATH:
04229 fileNameMaybeStripped = fileInfo.baseName();
04230 break;
04231
04232 case MAIN_TITLE_BAR_FORMAT_PATH:
04233 fileNameMaybeStripped = m_currentFileWithPathAndFileExtension;
04234 break;
04235 }
04236
04237 title += QString (": %1")
04238 .arg (fileNameMaybeStripped);
04239 }
04240
04241
04242
04243 title += PLACEHOLDER;
04244
04245 setWindowTitle (title);
04246 }
04247
04248 GraphicsView &MainWindow::view ()
04249 {
04250 ENGAUGE_CHECK_PTR (m_view);
04251 return *m_view;
04252 }
04253
04254 const GraphicsView &MainWindow::view () const
04255 {
04256 ENGAUGE_CHECK_PTR (m_view);
04257 return *m_view;
04258 }
04259
04260 void MainWindow::writeCheckpointToLogFile ()
04261 {
04262
04263 QString checkpointDoc;
04264 QTextStream strDoc (&checkpointDoc);
04265 m_cmdMediator->document().printStream(INDENTATION_PAST_TIMESTAMP,
04266 strDoc);
04267
04268
04269 QString checkpointScene;
04270 QTextStream strScene (&checkpointScene);
04271 m_scene->printStream (INDENTATION_PAST_TIMESTAMP,
04272 strScene);
04273
04274
04275 if (mainCat->getPriority() == log4cpp::Priority::DEBUG) {
04276
04277 LOG4CPP_DEBUG_S ((*mainCat)) << "MainWindow::writeCheckpointToLogFile\n"
04278 << "--------------DOCUMENT CHECKPOINT START----------" << "\n"
04279 << checkpointDoc.toLatin1().data()
04280 << "---------------DOCUMENT CHECKPOINT END-----------" << "\n"
04281 << "----------------SCENE CHECKPOINT START-----------" << "\n"
04282 << checkpointScene.toLatin1().data()
04283 << "-----------------SCENE CHECKPOINT END------------" ;
04284 }
04285 }