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