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
435 QString textFunctions = m_editFunctionsPointsEvenlySpacing->text();
438 bool isGood = (m_validatorFunctionsPointsEvenlySpacing->validate (textFunctions, posFunctions) == QValidator::Acceptable);
440 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::goodIntervalFunctions"
441 <<
" text=" << textFunctions.toLatin1().data()
442 <<
" good=" << (isGood ?
"true" :
"false")
443 <<
" bottom=" << m_validatorFunctionsPointsEvenlySpacing->bottom()
444 <<
" top=" << m_validatorFunctionsPointsEvenlySpacing->top();
449 bool DlgSettingsExportFormat::goodIntervalRelations()
const
453 QString textRelations = m_editRelationsPointsEvenlySpacing->text();
456 bool isGood = (m_validatorRelationsPointsEvenlySpacing->validate (textRelations, posRelations) == QValidator::Acceptable);
458 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::goodIntervalRelations"
459 <<
" text=" << textRelations.toLatin1().data()
460 <<
" good=" << (isGood ?
"true" :
"false")
461 <<
" bottom=" << m_validatorRelationsPointsEvenlySpacing->bottom()
462 <<
" top=" << m_validatorRelationsPointsEvenlySpacing->top();
469 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::handleOk";
473 *m_modelExportBefore,
474 *m_modelExportAfter);
480 void DlgSettingsExportFormat::initializeIntervalConstraints ()
482 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::initializeIntervalConstraints";
484 const int MAX_POINTS_ACROSS_RANGE = 5000;
489 Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
495 double maxSizeGraph = qMax (ftor.boundingRectGraph(isEmpty).width(),
496 ftor.boundingRectGraph(isEmpty).height());
497 double maxSizeScreen = qMax (ftor.boundingRectScreen(isEmpty).width(),
498 ftor.boundingRectScreen(isEmpty).height());
499 m_minIntervalGraph = maxSizeGraph / MAX_POINTS_ACROSS_RANGE;
500 m_minIntervalScreen = maxSizeScreen / MAX_POINTS_ACROSS_RANGE;
505 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::load";
510 if (m_modelExportBefore != 0) {
511 delete m_modelExportBefore;
513 if (m_modelExportAfter != 0) {
514 delete m_modelExportAfter;
522 m_listExcluded->clear();
524 QStringList::const_iterator itr;
525 for (itr = curveNamesExcluded.begin (); itr != curveNamesExcluded.end(); ++itr) {
526 QString curveNameNotExported = *itr;
527 m_listExcluded->addItem (curveNameNotExported);
531 m_listIncluded->clear();
533 for (itr = curveNamesAll.begin (); itr != curveNamesAll.end(); itr++) {
534 QString curveName = *itr;
535 if (!curveNamesExcluded.contains (curveName)) {
536 m_listIncluded->addItem (curveName);
541 m_btnFunctionsPointsAllCurves->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_ALL_CURVES);
542 m_btnFunctionsPointsFirstCurve->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_FIRST_CURVE);
543 m_btnFunctionsPointsEvenlySpaced->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_PERIODIC);
544 m_btnFunctionsPointsRaw->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_RAW);
546 ExportLayoutFunctions layoutFunctions = m_modelExportAfter->
layoutFunctions ();
547 m_btnFunctionsLayoutAllCurves->setChecked (layoutFunctions == EXPORT_LAYOUT_ALL_PER_LINE);
548 m_btnFunctionsLayoutOneCurve->setChecked (layoutFunctions == EXPORT_LAYOUT_ONE_PER_LINE);
551 m_btnRelationsPointsEvenlySpaced->setChecked (pointsSelectionRelations == EXPORT_POINTS_SELECTION_RELATIONS_INTERPOLATE);
552 m_btnRelationsPointsRaw->setChecked (pointsSelectionRelations == EXPORT_POINTS_SELECTION_RELATIONS_RAW);
554 ExportDelimiter delimiter = m_modelExportAfter->
delimiter ();
555 m_btnDelimitersCommas->setChecked (delimiter == EXPORT_DELIMITER_COMMA);
556 m_btnDelimitersSpaces->setChecked (delimiter == EXPORT_DELIMITER_SPACE);
557 m_btnDelimitersTabs->setChecked (delimiter == EXPORT_DELIMITER_TAB);
559 m_chkOverrideCsvTsv->setChecked (m_modelExportAfter->
overrideCsvTsv());
561 ExportHeader header = m_modelExportAfter->
header ();
562 m_btnHeaderNone->setChecked (header == EXPORT_HEADER_NONE);
563 m_btnHeaderSimple->setChecked (header == EXPORT_HEADER_SIMPLE);
564 m_btnHeaderGnuplot->setChecked (header == EXPORT_HEADER_GNUPLOT);
566 m_editXLabel->setText (m_modelExportAfter->
xLabel());
573 int indexFunctions = m_cmbFunctionsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsFunctions));
574 int indexRelations = m_cmbRelationsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsRelations));
575 m_cmbFunctionsPointsEvenlySpacingUnits->setCurrentIndex (indexFunctions);
576 m_cmbRelationsPointsEvenlySpacingUnits->setCurrentIndex (indexRelations);
578 initializeIntervalConstraints ();
581 updateIntervalConstraints();
586 void DlgSettingsExportFormat::slotDelimitersCommas()
588 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersCommas";
590 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_COMMA);
595 void DlgSettingsExportFormat::slotDelimitersSpaces()
597 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersSpaces";
599 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_SPACE);
604 void DlgSettingsExportFormat::slotDelimitersTabs()
606 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersTabs";
613 void DlgSettingsExportFormat::slotExclude ()
615 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotExclude";
619 QStringList excluded;
620 for (i = 0; i < m_listIncluded->count(); i++) {
621 if (m_listIncluded->item(i)->isSelected()) {
622 excluded += m_listIncluded->item(i)->text();
627 for (i = 0; i < excluded.count(); i++) {
628 QString curveName = excluded.at (i);
629 m_listExcluded->addItem (curveName);
633 for (i = m_listIncluded->count() - 1; i>= 0; i--) {
634 QString curveName = m_listIncluded->item(i)->text();
635 if (excluded.contains (curveName)) {
636 QListWidgetItem *item = m_listIncluded->item (i);
637 m_listIncluded->removeItemWidget (item);
647 void DlgSettingsExportFormat::slotFunctionsLayoutAllCurves()
649 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsLayoutAllCurves";
656 void DlgSettingsExportFormat::slotFunctionsLayoutOneCurve()
658 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsLayoutOneCurve";
665 void DlgSettingsExportFormat::slotFunctionsPointsAllCurves()
667 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsAllCurves";
674 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced()
676 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced";
683 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval(
const QString &)
685 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval";
688 if (goodIntervalFunctions()) {
693 m_editPreview->setText(EMPTY_PREVIEW);
697 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits(
const QString &)
699 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits";
701 int index = m_cmbFunctionsPointsEvenlySpacingUnits->currentIndex();
702 ExportPointsIntervalUnits units = (ExportPointsIntervalUnits) m_cmbFunctionsPointsEvenlySpacingUnits->itemData (index).toInt();
705 updateIntervalConstraints();
710 void DlgSettingsExportFormat::slotFunctionsPointsFirstCurve()
712 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsFirstCurve";
719 void DlgSettingsExportFormat::slotFunctionsPointsRaw()
721 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsRaw";
728 void DlgSettingsExportFormat::slotHeaderGnuplot()
730 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderGnuplot";
732 m_modelExportAfter->
setHeader(EXPORT_HEADER_GNUPLOT);
737 void DlgSettingsExportFormat::slotHeaderNone()
739 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderNone";
741 m_modelExportAfter->
setHeader(EXPORT_HEADER_NONE);
746 void DlgSettingsExportFormat::slotHeaderSimple()
748 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderSimple";
750 m_modelExportAfter->
setHeader(EXPORT_HEADER_SIMPLE);
755 void DlgSettingsExportFormat::slotInclude ()
757 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotInclude";
761 QStringList included;
762 for (i = 0; i < m_listExcluded->count(); i++) {
763 if (m_listExcluded->item(i)->isSelected()) {
764 included += m_listExcluded->item(i)->text();
769 for (i = 0; i < included.count(); i++) {
770 QString curveName = included.at (i);
771 m_listIncluded->addItem (curveName);
775 QStringList excluded;
776 for (i = m_listExcluded->count() - 1; i>= 0; i--) {
777 QString curveName = m_listExcluded->item(i)->text();
778 QListWidgetItem *item = m_listExcluded->item (i);
779 if (included.contains (curveName)) {
780 m_listExcluded->removeItemWidget (item);
783 excluded += item->text();
792 void DlgSettingsExportFormat::slotListExcluded()
794 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotListExcluded";
800 void DlgSettingsExportFormat::slotListIncluded()
802 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotListIncluded";
808 void DlgSettingsExportFormat::slotOverrideCsvTsv(
int)
810 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotOverrideCsvTsv";
817 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced()
819 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced";
826 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval(
const QString &)
828 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval";
835 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits(
const QString &)
837 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits";
839 int index = m_cmbRelationsPointsEvenlySpacingUnits->currentIndex();
840 ExportPointsIntervalUnits units = (ExportPointsIntervalUnits) m_cmbRelationsPointsEvenlySpacingUnits->itemData (index).toInt();
843 updateIntervalConstraints();
848 void DlgSettingsExportFormat::slotRelationsPointsRaw()
850 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsRaw";
857 void DlgSettingsExportFormat::slotSaveDefault()
859 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotSaveDefault";
861 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
862 settings.beginGroup (SETTINGS_GROUP_EXPORT);
864 settings.setValue (SETTINGS_EXPORT_DELIMITER,
865 QVariant (m_modelExportAfter->
delimiter()));
866 settings.setValue (SETTINGS_EXPORT_HEADER,
867 QVariant (m_modelExportAfter->
header()));
868 settings.setValue (SETTINGS_EXPORT_LAYOUT_FUNCTIONS,
870 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_FUNCTIONS,
872 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_RELATIONS,
874 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_FUNCTIONS,
876 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_RELATIONS,
878 settings.setValue (SETTINGS_EXPORT_POINTS_SELECTION_FUNCTIONS,
880 settings.setValue (SETTINGS_EXPORT_POINTS_SELECTION_RELATIONS,
882 settings.setValue (SETTINGS_EXPORT_X_LABEL,
883 QVariant (m_modelExportAfter->
xLabel()));
885 settings.endGroup ();
888 void DlgSettingsExportFormat::slotTabChanged (
int)
890 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotTabChanged";
895 void DlgSettingsExportFormat::slotXLabel(
const QString &)
897 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotXLabel";
899 m_modelExportAfter->
setXLabel (m_editXLabel->text());
904 void DlgSettingsExportFormat::updateControls ()
906 bool isGoodState = goodIntervalFunctions() &&
907 goodIntervalRelations();
910 m_listIncluded->sortItems (Qt::AscendingOrder);
911 m_listExcluded->sortItems (Qt::AscendingOrder);
913 int selectedForInclude = m_listExcluded->selectedItems().count();
914 int selectedForExclude = m_listIncluded->selectedItems().count();
915 int inInclude = m_listIncluded->count();
917 m_btnInclude->setEnabled (selectedForInclude > 0);
918 m_btnExclude->setEnabled ((selectedForExclude > 0) && (inInclude - selectedForExclude > 0));
920 m_editFunctionsPointsEvenlySpacing->setEnabled (m_btnFunctionsPointsEvenlySpaced->isChecked ());
921 m_editRelationsPointsEvenlySpacing->setEnabled (m_btnRelationsPointsEvenlySpaced->isChecked ());
923 m_editXLabel->setEnabled (!m_btnHeaderNone->isChecked());
926 void DlgSettingsExportFormat::updateIntervalConstraints ()
930 m_minIntervalScreen);
933 m_minIntervalScreen);
935 if (m_tabWidget->currentIndex() == TAB_WIDGET_INDEX_FUNCTIONS) {
939 m_editFunctionsPointsEvenlySpacing->setText (QString::number (functionsMin));
943 m_validatorFunctionsPointsEvenlySpacing->setBottom (functionsMin);
949 m_editRelationsPointsEvenlySpacing->setText (QString::number (relationsMin));
953 m_validatorRelationsPointsEvenlySpacing->setBottom (relationsMin);
957 void DlgSettingsExportFormat::updatePreview()
960 int scrollPosition = m_editPreview->verticalScrollBar()->value();
962 QString exportedText;
963 QTextStream str (&exportedText);
965 if (
mainWindow().transformation().transformIsDefined()) {
968 if (m_tabWidget->currentIndex() == TAB_WIDGET_INDEX_FUNCTIONS) {
989 str <<
"Preview is unavailable until axis points are defined.";
992 m_editPreview->setText (exportedText);
995 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.