19#include <QDoubleValidator>
27#include <QRadioButton>
56 "DlgSettingsExportFormat",
58 m_validatorFunctionsPointsEvenlySpacing (
nullptr),
59 m_validatorRelationsPointsEvenlySpacing (
nullptr),
62 m_haveFunction (
false),
63 m_haveRelation (
false)
76 delete m_validatorFunctionsPointsEvenlySpacing;
77 delete m_validatorRelationsPointsEvenlySpacing;
91 m_listIncluded->setSortingEnabled (
false);
92 m_listIncluded->setWhatsThis (
tr (
"List of curves to be included in the exported file.\n\n"
93 "The order of the curves here does not affect the order in the exported file. That "
94 "order is determined by the Curves settings."));
95 m_listIncluded->setSelectionMode (QAbstractItemView::MultiSelection);
96 layout->addWidget (m_listIncluded,
row, 0, 4, 1);
100 m_listExcluded->setSortingEnabled (
false);
101 m_listExcluded->setWhatsThis (
tr (
"List of curves to be excluded from the exported file"));
102 m_listExcluded->setSelectionMode (QAbstractItemView::MultiSelection);
103 layout->addWidget (m_listExcluded,
row++, 2, 4, 1);
107 m_btnInclude->setEnabled (
false);
108 m_btnInclude->setWhatsThis (
tr (
"Move the currently selected curve(s) from the excluded list"));
109 layout->addWidget (m_btnInclude,
row++, 1);
113 m_btnExclude->setEnabled (
false);
114 m_btnExclude->setWhatsThis (
tr (
"Move the currently selected curve(s) from the included list"));
115 layout->addWidget (m_btnExclude,
row++, 1);
132 m_btnDelimitersCommas->setWhatsThis (
tr (
"Exported file will have commas between adjacent values, unless overridden by tabs in TSV files."));
137 m_btnDelimitersSpaces->setWhatsThis (
tr (
"Exported file will have spaces between adjacent values, unless overridden by commas in CSV files, "
138 "or tabs in TSV files."));
143 m_btnDelimitersTabs->setWhatsThis (
tr (
"Exported file will have tabs between adjacent values, unless overridden by commas in CSV files."));
148 m_btnDelimitersSemicolons->setWhatsThis (
tr (
"Exported file will have semicolons between adjacent values, unless overridden by commas in CSV files."));
152 m_chkOverrideCsvTsv =
new QCheckBox (
tr (
"Override in CSV/TSV files"));
153 m_chkOverrideCsvTsv->setWhatsThis (
tr (
"Comma-separated value (CSV) files and tab-separated value (TSV) files will use commas and tabs "
154 "respectively, unless this setting is selected. Selecting this setting will apply the delimiter setting "
170 m_btnCurvesLayoutAllCurves =
new QRadioButton (
tr (
"All curves on each line"));
171 m_btnCurvesLayoutAllCurves->setWhatsThis (
tr (
"Exported file will have, on each line, "
172 "an X value, the Y value for the first curve, the Y value for the second curve,..."));
176 m_btnCurvesLayoutOneCurve =
new QRadioButton (
tr (
"One curve on each line"));
177 m_btnCurvesLayoutOneCurve->setWhatsThis (
tr (
"Exported file will have all the points for "
178 "the first curve, with one X-Y pair on each line, then the points for the second curve,..."));
183void DlgSettingsExportFormat::createFunctionsPointsSelection (
QHBoxLayout *layoutFunctions)
201 m_btnFunctionsPointsAllCurves =
new QRadioButton (
tr (
"Interpolate Ys at Xs from all curves"));
202 m_btnFunctionsPointsAllCurves->setWhatsThis (
tr (
"Exported file will have values at every unique X "
203 "value from every curve. Y values will be linearly interpolated if necessary"));
208 m_chkExtrapolateOutsideEndpoints =
new QCheckBox (
tr (
"Extrapolate outside endpoints"));
209 m_chkExtrapolateOutsideEndpoints->setWhatsThis (
tr (
"Enable or disable extrapolation outside of endpoints of each curve. If disabled, "
210 "only points between the endpoints of each curve are exported"));
214 m_btnFunctionsPointsFirstCurve =
new QRadioButton (
tr (
"Interpolate Ys at Xs from first curve"));
215 m_btnFunctionsPointsFirstCurve->setWhatsThis (
tr (
"Exported file will have values at every unique X "
216 "value from the first curve. Y values will be linearly interpolated if necessary"));
220 m_btnFunctionsPointsEvenlySpaced =
new QRadioButton (
tr (
"Interpolate Ys at evenly spaced X values that are automatically selected"));
221 m_btnFunctionsPointsEvenlySpaced->setWhatsThis (
tr (
"Exported file will have values at evenly spaced X values, separated by the interval selected below."));
228 m_editFunctionsPointsEvenlySpacing =
new QLineEdit;
229 m_validatorFunctionsPointsEvenlySpacing =
new QDoubleValidator;
230 m_editFunctionsPointsEvenlySpacing->setValidator (m_validatorFunctionsPointsEvenlySpacing);
231 m_editFunctionsPointsEvenlySpacing->setMinimumWidth (
MIN_EDIT_WIDTH);
232 m_editFunctionsPointsEvenlySpacing->setMaximumWidth (
MAX_EDIT_WIDTH);
233 m_editFunctionsPointsEvenlySpacing->setWhatsThis (
tr (
"Interval, in the units of X, between successive points in the X direction.\n\n"
234 "If the scale is linear, then this interval is added to successive X values. If the scale is "
235 "logarithmic, then this interval is multiplied to successive X values.\n\n"
236 "The X values will be automatically aligned along simple numbers. If the first and/or last "
237 "points are not along the aligned X values, then one or two additional points are added "
242 m_cmbFunctionsPointsEvenlySpacingUnits =
new QComboBox;
243 m_cmbFunctionsPointsEvenlySpacingUnits->setWhatsThis (
tr (
"Units for spacing interval.\n\n"
244 "Pixel units are preferred when the spacing is to be independent of the X scale. The spacing will be "
245 "consistent across the graph, even if the X scale is logarithmic.\n\n"
246 "Graph units are preferred when the spacing is to depend on the X scale."));
252 this,
SLOT (slotFunctionsPointsEvenlySpacedIntervalUnits (
const QString &)));
255 m_btnFunctionsPointsGridLines =
new QRadioButton (
tr (
"Interpolate Ys at evenly spaced X values on grid lines"));
256 m_btnFunctionsPointsGridLines->setWhatsThis (
tr (
"Exported file will have values at evenly spaced X values at the vertical grid lines."));
260 m_btnFunctionsPointsRaw =
new QRadioButton (
tr (
"Raw Xs and Ys"));
261 m_btnFunctionsPointsRaw->setWhatsThis (
tr (
"Exported file will have only original X and Y values"));
282 m_btnHeaderNone->setWhatsThis (
tr (
"Exported file will have no header line"));
287 m_btnHeaderSimple->setWhatsThis (
tr (
"Exported file will have simple header line"));
292 m_btnHeaderGnuplot->setWhatsThis (
tr (
"Exported file will have gnuplot header line"));
305 m_btnSaveDefault->setWhatsThis (
tr (
"Save the settings for use as future defaults."));
307 layout->addWidget (m_btnSaveDefault, 0, Qt::AlignLeft);
310 m_btnLoadDefault->setWhatsThis (
tr (
"Load the default settings."));
312 layout->addWidget (m_btnLoadDefault, 0, Qt::AlignLeft);
319 QLabel *
label =
new QLabel (
tr (
"Preview"));
327 "<span style=\"background-color: %2\"> Relations </span>")
334 m_editPreview->setReadOnly (
true);
335 m_editPreview->setWhatsThis (
tr (
"Preview window shows how current settings affect the exported file.\n\n"
336 "Functions (shown here in blue) are output first, followed by relations "
337 "(shown here in green) if any exist."));
339 m_editPreview->document()->setDefaultStyleSheet(
"div { padding-left: 20px; }");
341 p.setColor (QPalette::Base,
QColor (240, 240, 240));
342 m_editPreview->setPalette (
p);
344 layout->addWidget (m_editPreview,
row++, 0, 1, 3);
365 m_btnRelationsPointsEvenlySpaced =
new QRadioButton (
tr (
"Interpolate Xs and Ys at evenly spaced intervals."));
366 m_btnRelationsPointsEvenlySpaced->setWhatsThis (
tr (
"Exported file will have points evenly spaced along each relation, separated by the interval "
367 "selected below. If the last interval does not end at the last point, then a shorter last interval "
368 "is added that ends on the last point."));
375 m_editRelationsPointsEvenlySpacing =
new QLineEdit;
376 m_validatorRelationsPointsEvenlySpacing =
new QDoubleValidator;
377 m_editRelationsPointsEvenlySpacing->setValidator (m_validatorRelationsPointsEvenlySpacing);
378 m_editRelationsPointsEvenlySpacing->setMinimumWidth (
MIN_EDIT_WIDTH);
379 m_editRelationsPointsEvenlySpacing->setMaximumWidth (
MAX_EDIT_WIDTH);
380 m_editRelationsPointsEvenlySpacing->setWhatsThis (
tr (
"Interval between successive points when "
381 "exporting at evenly spaced (X,Y) coordinates."));
385 m_cmbRelationsPointsEvenlySpacingUnits =
new QComboBox;
386 m_cmbRelationsPointsEvenlySpacingUnits->setWhatsThis (
tr (
"Units for spacing interval.\n\n"
387 "Pixel units are preferred when the spacing is to be independent of the X and Y scales. The spacing will be "
388 "consistent across the graph, even if a scale is logarithmic or the X and Y scales are different.\n\n"
389 "Graph units are usually preferred when the X and Y scales are identical."));
395 this,
SLOT (slotRelationsPointsEvenlySpacedIntervalUnits (
const QString &)));
398 m_btnRelationsPointsRaw =
new QRadioButton (
tr (
"Raw Xs and Ys"));
399 m_btnRelationsPointsRaw->setWhatsThis (
tr (
"Exported file will have only original X and Y values"));
439 layout->addWidget (m_tabWidget,
row++, 0, 1, 3);
445 "Controls for specifying the format of functions during export"));
453 "Controls for specifying the format of relations during export"));
460 createFunctionsPointsSelection (layoutFunctions);
474 m_editXLabel =
new QLineEdit;
475 m_editXLabel->setWhatsThis (
tr (
"Label in the header for x values"));
487 .replace (
"\n",
"<br>")
488 .replace (
" ",
" ")
490 .replace (
"\t",
" ");
492 QString html =
QString (
"<div style=\"display: inline; background-color: %1\">%2</div>")
499bool DlgSettingsExportFormat::goodIntervalFunctions()
const
510 <<
" good=" << (
isGood ?
"true" :
"false")
511 <<
" bottom=" << m_validatorFunctionsPointsEvenlySpacing->bottom()
512 <<
" top=" << m_validatorFunctionsPointsEvenlySpacing->top();
517bool DlgSettingsExportFormat::goodIntervalRelations()
const
528 <<
" good=" << (
isGood ?
"true" :
"false")
529 <<
" bottom=" << m_validatorRelationsPointsEvenlySpacing->bottom()
530 <<
" top=" << m_validatorRelationsPointsEvenlySpacing->top();
541 *m_modelExportBefore,
542 *m_modelExportAfter);
548void DlgSettingsExportFormat::initializeIntervalConstraints ()
566 double maxSizeGraph = boundingRectGraphMax.x() - boundingRectGraphMin.x();
579 delete m_modelExportBefore;
580 delete m_modelExportAfter;
587 m_listExcluded->clear();
589 QStringList::const_iterator
itr;
596 m_listIncluded->clear();
601 m_listIncluded->addItem (curveName);
628 m_chkOverrideCsvTsv->setChecked (m_modelExportAfter->
overrideCsvTsv());
635 m_editXLabel->setText (m_modelExportAfter->
xLabel());
642 int indexFunctions = m_cmbFunctionsPointsEvenlySpacingUnits->findData (
QVariant (pointsIntervalUnitsFunctions));
643 int indexRelations = m_cmbRelationsPointsEvenlySpacingUnits->findData (
QVariant (pointsIntervalUnitsRelations));
644 m_cmbFunctionsPointsEvenlySpacingUnits->setCurrentIndex (
indexFunctions);
645 m_cmbRelationsPointsEvenlySpacingUnits->setCurrentIndex (
indexRelations);
647 initializeIntervalConstraints ();
649 updateControlsUponLoad ();
651 updateIntervalConstraints();
663void DlgSettingsExportFormat::slotDelimitersCommas()
672void DlgSettingsExportFormat::slotDelimitersSemicolons()
681void DlgSettingsExportFormat::slotDelimitersSpaces()
690void DlgSettingsExportFormat::slotDelimitersTabs()
699void DlgSettingsExportFormat::slotExclude ()
706 for (
i = 0;
i < m_listIncluded->count();
i++) {
707 if (m_listIncluded->item(
i)->isSelected()) {
708 excluded += m_listIncluded->item(
i)->text();
715 m_listExcluded->addItem (curveName);
719 for (
i = m_listIncluded->count() - 1;
i>= 0;
i--) {
720 QString curveName = m_listIncluded->item(
i)->text();
721 if (
excluded.contains (curveName)) {
723 m_listIncluded->removeItemWidget (item);
733void DlgSettingsExportFormat::slotFunctionsExtrapolateOutsideEndpoints(
int)
742void DlgSettingsExportFormat::slotFunctionsLayoutAllCurves()
751void DlgSettingsExportFormat::slotFunctionsLayoutOneCurve()
760void DlgSettingsExportFormat::slotFunctionsPointsAllCurves()
769void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced()
778void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval(
const QString &)
783 if (goodIntervalFunctions()) {
792void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits(
const QString &)
794 LOG4CPP_INFO_S ((*
mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits";
796 int index = m_cmbFunctionsPointsEvenlySpacingUnits->currentIndex();
800 updateIntervalConstraints();
805void DlgSettingsExportFormat::slotFunctionsPointsFirstCurve()
814void DlgSettingsExportFormat::slotFunctionsPointsGridLines()
823void DlgSettingsExportFormat::slotFunctionsPointsRaw()
832void DlgSettingsExportFormat::slotHeaderGnuplot()
841void DlgSettingsExportFormat::slotHeaderNone()
850void DlgSettingsExportFormat::slotHeaderSimple()
859void DlgSettingsExportFormat::slotInclude ()
866 for (
i = 0;
i < m_listExcluded->count();
i++) {
867 if (m_listExcluded->item(
i)->isSelected()) {
868 included += m_listExcluded->item(
i)->text();
875 m_listIncluded->addItem (curveName);
880 for (
i = m_listExcluded->count() - 1;
i>= 0;
i--) {
881 QString curveName = m_listExcluded->item(
i)->text();
883 if (
included.contains (curveName)) {
884 m_listExcluded->removeItemWidget (item);
896void DlgSettingsExportFormat::slotListExcluded()
904void DlgSettingsExportFormat::slotListIncluded()
912void DlgSettingsExportFormat::slotLoadDefault()
937 m_editFunctionsPointsEvenlySpacing->setText (QString::number (
modelExportDefaults.pointsIntervalFunctions ()));
938 m_editRelationsPointsEvenlySpacing->setText (QString::number (
modelExportDefaults.pointsIntervalRelations ()));
949 m_chkExtrapolateOutsideEndpoints->setChecked (
modelExportDefaults.extrapolateOutsideEndpoints());
953 m_cmbFunctionsPointsEvenlySpacingUnits->setCurrentIndex (
indexFunctions);
954 m_cmbRelationsPointsEvenlySpacingUnits->setCurrentIndex (
indexRelations);
963void DlgSettingsExportFormat::slotOverrideCsvTsv(
int)
972void DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced()
981void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval(
const QString &)
990void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits(
const QString &)
992 LOG4CPP_INFO_S ((*
mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits";
994 int index = m_cmbRelationsPointsEvenlySpacingUnits->currentIndex();
998 updateIntervalConstraints();
1003void DlgSettingsExportFormat::slotRelationsPointsRaw()
1012void DlgSettingsExportFormat::slotSaveDefault()
1049void DlgSettingsExportFormat::slotTabChanged (
int)
1056void DlgSettingsExportFormat::slotXLabel(
const QString &)
1060 m_modelExportAfter->
setXLabel (m_editXLabel->text());
1065void DlgSettingsExportFormat::updateControls ()
1068 goodIntervalRelations();
1072 m_chkExtrapolateOutsideEndpoints->setEnabled (!m_btnFunctionsPointsRaw->isChecked ());
1076 int inInclude = m_listIncluded->count();
1081 m_editFunctionsPointsEvenlySpacing->setEnabled (m_haveFunction && m_btnFunctionsPointsEvenlySpaced->isChecked ());
1082 m_editRelationsPointsEvenlySpacing->setEnabled (m_haveRelation && m_btnRelationsPointsEvenlySpaced->isChecked ());
1084 m_editXLabel->setEnabled (!m_btnHeaderNone->isChecked());
1087void DlgSettingsExportFormat::updateControlsUponLoad ()
1091 m_haveFunction =
false;
1092 m_haveRelation =
false;
1096 QStringList::const_iterator
itr;
1097 for (
itr = curveNames.begin();
itr != curveNames.end ();
itr++) {
1102 m_haveFunction =
true;
1104 m_haveRelation =
true;
1109 m_btnFunctionsPointsAllCurves->setEnabled (m_haveFunction);
1110 m_btnFunctionsPointsFirstCurve->setEnabled (m_haveFunction);
1111 m_btnFunctionsPointsEvenlySpaced->setEnabled (m_haveFunction);
1112 m_editFunctionsPointsEvenlySpacing->setEnabled (m_haveFunction);
1113 m_cmbFunctionsPointsEvenlySpacingUnits->setEnabled (m_haveFunction);
1114 m_btnFunctionsPointsRaw->setEnabled (m_haveFunction);
1117 m_btnRelationsPointsEvenlySpaced->setEnabled (m_haveRelation);
1118 m_editRelationsPointsEvenlySpacing->setEnabled (m_haveRelation);
1119 m_cmbRelationsPointsEvenlySpacingUnits->setEnabled (m_haveRelation);
1120 m_btnRelationsPointsRaw->setEnabled (m_haveRelation);
1123 if (!m_haveRelation) {
1125 }
else if (!m_haveFunction) {
1130void DlgSettingsExportFormat::updateIntervalConstraints ()
1133 m_minIntervalGraph :
1134 m_minIntervalScreen);
1136 m_minIntervalGraph :
1137 m_minIntervalScreen);
1149 m_editFunctionsPointsEvenlySpacing->setText (QString::number (
functionsMin));
1153 m_validatorFunctionsPointsEvenlySpacing->setBottom (
functionsMin);
1159 m_editRelationsPointsEvenlySpacing->setText (QString::number (
relationsMin));
1163 m_validatorRelationsPointsEvenlySpacing->setBottom (
relationsMin);
1167void DlgSettingsExportFormat::updatePreview()
1170 int scrollPosition = m_editPreview->verticalScrollBar()->value();
1176 if (
mainWindow().transformation().transformIsDefined()) {
1214 exportedHtml =
tr (
"Preview is unavailable until axis points are defined.");
@ CONNECT_AS_FUNCTION_STRAIGHT
@ CONNECT_AS_RELATION_STRAIGHT
@ CONNECT_AS_RELATION_SMOOTH
@ CONNECT_AS_FUNCTION_SMOOTH
const int INNER_RADIUS_MIN
QString exportDelimiterToString(ExportDelimiter exportDelimiter)
ExportDelimiter
Delimiter values that may or may not be overridden by DOCUMENT_SERIALIZE_EXPORT_DELIMITER_OVERRIDE_CS...
@ EXPORT_DELIMITER_SEMICOLON
@ EXPORT_LAYOUT_ALL_PER_LINE
@ EXPORT_LAYOUT_ONE_PER_LINE
QString exportPointsIntervalUnitsToString(ExportPointsIntervalUnits exportPointsIntervalUnits)
ExportPointsIntervalUnits
@ EXPORT_POINTS_INTERVAL_UNITS_GRAPH
@ EXPORT_POINTS_INTERVAL_UNITS_SCREEN
ExportPointsSelectionFunctions
@ EXPORT_POINTS_SELECTION_FUNCTIONS_RAW
@ EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_FIRST_CURVE
@ EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_PERIODIC
@ EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_ALL_CURVES
@ EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_GRID_LINES
ExportPointsSelectionRelations
@ EXPORT_POINTS_SELECTION_RELATIONS_INTERPOLATE
@ EXPORT_POINTS_SELECTION_RELATIONS_RAW
log4cpp::Category * mainCat
const QString SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_RELATIONS
const QString SETTINGS_EXPORT_POINTS_SELECTION_FUNCTIONS
const QString SETTINGS_ENGAUGE
const QString SETTINGS_EXPORT_POINTS_INTERVAL_FUNCTIONS
const QString SETTINGS_EXPORT_X_LABEL
const QString SETTINGS_EXPORT_DELIMITER
const QString SETTINGS_GROUP_EXPORT
const QString SETTINGS_EXPORT_POINTS_INTERVAL_RELATIONS
const QString SETTINGS_EXPORT_LAYOUT_FUNCTIONS
const QString SETTINGS_EXPORT_POINTS_SELECTION_RELATIONS
const QString SETTINGS_EXPORT_EXTRAPOLATE_OUTSIDE_ENDPOINTS
const QString SETTINGS_EXPORT_HEADER
const QString SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_FUNCTIONS
const QString SETTINGS_EXPORT_DELIMITER_OVERRIDE_CSV_TSV
const QString SETTINGS_DIGITIZER
Callback for computing the bounding rectangles of the screen and graph coordinates of the points in t...
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
Container for LineStyle and PointStyle for one Curve.
LineStyle lineStyle() const
Get method for LineStyle.
Model for DlgSettingsCurveProperties and CmdSettingsCurveProperties.
Abstract base class for all Settings dialogs.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
void finishPanel(QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.
void enableOk(bool enable)
Let leaf subclass control the Ok button.
static int MINIMUM_PREVIEW_HEIGHT
Dialog layout constant that guarantees preview has sufficent room.
MainWindow & mainWindow()
Get method for MainWindow.
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
CurveStyles modelCurveStyles() const
Get method for CurveStyles.
Strategy class for exporting to a file. This strategy is external to the Document class so that class...
void exportToFile(const DocumentModelExportFormat &modelExportOverride, const Document &document, const MainWindowModel &modelMainWindow, const Transformation &transformation, QTextStream &str, unsigned int &numWritesSoFar) const
Export Document points according to the settings.
Strategy class for exporting to a file. This strategy is external to the Document class so that class...
void exportToFile(const DocumentModelExportFormat &modelExportOverride, const Document &document, const MainWindowModel &modelMainWindow, const Transformation &transformation, QTextStream &str, unsigned int &numWritesSoFar) const
Export Document points according to the settings.
CurveConnectAs curveConnectAs() const
Get method for connect type.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
#define LOG4CPP_INFO_S(logger)