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;
47 const int MINIMUM_DIALOG_WIDTH_EXPORT_FORMAT = 650;
51 "DlgSettingsExportFormat",
53 m_modelExportBefore (0),
54 m_modelExportAfter (0)
56 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::DlgSettingsExportFormat";
60 MINIMUM_DIALOG_WIDTH_EXPORT_FORMAT);
63 DlgSettingsExportFormat::~DlgSettingsExportFormat()
65 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::~DlgSettingsExportFormat";
68 void DlgSettingsExportFormat::createCurveSelection (QGridLayout *layout,
int &row)
70 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createCurveSelection";
72 QLabel *labelIncluded =
new QLabel (tr (
"Included"));
73 layout->addWidget (labelIncluded, row, 0);
75 QLabel *labelExcluded =
new QLabel (tr (
"Not included"));
76 layout->addWidget (labelExcluded, row++, 2);
78 m_listIncluded =
new QListWidget;
79 m_listIncluded->setSortingEnabled (
false);
80 m_listIncluded->setWhatsThis (tr (
"List of curves to be included in the exported file.\n\n"
81 "The order of the curves here does not affect the order in the exported file. That "
82 "order is determined by the Curves settings."));
83 m_listIncluded->setSelectionMode (QAbstractItemView::MultiSelection);
84 layout->addWidget (m_listIncluded, row, 0, 4, 1);
85 connect (m_listIncluded, SIGNAL (itemSelectionChanged ()),
this, SLOT (slotListIncluded()));
87 m_listExcluded =
new QListWidget;
88 m_listExcluded->setSortingEnabled (
false);
89 m_listExcluded->setWhatsThis (tr (
"List of curves to be excluded from the exported file"));
90 m_listExcluded->setSelectionMode (QAbstractItemView::MultiSelection);
91 layout->addWidget (m_listExcluded, row++, 2, 4, 1);
92 connect (m_listExcluded, SIGNAL (itemSelectionChanged ()),
this, SLOT (slotListExcluded()));
94 m_btnInclude =
new QPushButton (tr (
"<<Include"));
95 m_btnInclude->setEnabled (
false);
96 m_btnInclude->setWhatsThis (tr (
"Move the currently selected curve(s) from the excluded list"));
97 layout->addWidget (m_btnInclude, row++, 1);
98 connect (m_btnInclude, SIGNAL (released ()),
this, SLOT (slotInclude()));
100 m_btnExclude =
new QPushButton (tr (
"Exclude>>"));
101 m_btnExclude->setEnabled (
false);
102 m_btnExclude->setWhatsThis (tr (
"Move the currently selected curve(s) from the included list"));
103 layout->addWidget (m_btnExclude, row++, 1);
104 connect (m_btnExclude, SIGNAL (released ()),
this, SLOT (slotExclude()));
109 void DlgSettingsExportFormat::createDelimiters (QHBoxLayout *layoutMisc)
111 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createDelimiters";
113 QGroupBox *groupDelimiters =
new QGroupBox (tr (
"Delimiters"));
114 layoutMisc->addWidget (groupDelimiters, 1);
116 QVBoxLayout *layoutDelimiters =
new QVBoxLayout;
117 groupDelimiters->setLayout (layoutDelimiters);
119 m_btnDelimitersCommas =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_COMMA));
120 m_btnDelimitersCommas->setWhatsThis (tr (
"Exported file will have commas between adjacent values, unless overridden by tabs in TSV files."));
121 layoutDelimiters->addWidget (m_btnDelimitersCommas);
122 connect (m_btnDelimitersCommas, SIGNAL (released ()),
this, SLOT (slotDelimitersCommas()));
124 m_btnDelimitersSpaces =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_SPACE));
125 m_btnDelimitersSpaces->setWhatsThis (tr (
"Exported file will have spaces between adjacent values, unless overridden by commas in CSV files, "
126 "or tabs in TSV files."));
127 layoutDelimiters->addWidget (m_btnDelimitersSpaces);
128 connect (m_btnDelimitersSpaces, SIGNAL (released ()),
this, SLOT (slotDelimitersSpaces()));
130 m_btnDelimitersTabs =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_TAB));
131 m_btnDelimitersTabs->setWhatsThis (tr (
"Exported file will have tabs between adjacent values, unless overridden by commas in CSV files."));
132 layoutDelimiters->addWidget (m_btnDelimitersTabs);
133 connect (m_btnDelimitersTabs, SIGNAL (released ()),
this, SLOT (slotDelimitersTabs()));
135 m_btnDelimitersSemicolons =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_SEMICOLON));
136 m_btnDelimitersSemicolons->setWhatsThis (tr (
"Exported file will have semicolons between adjacent values, unless overridden by commas in CSV files."));
137 layoutDelimiters->addWidget (m_btnDelimitersSemicolons);
138 connect (m_btnDelimitersSemicolons, SIGNAL (released ()),
this, SLOT (slotDelimitersSemicolons()));
140 m_chkOverrideCsvTsv =
new QCheckBox (tr (
"Override in CSV/TSV files"));
141 m_chkOverrideCsvTsv->setWhatsThis (tr (
"Comma-separated value (CSV) files and tab-separated value (TSV) files will use commas and tabs "
142 "respectively, unless this setting is selected. Selecting this setting will apply the delimiter setting "
144 connect (m_chkOverrideCsvTsv, SIGNAL (stateChanged (
int)),
this, SLOT (slotOverrideCsvTsv(
int)));
145 layoutDelimiters->addWidget (m_chkOverrideCsvTsv);
148 void DlgSettingsExportFormat::createFileLayout (QHBoxLayout *layoutMisc)
150 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createFileLayout";
152 QGroupBox *groupLayout =
new QGroupBox (tr (
"Layout"));
153 layoutMisc->addWidget (groupLayout, 1);
155 QVBoxLayout *layoutLayout =
new QVBoxLayout;
156 groupLayout->setLayout (layoutLayout);
158 m_btnFunctionsLayoutAllCurves =
new QRadioButton (tr (
"All curves on each line"));
159 m_btnFunctionsLayoutAllCurves->setWhatsThis (tr (
"Exported file will have, on each line, "
160 "an X value, the Y value for the first curve, the Y value for the second curve,..."));
161 layoutLayout->addWidget (m_btnFunctionsLayoutAllCurves);
162 connect (m_btnFunctionsLayoutAllCurves, SIGNAL (released()),
this, SLOT (slotFunctionsLayoutAllCurves ()));
164 m_btnFunctionsLayoutOneCurve =
new QRadioButton (tr (
"One curve on each line"));
165 m_btnFunctionsLayoutOneCurve->setWhatsThis (tr (
"Exported file will have all the points for "
166 "the first curve, with one X-Y pair on each line, then the points for the second curve,..."));
167 layoutLayout->addWidget (m_btnFunctionsLayoutOneCurve);
168 connect (m_btnFunctionsLayoutOneCurve, SIGNAL (released()),
this, SLOT (slotFunctionsLayoutOneCurve ()));
171 void DlgSettingsExportFormat::createFunctionsPointsSelection (QHBoxLayout *layoutFunctions)
173 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createFunctionsPointsSelection";
175 QGroupBox *groupPointsSelection =
new QGroupBox (tr (
"Points Selection"));
176 layoutFunctions->addWidget (groupPointsSelection, 1);
178 QGridLayout *layoutPointsSelections =
new QGridLayout;
179 groupPointsSelection->setLayout (layoutPointsSelections);
181 layoutPointsSelections->setColumnMinimumWidth(0, MIN_INDENT_COLUMN_WIDTH);
182 layoutPointsSelections->setColumnStretch (0, 0);
183 layoutPointsSelections->setColumnStretch (1, 0);
184 layoutPointsSelections->setColumnStretch (2, 0);
185 layoutPointsSelections->setColumnStretch (3, 1);
188 m_btnFunctionsPointsAllCurves =
new QRadioButton (tr (
"Interpolate Ys at Xs from all curves"));
189 m_btnFunctionsPointsAllCurves->setWhatsThis (tr (
"Exported file will have values at every unique X "
190 "value from every curve. Y values will be linearly interpolated if necessary"));
191 layoutPointsSelections->addWidget (m_btnFunctionsPointsAllCurves, row++, 0, 1, 4);
192 connect (m_btnFunctionsPointsAllCurves, SIGNAL (released()),
this, SLOT (slotFunctionsPointsAllCurves()));
194 m_btnFunctionsPointsFirstCurve =
new QRadioButton (tr (
"Interpolate Ys at Xs from first curve"));
195 m_btnFunctionsPointsFirstCurve->setWhatsThis (tr (
"Exported file will have values at every unique X "
196 "value from the first curve. Y values will be linearly interpolated if necessary"));
197 layoutPointsSelections->addWidget (m_btnFunctionsPointsFirstCurve, row++, 0, 1, 4);
198 connect (m_btnFunctionsPointsFirstCurve, SIGNAL (released()),
this, SLOT (slotFunctionsPointsFirstCurve()));
200 m_btnFunctionsPointsEvenlySpaced =
new QRadioButton (tr (
"Interpolate Ys at evenly spaced X values."));
201 m_btnFunctionsPointsEvenlySpaced->setWhatsThis (tr (
"Exported file will have values at evenly spaced X values, separated by the interval selected below."));
202 layoutPointsSelections->addWidget (m_btnFunctionsPointsEvenlySpaced, row++, 0, 1, 4);
203 connect (m_btnFunctionsPointsEvenlySpaced, SIGNAL (released()),
this, SLOT (slotFunctionsPointsEvenlySpaced()));
205 QLabel *labelInterval =
new QLabel (tr (
"Interval:"));
206 layoutPointsSelections->addWidget (labelInterval, row, 1, 1, 1, Qt::AlignRight);
208 m_editFunctionsPointsEvenlySpacing =
new QLineEdit;
209 m_validatorFunctionsPointsEvenlySpacing =
new QDoubleValidator;
210 m_editFunctionsPointsEvenlySpacing->setValidator (m_validatorFunctionsPointsEvenlySpacing);
211 m_editFunctionsPointsEvenlySpacing->setMinimumWidth (MIN_EDIT_WIDTH);
212 m_editFunctionsPointsEvenlySpacing->setMaximumWidth (MAX_EDIT_WIDTH);
213 m_editFunctionsPointsEvenlySpacing->setWhatsThis (tr (
"Interval, in the units of X, between successive points in the X direction.\n\n"
214 "If the scale is linear, then this interval is added to successive X values. If the scale is "
215 "logarithmic, then this interval is multiplied to successive X values.\n\n"
216 "The X values will be automatically aligned along simple numbers. If the first and/or last "
217 "points are not along the aligned X values, then one or two additional points are added "
219 layoutPointsSelections->addWidget (m_editFunctionsPointsEvenlySpacing, row, 2, 1, 1, Qt::AlignLeft);
220 connect (m_editFunctionsPointsEvenlySpacing, SIGNAL (textChanged(
const QString &)),
this, SLOT (slotFunctionsPointsEvenlySpacedInterval(
const QString &)));
222 m_cmbFunctionsPointsEvenlySpacingUnits =
new QComboBox;
223 m_cmbFunctionsPointsEvenlySpacingUnits->setWhatsThis (tr (
"Units for spacing interval.\n\n"
224 "Pixel units are preferred when the spacing is to be independent of the X scale. The spacing will be "
225 "consistent across the graph, even if the X scale is logarithmic.\n\n"
226 "Graph units are preferred when the spacing is to depend on the X scale."));
227 m_cmbFunctionsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_GRAPH),
228 QVariant (EXPORT_POINTS_INTERVAL_UNITS_GRAPH));
229 m_cmbFunctionsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_SCREEN),
230 QVariant (EXPORT_POINTS_INTERVAL_UNITS_SCREEN));
231 connect (m_cmbFunctionsPointsEvenlySpacingUnits, SIGNAL (activated (
const QString &)),
232 this, SLOT (slotFunctionsPointsEvenlySpacedIntervalUnits (
const QString &)));
233 layoutPointsSelections->addWidget (m_cmbFunctionsPointsEvenlySpacingUnits, row++, 3, 1, 1, Qt::AlignLeft);
235 m_btnFunctionsPointsRaw =
new QRadioButton (tr (
"Raw Xs and Ys"));
236 m_btnFunctionsPointsRaw->setWhatsThis (tr (
"Exported file will have only original X and Y values"));
237 layoutPointsSelections->addWidget (m_btnFunctionsPointsRaw, row++, 0, 1, 4);
238 connect (m_btnFunctionsPointsRaw, SIGNAL (released()),
this, SLOT (slotFunctionsPointsRaw()));
241 void DlgSettingsExportFormat::createHeader (QHBoxLayout *layoutMisc)
243 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createHeader";
245 const int COLUMN_RADIO_BUTTONS = 0, COLUMN_EMPTY = 1, COLUMN_LABEL = 2;
247 QGroupBox *groupHeader =
new QGroupBox (tr (
"Header"));
248 layoutMisc->addWidget (groupHeader, 1);
250 QGridLayout *layoutHeader =
new QGridLayout;
251 layoutHeader->setColumnMinimumWidth(COLUMN_EMPTY,
252 MIN_HEADER_EMPTY_COLUMN_WIDTH);
253 groupHeader->setLayout (layoutHeader);
256 m_btnHeaderNone =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_NONE));
257 m_btnHeaderNone->setWhatsThis (tr (
"Exported file will have no header line"));
258 layoutHeader->addWidget (m_btnHeaderNone, row++, COLUMN_RADIO_BUTTONS, 1, 1);
259 connect (m_btnHeaderNone, SIGNAL (released ()),
this, SLOT (slotHeaderNone()));
261 m_btnHeaderSimple =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_SIMPLE));
262 m_btnHeaderSimple->setWhatsThis (tr (
"Exported file will have simple header line"));
263 layoutHeader->addWidget (m_btnHeaderSimple, row++, COLUMN_RADIO_BUTTONS, 1, 1);
264 connect (m_btnHeaderSimple, SIGNAL (released ()),
this, SLOT (slotHeaderSimple()));
266 m_btnHeaderGnuplot =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_GNUPLOT));
267 m_btnHeaderGnuplot->setWhatsThis (tr (
"Exported file will have gnuplot header line"));
268 layoutHeader->addWidget (m_btnHeaderGnuplot, row++, COLUMN_RADIO_BUTTONS, 1, 1);
269 connect (m_btnHeaderGnuplot, SIGNAL (released()),
this, SLOT (slotHeaderGnuplot()));
271 createXLabel (layoutHeader,
277 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createOptionalSaveDefault";
279 m_btnSaveDefault =
new QPushButton (tr (
"Save As Default"));
280 m_btnSaveDefault->setWhatsThis (tr (
"Save the settings for use as future defaults."));
281 connect (m_btnSaveDefault, SIGNAL (released ()),
this, SLOT (slotSaveDefault ()));
282 layout->addWidget (m_btnSaveDefault, 0, Qt::AlignLeft);
285 void DlgSettingsExportFormat::createPreview(QGridLayout *layout,
int &row)
287 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createPreview";
289 QLabel *label =
new QLabel (tr (
"Preview"));
290 layout->addWidget (label, row++, 0, 1, 3);
292 m_editPreview =
new QTextEdit;
293 m_editPreview->setReadOnly (
true);
294 m_editPreview->setWhatsThis (tr (
"Preview window shows how current settings affect the exported file"));
297 layout->addWidget (m_editPreview, row++, 0, 1, 3);
300 void DlgSettingsExportFormat::createRelationsPointsSelection (QHBoxLayout *layoutRelations)
302 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createRelationsPointsSelection";
304 QGroupBox *groupPointsSelection =
new QGroupBox (tr (
"Points Selection"));
305 layoutRelations->addWidget (groupPointsSelection);
307 QGridLayout *layoutPointsSelections =
new QGridLayout;
308 groupPointsSelection->setLayout (layoutPointsSelections);
310 layoutPointsSelections->setColumnMinimumWidth(0, MIN_INDENT_COLUMN_WIDTH);
311 layoutPointsSelections->setColumnStretch (0, 0);
312 layoutPointsSelections->setColumnStretch (1, 0);
313 layoutPointsSelections->setColumnStretch (2, 0);
314 layoutPointsSelections->setColumnStretch (3, 1);
317 m_btnRelationsPointsEvenlySpaced =
new QRadioButton (tr (
"Interpolate Xs and Ys at evenly spaced intervals."));
318 m_btnRelationsPointsEvenlySpaced->setWhatsThis (tr (
"Exported file will have points evenly spaced along each relation, separated by the interval "
319 "selected below. If the last interval does not end at the last point, then a shorter last interval "
320 "is added that ends on the last point."));
321 layoutPointsSelections->addWidget (m_btnRelationsPointsEvenlySpaced, row++, 0, 1, 4);
322 connect (m_btnRelationsPointsEvenlySpaced, SIGNAL (released()),
this, SLOT (slotRelationsPointsEvenlySpaced()));
324 QLabel *labelInterval =
new QLabel (tr (
"Interval:"));
325 layoutPointsSelections->addWidget (labelInterval, row, 1, 1, 1, Qt::AlignRight);
327 m_editRelationsPointsEvenlySpacing =
new QLineEdit;
328 m_validatorRelationsPointsEvenlySpacing =
new QDoubleValidator;
329 m_editRelationsPointsEvenlySpacing->setValidator (m_validatorRelationsPointsEvenlySpacing);
330 m_editRelationsPointsEvenlySpacing->setMinimumWidth (MIN_EDIT_WIDTH);
331 m_editRelationsPointsEvenlySpacing->setMaximumWidth (MAX_EDIT_WIDTH);
332 m_editRelationsPointsEvenlySpacing->setWhatsThis (tr (
"Interval between successive points when "
333 "exporting at evenly spaced (X,Y) coordinates."));
334 layoutPointsSelections->addWidget (m_editRelationsPointsEvenlySpacing, row, 2, 1, 1, Qt::AlignLeft);
335 connect (m_editRelationsPointsEvenlySpacing, SIGNAL (textChanged(
const QString &)),
this, SLOT (slotRelationsPointsEvenlySpacedInterval(
const QString &)));
337 m_cmbRelationsPointsEvenlySpacingUnits =
new QComboBox;
338 m_cmbRelationsPointsEvenlySpacingUnits->setWhatsThis (tr (
"Units for spacing interval.\n\n"
339 "Pixel units are preferred when the spacing is to be independent of the X and Y scales. The spacing will be "
340 "consistent across the graph, even if a scale is logarithmic or the X and Y scales are different.\n\n"
341 "Graph units are usually preferred when the X and Y scales are identical."));
342 m_cmbRelationsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_GRAPH),
343 QVariant (EXPORT_POINTS_INTERVAL_UNITS_GRAPH));
344 m_cmbRelationsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_SCREEN),
345 QVariant (EXPORT_POINTS_INTERVAL_UNITS_SCREEN));
346 connect (m_cmbRelationsPointsEvenlySpacingUnits, SIGNAL (activated (
const QString &)),
347 this, SLOT (slotRelationsPointsEvenlySpacedIntervalUnits (
const QString &)));
348 layoutPointsSelections->addWidget (m_cmbRelationsPointsEvenlySpacingUnits, row++, 3, 1, 1, Qt::AlignLeft);
350 m_btnRelationsPointsRaw =
new QRadioButton (tr (
"Raw Xs and Ys"));
351 m_btnRelationsPointsRaw->setWhatsThis (tr (
"Exported file will have only original X and Y values"));
352 layoutPointsSelections->addWidget (m_btnRelationsPointsRaw, row++, 0, 1, 4);
353 connect (m_btnRelationsPointsRaw, SIGNAL (released()),
this, SLOT (slotRelationsPointsRaw()));
358 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createSubPanel";
360 QWidget *subPanel =
new QWidget ();
361 QGridLayout *layout =
new QGridLayout (subPanel);
362 subPanel->setLayout (layout);
365 createCurveSelection (layout, row);
367 createTabWidget (layout,
370 QWidget *widgetMisc =
new QWidget;
371 layout->addWidget (widgetMisc, row++, 0, 1, 3);
372 QHBoxLayout *layoutMisc =
new QHBoxLayout;
373 widgetMisc->setLayout (layoutMisc);
375 createDelimiters (layoutMisc);
376 createHeader (layoutMisc);
377 createFileLayout (layoutMisc);
379 createPreview (layout, row);
384 void DlgSettingsExportFormat::createTabWidget (QGridLayout *layout,
387 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createTabWidget";
389 m_tabWidget =
new QTabWidget;
391 layout->addWidget (m_tabWidget, row++, 0, 1, 3);
393 QWidget *widgetFunctions =
new QWidget;
394 int indexFunctions = m_tabWidget->addTab (widgetFunctions, tr (
"Functions"));
395 QWidget *tabFunctions = m_tabWidget->widget (indexFunctions);
396 tabFunctions->setWhatsThis (tr (
"Functions Tab\n\n"
397 "Controls for specifying the format of functions during export"));
398 QHBoxLayout *layoutFunctions =
new QHBoxLayout;
399 widgetFunctions->setLayout (layoutFunctions);
401 QWidget *widgetRelations =
new QWidget;
402 int indexRelations = m_tabWidget->addTab (widgetRelations, tr (
"Relations"));
403 QWidget *tabRelations = m_tabWidget->widget (indexRelations);
404 tabRelations->setWhatsThis (tr (
"Relations Tab\n\n"
405 "Controls for specifying the format of relations during export"));
406 QHBoxLayout *layoutRelations =
new QHBoxLayout;
407 widgetRelations->setLayout (layoutRelations);
410 connect (m_tabWidget, SIGNAL (currentChanged (
int)),
this, SLOT (slotTabChanged (
int)));
412 createFunctionsPointsSelection (layoutFunctions);
413 createRelationsPointsSelection (layoutRelations);
416 void DlgSettingsExportFormat::createXLabel (QGridLayout *layoutHeader,
419 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createXLabel";
425 title =
new QLabel (tr (
"X Label:"));
427 title =
new QLabel (tr (
"Theta Label:"));
429 layoutHeader->addWidget (title, row++, colLabel, 1, 1);
431 m_editXLabel =
new QLineEdit;
433 m_editXLabel->setWhatsThis (tr (
"Label in the header for x values"));
435 m_editXLabel->setWhatsThis (tr (
"Label in the header for theta values"));
437 layoutHeader->addWidget (m_editXLabel, row++, colLabel, 1, 1);
438 connect (m_editXLabel, SIGNAL (textChanged (
const QString &)),
this, SLOT (slotXLabel(
const QString &)));
441 bool DlgSettingsExportFormat::goodIntervalFunctions()
const
445 QString textFunctions = m_editFunctionsPointsEvenlySpacing->text();
448 bool isGood = (m_validatorFunctionsPointsEvenlySpacing->validate (textFunctions, posFunctions) == QValidator::Acceptable);
450 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::goodIntervalFunctions"
451 <<
" text=" << textFunctions.toLatin1().data()
452 <<
" good=" << (isGood ?
"true" :
"false")
453 <<
" bottom=" << m_validatorFunctionsPointsEvenlySpacing->bottom()
454 <<
" top=" << m_validatorFunctionsPointsEvenlySpacing->top();
459 bool DlgSettingsExportFormat::goodIntervalRelations()
const
463 QString textRelations = m_editRelationsPointsEvenlySpacing->text();
466 bool isGood = (m_validatorRelationsPointsEvenlySpacing->validate (textRelations, posRelations) == QValidator::Acceptable);
468 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::goodIntervalRelations"
469 <<
" text=" << textRelations.toLatin1().data()
470 <<
" good=" << (isGood ?
"true" :
"false")
471 <<
" bottom=" << m_validatorRelationsPointsEvenlySpacing->bottom()
472 <<
" top=" << m_validatorRelationsPointsEvenlySpacing->top();
479 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::handleOk";
483 *m_modelExportBefore,
484 *m_modelExportAfter);
490 void DlgSettingsExportFormat::initializeIntervalConstraints ()
492 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::initializeIntervalConstraints";
494 const int MAX_POINTS_ACROSS_RANGE = 5000;
499 Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
505 double maxSizeGraph = qMax (ftor.boundingRectGraph(isEmpty).width(),
506 ftor.boundingRectGraph(isEmpty).height());
507 double maxSizeScreen = qMax (ftor.boundingRectScreen(isEmpty).width(),
508 ftor.boundingRectScreen(isEmpty).height());
509 m_minIntervalGraph = maxSizeGraph / MAX_POINTS_ACROSS_RANGE;
510 m_minIntervalScreen = maxSizeScreen / MAX_POINTS_ACROSS_RANGE;
515 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::load";
520 if (m_modelExportBefore != 0) {
521 delete m_modelExportBefore;
523 if (m_modelExportAfter != 0) {
524 delete m_modelExportAfter;
532 m_listExcluded->clear();
534 QStringList::const_iterator itr;
535 for (itr = curveNamesExcluded.begin (); itr != curveNamesExcluded.end(); ++itr) {
536 QString curveNameNotExported = *itr;
537 m_listExcluded->addItem (curveNameNotExported);
541 m_listIncluded->clear();
543 for (itr = curveNamesAll.begin (); itr != curveNamesAll.end(); itr++) {
544 QString curveName = *itr;
545 if (!curveNamesExcluded.contains (curveName)) {
546 m_listIncluded->addItem (curveName);
551 m_btnFunctionsPointsAllCurves->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_ALL_CURVES);
552 m_btnFunctionsPointsFirstCurve->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_FIRST_CURVE);
553 m_btnFunctionsPointsEvenlySpaced->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_PERIODIC);
554 m_btnFunctionsPointsRaw->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_RAW);
556 ExportLayoutFunctions layoutFunctions = m_modelExportAfter->
layoutFunctions ();
557 m_btnFunctionsLayoutAllCurves->setChecked (layoutFunctions == EXPORT_LAYOUT_ALL_PER_LINE);
558 m_btnFunctionsLayoutOneCurve->setChecked (layoutFunctions == EXPORT_LAYOUT_ONE_PER_LINE);
561 m_btnRelationsPointsEvenlySpaced->setChecked (pointsSelectionRelations == EXPORT_POINTS_SELECTION_RELATIONS_INTERPOLATE);
562 m_btnRelationsPointsRaw->setChecked (pointsSelectionRelations == EXPORT_POINTS_SELECTION_RELATIONS_RAW);
564 ExportDelimiter delimiter = m_modelExportAfter->
delimiter ();
565 m_btnDelimitersCommas->setChecked (delimiter == EXPORT_DELIMITER_COMMA);
566 m_btnDelimitersSpaces->setChecked (delimiter == EXPORT_DELIMITER_SPACE);
567 m_btnDelimitersTabs->setChecked (delimiter == EXPORT_DELIMITER_TAB);
568 m_btnDelimitersSemicolons->setChecked (delimiter == EXPORT_DELIMITER_SEMICOLON);
570 m_chkOverrideCsvTsv->setChecked (m_modelExportAfter->
overrideCsvTsv());
572 ExportHeader header = m_modelExportAfter->
header ();
573 m_btnHeaderNone->setChecked (header == EXPORT_HEADER_NONE);
574 m_btnHeaderSimple->setChecked (header == EXPORT_HEADER_SIMPLE);
575 m_btnHeaderGnuplot->setChecked (header == EXPORT_HEADER_GNUPLOT);
577 m_editXLabel->setText (m_modelExportAfter->
xLabel());
584 int indexFunctions = m_cmbFunctionsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsFunctions));
585 int indexRelations = m_cmbRelationsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsRelations));
586 m_cmbFunctionsPointsEvenlySpacingUnits->setCurrentIndex (indexFunctions);
587 m_cmbRelationsPointsEvenlySpacingUnits->setCurrentIndex (indexRelations);
589 initializeIntervalConstraints ();
592 updateIntervalConstraints();
597 void DlgSettingsExportFormat::slotDelimitersCommas()
599 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersCommas";
601 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_COMMA);
606 void DlgSettingsExportFormat::slotDelimitersSemicolons()
608 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersSemicolons";
610 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_SEMICOLON);
615 void DlgSettingsExportFormat::slotDelimitersSpaces()
617 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersSpaces";
619 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_SPACE);
624 void DlgSettingsExportFormat::slotDelimitersTabs()
626 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersTabs";
633 void DlgSettingsExportFormat::slotExclude ()
635 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotExclude";
639 QStringList excluded;
640 for (i = 0; i < m_listIncluded->count(); i++) {
641 if (m_listIncluded->item(i)->isSelected()) {
642 excluded += m_listIncluded->item(i)->text();
647 for (i = 0; i < excluded.count(); i++) {
648 QString curveName = excluded.at (i);
649 m_listExcluded->addItem (curveName);
653 for (i = m_listIncluded->count() - 1; i>= 0; i--) {
654 QString curveName = m_listIncluded->item(i)->text();
655 if (excluded.contains (curveName)) {
656 QListWidgetItem *item = m_listIncluded->item (i);
657 m_listIncluded->removeItemWidget (item);
667 void DlgSettingsExportFormat::slotFunctionsLayoutAllCurves()
669 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsLayoutAllCurves";
676 void DlgSettingsExportFormat::slotFunctionsLayoutOneCurve()
678 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsLayoutOneCurve";
685 void DlgSettingsExportFormat::slotFunctionsPointsAllCurves()
687 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsAllCurves";
694 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced()
696 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced";
703 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval(
const QString &)
705 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval";
708 if (goodIntervalFunctions()) {
713 m_editPreview->setText(EMPTY_PREVIEW);
717 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits(
const QString &)
719 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits";
721 int index = m_cmbFunctionsPointsEvenlySpacingUnits->currentIndex();
722 ExportPointsIntervalUnits units = (ExportPointsIntervalUnits) m_cmbFunctionsPointsEvenlySpacingUnits->itemData (index).toInt();
725 updateIntervalConstraints();
730 void DlgSettingsExportFormat::slotFunctionsPointsFirstCurve()
732 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsFirstCurve";
739 void DlgSettingsExportFormat::slotFunctionsPointsRaw()
741 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsRaw";
748 void DlgSettingsExportFormat::slotHeaderGnuplot()
750 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderGnuplot";
752 m_modelExportAfter->
setHeader(EXPORT_HEADER_GNUPLOT);
757 void DlgSettingsExportFormat::slotHeaderNone()
759 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderNone";
761 m_modelExportAfter->
setHeader(EXPORT_HEADER_NONE);
766 void DlgSettingsExportFormat::slotHeaderSimple()
768 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderSimple";
770 m_modelExportAfter->
setHeader(EXPORT_HEADER_SIMPLE);
775 void DlgSettingsExportFormat::slotInclude ()
777 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotInclude";
781 QStringList included;
782 for (i = 0; i < m_listExcluded->count(); i++) {
783 if (m_listExcluded->item(i)->isSelected()) {
784 included += m_listExcluded->item(i)->text();
789 for (i = 0; i < included.count(); i++) {
790 QString curveName = included.at (i);
791 m_listIncluded->addItem (curveName);
795 QStringList excluded;
796 for (i = m_listExcluded->count() - 1; i>= 0; i--) {
797 QString curveName = m_listExcluded->item(i)->text();
798 QListWidgetItem *item = m_listExcluded->item (i);
799 if (included.contains (curveName)) {
800 m_listExcluded->removeItemWidget (item);
803 excluded += item->text();
812 void DlgSettingsExportFormat::slotListExcluded()
814 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotListExcluded";
820 void DlgSettingsExportFormat::slotListIncluded()
822 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotListIncluded";
828 void DlgSettingsExportFormat::slotOverrideCsvTsv(
int)
830 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotOverrideCsvTsv";
837 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced()
839 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced";
846 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval(
const QString &)
848 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval";
855 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits(
const QString &)
857 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits";
859 int index = m_cmbRelationsPointsEvenlySpacingUnits->currentIndex();
860 ExportPointsIntervalUnits units = (ExportPointsIntervalUnits) m_cmbRelationsPointsEvenlySpacingUnits->itemData (index).toInt();
863 updateIntervalConstraints();
868 void DlgSettingsExportFormat::slotRelationsPointsRaw()
870 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsRaw";
877 void DlgSettingsExportFormat::slotSaveDefault()
879 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotSaveDefault";
881 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
882 settings.beginGroup (SETTINGS_GROUP_EXPORT);
884 settings.setValue (SETTINGS_EXPORT_DELIMITER,
885 QVariant (m_modelExportAfter->
delimiter()));
886 settings.setValue (SETTINGS_EXPORT_HEADER,
887 QVariant (m_modelExportAfter->
header()));
888 settings.setValue (SETTINGS_EXPORT_LAYOUT_FUNCTIONS,
890 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_FUNCTIONS,
892 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_RELATIONS,
894 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_FUNCTIONS,
896 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_RELATIONS,
898 settings.setValue (SETTINGS_EXPORT_POINTS_SELECTION_FUNCTIONS,
900 settings.setValue (SETTINGS_EXPORT_POINTS_SELECTION_RELATIONS,
902 settings.setValue (SETTINGS_EXPORT_X_LABEL,
903 QVariant (m_modelExportAfter->
xLabel()));
905 settings.endGroup ();
908 void DlgSettingsExportFormat::slotTabChanged (
int)
910 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotTabChanged";
915 void DlgSettingsExportFormat::slotXLabel(
const QString &)
917 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotXLabel";
919 m_modelExportAfter->
setXLabel (m_editXLabel->text());
924 void DlgSettingsExportFormat::updateControls ()
926 bool isGoodState = goodIntervalFunctions() &&
927 goodIntervalRelations();
930 int selectedForInclude = m_listExcluded->selectedItems().count();
931 int selectedForExclude = m_listIncluded->selectedItems().count();
932 int inInclude = m_listIncluded->count();
934 m_btnInclude->setEnabled (selectedForInclude > 0);
935 m_btnExclude->setEnabled ((selectedForExclude > 0) && (inInclude - selectedForExclude > 0));
937 m_editFunctionsPointsEvenlySpacing->setEnabled (m_btnFunctionsPointsEvenlySpaced->isChecked ());
938 m_editRelationsPointsEvenlySpacing->setEnabled (m_btnRelationsPointsEvenlySpaced->isChecked ());
940 m_editXLabel->setEnabled (!m_btnHeaderNone->isChecked());
943 void DlgSettingsExportFormat::updateIntervalConstraints ()
947 m_minIntervalScreen);
950 m_minIntervalScreen);
952 if (m_tabWidget->currentIndex() == TAB_WIDGET_INDEX_FUNCTIONS) {
956 m_editFunctionsPointsEvenlySpacing->setText (QString::number (functionsMin));
960 m_validatorFunctionsPointsEvenlySpacing->setBottom (functionsMin);
966 m_editRelationsPointsEvenlySpacing->setText (QString::number (relationsMin));
970 m_validatorRelationsPointsEvenlySpacing->setBottom (relationsMin);
974 void DlgSettingsExportFormat::updatePreview()
977 int scrollPosition = m_editPreview->verticalScrollBar()->value();
979 QString exportedText;
980 QTextStream str (&exportedText);
982 if (
mainWindow().transformation().transformIsDefined()) {
985 if (m_tabWidget->currentIndex() == TAB_WIDGET_INDEX_FUNCTIONS) {
1006 str <<
"Preview is unavailable until axis points are defined.";
1009 m_editPreview->setText (exportedText);
1012 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.
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.
void finishPanel(QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
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.