22#include <QDoubleValidator>
30#include <QRadioButton>
59 "DlgSettingsExportFormat",
61 m_validatorFunctionsPointsEvenlySpacing (nullptr),
62 m_validatorRelationsPointsEvenlySpacing (nullptr),
63 m_modelExportBefore (nullptr),
64 m_modelExportAfter (nullptr),
65 m_haveFunction (false),
66 m_haveRelation (false)
79 delete m_validatorFunctionsPointsEvenlySpacing;
80 delete m_validatorRelationsPointsEvenlySpacing;
83void DlgSettingsExportFormat::createCurveSelection (QGridLayout *layout,
int &row)
87 QLabel *labelIncluded =
new QLabel (tr (
"Included"));
88 layout->addWidget (labelIncluded, row, 0);
90 QLabel *labelExcluded =
new QLabel (tr (
"Not included"));
91 layout->addWidget (labelExcluded, row++, 2);
93 m_listIncluded =
new QListWidget;
94 m_listIncluded->setSortingEnabled (
false);
95 m_listIncluded->setWhatsThis (tr (
"List of curves to be included in the exported file.\n\n"
96 "The order of the curves here does not affect the order in the exported file. That "
97 "order is determined by the Curves settings."));
98 m_listIncluded->setSelectionMode (QAbstractItemView::MultiSelection);
99 layout->addWidget (m_listIncluded, row, 0, 4, 1);
100 connect (m_listIncluded, SIGNAL (itemSelectionChanged ()),
this, SLOT (slotListIncluded()));
102 m_listExcluded =
new QListWidget;
103 m_listExcluded->setSortingEnabled (
false);
104 m_listExcluded->setWhatsThis (tr (
"List of curves to be excluded from the exported file"));
105 m_listExcluded->setSelectionMode (QAbstractItemView::MultiSelection);
106 layout->addWidget (m_listExcluded, row++, 2, 4, 1);
107 connect (m_listExcluded, SIGNAL (itemSelectionChanged ()),
this, SLOT (slotListExcluded()));
109 m_btnInclude =
new QPushButton (QString (
"<<%1").arg (tr (
"Include")));
110 m_btnInclude->setEnabled (
false);
111 m_btnInclude->setWhatsThis (tr (
"Move the currently selected curve(s) from the excluded list"));
112 layout->addWidget (m_btnInclude, row++, 1);
113 connect (m_btnInclude, SIGNAL (released ()),
this, SLOT (slotInclude()));
115 m_btnExclude =
new QPushButton (QString (
"%1>>").arg (tr (
"Exclude")));
116 m_btnExclude->setEnabled (
false);
117 m_btnExclude->setWhatsThis (tr (
"Move the currently selected curve(s) from the included list"));
118 layout->addWidget (m_btnExclude, row++, 1);
119 connect (m_btnExclude, SIGNAL (released ()),
this, SLOT (slotExclude()));
124void DlgSettingsExportFormat::createDelimiters (QHBoxLayout *layoutMisc)
128 QGroupBox *groupDelimiters =
new QGroupBox (tr (
"Delimiters"));
129 layoutMisc->addWidget (groupDelimiters, 1);
131 QVBoxLayout *layoutDelimiters =
new QVBoxLayout;
132 groupDelimiters->setLayout (layoutDelimiters);
135 m_btnDelimitersCommas->setWhatsThis (tr (
"Exported file will have commas between adjacent values, unless overridden by tabs in TSV files."));
136 layoutDelimiters->addWidget (m_btnDelimitersCommas);
137 connect (m_btnDelimitersCommas, SIGNAL (released ()),
this, SLOT (slotDelimitersCommas()));
140 m_btnDelimitersSpaces->setWhatsThis (tr (
"Exported file will have spaces between adjacent values, unless overridden by commas in CSV files, "
141 "or tabs in TSV files."));
142 layoutDelimiters->addWidget (m_btnDelimitersSpaces);
143 connect (m_btnDelimitersSpaces, SIGNAL (released ()),
this, SLOT (slotDelimitersSpaces()));
146 m_btnDelimitersTabs->setWhatsThis (tr (
"Exported file will have tabs between adjacent values, unless overridden by commas in CSV files."));
147 layoutDelimiters->addWidget (m_btnDelimitersTabs);
148 connect (m_btnDelimitersTabs, SIGNAL (released ()),
this, SLOT (slotDelimitersTabs()));
151 m_btnDelimitersSemicolons->setWhatsThis (tr (
"Exported file will have semicolons between adjacent values, unless overridden by commas in CSV files."));
152 layoutDelimiters->addWidget (m_btnDelimitersSemicolons);
153 connect (m_btnDelimitersSemicolons, SIGNAL (released ()),
this, SLOT (slotDelimitersSemicolons()));
155 m_chkOverrideCsvTsv =
new QCheckBox (tr (
"Override in CSV/TSV files"));
156 m_chkOverrideCsvTsv->setWhatsThis (tr (
"Comma-separated value (CSV) files and tab-separated value (TSV) files will use commas and tabs "
157 "respectively, unless this setting is selected. Selecting this setting will apply the delimiter setting "
159 connect (m_chkOverrideCsvTsv, SIGNAL (stateChanged (
int)),
this, SLOT (slotOverrideCsvTsv(
int)));
160 layoutDelimiters->addWidget (m_chkOverrideCsvTsv);
163void DlgSettingsExportFormat::createFileLayout (QHBoxLayout *layoutMisc)
167 QGroupBox *groupLayout =
new QGroupBox (tr (
"Layout"));
168 layoutMisc->addWidget (groupLayout, 1);
170 QVBoxLayout *layoutLayout =
new QVBoxLayout;
171 groupLayout->setLayout (layoutLayout);
173 m_btnCurvesLayoutAllCurves =
new QRadioButton (tr (
"All curves on each line"));
174 m_btnCurvesLayoutAllCurves->setWhatsThis (tr (
"Exported file will have, on each line, "
175 "an X value, the Y value for the first curve, the Y value for the second curve,..."));
176 layoutLayout->addWidget (m_btnCurvesLayoutAllCurves);
177 connect (m_btnCurvesLayoutAllCurves, SIGNAL (released()),
this, SLOT (slotFunctionsLayoutAllCurves ()));
179 m_btnCurvesLayoutOneCurve =
new QRadioButton (tr (
"One curve on each line"));
180 m_btnCurvesLayoutOneCurve->setWhatsThis (tr (
"Exported file will have all the points for "
181 "the first curve, with one X-Y pair on each line, then the points for the second curve,..."));
182 layoutLayout->addWidget (m_btnCurvesLayoutOneCurve);
183 connect (m_btnCurvesLayoutOneCurve, SIGNAL (released()),
this, SLOT (slotFunctionsLayoutOneCurve ()));
186void DlgSettingsExportFormat::createFunctionsPointsSelection (QHBoxLayout *layoutFunctions)
190 QGroupBox *groupPointsSelection =
new QGroupBox (tr (
"Function Points Selection"));
191 layoutFunctions->addWidget (groupPointsSelection, 1);
193 QGridLayout *layoutPointsSelections =
new QGridLayout;
194 groupPointsSelection->setLayout (layoutPointsSelections);
197 layoutPointsSelections->setColumnStretch (0, 0);
198 layoutPointsSelections->setColumnStretch (1, 0);
199 layoutPointsSelections->setColumnStretch (2, 0);
200 layoutPointsSelections->setColumnStretch (3, 0);
201 layoutPointsSelections->setColumnStretch (4, 1);
205 m_btnFunctionsPointsAllCurves =
new QRadioButton (tr (
"Interpolate Ys at Xs from all curves"));
206 m_btnFunctionsPointsAllCurves->setWhatsThis (tr (
"Exported file will have values at every unique X "
207 "value from every curve. Y values will be linearly interpolated if necessary"));
208 layoutPointsSelections->addWidget (m_btnFunctionsPointsAllCurves, row, 0, 1, 2);
209 connect (m_btnFunctionsPointsAllCurves, SIGNAL (released()),
this, SLOT (slotFunctionsPointsAllCurves()));
212 m_chkExtrapolateOutsideEndpoints =
new QCheckBox (tr (
"Extrapolate outside endpoints"));
213 m_chkExtrapolateOutsideEndpoints->setWhatsThis (tr (
"Enable or disable extrapolation outside of endpoints of each curve. If disabled, "
214 "only points between the endpoints of each curve are exported"));
215 layoutPointsSelections->addWidget (m_chkExtrapolateOutsideEndpoints, row++, 4, 1, 1, Qt::AlignRight);
216 connect (m_chkExtrapolateOutsideEndpoints, SIGNAL (stateChanged (
int)),
this, SLOT (slotFunctionsExtrapolateOutsideEndpoints(
int)));
218 m_btnFunctionsPointsFirstCurve =
new QRadioButton (tr (
"Interpolate Ys at Xs from first curve"));
219 m_btnFunctionsPointsFirstCurve->setWhatsThis (tr (
"Exported file will have values at every unique X "
220 "value from the first curve. Y values will be linearly interpolated if necessary"));
221 layoutPointsSelections->addWidget (m_btnFunctionsPointsFirstCurve, row++, 0, 1, 4);
222 connect (m_btnFunctionsPointsFirstCurve, SIGNAL (released()),
this, SLOT (slotFunctionsPointsFirstCurve()));
224 m_btnFunctionsPointsEvenlySpaced =
new QRadioButton (tr (
"Interpolate Ys at evenly spaced X values that are automatically selected"));
225 m_btnFunctionsPointsEvenlySpaced->setWhatsThis (tr (
"Exported file will have values at evenly spaced X values, separated by the interval selected below."));
226 layoutPointsSelections->addWidget (m_btnFunctionsPointsEvenlySpaced, row++, 0, 1, 4);
227 connect (m_btnFunctionsPointsEvenlySpaced, SIGNAL (released()),
this, SLOT (slotFunctionsPointsEvenlySpaced()));
229 QLabel *labelInterval =
new QLabel (QString (
"%1:").arg (tr (
"Interval")));
230 layoutPointsSelections->addWidget (labelInterval, row, 1, 1, 1, Qt::AlignRight);
232 m_editFunctionsPointsEvenlySpacing =
new QLineEdit;
233 m_validatorFunctionsPointsEvenlySpacing =
new QDoubleValidator;
234 m_editFunctionsPointsEvenlySpacing->setValidator (m_validatorFunctionsPointsEvenlySpacing);
235 m_editFunctionsPointsEvenlySpacing->setMinimumWidth (
MIN_EDIT_WIDTH);
236 m_editFunctionsPointsEvenlySpacing->setMaximumWidth (
MAX_EDIT_WIDTH);
237 m_editFunctionsPointsEvenlySpacing->setWhatsThis (tr (
"Interval, in the units of X, between successive points in the X direction.\n\n"
238 "If the scale is linear, then this interval is added to successive X values. If the scale is "
239 "logarithmic, then this interval is multiplied to successive X values.\n\n"
240 "The X values will be automatically aligned along simple numbers. If the first and/or last "
241 "points are not along the aligned X values, then one or two additional points are added "
243 layoutPointsSelections->addWidget (m_editFunctionsPointsEvenlySpacing, row, 2, 1, 1, Qt::AlignLeft);
244 connect (m_editFunctionsPointsEvenlySpacing, SIGNAL (textChanged(
const QString &)),
this, SLOT (slotFunctionsPointsEvenlySpacedInterval(
const QString &)));
246 m_cmbFunctionsPointsEvenlySpacingUnits =
new QComboBox;
247 m_cmbFunctionsPointsEvenlySpacingUnits->setWhatsThis (tr (
"Units for spacing interval.\n\n"
248 "Pixel units are preferred when the spacing is to be independent of the X scale. The spacing will be "
249 "consistent across the graph, even if the X scale is logarithmic.\n\n"
250 "Graph units are preferred when the spacing is to depend on the X scale."));
255 connect (m_cmbFunctionsPointsEvenlySpacingUnits, SIGNAL (activated (
const QString &)),
256 this, SLOT (slotFunctionsPointsEvenlySpacedIntervalUnits (
const QString &)));
257 layoutPointsSelections->addWidget (m_cmbFunctionsPointsEvenlySpacingUnits, row, 3, 1, 1, Qt::AlignLeft);
259 m_lblOverflowFunctions =
new QLabel (tr (
"Too many points"));
260 m_lblOverflowFunctions->setStyleSheet (
"QLabel { color : red; }");
261 m_lblOverflowFunctions->setWhatsThis (tr (
"Warning that interval is too small. Adjust interval or increase point limit in Main Window settings"));
262 layoutPointsSelections->addWidget (m_lblOverflowFunctions, row++, 4, 1, 1, Qt::AlignLeft);
264 m_btnFunctionsPointsGridLines =
new QRadioButton (tr (
"Interpolate Ys at evenly spaced X values on grid lines"));
265 m_btnFunctionsPointsGridLines->setWhatsThis (tr (
"Exported file will have values at evenly spaced X values at the vertical grid lines."));
266 layoutPointsSelections->addWidget (m_btnFunctionsPointsGridLines, row++, 0, 1, 4);
267 connect (m_btnFunctionsPointsGridLines, SIGNAL (released()),
this, SLOT (slotFunctionsPointsGridLines()));
269 m_btnFunctionsPointsRaw =
new QRadioButton (tr (
"Raw Xs and Ys"));
270 m_btnFunctionsPointsRaw->setWhatsThis (tr (
"Exported file will have only original X and Y values"));
271 layoutPointsSelections->addWidget (m_btnFunctionsPointsRaw, row++, 0, 1, 4);
272 connect (m_btnFunctionsPointsRaw, SIGNAL (released()),
this, SLOT (slotFunctionsPointsRaw()));
275void DlgSettingsExportFormat::createHeader (QHBoxLayout *layoutMisc)
279 const int COLUMN_RADIO_BUTTONS = 0, COLUMN_EMPTY = 1, COLUMN_LABEL = 2;
281 QGroupBox *groupHeader =
new QGroupBox (tr (
"Header"));
282 layoutMisc->addWidget (groupHeader, 1);
284 QGridLayout *layoutHeader =
new QGridLayout;
285 layoutHeader->setColumnMinimumWidth(COLUMN_EMPTY,
287 groupHeader->setLayout (layoutHeader);
291 m_btnHeaderNone->setWhatsThis (tr (
"Exported file will have no header line"));
292 layoutHeader->addWidget (m_btnHeaderNone, row++, COLUMN_RADIO_BUTTONS, 1, 1);
293 connect (m_btnHeaderNone, SIGNAL (released ()),
this, SLOT (slotHeaderNone()));
296 m_btnHeaderSimple->setWhatsThis (tr (
"Exported file will have simple header line"));
297 layoutHeader->addWidget (m_btnHeaderSimple, row++, COLUMN_RADIO_BUTTONS, 1, 1);
298 connect (m_btnHeaderSimple, SIGNAL (released ()),
this, SLOT (slotHeaderSimple()));
301 m_btnHeaderGnuplot->setWhatsThis (tr (
"Exported file will have gnuplot header line"));
302 layoutHeader->addWidget (m_btnHeaderGnuplot, row++, COLUMN_RADIO_BUTTONS, 1, 1);
303 connect (m_btnHeaderGnuplot, SIGNAL (released()),
this, SLOT (slotHeaderGnuplot()));
305 createXLabel (layoutHeader,
313 m_btnSaveDefault =
new QPushButton (tr (
"Save As Default"));
314 m_btnSaveDefault->setWhatsThis (tr (
"Save the settings for use as future defaults."));
315 connect (m_btnSaveDefault, SIGNAL (released ()),
this, SLOT (slotSaveDefault ()));
316 layout->addWidget (m_btnSaveDefault, 0, Qt::AlignLeft);
318 m_btnLoadDefault =
new QPushButton (tr (
"Load Default"));
319 m_btnLoadDefault->setWhatsThis (tr (
"Load the default settings."));
320 connect (m_btnLoadDefault, SIGNAL (released ()),
this, SLOT (slotLoadDefault ()));
321 layout->addWidget (m_btnLoadDefault, 0, Qt::AlignLeft);
324void DlgSettingsExportFormat::createPreview(QGridLayout *layout,
int &row)
330 m_cmbFileExtension =
new QComboBox;
331 m_cmbFileExtension->setWhatsThis (tr (
"File extension used for preview. The CSV and TSV file extensions "
332 "normally use commas and tabs respectively, but that can be changed "
340 connect (m_cmbFileExtension, SIGNAL (activated (
const QString &)),
341 this, SLOT (slotFileExtension (
const QString &)));
342 layout->addWidget (m_cmbFileExtension, row, 0, 1, 1, Qt::AlignLeft);
345 QLabel *labelLegend =
new QLabel;
346 labelLegend->setTextFormat (Qt::RichText);
347 QString legendHtml = QString (
"<span style=\"background-color: %1\"> Functions </span>"
349 "<span style=\"background-color: %2\"> Relations </span>")
352 labelLegend->setText (legendHtml);
353 layout->addWidget (labelLegend, row++, 2, 1, 1, Qt::AlignRight);
355 m_editPreview =
new QTextEdit;
356 m_editPreview->setReadOnly (
true);
357 m_editPreview->setWhatsThis (tr (
"Preview window shows how current settings affect the exported file.\n\n"
358 "Functions (shown here in blue) are output first, followed by relations "
359 "(shown here in green) if any exist."));
361 m_editPreview->document()->setDefaultStyleSheet(
"div { padding-left: 20px; }");
362 QPalette p = m_editPreview->palette();
363 p.setColor (QPalette::Base, QColor (240, 240, 240));
364 m_editPreview->setPalette (p);
366 layout->addWidget (m_editPreview, row++, 0, 1, 3);
369void DlgSettingsExportFormat::createRelationsPointsSelection (QHBoxLayout *layoutRelations)
373 QGroupBox *groupPointsSelection =
new QGroupBox (tr (
"Relation Points Selection"));
374 layoutRelations->addWidget (groupPointsSelection);
376 QGridLayout *layoutPointsSelections =
new QGridLayout;
377 groupPointsSelection->setLayout (layoutPointsSelections);
380 layoutPointsSelections->setColumnStretch (0, 0);
381 layoutPointsSelections->setColumnStretch (1, 0);
382 layoutPointsSelections->setColumnStretch (2, 0);
383 layoutPointsSelections->setColumnStretch (3, 0);
384 layoutPointsSelections->setColumnStretch (4, 1);
388 m_btnRelationsPointsEvenlySpaced =
new QRadioButton (tr (
"Interpolate Xs and Ys at evenly spaced intervals."));
389 m_btnRelationsPointsEvenlySpaced->setWhatsThis (tr (
"Exported file will have points evenly spaced along each relation, separated by the interval "
390 "selected below. If the last interval does not end at the last point, then a shorter last interval "
391 "is added that ends on the last point."));
392 layoutPointsSelections->addWidget (m_btnRelationsPointsEvenlySpaced, row++, 0, 1, 4);
393 connect (m_btnRelationsPointsEvenlySpaced, SIGNAL (released()),
this, SLOT (slotRelationsPointsEvenlySpaced()));
395 QLabel *labelInterval =
new QLabel (QString (
"%1:").arg (tr (
"Interval")));
396 layoutPointsSelections->addWidget (labelInterval, row, 1, 1, 1, Qt::AlignRight);
398 m_editRelationsPointsEvenlySpacing =
new QLineEdit;
399 m_validatorRelationsPointsEvenlySpacing =
new QDoubleValidator;
400 m_editRelationsPointsEvenlySpacing->setValidator (m_validatorRelationsPointsEvenlySpacing);
401 m_editRelationsPointsEvenlySpacing->setMinimumWidth (
MIN_EDIT_WIDTH);
402 m_editRelationsPointsEvenlySpacing->setMaximumWidth (
MAX_EDIT_WIDTH);
403 m_editRelationsPointsEvenlySpacing->setWhatsThis (tr (
"Interval between successive points when "
404 "exporting at evenly spaced (X,Y) coordinates."));
405 layoutPointsSelections->addWidget (m_editRelationsPointsEvenlySpacing, row, 2, 1, 1, Qt::AlignLeft);
406 connect (m_editRelationsPointsEvenlySpacing, SIGNAL (textChanged(
const QString &)),
this, SLOT (slotRelationsPointsEvenlySpacedInterval(
const QString &)));
408 m_cmbRelationsPointsEvenlySpacingUnits =
new QComboBox;
409 m_cmbRelationsPointsEvenlySpacingUnits->setWhatsThis (tr (
"Units for spacing interval.\n\n"
410 "Pixel units are preferred when the spacing is to be independent of the X and Y scales. The spacing will be "
411 "consistent across the graph, even if a scale is logarithmic or the X and Y scales are different.\n\n"
412 "Graph units are usually preferred when the X and Y scales are identical."));
417 connect (m_cmbRelationsPointsEvenlySpacingUnits, SIGNAL (activated (
const QString &)),
418 this, SLOT (slotRelationsPointsEvenlySpacedIntervalUnits (
const QString &)));
419 layoutPointsSelections->addWidget (m_cmbRelationsPointsEvenlySpacingUnits, row, 3, 1, 1, Qt::AlignLeft);
421 m_lblOverflowRelations =
new QLabel (tr (
"Too many points"));
422 m_lblOverflowRelations->setStyleSheet (
"QLabel { color : red; }");
423 m_lblOverflowRelations->setWhatsThis (tr (
"Warning that interval is too small. Adjust interval or increase point limit in Main Window settings"));
424 layoutPointsSelections->addWidget (m_lblOverflowRelations, row++, 4, 1, 1, Qt::AlignLeft);
426 m_btnRelationsPointsRaw =
new QRadioButton (tr (
"Raw Xs and Ys"));
427 m_btnRelationsPointsRaw->setWhatsThis (tr (
"Exported file will have only original X and Y values"));
428 layoutPointsSelections->addWidget (m_btnRelationsPointsRaw, row++, 0, 1, 4);
429 connect (m_btnRelationsPointsRaw, SIGNAL (released()),
this, SLOT (slotRelationsPointsRaw()));
436 QWidget *subPanel =
new QWidget ();
437 QGridLayout *layout =
new QGridLayout (subPanel);
438 subPanel->setLayout (layout);
441 createCurveSelection (layout, row);
443 createTabWidget (layout,
446 QWidget *widgetMisc =
new QWidget;
447 layout->addWidget (widgetMisc, row++, 0, 1, 3);
448 QHBoxLayout *layoutMisc =
new QHBoxLayout;
449 widgetMisc->setLayout (layoutMisc);
451 createDelimiters (layoutMisc);
452 createHeader (layoutMisc);
453 createFileLayout (layoutMisc);
455 createPreview (layout, row);
460void DlgSettingsExportFormat::createTabWidget (QGridLayout *layout,
465 m_tabWidget =
new QTabWidget;
467 layout->addWidget (m_tabWidget, row++, 0, 1, 3);
469 QWidget *widgetFunctions =
new QWidget;
470 int indexFunctions = m_tabWidget->addTab (widgetFunctions, tr (
"Functions"));
471 QWidget *tabFunctions = m_tabWidget->widget (indexFunctions);
472 tabFunctions->setWhatsThis (tr (
"Functions Tab\n\n"
473 "Controls for specifying the format of functions during export"));
474 QHBoxLayout *layoutFunctions =
new QHBoxLayout;
475 widgetFunctions->setLayout (layoutFunctions);
477 QWidget *widgetRelations =
new QWidget;
478 int indexRelations = m_tabWidget->addTab (widgetRelations, tr (
"Relations"));
479 QWidget *tabRelations = m_tabWidget->widget (indexRelations);
480 tabRelations->setWhatsThis (tr (
"Relations Tab\n\n"
481 "Controls for specifying the format of relations during export"));
482 QHBoxLayout *layoutRelations =
new QHBoxLayout;
483 widgetRelations->setLayout (layoutRelations);
486 connect (m_tabWidget, SIGNAL (currentChanged (
int)),
this, SLOT (slotTabChanged (
int)));
488 createFunctionsPointsSelection (layoutFunctions);
489 createRelationsPointsSelection (layoutRelations);
492void DlgSettingsExportFormat::createXLabel (QGridLayout *layoutHeader,
499 QLabel *title =
new QLabel (QString (
"%1:").arg (tr (
"X Label")));
500 layoutHeader->addWidget (title, row++, colLabel, 1, 1);
502 m_editXLabel =
new QLineEdit;
503 m_editXLabel->setWhatsThis (tr (
"Label in the header for x values"));
504 layoutHeader->addWidget (m_editXLabel, row++, colLabel, 1, 1);
505 connect (m_editXLabel, SIGNAL (textChanged (
const QString &)),
this, SLOT (slotXLabel(
const QString &)));
508QString DlgSettingsExportFormat::exportedTextToExportedHtml (
const QString &text,
509 const QString &color)
const
511 QRegExp re (
"<br>$");
513 QString textCopy (text);
514 QString replaced = textCopy
515 .replace (
"\n",
"<br>")
516 .replace (
" ",
" ")
518 .replace (
"\t",
" ");
520 QString html = QString (
"<div style=\"display: inline; background-color: %1\">%2</div>")
527bool DlgSettingsExportFormat::goodIntervalFunctions()
const
531 QString textFunctions = m_editFunctionsPointsEvenlySpacing->text();
534 bool isGood = (m_validatorFunctionsPointsEvenlySpacing->validate (textFunctions, posFunctions) == QValidator::Acceptable);
537 <<
" text=" << textFunctions.toLatin1().data()
538 <<
" good=" << (isGood ?
"true" :
"false")
539 <<
" bottom=" << m_validatorFunctionsPointsEvenlySpacing->bottom()
540 <<
" top=" << m_validatorFunctionsPointsEvenlySpacing->top();
545bool DlgSettingsExportFormat::goodIntervalRelations()
const
549 QString textRelations = m_editRelationsPointsEvenlySpacing->text();
552 bool isGood = (m_validatorRelationsPointsEvenlySpacing->validate (textRelations, posRelations) == QValidator::Acceptable);
555 <<
" text=" << textRelations.toLatin1().data()
556 <<
" good=" << (isGood ?
"true" :
"false")
557 <<
" bottom=" << m_validatorRelationsPointsEvenlySpacing->bottom()
558 <<
" top=" << m_validatorRelationsPointsEvenlySpacing->top();
569 *m_modelExportBefore,
570 *m_modelExportAfter);
576void DlgSettingsExportFormat::initializeIntervalConstraints ()
586 Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
592 QPointF boundingRectGraphMin = ftor.boundingRectGraphMin (isEmpty);
593 QPointF boundingRectGraphMax = ftor.boundingRectGraphMax (isEmpty);
594 double maxSizeGraph = boundingRectGraphMax.x() - boundingRectGraphMin.x();
595 double maxSizeScreen = ftor.boundingRectScreen(isEmpty).width();
596 m_minIntervalGraph = maxSizeGraph / maxPointsAcrossRange;
597 m_minIntervalScreen = maxSizeScreen / maxPointsAcrossRange;
607 delete m_modelExportBefore;
608 delete m_modelExportAfter;
615 m_listExcluded->clear();
616 QStringList curveNamesExcluded = m_modelExportAfter->curveNamesNotExported();
617 QStringList::const_iterator itr;
618 for (itr = curveNamesExcluded.begin (); itr != curveNamesExcluded.end(); ++itr) {
619 QString curveNameNotExported = *itr;
620 m_listExcluded->addItem (curveNameNotExported);
624 m_listIncluded->clear();
625 QStringList curveNamesAll =
cmdMediator.document().curvesGraphsNames();
626 for (itr = curveNamesAll.begin (); itr != curveNamesAll.end(); itr++) {
627 QString curveName = *itr;
628 if (!curveNamesExcluded.contains (curveName)) {
629 m_listIncluded->addItem (curveName);
654 m_chkExtrapolateOutsideEndpoints->setChecked (m_modelExportAfter->extrapolateOutsideEndpoints ());
656 m_chkOverrideCsvTsv->setChecked (m_modelExportAfter->overrideCsvTsv());
663 m_editXLabel->setText (m_modelExportAfter->xLabel());
665 m_editFunctionsPointsEvenlySpacing->setText (QString::number (m_modelExportAfter->pointsIntervalFunctions()));
666 m_editRelationsPointsEvenlySpacing->setText (QString::number (m_modelExportAfter->pointsIntervalRelations()));
670 int indexFunctions = m_cmbFunctionsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsFunctions));
671 int indexRelations = m_cmbRelationsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsRelations));
672 m_cmbFunctionsPointsEvenlySpacingUnits->setCurrentIndex (indexFunctions);
673 m_cmbRelationsPointsEvenlySpacingUnits->setCurrentIndex (indexRelations);
677 initializeIntervalConstraints ();
679 updateControlsUponLoad ();
681 updateIntervalConstraints();
693void DlgSettingsExportFormat::slotDelimitersCommas()
702void DlgSettingsExportFormat::slotDelimitersSemicolons()
711void DlgSettingsExportFormat::slotDelimitersSpaces()
720void DlgSettingsExportFormat::slotDelimitersTabs()
729void DlgSettingsExportFormat::slotExclude ()
735 QStringList excluded;
736 for (i = 0; i < m_listIncluded->count(); i++) {
737 if (m_listIncluded->item(i)->isSelected()) {
738 excluded += m_listIncluded->item(i)->text();
743 for (i = 0; i < excluded.count(); i++) {
744 QString curveName = excluded.at (i);
745 m_listExcluded->addItem (curveName);
749 for (i = m_listIncluded->count() - 1; i>= 0; i--) {
750 QString curveName = m_listIncluded->item(i)->text();
751 if (excluded.contains (curveName)) {
752 QListWidgetItem *item = m_listIncluded->item (i);
753 m_listIncluded->removeItemWidget (item);
758 m_modelExportAfter->setCurveNamesNotExported(excluded);
763void DlgSettingsExportFormat::slotFileExtension (
const QString &)
768void DlgSettingsExportFormat::slotFunctionsExtrapolateOutsideEndpoints(
int)
772 m_modelExportAfter->setExtrapolateOutsideEndpoints (m_chkExtrapolateOutsideEndpoints->isChecked());
777void DlgSettingsExportFormat::slotFunctionsLayoutAllCurves()
786void DlgSettingsExportFormat::slotFunctionsLayoutOneCurve()
795void DlgSettingsExportFormat::slotFunctionsPointsAllCurves()
804void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced()
813void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval(
const QString &)
817 if (m_editFunctionsPointsEvenlySpacing->text().trimmed() ==
"") {
819 m_lblOverflowFunctions->hide ();
823 if (goodIntervalFunctions()) {
824 m_lblOverflowFunctions->hide ();
825 m_modelExportAfter->setPointsIntervalFunctions(m_editFunctionsPointsEvenlySpacing->text().toDouble());
829 m_lblOverflowFunctions->show ();
835void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits(
const QString &)
837 LOG4CPP_INFO_S ((*
mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits";
839 int index = m_cmbFunctionsPointsEvenlySpacingUnits->currentIndex();
843 if (goodIntervalFunctions()) {
844 m_lblOverflowFunctions->hide ();
845 m_modelExportAfter->setPointsIntervalUnitsFunctions(units);
846 updateIntervalConstraints();
850 m_lblOverflowFunctions->show ();
855void DlgSettingsExportFormat::slotFunctionsPointsFirstCurve()
864void DlgSettingsExportFormat::slotFunctionsPointsGridLines()
873void DlgSettingsExportFormat::slotFunctionsPointsRaw()
882void DlgSettingsExportFormat::slotHeaderGnuplot()
891void DlgSettingsExportFormat::slotHeaderNone()
900void DlgSettingsExportFormat::slotHeaderSimple()
909void DlgSettingsExportFormat::slotInclude ()
915 QStringList included;
916 for (i = 0; i < m_listExcluded->count(); i++) {
917 if (m_listExcluded->item(i)->isSelected()) {
918 included += m_listExcluded->item(i)->text();
923 for (i = 0; i < included.count(); i++) {
924 QString curveName = included.at (i);
925 m_listIncluded->addItem (curveName);
929 QStringList excluded;
930 for (i = m_listExcluded->count() - 1; i>= 0; i--) {
931 QString curveName = m_listExcluded->item(i)->text();
932 QListWidgetItem *item = m_listExcluded->item (i);
933 if (included.contains (curveName)) {
934 m_listExcluded->removeItemWidget (item);
937 excluded += item->text();
941 m_modelExportAfter->setCurveNamesNotExported(excluded);
946void DlgSettingsExportFormat::slotListExcluded()
954void DlgSettingsExportFormat::slotListIncluded()
962void DlgSettingsExportFormat::slotLoadDefault()
967 DocumentModelExportFormat modelExportDefaults;
975 m_editXLabel->setText (modelExportDefaults.
xLabel());
982 m_chkOverrideCsvTsv->setChecked (modelExportDefaults.
overrideCsvTsv());
987 m_editFunctionsPointsEvenlySpacing->setText (QString::number (modelExportDefaults.
pointsIntervalFunctions ()));
988 m_editRelationsPointsEvenlySpacing->setText (QString::number (modelExportDefaults.
pointsIntervalRelations ()));
1001 int indexFunctions = m_cmbFunctionsPointsEvenlySpacingUnits->findData (QVariant (modelExportDefaults.
pointsIntervalUnitsFunctions ()));
1002 int indexRelations = m_cmbRelationsPointsEvenlySpacingUnits->findData (QVariant (modelExportDefaults.
pointsIntervalUnitsRelations ()));
1003 m_cmbFunctionsPointsEvenlySpacingUnits->setCurrentIndex (indexFunctions);
1004 m_cmbRelationsPointsEvenlySpacingUnits->setCurrentIndex (indexRelations);
1007 *m_modelExportAfter = modelExportDefaults;
1013void DlgSettingsExportFormat::slotOverrideCsvTsv(
int)
1017 m_modelExportAfter->setOverrideCsvTsv(m_chkOverrideCsvTsv->isChecked());
1022void DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced()
1031void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval(
const QString &)
1035 if (m_editRelationsPointsEvenlySpacing->text().trimmed() ==
"") {
1037 m_lblOverflowRelations->hide ();
1040 if (goodIntervalRelations()) {
1041 m_lblOverflowRelations->hide ();
1042 m_modelExportAfter->setPointsIntervalRelations(m_editRelationsPointsEvenlySpacing->text().toDouble());
1046 m_lblOverflowRelations->show ();
1052void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits(
const QString &)
1054 LOG4CPP_INFO_S ((*
mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits";
1056 int index = m_cmbRelationsPointsEvenlySpacingUnits->currentIndex();
1059 if (goodIntervalRelations()) {
1060 m_lblOverflowRelations->hide ();
1061 m_modelExportAfter->setPointsIntervalUnitsRelations(units);
1062 updateIntervalConstraints();
1066 m_lblOverflowRelations->show ();
1071void DlgSettingsExportFormat::slotRelationsPointsRaw()
1080void DlgSettingsExportFormat::slotSaveDefault()
1090 QVariant (m_modelExportAfter->delimiter()));
1092 QVariant (m_modelExportAfter->overrideCsvTsv()));
1094 QVariant (m_modelExportAfter->extrapolateOutsideEndpoints()));
1096 QVariant (m_modelExportAfter->header()));
1098 QVariant (m_modelExportAfter->layoutFunctions()));
1100 QVariant (m_modelExportAfter->pointsIntervalFunctions()));
1102 QVariant (m_modelExportAfter->pointsIntervalRelations()));
1104 QVariant (m_modelExportAfter->pointsIntervalUnitsFunctions()));
1106 QVariant (m_modelExportAfter->pointsIntervalUnitsRelations()));
1108 QVariant (m_modelExportAfter->pointsSelectionFunctions()));
1110 QVariant (m_modelExportAfter->pointsSelectionRelations()));
1112 QVariant (m_modelExportAfter->xLabel()));
1114 settings.endGroup ();
1117void DlgSettingsExportFormat::slotTabChanged (
int)
1124void DlgSettingsExportFormat::slotXLabel(
const QString &)
1128 m_modelExportAfter->setXLabel (m_editXLabel->text());
1133void DlgSettingsExportFormat::updateControls ()
1135 bool isGoodState = goodIntervalFunctions() &&
1136 goodIntervalRelations();
1140 m_chkExtrapolateOutsideEndpoints->setEnabled (!m_btnFunctionsPointsRaw->isChecked ());
1142 int selectedForInclude = m_listExcluded->selectedItems().count();
1143 int selectedForExclude = m_listIncluded->selectedItems().count();
1144 int inInclude = m_listIncluded->count();
1146 m_btnInclude->setEnabled (selectedForInclude > 0);
1147 m_btnExclude->setEnabled ((selectedForExclude > 0) && (inInclude - selectedForExclude > 0));
1149 m_editFunctionsPointsEvenlySpacing->setEnabled (m_haveFunction && m_btnFunctionsPointsEvenlySpaced->isChecked ());
1150 m_editRelationsPointsEvenlySpacing->setEnabled (m_haveRelation && m_btnRelationsPointsEvenlySpaced->isChecked ());
1152 m_editXLabel->setEnabled (!m_btnHeaderNone->isChecked());
1155void DlgSettingsExportFormat::updateControlsUponLoad ()
1159 m_haveFunction =
false;
1160 m_haveRelation =
false;
1162 QStringList curveNames = curveStyles.
curveNames();
1164 QStringList::const_iterator itr;
1165 for (itr = curveNames.begin(); itr != curveNames.end (); itr++) {
1166 QString curveName = *itr;
1167 CurveStyle curveStyle = curveStyles.
curveStyle (curveName);
1170 m_haveFunction =
true;
1172 m_haveRelation =
true;
1177 m_btnFunctionsPointsAllCurves->setEnabled (m_haveFunction);
1178 m_btnFunctionsPointsFirstCurve->setEnabled (m_haveFunction);
1179 m_btnFunctionsPointsEvenlySpaced->setEnabled (m_haveFunction);
1180 m_editFunctionsPointsEvenlySpacing->setEnabled (m_haveFunction);
1181 m_cmbFunctionsPointsEvenlySpacingUnits->setEnabled (m_haveFunction);
1182 m_btnFunctionsPointsRaw->setEnabled (m_haveFunction);
1185 m_btnRelationsPointsEvenlySpaced->setEnabled (m_haveRelation);
1186 m_editRelationsPointsEvenlySpacing->setEnabled (m_haveRelation);
1187 m_cmbRelationsPointsEvenlySpacingUnits->setEnabled (m_haveRelation);
1188 m_btnRelationsPointsRaw->setEnabled (m_haveRelation);
1191 if (!m_haveRelation) {
1193 }
else if (!m_haveFunction) {
1198void DlgSettingsExportFormat::updateIntervalConstraints ()
1201 m_minIntervalGraph :
1202 m_minIntervalScreen);
1204 m_minIntervalGraph :
1205 m_minIntervalScreen);
1210 functionsMin = qMax (1.00000001, functionsMin);
1215 if (m_modelExportAfter->pointsIntervalFunctions() < functionsMin) {
1217 m_editFunctionsPointsEvenlySpacing->setText (QString::number (functionsMin));
1221 m_validatorFunctionsPointsEvenlySpacing->setBottom (functionsMin);
1225 if (m_modelExportAfter->pointsIntervalRelations() < relationsMin) {
1227 m_editRelationsPointsEvenlySpacing->setText (QString::number (relationsMin));
1231 m_validatorRelationsPointsEvenlySpacing->setBottom (relationsMin);
1235void DlgSettingsExportFormat::updatePreview()
1238 int scrollPosition = m_editPreview->verticalScrollBar()->value();
1240 QString exportedTextFunctions, exportedTextRelations, exportedHtml;
1241 QTextStream strFunctions (&exportedTextFunctions);
1242 QTextStream strRelations (&exportedTextRelations);
1244 if (
mainWindow().transformation().transformIsDefined()) {
1246 unsigned int numWritesSoFar = 0;
1252 ExportFileExtensionOverride extensionOverride;
1253 ExportToFile exportToFile;
1254 DocumentModelExportFormat modelAfterWithFileExtension = extensionOverride.
modelExportOverride(*m_modelExportAfter,
1258 ExportFileFunctions exportStrategyFunctions;
1259 exportStrategyFunctions.
exportToFile (modelAfterWithFileExtension,
1266 ExportFileRelations exportStrategyRelations;
1267 exportStrategyRelations.
exportToFile (modelAfterWithFileExtension,
1278 QString exportedHtmlFunctions, exportedHtmlRelations;
1279 if (! exportedTextFunctions.isEmpty ()) {
1281 exportedHtmlFunctions = exportedTextToExportedHtml (exportedTextFunctions,
COLOR_FUNCTIONS);
1283 if (! exportedTextRelations.isEmpty ()) {
1285 exportedHtmlRelations = exportedTextToExportedHtml (exportedTextRelations,
COLOR_RELATIONS);
1288 exportedHtml = exportedHtmlFunctions + exportedHtmlRelations;
1292 exportedHtml = tr (
"Preview is unavailable until axis points are defined.");
1295 m_editPreview->setHtml (exportedHtml);
1298 m_editPreview->verticalScrollBar()->setValue (scrollPosition);
@ CONNECT_AS_FUNCTION_STRAIGHT
@ CONNECT_AS_RELATION_STRAIGHT
@ CONNECT_AS_RELATION_SMOOTH
@ CONNECT_AS_FUNCTION_SMOOTH
QString exportDelimiterToString(ExportDelimiter exportDelimiter)
ExportDelimiter
Delimiter values that may or may not be overridden by DOCUMENT_SERIALIZE_EXPORT_DELIMITER_OVERRIDE_CS...
@ EXPORT_DELIMITER_SEMICOLON
QString exportFileExtensionToFilename(ExportFileExtension exportFileExtension)
Internally-used sample file name for each ExportFileExtension value.
QString exportFileExtensionToPreviewString(ExportFileExtension exportFileExtension)
Displayed text for each ExportFileExtension value.
@ EXPORT_FILE_EXTENSION_NOT_CSV_TSV
@ EXPORT_FILE_EXTENSION_CSV
@ EXPORT_FILE_EXTENSION_TSV
@ 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.
LineStyle lineStyle() const
Get method for LineStyle.
CurveStyle curveStyle(const QString &curveName) const
CurveStyle in specified curve.
QStringList curveNames() const
List of all curve names.
DlgSettingsAbstractBase(const QString &title, const QString &dialogName, MainWindow &mainWindow)
Single constructor.
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.
CurveStyles modelCurveStyles() const
Get method for CurveStyles.
DocumentModelExportFormat modelExportOverride(const DocumentModelExportFormat &modelExportFormatBefore, const ExportToFile &exportStrategy, const QString &selectedNameFilter) const
Adjust export settings given filename extension.
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.
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.
int maximumExportedPointsPerCurve() const
Get method for maximum number of exported points per curve.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
MainWindowModel modelMainWindow() const
Get method for main window model.
#define LOG4CPP_INFO_S(logger)