7 #include "CallbackBoundingRects.h"
8 #include "CmdMediator.h"
9 #include "CmdSettingsExportFormat.h"
10 #include "DocumentModelExportFormat.h"
11 #include "DlgSettingsExportFormat.h"
12 #include "ExportFileFunctions.h"
13 #include "ExportFileRelations.h"
15 #include "MainWindow.h"
16 #include "MainWindowModel.h"
19 #include <QDoubleValidator>
20 #include <QGridLayout>
22 #include <QHBoxLayout>
25 #include <QListWidget>
26 #include <QPushButton>
27 #include <QRadioButton>
32 #include <QTextStream>
33 #include <QVBoxLayout>
35 #include "Transformation.h"
37 const int MIN_INDENT_COLUMN_WIDTH = 20;
38 const int MIN_HEADER_EMPTY_COLUMN_WIDTH = 10;
39 const int MIN_EDIT_WIDTH = 110;
40 const int MAX_EDIT_WIDTH = 180;
42 const int TAB_WIDGET_INDEX_FUNCTIONS = 0;
45 const QString EMPTY_PREVIEW;
49 "DlgSettingsExportFormat",
51 m_modelExportBefore (0),
52 m_modelExportAfter (0)
54 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::DlgSettingsExportFormat";
60 DlgSettingsExportFormat::~DlgSettingsExportFormat()
62 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::~DlgSettingsExportFormat";
65 void DlgSettingsExportFormat::createCurveSelection (QGridLayout *layout,
int &row)
67 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createCurveSelection";
69 QLabel *labelIncluded =
new QLabel (tr (
"Included"));
70 layout->addWidget (labelIncluded, row, 0);
72 QLabel *labelExcluded =
new QLabel (tr (
"Not included"));
73 layout->addWidget (labelExcluded, row++, 2);
75 m_listIncluded =
new QListWidget;
76 m_listIncluded->setWhatsThis (tr (
"List of curves to be included in the exported file.\n\n"
77 "The order of the curves here does not affect the order in the exported file. That "
78 "order is determined by the Curves settings."));
79 m_listIncluded->setSelectionMode (QAbstractItemView::MultiSelection);
80 layout->addWidget (m_listIncluded, row, 0, 4, 1);
81 connect (m_listIncluded, SIGNAL (itemSelectionChanged ()),
this, SLOT (slotListIncluded()));
83 m_listExcluded =
new QListWidget;
84 m_listExcluded->setWhatsThis (tr (
"List of curves to be excluded from the exported file"));
85 m_listExcluded->setSelectionMode (QAbstractItemView::MultiSelection);
86 layout->addWidget (m_listExcluded, row++, 2, 4, 1);
87 connect (m_listExcluded, SIGNAL (itemSelectionChanged ()),
this, SLOT (slotListExcluded()));
89 m_btnInclude =
new QPushButton (tr (
"<<Include"));
90 m_btnInclude->setEnabled (
false);
91 m_btnInclude->setWhatsThis (tr (
"Move the currently selected curve(s) from the excluded list"));
92 layout->addWidget (m_btnInclude, row++, 1);
93 connect (m_btnInclude, SIGNAL (released ()),
this, SLOT (slotInclude()));
95 m_btnExclude =
new QPushButton (tr (
"Exclude>>"));
96 m_btnExclude->setEnabled (
false);
97 m_btnExclude->setWhatsThis (tr (
"Move the currently selected curve(s) from the included list"));
98 layout->addWidget (m_btnExclude, row++, 1);
99 connect (m_btnExclude, SIGNAL (released ()),
this, SLOT (slotExclude()));
104 void DlgSettingsExportFormat::createDelimiters (QHBoxLayout *layoutMisc)
106 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createDelimiters";
108 QGroupBox *groupDelimiters =
new QGroupBox (tr (
"Delimiters"));
109 layoutMisc->addWidget (groupDelimiters, 1);
111 QVBoxLayout *layoutDelimiters =
new QVBoxLayout;
112 groupDelimiters->setLayout (layoutDelimiters);
114 m_btnDelimitersCommas =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_COMMA));
115 m_btnDelimitersCommas->setWhatsThis (tr (
"Exported file will have commas between adjacent values, unless overridden by tabs in TSV files."));
116 layoutDelimiters->addWidget (m_btnDelimitersCommas);
117 connect (m_btnDelimitersCommas, SIGNAL (released ()),
this, SLOT (slotDelimitersCommas()));
119 m_btnDelimitersSpaces =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_SPACE));
120 m_btnDelimitersSpaces->setWhatsThis (tr (
"Exported file will have spaces between adjacent values, unless overridden by commas in CSV files, "
121 "or tabs in TSV files."));
122 layoutDelimiters->addWidget (m_btnDelimitersSpaces);
123 connect (m_btnDelimitersSpaces, SIGNAL (released ()),
this, SLOT (slotDelimitersSpaces()));
125 m_btnDelimitersTabs =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_TAB));
126 m_btnDelimitersTabs->setWhatsThis (tr (
"Exported file will have tabs between adjacent values, unless overridden by commas in CSV files."));
127 layoutDelimiters->addWidget (m_btnDelimitersTabs);
128 connect (m_btnDelimitersTabs, SIGNAL (released ()),
this, SLOT (slotDelimitersTabs()));
130 m_chkOverrideCsvTsv =
new QCheckBox (tr (
"Override in CSV/TSV files"));
131 m_chkOverrideCsvTsv->setWhatsThis (tr (
"Comma-separated value (CSV) files and tab-separated value (TSV) files will use commas and tabs "
132 "respectively, unless this setting is selected. Selecting this setting will apply the delimiter setting "
134 connect (m_chkOverrideCsvTsv, SIGNAL (stateChanged (
int)),
this, SLOT (slotOverrideCsvTsv(
int)));
135 layoutDelimiters->addWidget (m_chkOverrideCsvTsv);
138 void DlgSettingsExportFormat::createFileLayout (QHBoxLayout *layoutMisc)
140 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createFileLayout";
142 QGroupBox *groupLayout =
new QGroupBox (tr (
"Layout"));
143 layoutMisc->addWidget (groupLayout, 1);
145 QVBoxLayout *layoutLayout =
new QVBoxLayout;
146 groupLayout->setLayout (layoutLayout);
148 m_btnFunctionsLayoutAllCurves =
new QRadioButton (tr (
"All curves on each line"));
149 m_btnFunctionsLayoutAllCurves->setWhatsThis (tr (
"Exported file will have, on each line, "
150 "an X value, the Y value for the first curve, the Y value for the second curve,..."));
151 layoutLayout->addWidget (m_btnFunctionsLayoutAllCurves);
152 connect (m_btnFunctionsLayoutAllCurves, SIGNAL (released()),
this, SLOT (slotFunctionsLayoutAllCurves ()));
154 m_btnFunctionsLayoutOneCurve =
new QRadioButton (tr (
"One curve on each line"));
155 m_btnFunctionsLayoutOneCurve->setWhatsThis (tr (
"Exported file will have all the points for "
156 "the first curve, with one X-Y pair on each line, then the points for the second curve,..."));
157 layoutLayout->addWidget (m_btnFunctionsLayoutOneCurve);
158 connect (m_btnFunctionsLayoutOneCurve, SIGNAL (released()),
this, SLOT (slotFunctionsLayoutOneCurve ()));
161 void DlgSettingsExportFormat::createFunctionsPointsSelection (QHBoxLayout *layoutFunctions)
163 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createFunctionsPointsSelection";
165 QGroupBox *groupPointsSelection =
new QGroupBox (tr (
"Points Selection"));
166 layoutFunctions->addWidget (groupPointsSelection, 1);
168 QGridLayout *layoutPointsSelections =
new QGridLayout;
169 groupPointsSelection->setLayout (layoutPointsSelections);
171 layoutPointsSelections->setColumnMinimumWidth(0, MIN_INDENT_COLUMN_WIDTH);
172 layoutPointsSelections->setColumnStretch (0, 0);
173 layoutPointsSelections->setColumnStretch (1, 0);
174 layoutPointsSelections->setColumnStretch (2, 0);
175 layoutPointsSelections->setColumnStretch (3, 1);
178 m_btnFunctionsPointsAllCurves =
new QRadioButton (tr (
"Interpolate Ys at Xs from all curves"));
179 m_btnFunctionsPointsAllCurves->setWhatsThis (tr (
"Exported file will have values at every unique X "
180 "value from every curve. Y values will be linearly interpolated if necessary"));
181 layoutPointsSelections->addWidget (m_btnFunctionsPointsAllCurves, row++, 0, 1, 4);
182 connect (m_btnFunctionsPointsAllCurves, SIGNAL (released()),
this, SLOT (slotFunctionsPointsAllCurves()));
184 m_btnFunctionsPointsFirstCurve =
new QRadioButton (tr (
"Interpolate Ys at Xs from first curve"));
185 m_btnFunctionsPointsFirstCurve->setWhatsThis (tr (
"Exported file will have values at every unique X "
186 "value from the first curve. Y values will be linearly interpolated if necessary"));
187 layoutPointsSelections->addWidget (m_btnFunctionsPointsFirstCurve, row++, 0, 1, 4);
188 connect (m_btnFunctionsPointsFirstCurve, SIGNAL (released()),
this, SLOT (slotFunctionsPointsFirstCurve()));
190 m_btnFunctionsPointsEvenlySpaced =
new QRadioButton (tr (
"Interpolate Ys at evenly spaced X values."));
191 m_btnFunctionsPointsEvenlySpaced->setWhatsThis (tr (
"Exported file will have values at evenly spaced X values, separated by the interval selected below."));
192 layoutPointsSelections->addWidget (m_btnFunctionsPointsEvenlySpaced, row++, 0, 1, 4);
193 connect (m_btnFunctionsPointsEvenlySpaced, SIGNAL (released()),
this, SLOT (slotFunctionsPointsEvenlySpaced()));
195 QLabel *labelInterval =
new QLabel (tr (
"Interval:"));
196 layoutPointsSelections->addWidget (labelInterval, row, 1, 1, 1, Qt::AlignRight);
198 m_editFunctionsPointsEvenlySpacing =
new QLineEdit;
199 m_validatorFunctionsPointsEvenlySpacing =
new QDoubleValidator;
200 m_editFunctionsPointsEvenlySpacing->setValidator (m_validatorFunctionsPointsEvenlySpacing);
201 m_editFunctionsPointsEvenlySpacing->setMinimumWidth (MIN_EDIT_WIDTH);
202 m_editFunctionsPointsEvenlySpacing->setMaximumWidth (MAX_EDIT_WIDTH);
203 m_editFunctionsPointsEvenlySpacing->setWhatsThis (tr (
"Interval, in the units of X, between successive points in the X direction.\n\n"
204 "If the scale is linear, then this interval is added to successive X values. If the scale is "
205 "logarithmic, then this interval is multiplied to successive X values.\n\n"
206 "The X values will be automatically aligned along simple numbers. If the first and/or last "
207 "points are not along the aligned X values, then one or two additional points are added "
209 layoutPointsSelections->addWidget (m_editFunctionsPointsEvenlySpacing, row, 2, 1, 1, Qt::AlignLeft);
210 connect (m_editFunctionsPointsEvenlySpacing, SIGNAL (textChanged(
const QString &)),
this, SLOT (slotFunctionsPointsEvenlySpacedInterval(
const QString &)));
212 m_cmbFunctionsPointsEvenlySpacingUnits =
new QComboBox;
213 m_cmbFunctionsPointsEvenlySpacingUnits->setWhatsThis (tr (
"Units for spacing interval.\n\n"
214 "Pixel units are preferred when the spacing is to be independent of the X scale. The spacing will be "
215 "consistent across the graph, even if the X scale is logarithmic.\n\n"
216 "Graph units are preferred when the spacing is to depend on the X scale."));
217 m_cmbFunctionsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_GRAPH),
218 QVariant (EXPORT_POINTS_INTERVAL_UNITS_GRAPH));
219 m_cmbFunctionsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_SCREEN),
220 QVariant (EXPORT_POINTS_INTERVAL_UNITS_SCREEN));
221 connect (m_cmbFunctionsPointsEvenlySpacingUnits, SIGNAL (activated (
const QString &)),
222 this, SLOT (slotFunctionsPointsEvenlySpacedIntervalUnits (
const QString &)));
223 layoutPointsSelections->addWidget (m_cmbFunctionsPointsEvenlySpacingUnits, row++, 3, 1, 1, Qt::AlignLeft);
225 m_btnFunctionsPointsRaw =
new QRadioButton (tr (
"Raw Xs and Ys"));
226 m_btnFunctionsPointsRaw->setWhatsThis (tr (
"Exported file will have only original X and Y values"));
227 layoutPointsSelections->addWidget (m_btnFunctionsPointsRaw, row++, 0, 1, 4);
228 connect (m_btnFunctionsPointsRaw, SIGNAL (released()),
this, SLOT (slotFunctionsPointsRaw()));
231 void DlgSettingsExportFormat::createHeader (QHBoxLayout *layoutMisc)
233 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createHeader";
235 const int COLUMN_RADIO_BUTTONS = 0, COLUMN_EMPTY = 1, COLUMN_LABEL = 2;
237 QGroupBox *groupHeader =
new QGroupBox (tr (
"Header"));
238 layoutMisc->addWidget (groupHeader, 1);
240 QGridLayout *layoutHeader =
new QGridLayout;
241 layoutHeader->setColumnMinimumWidth(COLUMN_EMPTY,
242 MIN_HEADER_EMPTY_COLUMN_WIDTH);
243 groupHeader->setLayout (layoutHeader);
246 m_btnHeaderNone =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_NONE));
247 m_btnHeaderNone->setWhatsThis (tr (
"Exported file will have no header line"));
248 layoutHeader->addWidget (m_btnHeaderNone, row++, COLUMN_RADIO_BUTTONS, 1, 1);
249 connect (m_btnHeaderNone, SIGNAL (released ()),
this, SLOT (slotHeaderNone()));
251 m_btnHeaderSimple =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_SIMPLE));
252 m_btnHeaderSimple->setWhatsThis (tr (
"Exported file will have simple header line"));
253 layoutHeader->addWidget (m_btnHeaderSimple, row++, COLUMN_RADIO_BUTTONS, 1, 1);
254 connect (m_btnHeaderSimple, SIGNAL (released ()),
this, SLOT (slotHeaderSimple()));
256 m_btnHeaderGnuplot =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_GNUPLOT));
257 m_btnHeaderGnuplot->setWhatsThis (tr (
"Exported file will have gnuplot header line"));
258 layoutHeader->addWidget (m_btnHeaderGnuplot, row++, COLUMN_RADIO_BUTTONS, 1, 1);
259 connect (m_btnHeaderGnuplot, SIGNAL (released()),
this, SLOT (slotHeaderGnuplot()));
261 createXLabel (layoutHeader,
267 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createOptionalSaveDefault";
269 m_btnSaveDefault =
new QPushButton (tr (
"Save As Default"));
270 m_btnSaveDefault->setWhatsThis (tr (
"Save the settings for use as future defaults."));
271 connect (m_btnSaveDefault, SIGNAL (released ()),
this, SLOT (slotSaveDefault ()));
272 layout->addWidget (m_btnSaveDefault, 0, Qt::AlignLeft);
275 void DlgSettingsExportFormat::createPreview(QGridLayout *layout,
int &row)
277 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createPreview";
279 QLabel *label =
new QLabel (tr (
"Preview"));
280 layout->addWidget (label, row++, 0, 1, 3);
282 m_editPreview =
new QTextEdit;
283 m_editPreview->setReadOnly (
true);
284 m_editPreview->setWhatsThis (tr (
"Preview window shows how current settings affect the exported file"));
287 layout->addWidget (m_editPreview, row++, 0, 1, 3);
290 void DlgSettingsExportFormat::createRelationsPointsSelection (QHBoxLayout *layoutRelations)
292 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createRelationsPointsSelection";
294 QGroupBox *groupPointsSelection =
new QGroupBox (tr (
"Points Selection"));
295 layoutRelations->addWidget (groupPointsSelection);
297 QGridLayout *layoutPointsSelections =
new QGridLayout;
298 groupPointsSelection->setLayout (layoutPointsSelections);
300 layoutPointsSelections->setColumnMinimumWidth(0, MIN_INDENT_COLUMN_WIDTH);
301 layoutPointsSelections->setColumnStretch (0, 0);
302 layoutPointsSelections->setColumnStretch (1, 0);
303 layoutPointsSelections->setColumnStretch (2, 0);
304 layoutPointsSelections->setColumnStretch (3, 1);
307 m_btnRelationsPointsEvenlySpaced =
new QRadioButton (tr (
"Interpolate Xs and Ys at evenly spaced intervals."));
308 m_btnRelationsPointsEvenlySpaced->setWhatsThis (tr (
"Exported file will have points evenly spaced along each relation, separated by the interval "
309 "selected below. If the last interval does not end at the last point, then a shorter last interval "
310 "is added that ends on the last point."));
311 layoutPointsSelections->addWidget (m_btnRelationsPointsEvenlySpaced, row++, 0, 1, 4);
312 connect (m_btnRelationsPointsEvenlySpaced, SIGNAL (released()),
this, SLOT (slotRelationsPointsEvenlySpaced()));
314 QLabel *labelInterval =
new QLabel (tr (
"Interval:"));
315 layoutPointsSelections->addWidget (labelInterval, row, 1, 1, 1, Qt::AlignRight);
317 m_editRelationsPointsEvenlySpacing =
new QLineEdit;
318 m_validatorRelationsPointsEvenlySpacing =
new QDoubleValidator;
319 m_editRelationsPointsEvenlySpacing->setValidator (m_validatorRelationsPointsEvenlySpacing);
320 m_editRelationsPointsEvenlySpacing->setMinimumWidth (MIN_EDIT_WIDTH);
321 m_editRelationsPointsEvenlySpacing->setMaximumWidth (MAX_EDIT_WIDTH);
322 m_editRelationsPointsEvenlySpacing->setWhatsThis (tr (
"Interval between successive points when "
323 "exporting at evenly spaced (X,Y) coordinates."));
324 layoutPointsSelections->addWidget (m_editRelationsPointsEvenlySpacing, row, 2, 1, 1, Qt::AlignLeft);
325 connect (m_editRelationsPointsEvenlySpacing, SIGNAL (textChanged(
const QString &)),
this, SLOT (slotRelationsPointsEvenlySpacedInterval(
const QString &)));
327 m_cmbRelationsPointsEvenlySpacingUnits =
new QComboBox;
328 m_cmbRelationsPointsEvenlySpacingUnits->setWhatsThis (tr (
"Units for spacing interval.\n\n"
329 "Pixel units are preferred when the spacing is to be independent of the X and Y scales. The spacing will be "
330 "consistent across the graph, even if a scale is logarithmic or the X and Y scales are different.\n\n"
331 "Graph units are usually preferred when the X and Y scales are identical."));
332 m_cmbRelationsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_GRAPH),
333 QVariant (EXPORT_POINTS_INTERVAL_UNITS_GRAPH));
334 m_cmbRelationsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_SCREEN),
335 QVariant (EXPORT_POINTS_INTERVAL_UNITS_SCREEN));
336 connect (m_cmbRelationsPointsEvenlySpacingUnits, SIGNAL (activated (
const QString &)),
337 this, SLOT (slotRelationsPointsEvenlySpacedIntervalUnits (
const QString &)));
338 layoutPointsSelections->addWidget (m_cmbRelationsPointsEvenlySpacingUnits, row++, 3, 1, 1, Qt::AlignLeft);
340 m_btnRelationsPointsRaw =
new QRadioButton (tr (
"Raw Xs and Ys"));
341 m_btnRelationsPointsRaw->setWhatsThis (tr (
"Exported file will have only original X and Y values"));
342 layoutPointsSelections->addWidget (m_btnRelationsPointsRaw, row++, 0, 1, 4);
343 connect (m_btnRelationsPointsRaw, SIGNAL (released()),
this, SLOT (slotRelationsPointsRaw()));
348 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createSubPanel";
350 QWidget *subPanel =
new QWidget ();
351 QGridLayout *layout =
new QGridLayout (subPanel);
352 subPanel->setLayout (layout);
355 createCurveSelection (layout, row);
357 createTabWidget (layout,
360 QWidget *widgetMisc =
new QWidget;
361 layout->addWidget (widgetMisc, row++, 0, 1, 3);
362 QHBoxLayout *layoutMisc =
new QHBoxLayout;
363 widgetMisc->setLayout (layoutMisc);
365 createDelimiters (layoutMisc);
366 createHeader (layoutMisc);
367 createFileLayout (layoutMisc);
369 createPreview (layout, row);
374 void DlgSettingsExportFormat::createTabWidget (QGridLayout *layout,
377 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createTabWidget";
379 m_tabWidget =
new QTabWidget;
381 layout->addWidget (m_tabWidget, row++, 0, 1, 3);
383 QWidget *widgetFunctions =
new QWidget;
384 int indexFunctions = m_tabWidget->addTab (widgetFunctions, tr (
"Functions"));
385 QWidget *tabFunctions = m_tabWidget->widget (indexFunctions);
386 tabFunctions->setWhatsThis (tr (
"Functions Tab\n\n"
387 "Controls for specifying the format of functions during export"));
388 QHBoxLayout *layoutFunctions =
new QHBoxLayout;
389 widgetFunctions->setLayout (layoutFunctions);
391 QWidget *widgetRelations =
new QWidget;
392 int indexRelations = m_tabWidget->addTab (widgetRelations, tr (
"Relations"));
393 QWidget *tabRelations = m_tabWidget->widget (indexRelations);
394 tabRelations->setWhatsThis (tr (
"Relations Tab\n\n"
395 "Controls for specifying the format of relations during export"));
396 QHBoxLayout *layoutRelations =
new QHBoxLayout;
397 widgetRelations->setLayout (layoutRelations);
400 connect (m_tabWidget, SIGNAL (currentChanged (
int)),
this, SLOT (slotTabChanged (
int)));
402 createFunctionsPointsSelection (layoutFunctions);
403 createRelationsPointsSelection (layoutRelations);
406 void DlgSettingsExportFormat::createXLabel (QGridLayout *layoutHeader,
409 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createXLabel";
415 title =
new QLabel (tr (
"X Label:"));
417 title =
new QLabel (tr (
"Theta Label:"));
419 layoutHeader->addWidget (title, row++, colLabel, 1, 1);
421 m_editXLabel =
new QLineEdit;
423 m_editXLabel->setWhatsThis (tr (
"Label in the header for x values"));
425 m_editXLabel->setWhatsThis (tr (
"Label in the header for theta values"));
427 layoutHeader->addWidget (m_editXLabel, row++, colLabel, 1, 1);
428 connect (m_editXLabel, SIGNAL (textChanged (
const QString &)),
this, SLOT (slotXLabel(
const QString &)));
431 bool DlgSettingsExportFormat::goodIntervalFunctions()
const
433 QString textFunctions = m_editFunctionsPointsEvenlySpacing->text();
436 bool isGood = (m_validatorFunctionsPointsEvenlySpacing->validate (textFunctions, posFunctions) == QValidator::Acceptable);
441 bool DlgSettingsExportFormat::goodIntervalRelations()
const
443 QString textRelations = m_editRelationsPointsEvenlySpacing->text();
446 return (m_validatorRelationsPointsEvenlySpacing->validate (textRelations, posRelations) == QValidator::Acceptable);
451 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::handleOk";
455 *m_modelExportBefore,
456 *m_modelExportAfter);
462 void DlgSettingsExportFormat::initializeIntervalConstraints ()
464 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::initializeIntervalConstraints";
466 const int MAX_POINTS_ACROSS_RANGE = 1000;
471 Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
477 double maxSizeGraph = qMax (ftor.boundingRectGraph(isEmpty).width(),
478 ftor.boundingRectGraph(isEmpty).height());
479 double maxSizeScreen = qMax (ftor.boundingRectScreen(isEmpty).width(),
480 ftor.boundingRectScreen(isEmpty).height());
481 m_minIntervalGraph = maxSizeGraph / MAX_POINTS_ACROSS_RANGE;
482 m_minIntervalScreen = maxSizeScreen / MAX_POINTS_ACROSS_RANGE;
487 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::load";
492 if (m_modelExportBefore != 0) {
493 delete m_modelExportBefore;
495 if (m_modelExportAfter != 0) {
496 delete m_modelExportAfter;
504 m_listExcluded->clear();
506 QStringList::const_iterator itr;
507 for (itr = curveNamesExcluded.begin (); itr != curveNamesExcluded.end(); ++itr) {
508 QString curveNameNotExported = *itr;
509 m_listExcluded->addItem (curveNameNotExported);
513 m_listIncluded->clear();
515 for (itr = curveNamesAll.begin (); itr != curveNamesAll.end(); itr++) {
516 QString curveName = *itr;
517 if (!curveNamesExcluded.contains (curveName)) {
518 m_listIncluded->addItem (curveName);
523 m_btnFunctionsPointsAllCurves->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_ALL_CURVES);
524 m_btnFunctionsPointsFirstCurve->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_FIRST_CURVE);
525 m_btnFunctionsPointsEvenlySpaced->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_PERIODIC);
526 m_btnFunctionsPointsRaw->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_RAW);
528 ExportLayoutFunctions layoutFunctions = m_modelExportAfter->
layoutFunctions ();
529 m_btnFunctionsLayoutAllCurves->setChecked (layoutFunctions == EXPORT_LAYOUT_ALL_PER_LINE);
530 m_btnFunctionsLayoutOneCurve->setChecked (layoutFunctions == EXPORT_LAYOUT_ONE_PER_LINE);
533 m_btnRelationsPointsEvenlySpaced->setChecked (pointsSelectionRelations == EXPORT_POINTS_SELECTION_RELATIONS_INTERPOLATE);
534 m_btnRelationsPointsRaw->setChecked (pointsSelectionRelations == EXPORT_POINTS_SELECTION_RELATIONS_RAW);
536 ExportDelimiter delimiter = m_modelExportAfter->
delimiter ();
537 m_btnDelimitersCommas->setChecked (delimiter == EXPORT_DELIMITER_COMMA);
538 m_btnDelimitersSpaces->setChecked (delimiter == EXPORT_DELIMITER_SPACE);
539 m_btnDelimitersTabs->setChecked (delimiter == EXPORT_DELIMITER_TAB);
541 m_chkOverrideCsvTsv->setChecked (m_modelExportAfter->
overrideCsvTsv());
543 ExportHeader header = m_modelExportAfter->
header ();
544 m_btnHeaderNone->setChecked (header == EXPORT_HEADER_NONE);
545 m_btnHeaderSimple->setChecked (header == EXPORT_HEADER_SIMPLE);
546 m_btnHeaderGnuplot->setChecked (header == EXPORT_HEADER_GNUPLOT);
548 m_editXLabel->setText (m_modelExportAfter->
xLabel());
554 int indexFunctions = m_cmbRelationsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsFunctions));
555 int indexRelations = m_cmbRelationsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsRelations));
556 m_cmbFunctionsPointsEvenlySpacingUnits->setCurrentIndex (indexFunctions);
557 m_cmbRelationsPointsEvenlySpacingUnits->setCurrentIndex (indexRelations);
559 initializeIntervalConstraints ();
562 updateIntervalConstraints();
567 void DlgSettingsExportFormat::slotDelimitersCommas()
569 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersCommas";
571 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_COMMA);
576 void DlgSettingsExportFormat::slotDelimitersSpaces()
578 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersSpaces";
580 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_SPACE);
585 void DlgSettingsExportFormat::slotDelimitersTabs()
587 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersTabs";
594 void DlgSettingsExportFormat::slotExclude ()
596 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotExclude";
600 QStringList excluded;
601 for (i = 0; i < m_listIncluded->count(); i++) {
602 if (m_listIncluded->item(i)->isSelected()) {
603 excluded += m_listIncluded->item(i)->text();
608 for (i = 0; i < excluded.count(); i++) {
609 QString curveName = excluded.at (i);
610 m_listExcluded->addItem (curveName);
614 for (i = m_listIncluded->count() - 1; i>= 0; i--) {
615 QString curveName = m_listIncluded->item(i)->text();
616 if (excluded.contains (curveName)) {
617 QListWidgetItem *item = m_listIncluded->item (i);
618 m_listIncluded->removeItemWidget (item);
628 void DlgSettingsExportFormat::slotFunctionsLayoutAllCurves()
630 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsLayoutAllCurves";
637 void DlgSettingsExportFormat::slotFunctionsLayoutOneCurve()
639 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsLayoutOneCurve";
646 void DlgSettingsExportFormat::slotFunctionsPointsAllCurves()
648 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsAllCurves";
655 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced()
657 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced";
664 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval(
const QString &)
666 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval";
669 if (goodIntervalFunctions()) {
674 m_editPreview->setText(EMPTY_PREVIEW);
678 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits(
const QString &)
680 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits";
682 int index = m_cmbFunctionsPointsEvenlySpacingUnits->currentIndex();
683 ExportPointsIntervalUnits units = (ExportPointsIntervalUnits) m_cmbFunctionsPointsEvenlySpacingUnits->itemData (index).toInt();
686 updateIntervalConstraints();
691 void DlgSettingsExportFormat::slotFunctionsPointsFirstCurve()
693 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsFirstCurve";
700 void DlgSettingsExportFormat::slotFunctionsPointsRaw()
702 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsRaw";
709 void DlgSettingsExportFormat::slotHeaderGnuplot()
711 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderGnuplot";
713 m_modelExportAfter->
setHeader(EXPORT_HEADER_GNUPLOT);
718 void DlgSettingsExportFormat::slotHeaderNone()
720 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderNone";
722 m_modelExportAfter->
setHeader(EXPORT_HEADER_NONE);
727 void DlgSettingsExportFormat::slotHeaderSimple()
729 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderSimple";
731 m_modelExportAfter->
setHeader(EXPORT_HEADER_SIMPLE);
736 void DlgSettingsExportFormat::slotInclude ()
738 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotInclude";
742 QStringList included;
743 for (i = 0; i < m_listExcluded->count(); i++) {
744 if (m_listExcluded->item(i)->isSelected()) {
745 included += m_listExcluded->item(i)->text();
750 for (i = 0; i < included.count(); i++) {
751 QString curveName = included.at (i);
752 m_listIncluded->addItem (curveName);
756 QStringList excluded;
757 for (i = m_listExcluded->count() - 1; i>= 0; i--) {
758 QString curveName = m_listExcluded->item(i)->text();
759 QListWidgetItem *item = m_listExcluded->item (i);
760 if (included.contains (curveName)) {
761 m_listExcluded->removeItemWidget (item);
764 excluded += item->text();
773 void DlgSettingsExportFormat::slotListExcluded()
775 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotListExcluded";
781 void DlgSettingsExportFormat::slotListIncluded()
783 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotListIncluded";
789 void DlgSettingsExportFormat::slotOverrideCsvTsv(
int)
791 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotOverrideCsvTsv";
798 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced()
800 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced";
807 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval(
const QString &)
809 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval";
816 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits(
const QString &)
818 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits";
820 int index = m_cmbRelationsPointsEvenlySpacingUnits->currentIndex();
821 ExportPointsIntervalUnits units = (ExportPointsIntervalUnits) m_cmbRelationsPointsEvenlySpacingUnits->itemData (index).toInt();
824 updateIntervalConstraints();
829 void DlgSettingsExportFormat::slotRelationsPointsRaw()
831 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsRaw";
838 void DlgSettingsExportFormat::slotSaveDefault()
840 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotSaveDefault";
842 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
843 settings.beginGroup (SETTINGS_GROUP_EXPORT);
845 settings.setValue (SETTINGS_EXPORT_DELIMITER,
846 QVariant (m_modelExportAfter->
delimiter()));
847 settings.setValue (SETTINGS_EXPORT_HEADER,
848 QVariant (m_modelExportAfter->
header()));
849 settings.setValue (SETTINGS_EXPORT_LAYOUT_FUNCTIONS,
851 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_FUNCTIONS,
853 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_RELATIONS,
855 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_FUNCTIONS,
857 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_RELATIONS,
859 settings.setValue (SETTINGS_EXPORT_POINTS_SELECTION_FUNCTIONS,
861 settings.setValue (SETTINGS_EXPORT_POINTS_SELECTION_RELATIONS,
863 settings.setValue (SETTINGS_EXPORT_X_LABEL,
864 QVariant (m_modelExportAfter->
xLabel()));
866 settings.endGroup ();
869 void DlgSettingsExportFormat::slotTabChanged (
int)
871 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotTabChanged";
876 void DlgSettingsExportFormat::slotXLabel(
const QString &)
878 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotXLabel";
880 m_modelExportAfter->
setXLabel (m_editXLabel->text());
885 void DlgSettingsExportFormat::updateControls ()
887 bool isGoodState = goodIntervalFunctions() &&
888 goodIntervalRelations();
891 m_listIncluded->sortItems (Qt::AscendingOrder);
892 m_listExcluded->sortItems (Qt::AscendingOrder);
894 int selectedForInclude = m_listExcluded->selectedItems().count();
895 int selectedForExclude = m_listIncluded->selectedItems().count();
896 int inInclude = m_listIncluded->count();
898 m_btnInclude->setEnabled (selectedForInclude > 0);
899 m_btnExclude->setEnabled ((selectedForExclude > 0) && (inInclude - selectedForExclude > 0));
901 m_editFunctionsPointsEvenlySpacing->setEnabled (m_btnFunctionsPointsEvenlySpaced->isChecked ());
902 m_editRelationsPointsEvenlySpacing->setEnabled (m_btnRelationsPointsEvenlySpaced->isChecked ());
904 m_editXLabel->setEnabled (!m_btnHeaderNone->isChecked());
907 void DlgSettingsExportFormat::updateIntervalConstraints ()
911 m_minIntervalScreen);
914 m_minIntervalScreen);
916 if (m_tabWidget->currentIndex() == TAB_WIDGET_INDEX_FUNCTIONS) {
920 m_editFunctionsPointsEvenlySpacing->setText (QString::number (functionsMin));
924 m_validatorFunctionsPointsEvenlySpacing->setBottom (functionsMin);
930 m_editRelationsPointsEvenlySpacing->setText (QString::number (relationsMin));
931 m_validatorFunctionsPointsEvenlySpacing->setBottom (relationsMin);
935 m_validatorRelationsPointsEvenlySpacing->setBottom (relationsMin);
939 void DlgSettingsExportFormat::updatePreview()
942 int scrollPosition = m_editPreview->verticalScrollBar()->value();
944 QString exportedText;
945 QTextStream str (&exportedText);
947 if (
mainWindow().transformation().transformIsDefined()) {
950 if (m_tabWidget->currentIndex() == TAB_WIDGET_INDEX_FUNCTIONS) {
971 str <<
"Preview is unavailable until axis points are defined.";
974 m_editPreview->setText (exportedText);
977 m_editPreview->verticalScrollBar()->setValue (scrollPosition);
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
void exportToFile(const DocumentModelExportFormat &modelExportOverride, const Document &document, const MainWindowModel &modelMainWindow, const Transformation &transformation, QTextStream &str) const
Export Document points according to the settings.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
Strategy class for exporting to a file. This strategy is external to the Document class so that class...
QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
void finishPanel(QWidget *subPanel)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
static int MINIMUM_PREVIEW_HEIGHT
Dialog layout constant that guarantees preview has sufficent room.
void enableOk(bool enable)
Let leaf subclass control the Ok button.
Strategy class for exporting to a file. This strategy is external to the Document class so that class...
Abstract base class for all Settings dialogs.
Callback for computing the bounding rectangles of the screen and graph coordinates of the points in t...
MainWindow & mainWindow()
Get method for MainWindow.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.
void exportToFile(const DocumentModelExportFormat &modelExportOverride, const Document &document, const MainWindowModel &modelMainWindow, const Transformation &transformation, QTextStream &str) const
Export Document points according to the settings.