Engauge Digitizer 2
Loading...
Searching...
No Matches
MainWindowModel.cpp
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5 ******************************************************************************************************/
6
7#include "CmdMediator.h"
8#include "DocumentSerialize.h"
9#include "GraphicsPoint.h"
10#include "GridLineLimiter.h"
12#include "Logger.h"
13#include "MainWindowModel.h"
14#include "PdfResolution.h"
15#include <QLocale>
16#include <QObject>
17#include <QTextStream>
18#include "QtToString.h"
19#include <QXmlStreamWriter>
20#include "Xml.h"
21#include "ZoomFactorInitial.h"
22
23// Prevent comma ambiguity with group separator commas and field delimiting commas
24const QLocale::NumberOption HIDE_GROUP_SEPARATOR = QLocale::OmitGroupSeparator;
25
26const bool DEFAULT_DRAG_DROP_EXPORT = false; // False value allows intuitive copy-and-drag to select a rectangular set of table cells
28const bool DEFAULT_SMALL_DIALOGS = false;
29const bool DEFAULT_IMAGE_REPLACE_RENAMES_DOCUMENT = true; // Pre-version 11.3 behavior
30const int DEFAULT_MAXIMUM_EXPORTED_POINTS_PER_CURVE = 5000; // Moved 1/2020 from Export classes
31const LoadViews DEFAULT_LOAD_VIEWS = LOAD_VIEWS_KEEP_CURRENT; // Pre-version 13 behavior
32
35 m_zoomFactorInitial (DEFAULT_ZOOM_FACTOR_INITIAL),
36 m_mainTitleBarFormat (MAIN_TITLE_BAR_FORMAT_PATH),
37 m_pdfResolution (DEFAULT_IMPORT_PDF_RESOLUTION),
38 m_importCropping (DEFAULT_IMPORT_CROPPING),
39 m_loadViews (DEFAULT_LOAD_VIEWS),
40 m_maximumGridLines (DEFAULT_MAXIMUM_GRID_LINES),
41 m_highlightOpacity (DEFAULT_HIGHLIGHT_OPACITY),
42 m_smallDialogs (DEFAULT_SMALL_DIALOGS),
43 m_dragDropExport (DEFAULT_DRAG_DROP_EXPORT),
44 m_significantDigits (DEFAULT_SIGNIFICANT_DIGITS),
45 m_imageReplaceRenamesDocument (DEFAULT_IMAGE_REPLACE_RENAMES_DOCUMENT),
46 m_maximumExportedPointsPerCurve (DEFAULT_MAXIMUM_EXPORTED_POINTS_PER_CURVE)
47{
48 // Locale member variable m_locale is initialized to default locale when default constructor is called
49}
50
52 m_locale (other.locale()),
53 m_zoomControl (other.zoomControl()),
54 m_zoomFactorInitial (other.zoomFactorInitial()),
55 m_mainTitleBarFormat (other.mainTitleBarFormat()),
56 m_pdfResolution (other.pdfResolution()),
57 m_importCropping (other.importCropping()),
58 m_loadViews (other.loadViews()),
59 m_maximumGridLines (other.maximumGridLines()),
60 m_highlightOpacity (other.highlightOpacity()),
61 m_smallDialogs (other.smallDialogs()),
62 m_dragDropExport (other.dragDropExport()),
63 m_significantDigits (other.significantDigits()),
64 m_imageReplaceRenamesDocument (other.imageReplaceRenamesDocument()),
65 m_maximumExportedPointsPerCurve (other.maximumExportedPointsPerCurve ())
66{
67}
68
70{
71 m_locale = other.locale();
72 m_zoomControl = other.zoomControl();
73 m_zoomFactorInitial = other.zoomFactorInitial();
74 m_mainTitleBarFormat = other.mainTitleBarFormat();
75 m_pdfResolution = other.pdfResolution();
76 m_importCropping = other.importCropping();
77 m_loadViews = other.loadViews();
78 m_maximumGridLines = other.maximumGridLines();
79 m_highlightOpacity = other.highlightOpacity();
80 m_smallDialogs = other.smallDialogs();
81 m_dragDropExport = other.dragDropExport();
82 m_significantDigits = other.significantDigits();
83 m_imageReplaceRenamesDocument = other.imageReplaceRenamesDocument();
84 m_maximumExportedPointsPerCurve = other.maximumExportedPointsPerCurve();
85
86 return *this;
87}
88
90{
91 return m_dragDropExport;
92}
93
95{
96 return m_highlightOpacity;
97}
98
100{
101 return m_imageReplaceRenamesDocument;
102}
103
105{
106 return m_importCropping;
107}
108
110{
111 return m_loadViews;
112}
113
114void MainWindowModel::loadXml(QXmlStreamReader & /* reader */)
115{
116 LOG4CPP_ERROR_S ((*mainCat)) << "MainWindowModel::loadXml";
117
118 // This class is never serialized
119}
120
122{
123 return m_locale;
124}
125
127{
128 return m_mainTitleBarFormat;
129}
130
132{
133 return m_maximumExportedPointsPerCurve;
134}
135
137{
138 return m_maximumGridLines;
139}
140
142{
143 return m_pdfResolution;
144}
145
146void MainWindowModel::printStream(QString indentation,
147 QTextStream &str) const
148{
149 str << indentation << "MainWindowModel\n";
150
151 indentation += INDENTATION_DELTA;
152
153 str << indentation << "locale=" << m_locale.name() << "\n";
154 str << indentation << "zoomControl=" << m_zoomControl << "\n";
155 str << indentation << "zoomFactorInitial=" << m_zoomFactorInitial << "\n";
156 str << indentation << "mainWindowTitleBarFormat=" << (m_mainTitleBarFormat == MAIN_TITLE_BAR_FORMAT_NO_PATH ?
157 "NoPath" :
158 "Path") << "\n";
159 str << indentation << "pdfResolution=" << m_pdfResolution << "\n";
160 str << indentation << "importCropping=" << ImportCroppingUtilBase::importCroppingToString (m_importCropping).toLatin1().data() << "\n";
161 str << indentation << "loadViews=" << (m_loadViews == LOAD_VIEWS_KEEP_CURRENT ?
162
163 "KeepCurrent" :
164 "UseDocument") << "\n";
165 str << indentation << "maximumGridLines=" << m_maximumGridLines << "\n";
166 str << indentation << "highlightOpacity=" << m_highlightOpacity << "\n";
167 str << indentation << "smallDialogs=" << (m_smallDialogs ? "yes" : "no") << "\n";
168 str << indentation << "dragDropExport=" << (m_dragDropExport ? "yes" : "no") << "\n";
169 str << indentation << "significantDigits=" << m_significantDigits << "\n";
170 str << indentation << "imageReplaceRenamesDocument=" << (m_imageReplaceRenamesDocument ? "yes" : "no") << "\n";
171 str << indentation << "maximumExportedPointsPerCurve=" << m_maximumExportedPointsPerCurve << "\n";
172}
173
174void MainWindowModel::saveXml(QXmlStreamWriter & /* writer */) const
175{
176 LOG4CPP_ERROR_S ((*mainCat)) << "MainWindowModel::saveXml";
177
178 // This class is never serialized
179}
180
182{
183 m_dragDropExport = dragDropExport;
184}
185
187{
188 m_highlightOpacity = highlightOpacity;
189}
190
195
200
202{
203 m_loadViews = loadViews;
204}
205
206void MainWindowModel::setLocale (QLocale::Language language,
207 QLocale::Country country)
208{
209 QLocale locale (language,
210 country);
211 locale.setNumberOptions(HIDE_GROUP_SEPARATOR);
212
213 m_locale = locale;
214}
215
217{
218 m_locale = locale;
219 m_locale.setNumberOptions(HIDE_GROUP_SEPARATOR);
220}
221
226
231
233{
234 m_maximumGridLines = maximumGridLines;
235}
236
238{
239 m_pdfResolution = resolution;
240}
241
243{
244 m_significantDigits = significantDigits;
245}
246
248{
249 m_smallDialogs = smallDialogs;
250}
251
256
261
263{
264 return m_significantDigits;
265}
266
268{
269 return m_smallDialogs;
270}
271
273{
274 return m_zoomControl;
275}
276
278{
279 return m_zoomFactorInitial;
280}
const double DEFAULT_HIGHLIGHT_OPACITY
const int DEFAULT_MAXIMUM_GRID_LINES
Default for maximum number of grid lines.
const ImportCropping DEFAULT_IMPORT_CROPPING
ImportCropping
LoadViews
Options for loading view states.
Definition LoadViews.h:13
@ LOAD_VIEWS_KEEP_CURRENT
Definition LoadViews.h:14
log4cpp::Category * mainCat
Definition Logger.cpp:14
const QString INDENTATION_DELTA
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 QLocale::NumberOption HIDE_GROUP_SEPARATOR
const LoadViews DEFAULT_LOAD_VIEWS
const bool DEFAULT_IMAGE_REPLACE_RENAMES_DOCUMENT
const int DEFAULT_SIGNIFICANT_DIGITS
const bool DEFAULT_DRAG_DROP_EXPORT
const bool DEFAULT_SMALL_DIALOGS
const int DEFAULT_MAXIMUM_EXPORTED_POINTS_PER_CURVE
const LoadViews DEFAULT_LOAD_VIEWS
const bool DEFAULT_IMAGE_REPLACE_RENAMES_DOCUMENT
const int DEFAULT_SIGNIFICANT_DIGITS
const bool DEFAULT_DRAG_DROP_EXPORT
int DEFAULT_IMPORT_PDF_RESOLUTION
ZoomControl
Definition ZoomControl.h:10
@ ZOOM_CONTROL_MENU_WHEEL_PLUSMINUS
Definition ZoomControl.h:14
const ZoomFactorInitial DEFAULT_ZOOM_FACTOR_INITIAL
ZoomFactorInitial
static QString importCroppingToString(ImportCropping importCropping)
Option as string for display to user.
virtual void saveXml(QXmlStreamWriter &writer) const
Save entire model as xml into stream.
void setSmallDialogs(bool smallDialogs)
Set method for small dialogs flag.
QLocale locale() const
Get method for locale.
MainWindowModel()
Default constructor.
LoadViews loadViews() const
Get method for how to load views.
void setImageReplaceRenamesDocument(bool imageReplaceRenamesDocument)
Set method for image replace renames document.
MainWindowModel & operator=(const MainWindowModel &other)
Assignment constructor.
bool dragDropExport() const
Get method for drag and drop export.
bool imageReplaceRenamesDocument() const
Get method for image replaces renames document.
ZoomFactorInitial zoomFactorInitial() const
Get method for initial zoom factor.
void setImportCropping(ImportCropping importCropping)
Set method for import cropping.
void setMaximumExportedPointsPerCurve(int maximumExportedPointsPerCurve)
Set method for maximum number of exported points per curve.
ImportCropping importCropping() const
Get method for import cropping.
bool smallDialogs() const
Get method for small dialogs flag.
void setLoadViews(LoadViews loadViews)
Set method for how to load views.
void setMainTitleBarFormat(MainTitleBarFormat mainTitleBarFormat)
Set method for MainWindow titlebar filename format.
void setDragDropExport(bool dragDropExport)
Set method for drag and drop export.
double highlightOpacity() const
Get method for highlight opacity.
void printStream(QString indentation, QTextStream &str) const
Debugging method that supports print method of this class and printStream method of some other class(...
void setZoomControl(ZoomControl zoomControl)
Set method for zoom control.
void setMaximumGridLines(int maximumGridLines)
Set method for maximum number of grid lines.
ZoomControl zoomControl() const
Get method for zoom control.
virtual void loadXml(QXmlStreamReader &reader)
Load model from serialized xml.
void setPdfResolution(int resolution)
Set method for resolution of imported PDF files, in dots per inch.
int maximumGridLines() const
Get method for maximum number of grid lines.
int significantDigits() const
Get method for significant digits.
void setZoomFactorInitial(ZoomFactorInitial zoomFactorInitial)
Set method for initial zoom factor.
MainTitleBarFormat mainTitleBarFormat() const
Get method for MainWindow titlebar filename format.
void setHighlightOpacity(double highlightOpacity)
Set method for highlight opacity.
int maximumExportedPointsPerCurve() const
Get method for maximum number of exported points per curve.
void setLocale(QLocale::Language language, QLocale::Country country)
Set method for locale given attributes.
int pdfResolution() const
Get method for resolution of imported PDF files, in dots per inch.
void setSignificantDigits(int significantDigits)
Set method for significant digits.
#define LOG4CPP_ERROR_S(logger)
Definition convenience.h:12