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