65#if !defined(OSX_DEBUG) && !defined(OSX_RELEASE)
69#ifdef ENGAUGE_JPEG2000
88#include <QApplication>
93#include <QDesktopServices>
95#include <QDomDocument>
98#include <QImageReader>
100#include <QKeySequence>
102#include <QMessageBox>
103#include <QMouseEvent>
104#include <QPrintDialog>
107#include <QPushButton>
109#include <QSignalMapper>
110#include <QTextStream>
111#if !defined(OSX_DEBUG) && !defined(OSX_RELEASE)
116#include <QToolButton>
118#include <QVBoxLayout>
120#include <QXmlStreamReader>
121#include <QXmlStreamWriter>
135static const char *ENGAUGE_FILENAME_DESCRIPTION =
"Engauge Document";
141 const QString &fileCmdScriptFile,
142 bool isDropRegression,
143 bool isRegressionTest,
147 bool isExtractImageOnly,
148 const QString &extractImageOnlyExtension,
149 const QStringList &loadStartupFiles,
150 const QStringList &commandLineWithoutLoadStartupFiles,
153 m_originalFileWasImported (false),
154 m_isDocumentExported (false),
160 m_loadImageFromUrl (nullptr),
161 m_cmdMediator (nullptr),
162 m_digitizeStateContext (nullptr),
163 m_transformationStateContext (nullptr),
164 m_backgroundStateContext (nullptr),
165 m_networkClient (nullptr),
167 m_commandLineWithoutLoadStartupFiles (commandLineWithoutLoadStartupFiles),
169 m_timerRegressionErrorReport(nullptr),
170 m_fileCmdScript (nullptr),
171 m_isErrorReportRegressionTest (isRegressionTest),
172 m_timerRegressionFileCmdScript(nullptr),
173 m_guidelines (*this),
174 m_fittingCurve (nullptr),
175 m_isExportOnly (isExportOnly),
176 m_isExtractImageOnly (isExtractImageOnly),
177 m_extractImageOnlyExtension (extractImageOnlyExtension)
180 <<
" curDir=" << QDir::currentPath().toLatin1().data();
182#if defined(OSX_DEBUG) || defined(OSX_RELEASE)
183 qApp->setApplicationName (
"Engauge Digitizer");
184 qApp->setOrganizationDomain (
"Mark Mitchell");
189 m_startupDirectory = QDir::currentPath();
194 createFacade.
create (*
this);
198 settingsRead (isReset);
200 setUnifiedTitleAndToolBarOnMac(
true);
202 installEventFilter(
this);
206 QString originalPath = QDir::currentPath();
207 QDir::setCurrent (m_startupDirectory);
209 m_loadStartupFiles = loadStartupFiles;
210 m_regressionFile = exportRegressionFilenameFromInputFilename (loadStartupFiles.first ());
211 slotLoadStartupFiles ();
214 }
else if (isExtractImageOnly) {
215 m_loadStartupFiles = loadStartupFiles;
216 m_regressionFile = exportRegressionFilenameFromInputFilename (loadStartupFiles.first ());
217 slotLoadStartupFiles ();
218 handlerFileExtractImage ();
220 }
else if (!errorReportFile.isEmpty()) {
221 loadErrorReportFile(errorReportFile);
222 if (m_isErrorReportRegressionTest) {
223 startRegressionTestErrorReport(errorReportFile);
225 }
else if (!fileCmdScriptFile.isEmpty()) {
227 startRegressionTestFileCmdScript();
228 }
else if (isDropRegression) {
230 startRegressionDropTest (loadStartupFiles);
235 m_loadStartupFiles = loadStartupFiles;
237 QDir::setCurrent (originalPath);
242#if !defined(OSX_DEBUG) && !defined(OSX_RELEASE)
245 delete m_tutorialDlg;
246 delete m_cmdMediator;
247 delete m_cmdStackShadow;
248 delete m_digitizeStateContext;
249 delete m_transformationStateContext;
250 delete m_backgroundStateContext;
251 delete m_dlgSettingsAxesChecker;
252 delete m_dlgSettingsColorFilter;
253 delete m_dlgSettingsCoords;
254 delete m_dlgSettingsCurveList;
255 delete m_dlgSettingsCurveProperties;
256 delete m_dlgSettingsDigitizeCurve;
257 delete m_dlgSettingsExportFormat;
258 delete m_dlgSettingsGeneral;
259 delete m_dlgSettingsGridDisplay;
260 delete m_dlgSettingsGridRemoval;
261 delete m_dlgSettingsMainWindow;
262 delete m_dlgSettingsPointMatch;
263 delete m_dlgSettingsSegments;
264 delete m_fileCmdScript;
265 m_gridLines.clear ();
266 m_guidelines.clear ();
269void MainWindow::addDockWindow (QDockWidget *dockWidget,
271 const QString &settingsTokenArea,
272 const QString &settingsTokenGeometry,
273 Qt::DockWidgetArea dockWidgetArea)
278 const bool DOCKED_EQUALS_NOT_FLOATING =
false;
279 Qt::DockWidgetArea area =
static_cast<Qt::DockWidgetArea
> (settings.value (settingsTokenArea,
280 Qt::NoDockWidgetArea).toInt());
282 if (area == Qt::NoDockWidgetArea) {
284 addDockWidget (dockWidgetArea,
286 dockWidget->setFloating(DOCKED_EQUALS_NOT_FLOATING);
287 if (settings.contains (settingsTokenGeometry)) {
288 dockWidget->restoreGeometry (settings.value (settingsTokenGeometry).toByteArray());
299void MainWindow::applyZoomFactorAfterLoad()
304 if (m_zoomMapFromInitial.contains (zoomFactorInitial)) {
305 zoomFactor = m_zoomMapFromInitial [zoomFactorInitial];
307 zoomFactor = currentZoomFactor ();
309 LOG4CPP_ERROR_S ((*
mainCat)) <<
"MainWindow::applyZoomFactorAfterLoad unexpected zoom factor " << zoomFactorInitial;
311 zoomFactor = currentZoomFactor();
314 slotViewZoom (zoomFactor);
317void MainWindow::closeEvent(QCloseEvent *event)
331 setWindowModified (
false);
348 m_regressionFile = exportRegressionFilenameFromInputFilename (fileName);
349 fileImport (fileName,
357 m_regressionFile = exportRegressionFilenameFromInputFilename (fileName);
358 loadDocumentFile(fileName);
364 return m_cmdMediator;
367ZoomFactor MainWindow::currentZoomFactor ()
const
372 if (m_zoomMapToAction [zoomFactor]->isChecked ()) {
385 if (event->type () == QEvent::KeyPress) {
387 QKeyEvent *eventKeyPress =
static_cast<QKeyEvent *
> (event);
390 if ((eventKeyPress->key() == Qt::Key_E) &&
391 ((eventKeyPress->modifiers() & Qt::ShiftModifier) != 0) &&
392 ((eventKeyPress->modifiers() & Qt::ControlModifier) != 0)) {
402 return QObject::eventFilter (target, event);
405#if !defined(OSX_DEBUG) && !defined(OSX_RELEASE)
406void MainWindow::exportAllCoordinateSystemsAfterRegressionTests()
408 LOG4CPP_INFO_S ((*
mainCat)) <<
"MainWindow::exportAllCoordinateSystemsAfterRegressionTests curDir=" << QDir::currentPath().toLatin1().data();
415 QString regressionFile = QString (
"%1_%2")
416 .arg (m_regressionFile)
424 exportStrategy.fileExport (regressionFile);
428 ExportToFile exportStrategy;
430 fileExport (regressionFile,
437QString MainWindow::exportRegressionFilenameFromInputFilename (
const QString &fileName)
const
442 befores <<
".dig" <<
".gif" <<
".html" <<
".htm" <<
".jp2" <<
".jpg" <<
".pbm"
443 <<
".pdf" <<
".pgm" <<
".png" <<
".ppm" <<
".webp" <<
".xbm" <<
".xpm" <<
".xml";
445 QString outFileName = fileName;
447 QStringList::iterator itr;
448 for (itr = befores.begin(); itr != befores.end(); itr++) {
449 QString suffix = *itr;
451 outFileName = outFileName.replace (suffix,
".csv_actual", Qt::CaseInsensitive);
457void MainWindow::fileExport(
const QString &fileName,
461 <<
" curDir=" << QDir::currentPath().toLatin1().data()
462 <<
" fileName=" << fileName.toLatin1().data();
464 QFile file (fileName);
465 if (file.open(QIODevice::WriteOnly)) {
467 QTextStream str (&file);
469 ExportFileExtensionOverride extensionOverride;
470 DocumentModelExportFormat modelExportFormat = extensionOverride.
modelExportOverride (m_cmdMediator->document().modelExport(),
474 m_cmdMediator->document(),
479 m_isDocumentExported =
true;
481 updateChecklistGuide ();
482 m_statusBar->showTemporaryMessage(
"File saved");
487 <<
" file=" << fileName.toLatin1().data()
488 <<
" curDir=" << QDir::currentPath().toLatin1().data();
489 QMessageBox::critical (
nullptr,
491 tr (
"Unable to export to file") +
" " + fileName);
495void MainWindow::fileExtractImage (
const QString &fileName)
498 <<
" curDir=" << QDir::currentPath().toLatin1().data()
499 <<
" fileName=" << fileName.toLatin1().data();
501 QFile file (fileName);
502 if (file.open(QIODevice::WriteOnly)) {
504 QPixmap pixmap = m_cmdMediator->pixmap();
508 if (m_isErrorReportRegressionTest) {
509 QString csvFile = QString (
"%1_1")
510 .arg (exportRegressionFilenameFromInputFilename (m_regressionFile));
514 process.start (
"bash -c \"cksum " + fileName +
" | awk '{print $1}' > " + csvFile +
"\"");
515 process.waitForFinished (-1);
521 <<
" file=" << fileName.toLatin1().data()
522 <<
" curDir=" << QDir::currentPath().toLatin1().data();
523 QMessageBox::critical (
nullptr,
525 tr (
"Unable to extract image to file") +
" " + fileName);
529void MainWindow::fileImport (
const QString &fileName,
530 ImportType importType)
533 <<
" fileName=" << fileName.toLatin1 ().data ()
534 <<
" curDir=" << QDir::currentPath().toLatin1().data()
535 <<
" importType=" << importType;
537 QString originalFileOld = m_originalFile;
538 bool originalFileWasImported = m_originalFileWasImported;
540 m_originalFile = fileName;
541 m_originalFileWasImported =
true;
543 if (importType == IMPORT_TYPE_ADVANCED) {
556#ifdef ENGAUGE_JPEG2000
558 loaded = jpeg2000.
load (fileName,
568 m_modelMainWindow.pdfResolution(),
569 m_modelMainWindow.importCropping(),
570 m_isErrorReportRegressionTest);
586 m_modelMainWindow.importCropping(),
587 m_isErrorReportRegressionTest);
599 QString msg = messageCannotReadFile (fileName);
603 msg = QString (
"%1.\n\n%2.")
605 .arg (tr (
"In OSX, files loaded at startup must be in the Downloads, Pictures or "
606 "Library/Containers/Digitizer/Data directories"));
610 if (fileName.contains (
"???")) {
615 msg += QObject::tr (
"The file appears to have characters from multiple language "
616 "alphabets, which does not work in the Windows command line");
619 QMessageBox::warning (
this,
624 m_originalFile = originalFileOld;
625 m_originalFileWasImported = originalFileWasImported;
629 loaded = loadImage (fileName,
636 if ((m_cmdMediator->document().coordSystemCount() > 1) &&
637 ! m_actionViewCoordSystem->isChecked ()) {
640 m_actionViewCoordSystem->trigger ();
646 if (importType == IMPORT_TYPE_ADVANCED) {
656 m_originalFile = originalFileOld;
657 m_originalFileWasImported = originalFileWasImported;
663void MainWindow::fileImportWithPrompts (ImportType importType)
666 <<
" importType=" << importType;
670 bool okToContinue =
true;
671 if (importType != IMPORT_TYPE_IMAGE_REPLACE) {
672 okToContinue = maybeSave ();
678 QTextStream str (&filter);
680 ImportImageExtensions importImageExtensions;
683 str <<
"Image Files (" << supportedImageFormatStrings.join (
" ") <<
")";
687 str <<
";; All Files (*.*)";
689 MainDirectoryPersist directoryPersist;
690 QString fileName = QFileDialog::getOpenFileName (
this,
694 if (!fileName.isEmpty ()) {
699 fileImport (fileName,
705QString MainWindow::fileNameForExportOnly ()
const
707 ExportToFile exportStrategy;
710 if (m_isErrorReportRegressionTest) {
713 fileName = QString (
"%1_1")
714 .arg (exportRegressionFilenameFromInputFilename (m_regressionFile));
719 QString dir = QFileInfo (m_currentFileWithPathAndFileExtension).absolutePath();
720 fileName = QString (
"%1/%2.%3")
729QString MainWindow::fileNameForExtractImageOnly ()
const
732 QString dir = QFileInfo (m_currentFileWithPathAndFileExtension).absolutePath();
733 QString fileName = QString (
"%1/%2.%3")
736 .arg (m_extractImageOnlyExtension);
741void MainWindow::filePaste (ImportType importType)
744 <<
" importType=" << importType;
746 QString originalFileOld = m_originalFile;
747 bool originalFileWasImported = m_originalFileWasImported;
749 QString fileName (
"clipboard");
750 m_originalFile = fileName;
751 m_originalFileWasImported =
true;
753 if (importType == IMPORT_TYPE_ADVANCED) {
764 QImage image = QApplication::clipboard()->image();
768 loaded = !image.isNull();
772 QMessageBox::warning (
this,
774 messageCannotReadFile (fileName));
777 m_originalFile = originalFileOld;
778 m_originalFileWasImported = originalFileWasImported;
782 loaded = loadImage (fileName,
789 if (importType == IMPORT_TYPE_ADVANCED) {
799 m_originalFile = originalFileOld;
800 m_originalFileWasImported = originalFileWasImported;
806void MainWindow::ghostsCreate ()
811 m_ghosts =
new Ghosts (m_cmdMediator->document().coordSystemIndex());
813 for (
unsigned int index = 0; index < m_cmdMediator->document().coordSystemCount(); index++) {
816 if (index != m_ghosts->coordSystemIndexToBeRestored ()) {
821 m_ghosts->captureGraphicsItems (*m_scene);
829 m_ghosts->createGhosts (*m_scene);
832void MainWindow::ghostsDestroy ()
838 m_ghosts->destroyGhosts(*m_scene);
850 m_guidelines.createGuidelineX (identifier,
853 m_guidelines.createGuidelineT (identifier,
857 m_cmdMediator->document().setModelGuidelines (m_guidelines.modelGuidelines ());
860void MainWindow::guidelineAddXTEnqueue (
double xT)
866 m_cmdMediator->push (cmd);
875 m_guidelines.createGuidelineY (identifier,
878 m_guidelines.createGuidelineR (identifier,
885void MainWindow::guidelineAddYREnqueue (
double yR)
891 m_cmdMediator->push (cmd);
899 m_guidelines.moveGuidelineXT (identifier,
910 m_guidelines.moveGuidelineYR (identifier,
913 m_cmdMediator->document().setModelGuidelines (m_guidelines.modelGuidelines ());
920 m_guidelines.removeGuideline (identifier);
921 m_cmdMediator->document().setModelGuidelines (m_guidelines.modelGuidelines ());
931 return (guidelinesVisibilityCanBeEnabled () &&
932 (m_actionViewGuidelinesEdit->isChecked() || m_actionViewGuidelinesLock->isChecked()));
935bool MainWindow::guidelinesVisibilityCanBeEnabled ()
const
946 return (!m_currentFile.isEmpty() &&
955 m_actionViewGuidelinesHide->setChecked (
true);
959 m_actionViewGuidelinesEdit->setChecked (
true);
963 m_actionViewGuidelinesLock->setChecked (
true);
977void MainWindow::handleGuidelineMode ()
980 m_actionViewGuidelinesLock->isChecked());
983void MainWindow::handlerFileExtractImage ()
987 if (m_isExtractImageOnly) {
988 QString fileName = fileNameForExtractImageOnly ();
990 MainDirectoryPersist directoryPersist;
993 fileExtractImage(fileName);
999 return m_backgroundStateContext->imageForCurveState();
1007void MainWindow::loadCoordSystemListFromCmdMediator ()
1011 m_cmbCoordSystem->clear();
1015 for (
unsigned int i = 0; i < numberCoordSystem; i++) {
1016 int index1Based = signed (i + 1);
1017 m_cmbCoordSystem->addItem (QString::number (index1Based),
1022 m_cmbCoordSystem->setCurrentIndex (0);
1025 bool enable = (m_cmbCoordSystem->count() > 1);
1026 m_cmbCoordSystem->setEnabled (enable);
1027 m_btnShowAll->setEnabled (enable);
1028 m_btnPrintAll->setEnabled (enable);
1031void MainWindow::loadCurveListFromCmdMediator ()
1035 m_cmbCurve->clear ();
1036 QStringList curvesGraphsNames = m_cmdMediator->curvesGraphsNames ();
1037 QStringList::iterator itr;
1038 for (itr = curvesGraphsNames.begin (); itr != curvesGraphsNames.end (); itr++) {
1040 QString curvesGraphName = *itr;
1041 m_cmbCurve->addItem (curvesGraphName);
1045 m_cmbCurve->setCurrentText (m_cmdMediator->selectedCurveName ());
1048void MainWindow::loadDocumentFile (
const QString &fileName)
1050 LOG4CPP_INFO_S ((*
mainCat)) <<
"MainWindow::loadDocumentFile fileName=" << fileName.toLatin1 ().data ();
1052 QApplication::setOverrideCursor(Qt::WaitCursor);
1053 CmdMediator *
cmdMediator =
new CmdMediator (*
this,
1058 setCurrentPathFromFile (fileName);
1059 rebuildRecentFileListForCurrentFile(fileName);
1060 m_currentFile = fileName;
1062 delete m_cmdMediator;
1065 setupAfterLoadNewDocument (fileName,
1067 IMPORT_TYPE_SIMPLE);
1070 m_actionDigitizeSelect->setChecked (
true);
1071 slotDigitizeSelect();
1073 m_engaugeFile = fileName;
1074 m_originalFile = fileName;
1075 m_originalFileWasImported =
false;
1080 QApplication::restoreOverrideCursor();
1084 QApplication::restoreOverrideCursor();
1086 QString msg = messageCannotReadFile (fileName);
1087 QMessageBox::warning (
this,
1097void MainWindow::loadErrorReportFile(
const QString &errorReportFile)
1100 <<
" file=" << errorReportFile.toLatin1().data();
1102 QFile file (errorReportFile);
1103 if (!file.exists()) {
1105 QFileInfo fileInfo (errorReportFile);
1107 QMessageBox::critical (
this,
1109 tr (
"File not found") +
": " + fileInfo.absoluteFilePath());
1114 QXmlStreamReader reader (&file);
1115 file.open(QIODevice::ReadOnly | QIODevice::Text);
1116 m_cmdMediator =
new CmdMediator(*
this,
1120 m_cmdStackShadow->loadCommands (*
this,
1121 m_cmdMediator->document(),
1125 setupAfterLoadNewDocument (errorReportFile,
1126 tr (
"Error report opened"),
1127 IMPORT_TYPE_SIMPLE);
1130 m_actionDigitizeSelect->setChecked (
true);
1131 slotDigitizeSelect();
1136void MainWindow::loadGuidelinesFromCmdMediator ()
1140 m_guidelines.setModelGuidelines (m_cmdMediator->document().modelCoords().coordsType(),
1141 m_cmdMediator->document().modelGuidelines());
1144bool MainWindow::loadImage (
const QString &fileName,
1145 const QImage &image,
1146 ImportType importType)
1149 <<
" fileName=" << fileName.toLatin1 ().data ()
1150 <<
" importType=" << importType;
1153 if (importType == IMPORT_TYPE_IMAGE_REPLACE) {
1154 success = loadImageReplacingImage (fileName,
1158 success = loadImageNewDocument (fileName,
1166bool MainWindow::loadImageNewDocument (
const QString &fileName,
1167 const QImage &image,
1168 ImportType importType)
1171 <<
" fileName=" << fileName.toLatin1 ().data ()
1172 <<
" importType=" << importType;
1176 QApplication::setOverrideCursor(Qt::WaitCursor);
1177 CmdMediator *
cmdMediator =
new CmdMediator (*
this,
1179 QApplication::restoreOverrideCursor();
1181 setCurrentPathFromFile (fileName);
1185 delete m_cmdMediator;
1188 bool accepted = setupAfterLoadNewDocument (fileName,
1189 tr (
"File imported"),
1195 if (m_actionHelpChecklistGuideWizard->isChecked () &&
1196 (m_fileCmdScript ==
nullptr)) {
1199 ChecklistGuideWizard *wizard =
new ChecklistGuideWizard (*
this,
1200 m_cmdMediator->document().coordSystemCount());
1201 if (wizard->exec() == QDialog::Accepted) {
1203 for (
CoordSystemIndex coordSystemIndex = 0; coordSystemIndex < m_cmdMediator->document().coordSystemCount(); coordSystemIndex++) {
1206 m_dockChecklistGuide->setTemplateHtml (wizard->
templateHtml(coordSystemIndex),
1210 CurvesGraphs curvesGraphs;
1213 m_cmdMediator->document().setCurvesGraphs(curvesGraphs);
1217 m_actionViewChecklistGuide->setChecked (
true);
1220 loadCurveListFromCmdMediator();
1223 loadCoordSystemListFromCmdMediator();
1229 m_actionDigitizeAxis->setChecked (
true);
1233 slotDigitizeScale ();
1234 }
else if (modeGraph ()) {
1235 slotDigitizeAxis ();
1244bool MainWindow::loadImageReplacingImage (
const QString &fileName,
1245 const QImage &image,
1246 ImportType importType)
1249 <<
" fileName=" << fileName.toLatin1 ().data ()
1250 <<
" importType=" << importType;
1254 setCurrentPathFromFile (fileName);
1260 m_cmdMediator->document().setPixmap (image);
1262 bool accepted = setupAfterLoadReplacingImage (fileName,
1263 tr (
"File imported"),
1271void MainWindow::loadInputFileForErrorReport(QDomDocument &domInputFile)
const
1273 QFile file (m_originalFile);
1277 if (!file.open (QIODevice::ReadOnly)) {
1281 domInputFile.setContent (&file);
1285void MainWindow::loadToolTips()
1287 if (m_actionViewToolTips->isChecked ()) {
1290 m_actionDigitizeSelect->setToolTip (m_actionDigitizeSelect->text());
1291 m_actionDigitizeAxis->setToolTip (m_actionDigitizeAxis->text());
1292 m_actionDigitizeScale->setToolTip (m_actionDigitizeScale->text());
1293 m_actionDigitizeCurve->setToolTip (m_actionDigitizeCurve->text());
1294 m_actionDigitizePointMatch->setToolTip (m_actionDigitizePointMatch->text());
1295 m_actionDigitizeColorPicker->setToolTip (m_actionDigitizeColorPicker->text());
1296 m_actionDigitizeSegment->setToolTip (m_actionDigitizeSegment->text());
1297 m_cmbBackground->setToolTip (tr (
"Background image."));
1298 m_cmbCurve->setToolTip (tr (
"Currently selected curve."));
1299 m_viewPointStyle->setToolTip (tr (
"Point style for currently selected curve."));
1300 m_viewSegmentFilter->setToolTip (tr (
"Segment Fill filter for currently selected curve."));
1305 m_actionDigitizeSelect->setToolTip (
"");
1306 m_actionDigitizeAxis->setToolTip (
"");
1307 m_actionDigitizeScale->setToolTip (
"");
1308 m_actionDigitizeCurve->setToolTip (
"");
1309 m_actionDigitizePointMatch->setToolTip (
"");
1310 m_actionDigitizeColorPicker->setToolTip (
"");
1311 m_actionDigitizeSegment->setToolTip (
"");
1312 m_cmbBackground->setToolTip (
"");
1313 m_cmbCurve->setToolTip (
"");
1314 m_viewPointStyle->setToolTip (
"");
1315 m_viewSegmentFilter->setToolTip (
"");
1320bool MainWindow::maybeSave()
1322 if (m_cmdMediator !=
nullptr) {
1323 if (m_cmdMediator->isModified()) {
1324 QMessageBox::StandardButton ret = QMessageBox::warning (
this,
1326 tr(
"The document has been modified.\n"
1327 "Do you want to save your changes?"),
1328 QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
1329 if (ret == QMessageBox::Save) {
1330 return slotFileSave();
1331 }
else if (ret == QMessageBox::Cancel) {
1340QString MainWindow::messageCannotReadFile (
const QString &fileName)
const
1342 return QString(
"%1 %2")
1343 .arg (tr (
"Cannot read file"))
1347bool MainWindow::modeGraph ()
const
1349 bool success =
false;
1351 if (m_cmdMediator !=
nullptr) {
1360 bool success =
false;
1362 if (m_cmdMediator !=
nullptr) {
1371 return m_modelMainWindow;
1374void MainWindow::rebuildRecentFileListForCurrentFile(
const QString &filePath)
1378 setWindowFilePath (filePath);
1382 recentFilePaths.removeAll (filePath);
1383 recentFilePaths.prepend (filePath);
1385 recentFilePaths.removeLast ();
1389 updateRecentFileList();
1396 if (m_actionZoomFill->isChecked ()) {
1400 QMainWindow::resizeEvent(event);
1403bool MainWindow::saveDocumentFile (
const QString &fileName)
1405 LOG4CPP_INFO_S ((*
mainCat)) <<
"MainWindow::saveDocumentFile fileName=" << fileName.toLatin1 ().data ();
1407 QFile file(fileName);
1408 if (!file.open(QFile::WriteOnly)) {
1409 QMessageBox::warning (
this,
1411 QString (
"%1 %2: \n%3.")
1412 .arg(tr (
"Cannot write file"))
1414 .arg(file.errorString()));
1418 rebuildRecentFileListForCurrentFile (fileName);
1420 QApplication::setOverrideCursor (Qt::WaitCursor);
1421 QXmlStreamWriter writer(&file);
1422 writer.setAutoFormatting(
true);
1423 writer.writeStartDocument();
1424 writer.writeDTD(
"<!DOCTYPE engauge>");
1425 m_cmdMediator->document().saveXml(writer);
1426 writer.writeEndDocument();
1427 QApplication::restoreOverrideCursor ();
1431 m_cmdMediator->setClean ();
1433 setCurrentFile(fileName);
1434 m_engaugeFile = fileName;
1436 m_statusBar->showTemporaryMessage(
"File saved");
1444 const char *comment)
1448 if ((m_cmdMediator !=
nullptr) && !m_isErrorReportRegressionTest) {
1450 QString report = saveErrorReportFileAndExitXml (context,
1456 if (dlg.exec() == QDialog::Accepted) {
1459 QString fileName = dlg.getSaveFileName (
this,
1461 "error_report.xml");
1462 if (!fileName.isEmpty ()) {
1464 QFile fileError (fileName);
1465 QTextStream str (&fileError);
1466 fileError.open (QIODevice::WriteOnly | QIODevice::Text);
1476QString MainWindow::saveErrorReportFileAndExitXml (
const char *context,
1479 const char *comment)
const
1481 const bool DEEP_COPY =
true;
1483 QString xmlErrorReport;
1484 QXmlStreamWriter writer (&xmlErrorReport);
1485 writer.setAutoFormatting(
true);
1493 writer.writeEndElement();
1497 QXmlStreamReader reader (m_startingDocumentSnapshot);
1498 while (!reader.atEnd ()) {
1500 if (reader.tokenType() != QXmlStreamReader::StartDocument &&
1501 reader.tokenType() != QXmlStreamReader::EndDocument &&
1502 reader.tokenType() != QXmlStreamReader::Invalid) {
1503 writer.writeCurrentToken (reader);
1511 writer.writeEndElement();
1517 writer.writeEndElement();
1520 m_cmdMediator->saveXml(writer);
1528 writer.writeEndElement();
1530 writer.writeEndElement();
1533 QDomDocument domErrorReport (
"ErrorReport");
1534 domErrorReport.setContent (xmlErrorReport);
1537 if (!m_originalFileWasImported) {
1541 QDomDocument domInputFile;
1542 loadInputFileForErrorReport (domInputFile);
1543 QDomDocumentFragment fragmentFileFrom = domErrorReport.createDocumentFragment();
1544 if (!domInputFile.isNull()) {
1545 fragmentFileFrom.appendChild (domErrorReport.importNode (domInputFile.documentElement(), DEEP_COPY));
1548 if (nodesFileTo.count () > 0) {
1549 QDomNode nodeFileTo = nodesFileTo.at (0);
1550 nodeFileTo.appendChild (fragmentFileFrom);
1558 for (
int i = 0 ; i < nodesDocument.count(); i++) {
1559 QDomNode nodeDocument = nodesDocument.at (i);
1561 if (!elemImage.isNull()) {
1570 QDomNode nodeReplacement;
1571 QDomElement elemReplacement = nodeReplacement.toElement();
1576 nodeDocument.insertBefore (nodeReplacement,
1578 nodeDocument.removeChild(elemImage);
1584 return domErrorReport.toString();
1587void MainWindow::saveStartingDocumentSnapshot()
1591 QXmlStreamWriter writer (&m_startingDocumentSnapshot);
1592 writer.setAutoFormatting (
true);
1593 m_cmdMediator->document().saveXml (writer);
1608 int index = m_cmbBackground->findData (backgroundImage);
1611 m_cmbBackground->setCurrentIndex(index);
1613 return previousBackground;
1618 return m_cmbCurve->currentText ();
1628void MainWindow::setCurrentFile (
const QString &fileName)
1632 QString fileNameStripped;
1633 if (!fileName.isEmpty()) {
1637 QFileInfo fileInfo (fileName);
1638 fileNameStripped = fileInfo.completeBaseName();
1641 m_currentFile = fileNameStripped;
1642 m_currentFileWithPathAndFileExtension = fileName;
1644 updateWindowTitle ();
1647void MainWindow::setCurrentPathFromFile (
const QString &fileName)
1649 QDir dir = QFileInfo (fileName).absoluteDir();
1651 if (dir.exists ()) {
1653 bool success = QDir::setCurrent (dir.absolutePath ());
1662void MainWindow::setNonFillZoomFactor (
ZoomFactor newZoomFactor)
1667 m_zoomMapToAction [newZoomFactor]->setChecked (
true);
1668 slotViewZoomFactor (newZoomFactor);
1671void MainWindow::setPixmap (
const QString &curveSelected,
1672 const QPixmap &pixmap)
1676 m_digitizeStateContext->setImageIsLoaded (m_cmdMediator,
1681 m_backgroundStateContext->setPixmap (m_isGnuplot,
1683 m_cmdMediator->document().modelGridRemoval(),
1684 m_cmdMediator->document().modelColorFilter(),
1688 m_guidelines.initialize (*m_scene);
1691void MainWindow::settingsRead (
bool isReset)
1700 settingsReadEnvironment (settings);
1701 settingsReadMainWindow (settings);
1704void MainWindow::settingsReadEnvironment (QSettings &settings)
1708 QDir::currentPath ()).toString ());
1709 settings.endGroup ();
1712void MainWindow::settingsReadMainWindow (QSettings &settings)
1717 const int DEFAULT_MAIN_WINDOW_WIDTH = 800, DEFAULT_MAIN_WINDOW_HEIGHT = 800;
1718 const int DEFAULT_MAIN_WINDOW_OFFSET_X = 100, DEFAULT_MAIN_WINDOW_OFFSET_Y = 100;
1722 QSize (DEFAULT_MAIN_WINDOW_WIDTH, DEFAULT_MAIN_WINDOW_HEIGHT)).toSize ());
1724 QPoint (DEFAULT_MAIN_WINDOW_OFFSET_X, DEFAULT_MAIN_WINDOW_OFFSET_Y)).toPoint ());
1727#if !defined(OSX_DEBUG) && !defined(OSX_RELEASE)
1729 QSize (900, 600)).toSize();
1730 m_helpWindow->resize (helpSize);
1733 m_helpWindow->move (helpPos);
1744 m_actionViewBackground->setChecked (viewBackgroundToolBar);
1745 m_toolBackground->setVisible (viewBackgroundToolBar);
1748 int indexBackground = m_cmbBackground->findData (QVariant (backgroundImage));
1749 m_cmbBackground->setCurrentIndex (indexBackground);
1754 m_actionViewDigitize->setChecked (viewDigitizeToolBar);
1755 m_toolDigitize->setVisible (viewDigitizeToolBar);
1760 m_actionViewSettingsViews->setChecked (viewSettingsViewsToolBar);
1761 m_toolSettingsViews->setVisible (viewSettingsViewsToolBar);
1766 m_actionViewCoordSystem->setChecked (viewCoordSystemToolbar);
1767 m_toolCoordSystem->setVisible (viewCoordSystemToolbar);
1772 m_actionViewToolTips->setChecked (viewToolTips);
1778 m_statusBar->setStatusBarMode (statusBarMode);
1783 addDockWindow (m_dockChecklistGuide,
1787 Qt::RightDockWidgetArea);
1788 addDockWindow (m_dockFittingWindow,
1792 Qt::RightDockWidgetArea);
1793 addDockWindow (m_dockGeometryWindow,
1797 Qt::RightDockWidgetArea);
1802 QLocale localeDefault;
1804 QVariant (localeDefault.language())).toInt());
1806 QVariant (localeDefault.country())).toInt());
1807 QLocale locale (language,
1811 m_modelMainWindow.setLocale (locale);
1838 MainDirectoryPersist directoryPersist;
1840 QVariant (QDir::currentPath())).toString ());
1842 QVariant (QDir::currentPath())).toString ());
1845 updateSmallDialogs();
1847 settings.endGroup();
1850void MainWindow::settingsWrite ()
1852 MainDirectoryPersist directoryPersist;
1858 settings.endGroup ();
1863#if !defined(OSX_DEBUG) && !defined(OSX_RELEASE)
1867 if (m_dockChecklistGuide->isFloating()) {
1877 if (m_dockFittingWindow->isFloating()) {
1885 if (m_dockGeometryWindow->isFloating()) {
1921 settings.endGroup ();
1924bool MainWindow::setupAfterLoadNewDocument (
const QString &fileName,
1925 const QString &temporaryMessage ,
1926 ImportType importType)
1929 <<
" file=" << fileName.toLatin1().data()
1930 <<
" message=" << temporaryMessage.toLatin1().data()
1931 <<
" importType=" << importType;
1936 const QString EMPTY_CURVE_NAME_TO_SKIP_BACKGROUND_PROCESSING;
1940 m_digitizeStateContext->resetOnLoad (m_cmdMediator);
1941 m_backgroundStateContext->setCurveSelected (m_isGnuplot,
1943 m_cmdMediator->document().modelGridRemoval(),
1944 m_cmdMediator->document().modelColorFilter(),
1945 EMPTY_CURVE_NAME_TO_SKIP_BACKGROUND_PROCESSING);
1946 setPixmap (m_cmdMediator->document().curvesGraphsNames().first(),
1947 m_cmdMediator->pixmap ());
1951 if (importType == IMPORT_TYPE_ADVANCED) {
1953 applyZoomFactorAfterLoad();
1955 DlgImportAdvanced dlgImportAdvanced (*
this);
1956 dlgImportAdvanced.exec();
1958 if (dlgImportAdvanced.result() == QDialog::Rejected) {
1962 int numberCoordSystem = signed (dlgImportAdvanced.numberCoordSystem());
1963 m_cmdMediator->document().addCoordSystems (
unsigned (numberCoordSystem - 1));
1964 m_cmdMediator->setDocumentAxesPointsRequired (dlgImportAdvanced.documentAxesPointsRequired());
1967 m_transformation.resetOnLoad();
1968 m_transformationStateContext->resetOnLoad();
1969 m_scene->resetOnLoad();
1971 connect (m_actionEditUndo, SIGNAL (triggered ()), m_cmdMediator, SLOT (undo ()));
1972 connect (m_actionEditUndo, SIGNAL (triggered ()), m_cmdStackShadow, SLOT (slotUndo ()));
1973 connect (m_actionEditRedo, SIGNAL (triggered ()), m_cmdMediator, SLOT (redo ()));
1974 connect (m_actionEditRedo, SIGNAL (triggered ()), m_cmdStackShadow, SLOT (slotRedo ()));
1975 connect (m_cmdMediator, SIGNAL (canRedoChanged(
bool)),
this, SLOT (slotCanRedoChanged (
bool)));
1976 connect (m_cmdMediator, SIGNAL (canUndoChanged(
bool)),
this, SLOT (slotCanUndoChanged (
bool)));
1977 connect (m_cmdMediator, SIGNAL (redoTextChanged (
const QString &)),
this, SLOT (slotRedoTextChanged (
const QString &)));
1978 connect (m_cmdMediator, SIGNAL (undoTextChanged (
const QString &)),
this, SLOT (slotUndoTextChanged (
const QString &)));
1979 loadCurveListFromCmdMediator ();
1980 loadCoordSystemListFromCmdMediator ();
1983 m_isDocumentExported =
false;
1989 m_backgroundStateContext->setCurveSelected (m_isGnuplot,
1991 m_cmdMediator->document().modelGridRemoval(),
1992 m_cmdMediator->document().modelColorFilter(),
1993 m_cmbCurve->currentText ());
1994 m_backgroundStateContext->setBackgroundImage (
static_cast<BackgroundImage> (m_cmbBackground->currentIndex ()));
1996 applyZoomFactorAfterLoad();
1998 setCurrentFile(fileName);
1999 m_statusBar->showTemporaryMessage (temporaryMessage);
2000 m_statusBar->wakeUp ();
2002 saveStartingDocumentSnapshot();
2006 loadGuidelinesFromCmdMediator ();
2007 handleGuidelineMode ();
2012bool MainWindow::setupAfterLoadReplacingImage (
const QString &fileName,
2013 const QString &temporaryMessage ,
2014 ImportType importType)
2017 <<
" file=" << fileName.toLatin1().data()
2018 <<
" message=" << temporaryMessage.toLatin1().data()
2019 <<
" importType=" << importType;
2024 m_cmdMediator->clear();
2026 setPixmap (m_cmdMediator->document().curvesGraphsNames().first(),
2027 m_cmdMediator->pixmap ());
2029 m_isDocumentExported =
false;
2031 m_backgroundStateContext->setBackgroundImage (
static_cast<BackgroundImage> (m_cmbBackground->currentIndex ()));
2033 applyZoomFactorAfterLoad();
2036 if (m_modelMainWindow.imageReplaceRenamesDocument()) {
2037 setCurrentFile(fileName);
2040 m_statusBar->showTemporaryMessage (temporaryMessage);
2041 m_statusBar->wakeUp ();
2043 saveStartingDocumentSnapshot();
2053 <<
" files=" << m_loadStartupFiles.join (
",").toLatin1().data();
2055 QMainWindow::showEvent (event);
2057 if (m_loadStartupFiles.count() > 0) {
2059 m_timerLoadStartupFiles =
new QTimer;
2060 m_timerLoadStartupFiles->setSingleShot (
true);
2061 connect (m_timerLoadStartupFiles, SIGNAL (timeout ()),
this, SLOT (slotLoadStartupFiles ()));
2062 m_timerLoadStartupFiles->start (0);
2069 m_statusBar->showTemporaryMessage (temporaryMessage);
2072void MainWindow::slotBtnGuidelineBottomCartesian ()
2075 QPointF posGraph = guidelineOffset.
bottom (*m_view,
2077 guidelineAddXTEnqueue (posGraph.x ());
2080void MainWindow::slotBtnGuidelineBottomPolar ()
2082 GuidelineOffset guidelineOffset;
2083 QPointF posGraph = guidelineOffset.
bottom (*m_view,
2085 guidelineAddXTEnqueue (posGraph.x ());
2088void MainWindow::slotBtnGuidelineLeftCartesian ()
2090 GuidelineOffset guidelineOffset;
2091 QPointF posGraph = guidelineOffset.
left (*m_view,
2093 guidelineAddYREnqueue (posGraph.y ());
2096void MainWindow::slotBtnGuidelineLeftPolar ()
2098 GuidelineOffset guidelineOffset;
2099 QPointF posGraph = guidelineOffset.
left (*m_view,
2101 guidelineAddYREnqueue (posGraph.y ());
2104void MainWindow::slotBtnGuidelineRightCartesian ()
2106 GuidelineOffset guidelineOffset;
2107 QPointF posGraph = guidelineOffset.
right (*m_view,
2109 guidelineAddYREnqueue (posGraph.y ());
2112void MainWindow::slotBtnGuidelineRightPolar ()
2114 GuidelineOffset guidelineOffset;
2115 QPointF posGraph = guidelineOffset.
right (*m_view,
2117 guidelineAddYREnqueue (posGraph.y ());
2120void MainWindow::slotBtnGuidelineTopCartesian ()
2122 GuidelineOffset guidelineOffset;
2123 QPointF posGraph = guidelineOffset.
top (*m_view,
2125 guidelineAddXTEnqueue (posGraph.x ());
2128void MainWindow::slotBtnGuidelineTopPolar ()
2130 GuidelineOffset guidelineOffset;
2131 QPointF posGraph = guidelineOffset.
top (*m_view,
2133 guidelineAddXTEnqueue (posGraph.x ());
2136void MainWindow::slotBtnPrintAll ()
2142 QPrinter printer (QPrinter::HighResolution);
2143 QPrintDialog dlg (&printer,
this);
2144 if (dlg.exec() == QDialog::Accepted) {
2145 QPainter painter (&printer);
2146 m_view->render (&painter);
2153void MainWindow::slotBtnShowAllPressed ()
2161void MainWindow::slotBtnShowAllReleased ()
2169void MainWindow::slotCanRedoChanged (
bool canRedo)
2173 m_actionEditRedo->setEnabled (canRedo || m_cmdStackShadow->canRedo());
2176void MainWindow::slotCanUndoChanged (
bool canUndo)
2180 m_actionEditUndo->setEnabled (canUndo);
2183void MainWindow::slotChecklistClosed()
2187 m_actionViewChecklistGuide->setChecked (
false);
2190void MainWindow::slotCleanChanged(
bool clean)
2194 setWindowModified (!clean);
2197void MainWindow::slotCmbBackground(
int currentIndex)
2201 switch (currentIndex) {
2203 if (!m_actionViewBackgroundNone->isChecked()) {
2204 m_actionViewBackgroundNone->toggle();
2209 if (!m_actionViewBackgroundOriginal->isChecked ()) {
2210 m_actionViewBackgroundOriginal->toggle();
2215 if (!m_actionViewBackgroundFiltered->isChecked ()) {
2216 m_actionViewBackgroundFiltered->toggle();
2221 m_backgroundStateContext->setBackgroundImage (
static_cast<BackgroundImage> (currentIndex));
2224void MainWindow::slotCmbCoordSystem(
int index)
2228 CmdSelectCoordSystem *cmd =
new CmdSelectCoordSystem (*
this,
2229 m_cmdMediator->document(),
2232 m_cmdMediator->push (cmd);
2235void MainWindow::slotCmbCurve(
int )
2239 m_backgroundStateContext->setCurveSelected (m_isGnuplot,
2241 m_cmdMediator->document().modelGridRemoval(),
2242 m_cmdMediator->document().modelColorFilter(),
2243 m_cmbCurve->currentText ());
2244 m_digitizeStateContext->handleCurveChange (m_cmdMediator);
2245 m_cmdMediator->setSelectedCurveName (m_cmbCurve->currentText ());
2247 updateViewedCurves();
2249 updateFittingWindow();
2250 updateGeometryWindow();
2253void MainWindow::slotContextMenuEventAxis (QString pointIdentifier)
2255 LOG4CPP_INFO_S ((*
mainCat)) <<
"MainWindow::slotContextMenuEventAxis point=" << pointIdentifier.toLatin1 ().data ();
2257 m_digitizeStateContext->handleContextMenuEventAxis (m_cmdMediator,
2261void MainWindow::slotContextMenuEventGraph (QStringList pointIdentifiers)
2263 LOG4CPP_INFO_S ((*
mainCat)) <<
"MainWindow::slotContextMenuEventGraph point=" << pointIdentifiers.join(
",").toLatin1 ().data ();
2265 m_digitizeStateContext->handleContextMenuEventGraph (m_cmdMediator,
2269void MainWindow::slotDigitizeAxis ()
2273 m_digitizeStateContext->requestImmediateStateTransition (m_cmdMediator,
2275 m_cmbCurve->setEnabled (
false);
2276 m_viewPointStyle->setEnabled (
true);
2277 m_viewSegmentFilter->setEnabled (
true);
2281void MainWindow::slotDigitizeColorPicker ()
2285 m_digitizeStateContext->requestImmediateStateTransition (m_cmdMediator,
2287 m_cmbCurve->setEnabled (
true);
2288 m_viewPointStyle->setEnabled (
true);
2289 m_viewSegmentFilter->setEnabled (
true);
2293void MainWindow::slotDigitizeCurve ()
2297 m_digitizeStateContext->requestImmediateStateTransition (m_cmdMediator,
2299 m_cmbCurve->setEnabled (
true);
2300 m_viewPointStyle->setEnabled (
true);
2301 m_viewSegmentFilter->setEnabled (
true);
2305void MainWindow::slotDigitizePointMatch ()
2309 m_digitizeStateContext->requestImmediateStateTransition (m_cmdMediator,
2311 m_cmbCurve->setEnabled (
true);
2312 m_viewPointStyle->setEnabled (
true);
2313 m_viewSegmentFilter->setEnabled (
true);
2317void MainWindow::slotDigitizeScale ()
2321 m_digitizeStateContext->requestImmediateStateTransition (m_cmdMediator,
2323 m_cmbCurve->setEnabled (
false);
2324 m_viewPointStyle->setEnabled (
false);
2325 m_viewSegmentFilter->setEnabled (
false);
2329void MainWindow::slotDigitizeSegment ()
2333 m_digitizeStateContext->requestImmediateStateTransition (m_cmdMediator,
2335 m_cmbCurve->setEnabled (
true);
2336 m_viewPointStyle->setEnabled (
true);
2337 m_viewSegmentFilter->setEnabled (
true);
2341void MainWindow::slotDigitizeSelect ()
2345 m_digitizeStateContext->requestImmediateStateTransition (m_cmdMediator,
2347 m_cmbCurve->setEnabled (
false);
2348 m_viewPointStyle->setEnabled (
false);
2349 m_viewSegmentFilter->setEnabled (
false);
2353void MainWindow::slotEditCopy ()
2358 bool tableFittingIsActive, tableFittingIsCopyable;
2359 bool tableGeometryIsActive, tableGeometryIsCopyable;
2360 m_dockFittingWindow->getTableStatus (tableFittingIsActive, tableFittingIsCopyable);
2361 m_dockGeometryWindow->getTableStatus (tableGeometryIsActive, tableGeometryIsCopyable);
2363 if (tableFittingIsActive) {
2366 m_dockFittingWindow->doCopy ();
2368 }
else if (tableGeometryIsActive) {
2371 m_dockGeometryWindow->doCopy ();
2376 GraphicsItemsExtractor graphicsItemsExtractor;
2377 const QList<QGraphicsItem*> &items = m_scene->selectedItems();
2380 CmdCopy *cmd =
new CmdCopy (*
this,
2381 m_cmdMediator->document(),
2383 m_digitizeStateContext->appendNewCmd (m_cmdMediator,
2388void MainWindow::slotEditCut ()
2393 bool tableFittingIsActive, tableFittingIsCopyable;
2394 bool tableGeometryIsActive, tableGeometryIsCopyable;
2395 m_dockFittingWindow->getTableStatus (tableFittingIsActive, tableFittingIsCopyable);
2396 m_dockGeometryWindow->getTableStatus (tableGeometryIsActive, tableGeometryIsCopyable);
2398 if (tableFittingIsActive || tableGeometryIsActive) {
2405 GraphicsItemsExtractor graphicsItemsExtractor;
2406 const QList<QGraphicsItem*> &items = m_scene->selectedItems();
2409 CmdCut *cmd =
new CmdCut (*
this,
2410 m_cmdMediator->document(),
2412 m_digitizeStateContext->appendNewCmd (m_cmdMediator,
2417void MainWindow::slotEditDelete ()
2422 bool tableFittingIsActive, tableFittingIsCopyable;
2423 bool tableGeometryIsActive, tableGeometryIsCopyable;
2424 m_dockFittingWindow->getTableStatus (tableFittingIsActive, tableFittingIsCopyable);
2425 m_dockGeometryWindow->getTableStatus (tableGeometryIsActive, tableGeometryIsCopyable);
2427 if (tableFittingIsActive || tableGeometryIsActive) {
2436 ScaleBarAxisPointsUnite scaleBarAxisPoints;
2439 GraphicsItemsExtractor graphicsItemsExtractor;
2440 const QList<QGraphicsItem*> &items = m_scene->selectedItems();
2441 QStringList pointIdentifiers = scaleBarAxisPoints.
unite (m_cmdMediator,
2444 CmdDelete *cmd =
new CmdDelete (*
this,
2445 m_cmdMediator->document(),
2447 m_digitizeStateContext->appendNewCmd (m_cmdMediator,
2452void MainWindow::slotEditMenu ()
2456 m_actionEditPasteAsNew->setEnabled (!QApplication::clipboard()->image().isNull());
2457 m_actionEditPasteAsNewAdvanced->setEnabled (!QApplication::clipboard()->image().isNull());
2460void MainWindow::slotEditPaste ()
2464 QList<QPoint> points;
2465 QList<double> ordinals;
2467 MimePointsImport mimePointsImport;
2472 CmdAddPointsGraph *cmd =
new CmdAddPointsGraph (*
this,
2473 m_cmdMediator->document(),
2474 m_cmbCurve->currentText (),
2477 m_digitizeStateContext->appendNewCmd (m_cmdMediator,
2481void MainWindow::slotEditPasteAsNew ()
2485 filePaste (IMPORT_TYPE_SIMPLE);
2488void MainWindow::slotEditPasteAsNewAdvanced ()
2492 filePaste (IMPORT_TYPE_ADVANCED);
2495void MainWindow::slotFileClose()
2503 m_transformationStateContext->triggerStateTransition(m_isGnuplot,
2511 m_digitizeStateContext->requestImmediateStateTransition (m_cmdMediator,
2515 if (m_fittingCurve !=
nullptr) {
2516 m_scene->removeItem (m_fittingCurve);
2517 m_fittingCurve =
nullptr;
2521 m_scene->resetOnLoad ();
2524 m_backgroundStateContext->close ();
2527 m_scene->setSceneRect (QRectF (0, 0, 1, 1));
2530 m_dockFittingWindow->clear ();
2533 m_dockGeometryWindow->clear ();
2536 delete m_cmdMediator;
2539 m_cmdMediator =
nullptr;
2544 m_gridLines.clear();
2545 m_guidelines.clear();
2550void MainWindow::slotFileExport ()
2554 if (m_transformation.transformIsDefined()) {
2556 MainDirectoryPersist directoryPersist;
2557 ExportToFile exportStrategy;
2560 if (m_isExportOnly) {
2561 fileName = fileNameForExportOnly ();
2564 QString filter = QString (
"%1;;%2;;All files (*.*)")
2569 QString defaultFileName = QString (
"%1/%2.%3")
2571 .arg (m_currentFile)
2574 QString filterCsv = exportStrategy.
filterCsv ();
2576 fileName = dlg.getSaveFileName (
this,
2583 if (!fileName.isEmpty ()) {
2586 fileExport(fileName,
2590 DlgRequiresTransform dlg (
"Export");
2595void MainWindow::slotFileImport ()
2599 fileImportWithPrompts (IMPORT_TYPE_SIMPLE);
2602void MainWindow::slotFileImportAdvanced ()
2606 fileImportWithPrompts (IMPORT_TYPE_ADVANCED);
2609void MainWindow::slotFileImportDraggedImage(QImage image)
2616 IMPORT_TYPE_SIMPLE);
2619void MainWindow::slotFileImportDraggedImageUrl(QUrl url)
2621 LOG4CPP_INFO_S ((*
mainCat)) <<
"MainWindow::slotFileImportDraggedImageUrl url=" << url.toString ().toLatin1 ().data ();
2625 m_loadImageFromUrl->startLoadImage (url);
2628void MainWindow::slotFileImportImage(QString fileName, QImage image)
2630 LOG4CPP_INFO_S ((*
mainCat)) <<
"MainWindow::slotFileImportImage fileName=" << fileName.toLatin1 ().data ();
2633 loadImage (fileName,
2635 IMPORT_TYPE_SIMPLE);
2638void MainWindow::slotFileImportImageReplace ()
2642 fileImportWithPrompts (IMPORT_TYPE_IMAGE_REPLACE);
2645void MainWindow::slotFileOpen()
2653 QString filter = QString (
"%1 (*.%2);; All Files (*.*)")
2654 .arg (ENGAUGE_FILENAME_DESCRIPTION)
2657 MainDirectoryPersist directoryPersist;
2658 QString fileName = QFileDialog::getOpenFileName (
this,
2659 tr(
"Open Document"),
2662 if (!fileName.isEmpty ()) {
2665 loadDocumentFile (fileName);
2671void MainWindow::slotFileOpenDraggedDigFile (QString fileName)
2675 loadDocumentFile (fileName);
2678void MainWindow::slotFilePrint()
2682 QPrinter printer (QPrinter::HighResolution);
2683 QPrintDialog dlg (&printer,
this);
2684 if (dlg.exec() == QDialog::Accepted) {
2685 QPainter painter (&printer);
2686 m_view->render (&painter);
2691bool MainWindow::slotFileSave()
2695 if (m_engaugeFile.isEmpty()) {
2696 return slotFileSaveAs();
2698 return saveDocumentFile (m_engaugeFile);
2702bool MainWindow::slotFileSaveAs()
2707 QString filenameDefault = m_currentFile;
2709 filenameDefault = QString (
"%1.%2")
2710 .arg (m_currentFile)
2714 if (!m_engaugeFile.isEmpty()) {
2715 filenameDefault = m_engaugeFile;
2718 QString filterDigitizer = QString (
"%1 (*.%2)")
2719 .arg (ENGAUGE_FILENAME_DESCRIPTION)
2721 QString filterAll (
"All files (*. *)");
2723 QStringList filters;
2724 filters << filterDigitizer;
2725 filters << filterAll;
2727 MainDirectoryPersist directoryPersist;
2729 QFileDialog dlg(
this);
2730 dlg.setFileMode (QFileDialog::AnyFile);
2731 dlg.selectNameFilter (filterDigitizer);
2732 dlg.setNameFilters (filters);
2733#if !defined(OSX_DEBUG) && !defined(OSX_RELEASE)
2735 dlg.setWindowModality(Qt::WindowModal);
2737 dlg.setAcceptMode(QFileDialog::AcceptSave);
2738 dlg.selectFile(filenameDefault);
2742 QStringList files = dlg.selectedFiles();
2744 return saveDocumentFile(files.at(0));
2750void MainWindow::slotFittingWindowClosed()
2754 m_actionViewFittingWindow->setChecked (
false);
2765 <<
" order=" << fittingCurveCoef.size() - 1;
2767 if (m_fittingCurve !=
nullptr) {
2768 m_scene->removeItem (m_fittingCurve);
2769 delete m_fittingCurve;
2772 m_fittingCurve =
new FittingCurve (fittingCurveCoef,
2778 m_fittingCurve->setVisible (m_actionViewFittingWindow->isChecked ());
2779 m_scene->addItem (m_fittingCurve);
2782void MainWindow::slotGeometryWindowClosed()
2786 m_actionViewGeometryWindow->setChecked (
false);
2789void MainWindow::slotGuidelineDragged(QString identifierReplaced,
2791 bool draggedOffscreen,
2797 m_guidelines.createReplacementGuideline (identifierReplaced,
2799 guidelineStateForReplacement);
2802 GuidelineDragCommandFactory cmdFactory;
2805 m_cmdMediator->document(),
2807 m_cmdMediator->document().modelGuidelines (),
2811 m_cmdMediator->push (cmd);
2814void MainWindow::slotHelpAbout()
2818 DlgAbout dlg (*
this);
2822void MainWindow::slotHelpTutorial()
2826 m_tutorialDlg->show ();
2827 m_tutorialDlg->exec ();
2830void MainWindow::slotKeyPress (Qt::Key key,
2831 bool atLeastOneSelectedItem)
2834 <<
" key=" << QKeySequence (key).toString().toLatin1 ().data ()
2835 <<
" atLeastOneSelectedItem=" << (atLeastOneSelectedItem ?
"true" :
"false");
2837 m_digitizeStateContext->handleKeyPress (m_cmdMediator,
2839 atLeastOneSelectedItem);
2842void MainWindow::slotLoadStartupFiles ()
2848 QString fileName = m_loadStartupFiles.front();
2849 m_loadStartupFiles.pop_front();
2852 LoadFileInfo loadFileInfo;
2855 loadDocumentFile (fileName);
2859 fileImport (fileName,
2860 IMPORT_TYPE_SIMPLE);
2864 if (m_loadStartupFiles.count() > 0) {
2868 QProcess::startDetached (QCoreApplication::applicationFilePath(),
2869 m_commandLineWithoutLoadStartupFiles + m_loadStartupFiles);
2873void MainWindow::slotMouseMove (QPointF pos)
2878 if (m_cmdMediator !=
nullptr) {
2881 QString coordsScreen, coordsGraph, resolutionGraph;
2882 m_transformation.coordTextForStatusBar (pos,
2889 m_statusBar->setCoordinates (coordsScreen,
2896 m_digitizeStateContext->handleMouseMove (m_cmdMediator,
2901void MainWindow::slotMousePress (QPointF pos)
2905 m_scene->resetPositionHasChangedFlags();
2907 m_digitizeStateContext->handleMousePress (m_cmdMediator,
2911void MainWindow::slotMouseRelease (QPointF pos)
2915 if (pos.x() < 0 || pos.y() < 0) {
2924 m_digitizeStateContext->handleMouseRelease (m_cmdMediator,
2929void MainWindow::slotRecentFileAction ()
2933 QAction *action = qobject_cast<QAction*>(sender ());
2936 QString fileName = action->data().toString();
2937 loadDocumentFile (fileName);
2941void MainWindow::slotRecentFileClear ()
2945 QStringList emptyList;
2951 updateRecentFileList();
2954void MainWindow::slotRedoTextChanged (
const QString &text)
2958 QString completeText (
"Redo");
2959 if (!text.isEmpty ()) {
2960 completeText += QString (
" \"%1\"").arg (text);
2962 m_actionEditRedo->setText (completeText);
2965void MainWindow::slotSettingsAxesChecker ()
2969 m_dlgSettingsAxesChecker->load (*m_cmdMediator);
2970 m_dlgSettingsAxesChecker->show ();
2973void MainWindow::slotSettingsColorFilter ()
2977 m_dlgSettingsColorFilter->load (*m_cmdMediator);
2978 m_dlgSettingsColorFilter->show ();
2981void MainWindow::slotSettingsCoords ()
2985 m_dlgSettingsCoords->load (*m_cmdMediator);
2986 m_dlgSettingsCoords->show ();
2989void MainWindow::slotSettingsCurveList ()
2993 m_dlgSettingsCurveList->load (*m_cmdMediator);
2994 m_dlgSettingsCurveList->show ();
2997void MainWindow::slotSettingsCurveProperties ()
3001 m_dlgSettingsCurveProperties->load (*m_cmdMediator);
3003 m_dlgSettingsCurveProperties->show ();
3006void MainWindow::slotSettingsDigitizeCurve ()
3010 m_dlgSettingsDigitizeCurve->load (*m_cmdMediator);
3011 m_dlgSettingsDigitizeCurve->show ();
3014void MainWindow::slotSettingsExportFormat ()
3019 m_dlgSettingsExportFormat->load (*m_cmdMediator);
3020 m_dlgSettingsExportFormat->show ();
3022 DlgRequiresTransform dlg (
"Export settings");
3027void MainWindow::slotSettingsGeneral ()
3031 m_dlgSettingsGeneral->load (*m_cmdMediator);
3032 m_dlgSettingsGeneral->show ();
3035void MainWindow::slotSettingsGridDisplay()
3039 m_dlgSettingsGridDisplay->load (*m_cmdMediator);
3040 m_dlgSettingsGridDisplay->show ();
3043void MainWindow::slotSettingsGridRemoval ()
3047 m_dlgSettingsGridRemoval->load (*m_cmdMediator);
3048 m_dlgSettingsGridRemoval->show ();
3051void MainWindow::slotSettingsPointMatch ()
3055 m_dlgSettingsPointMatch->load (*m_cmdMediator);
3056 m_dlgSettingsPointMatch->show ();
3059void MainWindow::slotSettingsSegments ()
3063 m_dlgSettingsSegments->load (*m_cmdMediator);
3064 m_dlgSettingsSegments->show ();
3067void MainWindow::slotTableStatusChange ()
3076void MainWindow::slotSettingsMainWindow ()
3080 m_dlgSettingsMainWindow->loadMainWindowModel (*m_cmdMediator,
3082 m_dlgSettingsMainWindow->show ();
3085void MainWindow::slotTimeoutRegressionErrorReport ()
3088 <<
" cmdStackIndex=" << m_cmdMediator->index()
3089 <<
" cmdStackCount=" << m_cmdMediator->count();
3091 if (m_cmdStackShadow->canRedo()) {
3094 QDir::setCurrent (m_startupDirectory);
3096 m_cmdStackShadow->slotRedo();
3099 QDir::setCurrent (m_startupDirectory);
3103#if !defined(OSX_DEBUG) && !defined(OSX_RELEASE)
3104 exportAllCoordinateSystemsAfterRegressionTests ();
3108 m_cmdMediator->setClean();
3114void MainWindow::slotTimeoutRegressionFileCmdScript ()
3118 if (m_fileCmdScript->canRedo()) {
3121 QDir::setCurrent (m_startupDirectory);
3123 m_fileCmdScript->redo(*
this);
3126 QDir::setCurrent (m_startupDirectory);
3131 if (m_cmdMediator !=
nullptr) {
3133#if !defined(OSX_DEBUG) && !defined(OSX_RELEASE)
3134 exportAllCoordinateSystemsAfterRegressionTests ();
3138 m_cmdMediator->setClean();
3148void MainWindow::slotUndoTextChanged (
const QString &text)
3152 QString completeText (
"Undo");
3153 if (!text.isEmpty ()) {
3154 completeText += QString (
" \"%1\"").arg (text);
3156 m_actionEditUndo->setText (completeText);
3159void MainWindow::slotViewGridLines ()
3166void MainWindow::slotViewGroupBackground(QAction *action)
3172 int indexBackground;
3173 if (action == m_actionViewBackgroundNone) {
3176 }
else if (action == m_actionViewBackgroundOriginal) {
3179 }
else if (action == m_actionViewBackgroundFiltered) {
3191 m_cmbBackground->setCurrentIndex (indexBackground);
3192 m_backgroundStateContext->setBackgroundImage (backgroundImage);
3195void MainWindow::slotViewGroupCurves(QAction * )
3199 updateViewedCurves ();
3202void MainWindow::slotViewGroupGuidelines (QAction * )
3209 if (m_actionViewGuidelinesHide->isChecked ()) {
3211 }
else if (m_actionViewGuidelinesEdit->isChecked ()) {
3216 m_guidelineViewStateContext.handleStateChange (stateAfter);
3219 CmdAbstract *cmd =
new CmdGuidelineViewState (*
this,
3220 m_cmdMediator->document(),
3223 m_cmdMediator->push (cmd);
3226 handleGuidelineMode ();
3230void MainWindow::slotViewGroupStatus(QAction *action)
3236 if (action == m_actionStatusNever) {
3238 }
else if (action == m_actionStatusTemporary) {
3245void MainWindow::slotViewToolBarBackground ()
3249 if (m_actionViewBackground->isChecked ()) {
3250 m_toolBackground->show();
3252 m_toolBackground->hide();
3256void MainWindow::slotViewToolBarChecklistGuide ()
3260 if (m_actionViewChecklistGuide->isChecked ()) {
3261 m_dockChecklistGuide->show();
3263 m_dockChecklistGuide->hide();
3267void MainWindow::slotViewToolBarCoordSystem ()
3271 if (m_actionViewCoordSystem->isChecked ()) {
3272 m_toolCoordSystem->show();
3274 m_toolCoordSystem->hide();
3278void MainWindow::slotViewToolBarDigitize ()
3282 if (m_actionViewDigitize->isChecked ()) {
3283 m_toolDigitize->show();
3285 m_toolDigitize->hide();
3289void MainWindow::slotViewToolBarFittingWindow()
3293 if (m_actionViewFittingWindow->isChecked()) {
3294 m_dockFittingWindow->show ();
3295 if (m_fittingCurve !=
nullptr) {
3296 m_fittingCurve->setVisible (
true);
3299 m_dockFittingWindow->hide ();
3300 if (m_fittingCurve !=
nullptr) {
3301 m_fittingCurve->setVisible (
false);
3306void MainWindow::slotViewToolBarGeometryWindow ()
3310 if (m_actionViewGeometryWindow->isChecked ()) {
3311 m_dockGeometryWindow->show();
3313 m_dockGeometryWindow->hide();
3317void MainWindow::slotViewToolBarSettingsViews ()
3321 if (m_actionViewSettingsViews->isChecked ()) {
3322 m_toolSettingsViews->show();
3324 m_toolSettingsViews->hide();
3328void MainWindow::slotViewToolTips ()
3335void MainWindow::slotViewZoom (
int zoom)
3341 m_zoomMapToAction [zoomFactor]->setChecked (
true);
3342 slotViewZoomFactor (
static_cast<ZoomFactor> (zoom));
3345void MainWindow::slotViewZoomFactor (
ZoomFactor zoomFactor)
3350 m_backgroundStateContext->fitInView (*m_view);
3353 ZoomTransition zoomTransition;
3354 double factor = zoomTransition.
mapToFactor (zoomFactor);
3356 QTransform transform;
3357 transform.scale (factor, factor);
3358 m_view->setTransform (transform);
3364void MainWindow::slotViewZoomFactorInt (
int zoom)
3368 slotViewZoomFactor (
static_cast<ZoomFactor> (zoom));
3371void MainWindow::slotViewZoomIn ()
3375 ZoomTransition zoomTransition;
3377 m_view->transform ().m11 (),
3378 m_view->transform ().m22 (),
3379 m_actionZoomFill->isChecked ());
3380 setNonFillZoomFactor (zoomFactorNew);
3384void MainWindow::slotViewZoomInFromWheelEvent ()
3392 m_view->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
3397 m_view->setTransformationAnchor(QGraphicsView::NoAnchor);
3401void MainWindow::slotViewZoomOut ()
3406 ZoomTransition zoomTransition;
3408 m_view->transform ().m11 (),
3409 m_view->transform ().m22 (),
3410 m_actionZoomFill->isChecked ());
3411 setNonFillZoomFactor (zoomFactorNew);
3414void MainWindow::slotViewZoomOutFromWheelEvent ()
3422 m_view->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
3427 m_view->setTransformationAnchor(QGraphicsView::NoAnchor);
3431void MainWindow::startRegressionDropTest (
const QStringList &loadStartupFiles)
3440 connect (
this, SIGNAL (
signalDropRegression (QString)), m_view, SLOT (slotDropRegression (QString)));
3442 for (
int counter = 0; counter < loadStartupFiles.size (); counter++) {
3443 QString filenameDrop = loadStartupFiles.at (counter);
3448 QSize siz = m_view->size();
3450 QString filenameCsv;
3451 if (filenameDrop.startsWith (
"http")) {
3455 filenameCsv =
"../test/drag_and_drop_http.csv_actual_1";
3460 filenameCsv = QString (
"%1_%2")
3461 .arg (exportRegressionFilenameFromInputFilename (filenameDrop))
3465 QFile file (filenameCsv);
3466 file.open (QIODevice::WriteOnly);
3467 QTextStream str (&file);
3468 str << siz.width() <<
"x" << siz.height() <<
"\n";
3475void MainWindow::startRegressionTestErrorReport(
const QString ®ressionInputFile)
3486 m_regressionFile = exportRegressionFilenameFromInputFilename (regressionInputFile);
3488 m_timerRegressionErrorReport =
new QTimer();
3489 m_timerRegressionErrorReport->setSingleShot(
false);
3490 connect (m_timerRegressionErrorReport, SIGNAL (timeout()),
this, SLOT (slotTimeoutRegressionErrorReport()));
3495void MainWindow::startRegressionTestFileCmdScript()
3499 m_timerRegressionFileCmdScript =
new QTimer();
3500 m_timerRegressionFileCmdScript->setSingleShot(
false);
3501 connect (m_timerRegressionFileCmdScript, SIGNAL (timeout()),
this, SLOT (slotTimeoutRegressionFileCmdScript()));
3508 return m_transformation;
3524 updateAfterCommandStatusBarCoords ();
3526 updateHighlightOpacity ();
3529 m_digitizeStateContext->updateAfterPointAddition ();
3532 updateChecklistGuide ();
3533 updateFittingWindow ();
3534 updateGeometryWindow();
3539 writeCheckpointToLogFile ();
3541 docScrub.
check (*
this,
3542 m_cmdMediator->document ());
3546 m_view->setFocus ();
3549void MainWindow::updateAfterCommandStatusBarCoords ()
3556 const QPoint HACK_SO_GRAPH_COORDINATE_MATCHES_INPUT (1, 1);
3560 updateTransformationAndItsDependencies();
3563 if (!m_transformationBefore.transformIsDefined() && m_transformation.
transformIsDefined()) {
3572 }
else if (m_transformationBefore.transformIsDefined() && !m_transformation.transformIsDefined()) {
3575 m_transformationStateContext->triggerStateTransition(m_isGnuplot,
3581 }
else if (m_transformation.transformIsDefined() && (m_transformationBefore != m_transformation)) {
3585 m_transformationStateContext->updateAxesChecker(*m_cmdMediator,
3590 QPoint posLocal = m_view->mapFromGlobal (QCursor::pos ()) - HACK_SO_GRAPH_COORDINATE_MATCHES_INPUT;
3591 QPointF posScreen = m_view->mapToScene (posLocal);
3593 slotMouseMove (posScreen);
3603void MainWindow::updateChecklistGuide ()
3607 m_dockChecklistGuide->
update (*m_cmdMediator,
3608 m_isDocumentExported);
3611void MainWindow::updateControls ()
3614 <<
" selectedItems=" << m_scene->selectedItems().count();
3616 m_cmbBackground->setEnabled (!m_currentFile.isEmpty ());
3618 m_actionImportImageReplace->setEnabled (m_cmdMediator !=
nullptr);
3619#if !defined(OSX_DEBUG) && !defined(OSX_RELEASE)
3620 m_menuFileOpenRecent->setEnabled ((m_actionRecentFiles.count () > 0) &&
3621 (m_actionRecentFiles.at(0)->isVisible ()));
3623 m_actionClose->setEnabled (!m_currentFile.isEmpty ());
3624 m_actionSave->setEnabled (!m_currentFile.isEmpty ());
3625 m_actionSaveAs->setEnabled (!m_currentFile.isEmpty ());
3626 m_actionExport->setEnabled (!m_currentFile.isEmpty ());
3627 m_actionPrint->setEnabled (!m_currentFile.isEmpty ());
3629 if (m_cmdMediator ==
nullptr) {
3630 m_actionEditUndo->setEnabled (
false);
3631 m_actionEditRedo->setEnabled (
false);
3633 m_actionEditUndo->setEnabled (m_cmdMediator->canUndo ());
3634 m_actionEditRedo->setEnabled (m_cmdMediator->canRedo () || m_cmdStackShadow->canRedo ());
3636 bool tableFittingIsActive, tableFittingIsCopyable;
3637 bool tableGeometryIsActive, tableGeometryIsCopyable;
3638 m_dockFittingWindow->getTableStatus (tableFittingIsActive, tableFittingIsCopyable);
3639 m_dockGeometryWindow->getTableStatus (tableGeometryIsActive, tableGeometryIsCopyable);
3640 m_actionEditCut->setEnabled (!tableFittingIsActive &&
3641 !tableGeometryIsActive &&
3642 m_scene->selectedItems().count () > 0);
3643 m_actionEditCopy->setEnabled ((!tableFittingIsActive && !tableGeometryIsActive && m_scene->selectedItems().count () > 0) ||
3644 (tableFittingIsActive && tableFittingIsCopyable) ||
3645 (tableGeometryIsActive && tableGeometryIsCopyable));
3646 m_actionEditPaste->setEnabled (m_digitizeStateContext->canPaste (m_transformation,
3648 m_actionEditDelete->setEnabled (!tableFittingIsActive &&
3649 !tableGeometryIsActive &&
3650 m_scene->selectedItems().count () > 0);
3653 m_actionDigitizeAxis->setEnabled (modeGraph ());
3654 m_actionDigitizeScale->setEnabled (
modeMap ());
3655 m_actionDigitizeCurve ->setEnabled (!m_currentFile.isEmpty ());
3656 m_actionDigitizePointMatch->setEnabled (!m_currentFile.isEmpty ());
3657 m_actionDigitizeColorPicker->setEnabled (!m_currentFile.isEmpty ());
3658 m_actionDigitizeSegment->setEnabled (!m_currentFile.isEmpty ());
3659 m_actionDigitizeSelect->setEnabled (!m_currentFile.isEmpty ());
3660 if (m_transformation.transformIsDefined()) {
3661 m_actionViewGridLines->setEnabled (
true);
3663 m_actionViewGridLines->setEnabled (
false);
3664 m_actionViewGridLines->setChecked (
false);
3666 m_actionViewBackground->setEnabled (!m_currentFile.isEmpty());
3667 m_actionViewChecklistGuide->setEnabled (!m_dockChecklistGuide->browserIsEmpty());
3668 m_actionViewDigitize->setEnabled (!m_currentFile.isEmpty ());
3669 if (m_cmdMediator && m_transformation.transformIsDefined()) {
3672 bool editable = (m_actionViewGuidelinesEdit->isChecked ());
3673 bool selectable = (m_digitizeStateContext->guidelinesAreSelectable ());
3675 m_actionViewGuidelinesHide->setEnabled (
true);
3676 m_actionViewGuidelinesEdit->setEnabled (selectable);
3677 m_actionViewGuidelinesLock->setEnabled (
true);
3688 m_btnGuidelineBottomCartesian->setEnabled (m_btnGuidelineBottomCartesian->isVisible() && selectable);
3689 m_btnGuidelineBottomPolar->setEnabled (m_btnGuidelineBottomPolar->isVisible() && selectable);
3690 m_btnGuidelineLeftCartesian->setEnabled (m_btnGuidelineLeftCartesian->isVisible() && selectable);
3691 m_btnGuidelineLeftPolar->setEnabled (m_btnGuidelineLeftPolar->isVisible() && selectable);
3692 m_btnGuidelineRightCartesian->setEnabled (m_btnGuidelineRightCartesian->isVisible() && selectable);
3693 m_btnGuidelineRightPolar->setEnabled (m_btnGuidelineRightPolar->isVisible() && selectable);
3694 m_btnGuidelineTopCartesian->setEnabled (m_btnGuidelineTopCartesian->isVisible() && selectable);
3695 m_btnGuidelineTopPolar->setEnabled (m_btnGuidelineTopPolar->isVisible() && selectable);
3699 m_actionViewGuidelinesHide->setEnabled (
false);
3700 m_actionViewGuidelinesEdit->setEnabled (
false);
3701 m_actionViewGuidelinesLock->setEnabled (
false);
3703 m_btnGuidelineBottomCartesian->setVisible (
false);
3704 m_btnGuidelineBottomPolar->setVisible (
false);
3705 m_btnGuidelineLeftCartesian->setVisible (
false);
3706 m_btnGuidelineLeftPolar->setVisible (
false);
3707 m_btnGuidelineRightCartesian->setVisible (
false);
3708 m_btnGuidelineRightPolar->setVisible (
false);
3709 m_btnGuidelineTopCartesian->setVisible (
false);
3710 m_btnGuidelineTopPolar->setVisible (
false);
3712 m_btnGuidelineBottomCartesian->setEnabled (
false);
3713 m_btnGuidelineBottomPolar->setEnabled (
false);
3714 m_btnGuidelineLeftCartesian->setEnabled (
false);
3715 m_btnGuidelineLeftPolar->setEnabled (
false);
3716 m_btnGuidelineRightCartesian->setEnabled (
false);
3717 m_btnGuidelineRightPolar->setEnabled (
false);
3718 m_btnGuidelineTopCartesian->setEnabled (
false);
3719 m_btnGuidelineTopPolar->setEnabled (
false);
3721 m_actionViewSettingsViews->setEnabled (!m_currentFile.isEmpty ());
3723 m_actionSettingsCoords->setEnabled (!m_currentFile.isEmpty ());
3724 m_actionSettingsCurveList->setEnabled (!m_currentFile.isEmpty ());
3725 m_actionSettingsCurveProperties->setEnabled (!m_currentFile.isEmpty ());
3726 m_actionSettingsDigitizeCurve->setEnabled (!m_currentFile.isEmpty ());
3727 m_actionSettingsExport->setEnabled (!m_currentFile.isEmpty ());
3728 m_actionSettingsColorFilter->setEnabled (!m_currentFile.isEmpty ());
3729 m_actionSettingsAxesChecker->setEnabled (!m_currentFile.isEmpty ());
3730 m_actionSettingsGridDisplay->setEnabled (!m_currentFile.isEmpty () && m_transformation.transformIsDefined());
3731 m_actionSettingsGridRemoval->setEnabled (!m_currentFile.isEmpty ());
3732 m_actionSettingsPointMatch->setEnabled (!m_currentFile.isEmpty ());
3733 m_actionSettingsSegments->setEnabled (!m_currentFile.isEmpty ());
3734 m_actionSettingsGeneral->setEnabled (!m_currentFile.isEmpty ());
3736 m_groupBackground->setEnabled (!m_currentFile.isEmpty ());
3737 m_groupCurves->setEnabled (!m_currentFile.isEmpty ());
3738 m_groupGuidelines->setEnabled (m_transformation.transformIsDefined());
3739 m_groupZoom->setEnabled (!m_currentFile.isEmpty ());
3741 m_actionZoomIn->setEnabled (!m_currentFile.isEmpty ());
3742 m_actionZoomOut->setEnabled (!m_currentFile.isEmpty ());
3750 if ((
CoordSystemIndex) m_cmbCoordSystem->currentIndex() != coordSystemIndex) {
3751 m_cmbCoordSystem->setCurrentIndex (coordSystemIndex);
3756 m_cmdMediator->document().setCoordSystemIndex (coordSystemIndex);
3757 loadCurveListFromCmdMediator ();
3759 updateTransformationAndItsDependencies();
3761 loadGuidelinesFromCmdMediator();
3764 m_transformationStateContext->updateAxesChecker (*m_cmdMediator,
3774 switch (digitizeState) {
3776 m_actionDigitizeAxis->setChecked(
true);
3781 m_actionDigitizeColorPicker->setChecked(
true);
3782 slotDigitizeColorPicker();
3786 m_actionDigitizeCurve->setChecked(
true);
3787 slotDigitizeCurve();
3794 m_actionDigitizePointMatch->setChecked(
true);
3795 slotDigitizePointMatch();
3799 m_actionDigitizeScale->setChecked(
true);
3800 slotDigitizeScale();
3804 m_actionDigitizeSegment->setChecked(
true);
3805 slotDigitizeSegment();
3809 m_actionDigitizeSelect->setChecked(
true);
3810 slotDigitizeSelect();
3819void MainWindow::updateFittingWindow ()
3823 if (m_cmdMediator !=
nullptr &&
3824 m_cmbCurve !=
nullptr) {
3827 m_dockFittingWindow->
update (*m_cmdMediator,
3829 m_cmbCurve->currentText (),
3834void MainWindow::updateGeometryWindow ()
3838 if (m_cmdMediator !=
nullptr &&
3839 m_cmbCurve !=
nullptr) {
3842 m_dockGeometryWindow->update (*m_cmdMediator,
3844 m_cmbCurve->currentText (),
3853 m_scene->updateGraphicsLinesToMatchGraphicsPoints(m_cmdMediator->document().modelCurveStyles(),
3857void MainWindow::updateGridLines ()
3862 m_gridLines.
clear ();
3873 m_gridLines.
setVisible (m_actionViewGridLines->isChecked());
3876void MainWindow::updateHighlightOpacity ()
3878 if (m_cmdMediator !=
nullptr) {
3882 m_scene->updateAfterCommand (*m_cmdMediator,
3883 m_modelMainWindow.highlightOpacity(),
3884 m_dockGeometryWindow,
3889void MainWindow::updateRecentFileList()
3893#if !defined(OSX_DEBUG) && !defined(OSX_RELEASE)
3898 unsigned int count = unsigned (recentFilePaths.size());
3905 for (i = 0; i < signed (count); i++) {
3906 QString strippedName = QFileInfo (recentFilePaths.at(i)).fileName();
3907 m_actionRecentFiles.at (i)->setText (strippedName);
3908 m_actionRecentFiles.at (i)->setData (recentFilePaths.at (i));
3909 m_actionRecentFiles.at (i)->setVisible (
true);
3914 m_actionRecentFiles.at (i)->setVisible (
false);
3923 m_cmdMediator->document().setModelAxesChecker(modelAxesChecker);
3924 if (m_transformation.transformIsDefined()) {
3925 m_transformationStateContext->triggerStateTransition(m_isGnuplot,
3929 m_cmbCurve->currentText());
3931 m_transformationStateContext->triggerStateTransition(m_isGnuplot,
3935 m_cmbCurve->currentText());
3943 m_cmdMediator->document().setModelColorFilter(modelColorFilter);
3944 m_backgroundStateContext->updateColorFilter (m_isGnuplot,
3946 m_cmdMediator->document().modelGridRemoval(),
3948 m_cmbCurve->currentText());
3949 m_digitizeStateContext->handleCurveChange (m_cmdMediator);
3957 m_cmdMediator->document().setModelCoords(modelCoords);
3964 m_cmdMediator->document().setCurvesGraphs (curvesGraphs);
3965 loadCurveListFromCmdMediator();
3973 m_scene->updateCurveStyles(modelCurveStyles);
3974 m_cmdMediator->document().setModelCurveStyles(modelCurveStyles);
3982 m_cmdMediator->document().setModelDigitizeCurve(modelDigitizeCurve);
3983 m_digitizeStateContext->updateModelDigitizeCurve (m_cmdMediator,
3984 modelDigitizeCurve);
3991 m_cmdMediator->document().setModelExport (modelExport);
3998 m_cmdMediator->document().setModelGeneral(modelGeneral);
4005 m_cmdMediator->document().setModelGridDisplay(modelGridDisplay);
4013 m_cmdMediator->document().setModelGridRemoval(modelGridRemoval);
4023 m_actionZoomIn->setShortcut (tr (
""));
4024 m_actionZoomOut->setShortcut (tr (
""));
4028 m_actionZoomIn->setShortcut (tr (
"+"));
4029 m_actionZoomOut->setShortcut (tr (
"-"));
4033 if ((m_scene !=
nullptr) &&
4034 (m_cmdMediator !=
nullptr)) {
4035 m_scene->updateCurveStyles(m_cmdMediator->document().modelCurveStyles());
4038 updateHighlightOpacity();
4039 updateWindowTitle();
4040 updateFittingWindow();
4041 updateGeometryWindow();
4042 m_guidelines.updateColor ();
4057 m_cmdMediator->document().setModelPointMatch(modelPointMatch);
4064 m_cmdMediator->document().setModelSegments(modelSegments);
4065 m_digitizeStateContext->updateModelSegments(modelSegments);
4068void MainWindow::updateSmallDialogs ()
4085void MainWindow::updateTransformationAndItsDependencies()
4087 m_transformation.update (!m_currentFile.isEmpty (),
4092 m_backgroundStateContext->setCurveSelected (m_isGnuplot,
4094 m_cmdMediator->document().modelGridRemoval(),
4095 m_cmdMediator->document().modelColorFilter(),
4096 m_cmbCurve->currentText ());
4102 m_guidelines.updateWithLatestTransformation ();
4105void MainWindow::updateViewedCurves ()
4109 if (m_actionViewCurvesAll->isChecked ()) {
4111 m_scene->showCurves (
true,
true);
4113 }
else if (m_actionViewCurvesSelected->isChecked ()) {
4117 }
else if (m_actionViewCurvesNone->isChecked ()) {
4119 m_scene->showCurves (
false);
4131 QString activeCurve = m_digitizeStateContext->activeCurve ();
4138 if (activeCurve.isEmpty ()) {
4140 m_viewPointStyle->unsetPointStyle ();
4141 m_viewSegmentFilter->unsetColorFilterSettings ();
4146 PointStyle pointStyle = m_cmdMediator->document().modelCurveStyles().curveStyle(activeCurve).pointStyle();
4147 m_viewPointStyle->setPointStyle (pointStyle);
4149 ColorFilterSettings colorFilterSettings = m_cmdMediator->document().modelColorFilter().colorFilterSettings(activeCurve);
4150 m_viewSegmentFilter->setColorFilterSettings (colorFilterSettings,
4151 m_cmdMediator->pixmap ());
4156void MainWindow::updateWindowTitle ()
4160 const QString PLACEHOLDER (
"[*]");
4162 QString title = QString (
"%1 %2")
4163 .arg (tr (
"Engauge Digitizer"))
4166 QString fileNameMaybeStripped;
4167 if (!m_currentFileWithPathAndFileExtension.isEmpty()) {
4169 QFileInfo fileInfo (m_currentFileWithPathAndFileExtension);
4176 fileNameMaybeStripped = fileInfo.completeBaseName();
4180 fileNameMaybeStripped = m_currentFileWithPathAndFileExtension;
4184 title += QString (
": %1")
4185 .arg (fileNameMaybeStripped);
4190 title += PLACEHOLDER;
4192 setWindowTitle (title);
4207void MainWindow::writeCheckpointToLogFile ()
4210 QString checkpointDoc;
4211 QTextStream strDoc (&checkpointDoc);
4216 QString checkpointScene;
4217 QTextStream strScene (&checkpointScene);
4225 <<
"--------------DOCUMENT CHECKPOINT START----------" <<
"\n"
4226 << checkpointDoc.toLatin1().data()
4227 <<
"---------------DOCUMENT CHECKPOINT END-----------" <<
"\n"
4228 <<
"----------------SCENE CHECKPOINT START-----------" <<
"\n"
4229 << checkpointScene.toLatin1().data()
4230 <<
"-----------------SCENE CHECKPOINT END------------" ;
BackgroundImage
Background selection.
@ BACKGROUND_IMAGE_ORIGINAL
@ BACKGROUND_IMAGE_FILTERED
unsigned int CoordSystemIndex
Zero-based index for identifying CoordSystem instantiations.
DigitizeState
Set of possible states of Digitize toolbar.
@ DIGITIZE_STATE_POINT_MATCH
@ DIGITIZE_STATE_COLOR_PICKER
@ DOCUMENT_AXES_POINTS_REQUIRED_2
const QString DOCUMENT_SERIALIZE_ERROR
const QString DOCUMENT_SERIALIZE_APPLICATION
const QString DOCUMENT_SERIALIZE_ERROR_CONTEXT
const QString DOCUMENT_SERIALIZE_OPERATING_SYSTEM_WORD_SIZE
const QString DOCUMENT_SERIALIZE_FILE
const QString DOCUMENT_SERIALIZE_ERROR_COMMENT
const QString DOCUMENT_SERIALIZE_IMAGE
const QString DOCUMENT_SERIALIZE_IMAGE_HEIGHT
const QString DOCUMENT_SERIALIZE_ERROR_LINE
const QString DOCUMENT_SERIALIZE_IMAGE_WIDTH
const QString DOCUMENT_SERIALIZE_ERROR_FILE
const QString DOCUMENT_SERIALIZE_DOCUMENT
const QString DOCUMENT_SERIALIZE_OPERATING_SYSTEM_ENDIAN
const QString DOCUMENT_SERIALIZE_APPLICATION_VERSION_NUMBER
const QString DOCUMENT_SERIALIZE_FILE_IMPORTED
const QString DOCUMENT_SERIALIZE_OPERATING_SYSTEM
const QString DOCUMENT_SERIALIZE_ERROR_REPORT
const QString DOCUMENT_SERIALIZE_BOOL_TRUE
const QString DOCUMENT_SERIALIZE_BOOL_FALSE
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
#define ENGAUGE_CHECK_PTR(ptr)
Drop in replacement for Q_CHECK_PTR.
QString EndianToString(QSysInfo::Endian endian)
QVector< double > FittingCurveCoefficients
Coefficients x0, x1, ... in y = a0 + a1 * x + a2 * x^2 + ...
const double DEFAULT_HIGHLIGHT_OPACITY
const int DEFAULT_MAXIMUM_GRID_LINES
Default for maximum number of grid lines.
GuidelineState
Set of possible Guideline states. See class Guideline for more information.
GuidelineViewState
Set of possible Guideline view states.
@ GUIDELINE_VIEW_STATE_HIDE
@ GUIDELINE_VIEW_STATE_EDIT
@ NUM_GUIDELINE_VIEW_STATES
@ GUIDELINE_VIEW_STATE_LOCK
const ImportCropping DEFAULT_IMPORT_CROPPING
log4cpp::Category * mainCat
const QString INDENTATION_PAST_TIMESTAMP
MainTitleBarFormat
Format format in MainWindow title bar.
@ MAIN_TITLE_BAR_FORMAT_NO_PATH
@ MAIN_TITLE_BAR_FORMAT_PATH
Filename without path.
const bool DEFAULT_SMALL_DIALOGS
const int DEFAULT_MAXIMUM_EXPORTED_POINTS_PER_CURVE
const bool DEFAULT_IMAGE_REPLACE_RENAMES_DOCUMENT
const int DEFAULT_SIGNIFICANT_DIGITS
const bool DEFAULT_DRAG_DROP_EXPORT
const int REGRESSION_INTERVAL
const unsigned int MAX_RECENT_FILE_LIST_SIZE
const QString ENGAUGE_FILENAME_EXTENSION("dig")
const QString EMPTY_FILENAME("")
const unsigned int MAX_RECENT_FILE_LIST_SIZE
NonPdfReturn
Return values from load operation.
@ NON_PDF_RETURN_CANCELED
int DEFAULT_IMPORT_PDF_RESOLUTION
PdfReturn
Return values from load operation.
const QString SETTINGS_ZOOM_FACTOR
const QString SETTINGS_SMALL_DIALOGS
const QString SETTINGS_IMPORT_PDF_RESOLUTION
const QString SETTINGS_ENGAUGE
const QString SETTINGS_CHECKLIST_GUIDE_DOCK_AREA
const QString SETTINGS_FITTING_WINDOW_DOCK_AREA
const QString SETTINGS_MAIN_TITLE_BAR_FORMAT
const QString SETTINGS_MAIN_DIRECTORY_EXPORT_SAVE
const QString SETTINGS_MAXIMUM_GRID_LINES
const QString SETTINGS_IMAGE_REPLACE_RENAMES_DOCUMENT
const QString SETTINGS_MAIN_DIRECTORY_IMPORT_LOAD
const QString SETTINGS_GROUP_ENVIRONMENT
const QString SETTINGS_HELP_SIZE
const QString SETTINGS_HIGHLIGHT_OPACITY
const QString SETTINGS_CHECKLIST_GUIDE_DOCK_GEOMETRY
const QString SETTINGS_LOCALE_LANGUAGE
const QString SETTINGS_SIZE
const QString SETTINGS_IMPORT_CROPPING
const QString SETTINGS_RECENT_FILE_LIST
const QString SETTINGS_HELP_POS
const QString SETTINGS_VIEW_COORD_SYSTEM_TOOLBAR
const QString SETTINGS_VIEW_DIGITIZE_TOOLBAR
const QString SETTINGS_ZOOM_FACTOR_INITIAL
const QString SETTINGS_SIGNIFICANT_DIGITS
const QString SETTINGS_VIEW_BACKGROUND_TOOLBAR
const QString SETTINGS_VIEW_SETTINGS_VIEWS_TOOLBAR
const QString SETTINGS_MAXIMUM_EXPORTED_POINTS_PER_CURVE
const QString SETTINGS_CHECKLIST_GUIDE_WIZARD
const QString SETTINGS_DRAG_DROP_EXPORT
const QString SETTINGS_VIEW_STATUS_BAR
const QString SETTINGS_ZOOM_CONTROL
const QString SETTINGS_GROUP_MAIN_WINDOW
const QString SETTINGS_VIEW_TOOL_TIPS
const QString SETTINGS_BACKGROUND_IMAGE
const QString SETTINGS_GEOMETRY_WINDOW_DOCK_GEOMETRY
const QString SETTINGS_POS
const QString SETTINGS_DIGITIZER
const QString SETTINGS_CURRENT_DIRECTORY
const QString SETTINGS_FITTING_WINDOW_DOCK_GEOMETRY
const QString SETTINGS_LOCALE_COUNTRY
const QString SETTINGS_GEOMETRY_WINDOW_DOCK_AREA
@ STATUS_BAR_MODE_TEMPORARY
QString engaugeWindowTitle()
Text for title bars of dialogs.
const char * VERSION_NUMBER
@ ZOOM_CONTROL_MENU_WHEEL_PLUSMINUS
@ ZOOM_CONTROL_MENU_WHEEL
const ZoomFactorInitial DEFAULT_ZOOM_FACTOR_INITIAL
ZoomFactor
Zoom factors ordered by zoom level so next one above/below is the next zoom level.
QStringList curveNames(CoordSystemIndex coordSystemIndex) const
Curve names to be placed into Document.
QString templateHtml(CoordSystemIndex coordSystemIndex) const
Template html comprising the checklist for display.
void populateCurvesGraphs(CoordSystemIndex coordSystemIndex, CurvesGraphs &curvesGraphs)
Create entries in CurvesGraphs for each curve name that user provided.
void update(const CmdMediator &cmdMediator, bool documentIsExported)
Update using current CmdMediator/Document state.
Command for adding one X/T Guideline value.
Command for adding one Y/R Guideline value.
Color filter parameters for one curve. For a class, this is handled the same as LineStyle and PointSt...
void create(MainWindow &mw)
Create QAction facade.
Model for DlgSettingsCurveProperties and CmdSettingsCurveProperties.
Container for all graph curves. The axes point curve is external to this class.
Dialog for saving error report for later transmission to the developers.
virtual void setSmallDialogs(bool smallDialogs)
If false then dialogs have a minimum size so all controls are visible.
virtual void setSmallDialogs(bool smallDialogs)
If false then dialogs have a minimum size so all controls are visible.
virtual void setSmallDialogs(bool smallDialogs)
If false then dialogs have a minimum size so all controls are visible.
virtual void setSmallDialogs(bool smallDialogs)
If false then dialogs have a minimum size so all controls are visible.
virtual void setSmallDialogs(bool smallDialogs)
If false then dialogs have a minimum size so all controls are visible.
virtual void setSmallDialogs(bool smallDialogs)
If false then dialogs have a minimum size so all controls are visible.
virtual void setSmallDialogs(bool smallDialogs)
If false then dialogs have a minimum size so all controls are visible.
virtual void setSmallDialogs(bool smallDialogs)
If false then dialogs have a minimum size so all controls are visible.
virtual void setSmallDialogs(bool smallDialogs)
If false then dialogs have a minimum size so all controls are visible.
virtual void setSmallDialogs(bool smallDialogs)
If false then dialogs have a minimum size so all controls are visible.
virtual void setSmallDialogs(bool smallDialogs)
If false then dialogs have a minimum size so all controls are visible.
virtual void setSmallDialogs(bool smallDialogs)
If false then dialogs have a minimum size so all controls are visible.
Model for DlgSettingsAxesChecker and CmdSettingsAxesChecker.
Model for DlgSettingsColorFilter and CmdSettingsColorFilter.
Model for DlgSettingsCoords and CmdSettingsCoords.
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
Model for DlgSettingsGeneral and CmdSettingsGeneral.
Model for DlgSettingsGridDisplay and CmdSettingsGridDisplay.
Model for DlgSettingsGridRemoval and CmdSettingsGridRemoval. The settings are unstable until the user...
Model for DlgSettingsPointMatch and CmdSettingsPointMatch.
Model for DlgSettingsSegments and CmdSettingsSegments.
void check(MainWindow &mainWindow, const Document &document) const
Check document state.
unsigned int coordSystemCount() const
Number of CoordSystem.
void setModelGuidelines(const DocumentModelGuidelines &modelGuidelines)
Set method for DocumentModelGuidelines.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
DocumentModelGridDisplay modelGridDisplay() const
Get method for DocumentModelGridDisplay.
DocumentModelExportFormat modelExportOverride(const DocumentModelExportFormat &modelExportFormatBefore, const ExportToFile &exportStrategy, const QString &selectedNameFilter) const
Adjust export settings given filename extension.
Class for exporting during regression, when the Transformation has not yet been defined.
Strategy class for exporting to a file. This strategy is external to the Document class so that class...
QString filterTsv() const
QFileDialog filter for TSV files.
QString filterCsv() const
QFileDialog filter for CSV files.
void exportToFile(const DocumentModelExportFormat &modelExport, const Document &document, const MainWindowModel &modelMainWindow, const Transformation &transformation, QTextStream &str) const
Export Document points according to the settings.
QString fileExtensionCsv() const
File extension for csv export files.
File that manages a command stack for regression testing of file import/open/export/close.
virtual void update(const CmdMediator &cmdMediator, const MainWindowModel &modelMainWindow, const QString &curveSelected, const Transformation &transformation)
Populate the table with the specified Curve.
Add point and line handling to generic QGraphicsScene.
void printStream(QString indentation, QTextStream &str)
Debugging method that supports print method of this class and printStream method of some other class(...
QGraphicsView class with event handling added. Typically the events are sent to the active digitizing...
Factory class for generating the points, composed of QGraphicsItem objects, along a GridLine.
void setVisible(bool visible)
Make all grid lines visible or hidden.
void clear()
Deallocate and remove all grid lines.
CmdAbstract * createAfterDrag(MainWindow &mainWindow, Document &document, double newValue, const DocumentModelGuidelines &modelGuidelinesDocument, const QString &identifier, bool draggedOffscreen)
Create delete or move Cmd.
Calculate offset from edge for new Guidelines.
QPointF top(const QGraphicsView &view, const Transformation &transformation) const
Compute offset from top side and returns point in graph coordinates.
QPointF right(const QGraphicsView &view, const Transformation &transformation) const
Compute offset from right side and returns point in graph coordinates.
QPointF bottom(const QGraphicsView &view, const Transformation &transformation) const
Compute offset from bottom side and returns point in graph coordinates.
QPointF left(const QGraphicsView &view, const Transformation &transformation) const
Compute offset from left side and returns point in graph coordinates.
This class contains all Guideline objects.
void handleGuidelineMode(bool visible, bool locked)
User toggled guideline mode.
void handleActiveChange(bool active)
DigitizeState change so active status may (or may not) be toggled.
QStringList fileExtensionsWithAsterisks() const
File extensions for use in file dialogs.
bool load(const QString &filename, QImage &image) const
Load image from jpeg2000 file.
bool loadsAsDigFile(const QString &urlString) const
Returns true if specified file name can be loaded as a DIG file.
static void bindToMainWindow(MainWindow *mainWindow)
Bind to MainWindow so this class can access the command stack.
void setDirectoryExportSaveFromSavedPath(const QString &path)
Set the current Export/Save directory at startup to path from previous execution.
void setDirectoryImportOpenFromFilename(const QString &fileName)
Save the current Import/Open directory, after user has accepted the Import/Open dialog.
void setDirectoryExportSaveFromFilename(const QString &fileName)
Save the current Export/Save directory, after user has accepted the Export/Save dialog.
QDir getDirectoryImportOpen() const
Get the current Import/Open directory.
void setDirectoryImportLoadFromSavedPath(const QString &path)
Set the current Import/Open directory at startup to path from previous execution.
QDir getDirectoryExportSave() const
Get the current Export/Save directory.
Model for DlgSettingsMainWindow.
bool smallDialogs() const
Get method for small dialogs flag.
ZoomControl zoomControl() const
Get method for zoom control.
MainTitleBarFormat mainTitleBarFormat() const
Get method for MainWindow titlebar filename format.
void saveErrorReportFileAndExit(const char *comment, const char *file, int line, const char *context)
Save error report and exit.
void updateSettingsGridRemoval(const DocumentModelGridRemoval &modelGridRemoval)
Update with new grid removal properties.
void showTemporaryMessage(const QString &temporaryMessage)
Show temporary message in status bar.
CmdMediator * cmdMediator()
Accessor for commands to process the Document.
void sendGong()
Send signal to unit test framework indicating all commands have finished executing.
void guidelineRemove(const QString &identifier)
Remove a X/T or Y/R Guideline.
void updateSettingsGridDisplay(const DocumentModelGridDisplay &modelGridDisplay)
Update with new grid display properties.
virtual bool eventFilter(QObject *, QEvent *)
Catch secret keypresses.
void updateSettingsAxesChecker(const DocumentModelAxesChecker &modelAxesChecker)
Update with new axes indicator properties.
virtual void showEvent(QShowEvent *)
Processing performed after gui becomes available.
void updateSettingsDigitizeCurve(const DocumentModelDigitizeCurve &modelDigitizeCurve)
Update with new curve digitization styles.
bool isGnuplot() const
Get method for gnuplot flag.
void guidelineViewState(GuidelineViewState state) const
Guideline view state in View menu.
void updateSettingsCurveStyles(const CurveStyles &modelCurveStyles)
Update with new curve styles.
bool transformIsDefined() const
Return true if all three axis points have been defined.
MainWindowModel modelMainWindow() const
Get method for main window model.
bool guidelinesAreVisible() const
True/false if guidelines are visible. Selectability is handled elsewhere.
void cmdFileOpen(const QString &fileName)
Open file. This is called from a file script command.
void updateSettingsCurveList(const CurvesGraphs &curvesGraphs)
Update with new curves.
void updateAfterCommand()
See GraphicsScene::updateAfterCommand.
void updateSettingsExportFormat(const DocumentModelExportFormat &modelExport)
Update with new export properties.
void guidelineMoveXT(const QString &identifier, double xTAfter)
Move a X/T Guideline.
void updateSettingsSegments(const DocumentModelSegments &modelSegments)
Update with new segments properties.
BackgroundImage selectOriginal(BackgroundImage backgroundImage)
Make original background visible, for DigitizeStateColorPicker.
void cmdFileExport(const QString &fileName)
Export file. This is called from a file script command.
friend class CreateFacade
void updateViewsOfSettings(const QString &activeCurve)
Update curve-specific view of settings. Private version gets active curve name from DigitizeStateCont...
void updateSettingsMainWindow(const MainWindowModel &modelMainWindow)
Update with new main window properties.
void cmdFileClose()
Close file. This is called from a file script command.
void updateDigitizeStateIfSoftwareTriggered(DigitizeState digitizeState)
After software-triggered state transition, this method manually triggers the action as if user had cl...
bool modeMap() const
True if document scale is set using a scale bar, otherwise using axis points.
void guidelineAddYR(const QString &identifier, double yR)
Add a Y/R Guideline.
void signalDropRegression(QString)
Send drag and drop regression test url.
void updateSettingsGeneral(const DocumentModelGeneral &modelGeneral)
Update with new general properties.
void signalZoom(int)
Send zoom selection, picked from menu or keystroke, to StatusBar.
void guidelineMoveYR(const QString &identifier, double yRAfter)
Move a Y/R Guideline.
void updateSettingsPointMatch(const DocumentModelPointMatch &modelPointMatch)
Update with new point match properties.
MainWindow(const QString &errorReportFile, const QString &fileCmdScriptFile, bool isDropRegression, bool isRegressionTest, bool isGnuplot, bool isReset, bool isExportOnly, bool isExtractImageOnly, const QString &extractImageOnlyExtension, const QStringList &loadStartupFiles, const QStringList &commandLineWithoutLoadStartupFiles, QWidget *parent=nullptr)
Single constructor.
void cmdFileImport(const QString &fileName)
Import file. This is called from a file script command.
void updateGraphicsLinesToMatchGraphicsPoints()
Update the graphics lines so they follow the graphics points, after a drag, addition,...
void handleGuidelinesActiveChange(bool active)
Handle Guidelines active status toggle.
void signalGong()
Send wakeup signal to unit test framework when all other commands have finished executing.
QImage imageFiltered() const
Background image that has been filtered for the current curve. This asserts if a curve-specific image...
QString selectedGraphCurve() const
Curve name that is currently selected in m_cmbCurve.
GraphicsScene & scene()
Scene container for the QImage and QGraphicsItems.
void updateAfterMouseRelease()
Call MainWindow::updateControls (which is private) after the very specific case - a mouse press/relea...
void resizeEvent(QResizeEvent *event)
Intercept resize event so graphics scene can be appropriately resized when in Fill mode.
void guidelineAddXT(const QString &identifier, double xT)
Add a X/T Guideline.
Transformation transformation() const
Return read-only copy of transformation.
void updateSettingsColorFilter(const DocumentModelColorFilter &modelColorFilter)
Update with new color filter properties.
void updateCoordSystem(CoordSystemIndex coordSystemIndex)
Select a different CoordSystem.
void updateSettingsCoords(const DocumentModelCoords &modelCoords)
Update with new coordinate properties.
GraphicsView & view()
View for the QImage and QGraphicsItems, without const.
void retrievePoints(const Transformation &transformation, QList< QPoint > &points, QList< double > &ordinals) const
Retrieve points from clipboard.
NonPdfReturn load(const QString &fileName, QImage &image, ImportCropping importCropping, bool isErrorReportRegressionTest) const
Try to load the specified file. Success is indicated in the function return value.
PdfReturn load(const QString &fileName, QImage &image, int resolution, ImportCropping importCropping, bool isErrorReportRegressionTest) const
Try to load the specified file. Success is indicated in the function return value.
Details for a specific Point.
static void setIdentifierIndex(unsigned int identifierIndex)
Reset the current index while performing a Redo.
QStringList unite(CmdMediator *cmdMediator, const QStringList &pointIdentifiersIn) const
Add.
void triggerStateTransition(bool isGnuplot, TransformationState transformationState, CmdMediator &cmdMediator, const Transformation &transformation, const QString &selectedGraphCurve)
Trigger a state transition to be performed immediately.
double mapToFactor(ZoomFactor zoomFactor) const
Return the floating precision zoom factor given the enum value.
ZoomFactor zoomOut(ZoomFactor currentZoomFactor, double m11, double m22, bool actionZoomFillIsChecked) const
Zoom out.
ZoomFactor zoomIn(ZoomFactor currentZoomFactor, double m11, double m22, bool actionZoomFillIsChecked) const
Zoom in.
#define LOG4CPP_INFO_S(logger)
#define LOG4CPP_DEBUG_S(logger)
#define LOG4CPP_ERROR_S(logger)