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->setSortingEnabled (
false);
77 m_listIncluded->setWhatsThis (tr (
"List of curves to be included in the exported file.\n\n" 78 "The order of the curves here does not affect the order in the exported file. That " 79 "order is determined by the Curves settings."));
80 m_listIncluded->setSelectionMode (QAbstractItemView::MultiSelection);
81 layout->addWidget (m_listIncluded, row, 0, 4, 1);
82 connect (m_listIncluded, SIGNAL (itemSelectionChanged ()),
this, SLOT (slotListIncluded()));
84 m_listExcluded =
new QListWidget;
85 m_listExcluded->setSortingEnabled (
false);
86 m_listExcluded->setWhatsThis (tr (
"List of curves to be excluded from the exported file"));
87 m_listExcluded->setSelectionMode (QAbstractItemView::MultiSelection);
88 layout->addWidget (m_listExcluded, row++, 2, 4, 1);
89 connect (m_listExcluded, SIGNAL (itemSelectionChanged ()),
this, SLOT (slotListExcluded()));
91 m_btnInclude =
new QPushButton (tr (
"<<Include"));
92 m_btnInclude->setEnabled (
false);
93 m_btnInclude->setWhatsThis (tr (
"Move the currently selected curve(s) from the excluded list"));
94 layout->addWidget (m_btnInclude, row++, 1);
95 connect (m_btnInclude, SIGNAL (released ()),
this, SLOT (slotInclude()));
97 m_btnExclude =
new QPushButton (tr (
"Exclude>>"));
98 m_btnExclude->setEnabled (
false);
99 m_btnExclude->setWhatsThis (tr (
"Move the currently selected curve(s) from the included list"));
100 layout->addWidget (m_btnExclude, row++, 1);
101 connect (m_btnExclude, SIGNAL (released ()),
this, SLOT (slotExclude()));
106 void DlgSettingsExportFormat::createDelimiters (QHBoxLayout *layoutMisc)
108 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createDelimiters";
110 QGroupBox *groupDelimiters =
new QGroupBox (tr (
"Delimiters"));
111 layoutMisc->addWidget (groupDelimiters, 1);
113 QVBoxLayout *layoutDelimiters =
new QVBoxLayout;
114 groupDelimiters->setLayout (layoutDelimiters);
116 m_btnDelimitersCommas =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_COMMA));
117 m_btnDelimitersCommas->setWhatsThis (tr (
"Exported file will have commas between adjacent values, unless overridden by tabs in TSV files."));
118 layoutDelimiters->addWidget (m_btnDelimitersCommas);
119 connect (m_btnDelimitersCommas, SIGNAL (released ()),
this, SLOT (slotDelimitersCommas()));
121 m_btnDelimitersSpaces =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_SPACE));
122 m_btnDelimitersSpaces->setWhatsThis (tr (
"Exported file will have spaces between adjacent values, unless overridden by commas in CSV files, " 123 "or tabs in TSV files."));
124 layoutDelimiters->addWidget (m_btnDelimitersSpaces);
125 connect (m_btnDelimitersSpaces, SIGNAL (released ()),
this, SLOT (slotDelimitersSpaces()));
127 m_btnDelimitersTabs =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_TAB));
128 m_btnDelimitersTabs->setWhatsThis (tr (
"Exported file will have tabs between adjacent values, unless overridden by commas in CSV files."));
129 layoutDelimiters->addWidget (m_btnDelimitersTabs);
130 connect (m_btnDelimitersTabs, SIGNAL (released ()),
this, SLOT (slotDelimitersTabs()));
132 m_btnDelimitersSemicolons =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_SEMICOLON));
133 m_btnDelimitersSemicolons->setWhatsThis (tr (
"Exported file will have semicolons between adjacent values, unless overridden by commas in CSV files."));
134 layoutDelimiters->addWidget (m_btnDelimitersSemicolons);
135 connect (m_btnDelimitersSemicolons, SIGNAL (released ()),
this, SLOT (slotDelimitersSemicolons()));
137 m_chkOverrideCsvTsv =
new QCheckBox (tr (
"Override in CSV/TSV files"));
138 m_chkOverrideCsvTsv->setWhatsThis (tr (
"Comma-separated value (CSV) files and tab-separated value (TSV) files will use commas and tabs " 139 "respectively, unless this setting is selected. Selecting this setting will apply the delimiter setting " 141 connect (m_chkOverrideCsvTsv, SIGNAL (stateChanged (
int)),
this, SLOT (slotOverrideCsvTsv(
int)));
142 layoutDelimiters->addWidget (m_chkOverrideCsvTsv);
145 void DlgSettingsExportFormat::createFileLayout (QHBoxLayout *layoutMisc)
147 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createFileLayout";
149 QGroupBox *groupLayout =
new QGroupBox (tr (
"Layout"));
150 layoutMisc->addWidget (groupLayout, 1);
152 QVBoxLayout *layoutLayout =
new QVBoxLayout;
153 groupLayout->setLayout (layoutLayout);
155 m_btnFunctionsLayoutAllCurves =
new QRadioButton (tr (
"All curves on each line"));
156 m_btnFunctionsLayoutAllCurves->setWhatsThis (tr (
"Exported file will have, on each line, " 157 "an X value, the Y value for the first curve, the Y value for the second curve,..."));
158 layoutLayout->addWidget (m_btnFunctionsLayoutAllCurves);
159 connect (m_btnFunctionsLayoutAllCurves, SIGNAL (released()),
this, SLOT (slotFunctionsLayoutAllCurves ()));
161 m_btnFunctionsLayoutOneCurve =
new QRadioButton (tr (
"One curve on each line"));
162 m_btnFunctionsLayoutOneCurve->setWhatsThis (tr (
"Exported file will have all the points for " 163 "the first curve, with one X-Y pair on each line, then the points for the second curve,..."));
164 layoutLayout->addWidget (m_btnFunctionsLayoutOneCurve);
165 connect (m_btnFunctionsLayoutOneCurve, SIGNAL (released()),
this, SLOT (slotFunctionsLayoutOneCurve ()));
168 void DlgSettingsExportFormat::createFunctionsPointsSelection (QHBoxLayout *layoutFunctions)
170 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createFunctionsPointsSelection";
172 QGroupBox *groupPointsSelection =
new QGroupBox (tr (
"Points Selection"));
173 layoutFunctions->addWidget (groupPointsSelection, 1);
175 QGridLayout *layoutPointsSelections =
new QGridLayout;
176 groupPointsSelection->setLayout (layoutPointsSelections);
178 layoutPointsSelections->setColumnMinimumWidth(0, MIN_INDENT_COLUMN_WIDTH);
179 layoutPointsSelections->setColumnStretch (0, 0);
180 layoutPointsSelections->setColumnStretch (1, 0);
181 layoutPointsSelections->setColumnStretch (2, 0);
182 layoutPointsSelections->setColumnStretch (3, 1);
185 m_btnFunctionsPointsAllCurves =
new QRadioButton (tr (
"Interpolate Ys at Xs from all curves"));
186 m_btnFunctionsPointsAllCurves->setWhatsThis (tr (
"Exported file will have values at every unique X " 187 "value from every curve. Y values will be linearly interpolated if necessary"));
188 layoutPointsSelections->addWidget (m_btnFunctionsPointsAllCurves, row++, 0, 1, 4);
189 connect (m_btnFunctionsPointsAllCurves, SIGNAL (released()),
this, SLOT (slotFunctionsPointsAllCurves()));
191 m_btnFunctionsPointsFirstCurve =
new QRadioButton (tr (
"Interpolate Ys at Xs from first curve"));
192 m_btnFunctionsPointsFirstCurve->setWhatsThis (tr (
"Exported file will have values at every unique X " 193 "value from the first curve. Y values will be linearly interpolated if necessary"));
194 layoutPointsSelections->addWidget (m_btnFunctionsPointsFirstCurve, row++, 0, 1, 4);
195 connect (m_btnFunctionsPointsFirstCurve, SIGNAL (released()),
this, SLOT (slotFunctionsPointsFirstCurve()));
197 m_btnFunctionsPointsEvenlySpaced =
new QRadioButton (tr (
"Interpolate Ys at evenly spaced X values."));
198 m_btnFunctionsPointsEvenlySpaced->setWhatsThis (tr (
"Exported file will have values at evenly spaced X values, separated by the interval selected below."));
199 layoutPointsSelections->addWidget (m_btnFunctionsPointsEvenlySpaced, row++, 0, 1, 4);
200 connect (m_btnFunctionsPointsEvenlySpaced, SIGNAL (released()),
this, SLOT (slotFunctionsPointsEvenlySpaced()));
202 QLabel *labelInterval =
new QLabel (tr (
"Interval:"));
203 layoutPointsSelections->addWidget (labelInterval, row, 1, 1, 1, Qt::AlignRight);
205 m_editFunctionsPointsEvenlySpacing =
new QLineEdit;
206 m_validatorFunctionsPointsEvenlySpacing =
new QDoubleValidator;
207 m_editFunctionsPointsEvenlySpacing->setValidator (m_validatorFunctionsPointsEvenlySpacing);
208 m_editFunctionsPointsEvenlySpacing->setMinimumWidth (MIN_EDIT_WIDTH);
209 m_editFunctionsPointsEvenlySpacing->setMaximumWidth (MAX_EDIT_WIDTH);
210 m_editFunctionsPointsEvenlySpacing->setWhatsThis (tr (
"Interval, in the units of X, between successive points in the X direction.\n\n" 211 "If the scale is linear, then this interval is added to successive X values. If the scale is " 212 "logarithmic, then this interval is multiplied to successive X values.\n\n" 213 "The X values will be automatically aligned along simple numbers. If the first and/or last " 214 "points are not along the aligned X values, then one or two additional points are added " 216 layoutPointsSelections->addWidget (m_editFunctionsPointsEvenlySpacing, row, 2, 1, 1, Qt::AlignLeft);
217 connect (m_editFunctionsPointsEvenlySpacing, SIGNAL (textChanged(
const QString &)),
this, SLOT (slotFunctionsPointsEvenlySpacedInterval(
const QString &)));
219 m_cmbFunctionsPointsEvenlySpacingUnits =
new QComboBox;
220 m_cmbFunctionsPointsEvenlySpacingUnits->setWhatsThis (tr (
"Units for spacing interval.\n\n" 221 "Pixel units are preferred when the spacing is to be independent of the X scale. The spacing will be " 222 "consistent across the graph, even if the X scale is logarithmic.\n\n" 223 "Graph units are preferred when the spacing is to depend on the X scale."));
224 m_cmbFunctionsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_GRAPH),
225 QVariant (EXPORT_POINTS_INTERVAL_UNITS_GRAPH));
226 m_cmbFunctionsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_SCREEN),
227 QVariant (EXPORT_POINTS_INTERVAL_UNITS_SCREEN));
228 connect (m_cmbFunctionsPointsEvenlySpacingUnits, SIGNAL (activated (
const QString &)),
229 this, SLOT (slotFunctionsPointsEvenlySpacedIntervalUnits (
const QString &)));
230 layoutPointsSelections->addWidget (m_cmbFunctionsPointsEvenlySpacingUnits, row++, 3, 1, 1, Qt::AlignLeft);
232 m_btnFunctionsPointsRaw =
new QRadioButton (tr (
"Raw Xs and Ys"));
233 m_btnFunctionsPointsRaw->setWhatsThis (tr (
"Exported file will have only original X and Y values"));
234 layoutPointsSelections->addWidget (m_btnFunctionsPointsRaw, row++, 0, 1, 4);
235 connect (m_btnFunctionsPointsRaw, SIGNAL (released()),
this, SLOT (slotFunctionsPointsRaw()));
238 void DlgSettingsExportFormat::createHeader (QHBoxLayout *layoutMisc)
240 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createHeader";
242 const int COLUMN_RADIO_BUTTONS = 0, COLUMN_EMPTY = 1, COLUMN_LABEL = 2;
244 QGroupBox *groupHeader =
new QGroupBox (tr (
"Header"));
245 layoutMisc->addWidget (groupHeader, 1);
247 QGridLayout *layoutHeader =
new QGridLayout;
248 layoutHeader->setColumnMinimumWidth(COLUMN_EMPTY,
249 MIN_HEADER_EMPTY_COLUMN_WIDTH);
250 groupHeader->setLayout (layoutHeader);
253 m_btnHeaderNone =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_NONE));
254 m_btnHeaderNone->setWhatsThis (tr (
"Exported file will have no header line"));
255 layoutHeader->addWidget (m_btnHeaderNone, row++, COLUMN_RADIO_BUTTONS, 1, 1);
256 connect (m_btnHeaderNone, SIGNAL (released ()),
this, SLOT (slotHeaderNone()));
258 m_btnHeaderSimple =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_SIMPLE));
259 m_btnHeaderSimple->setWhatsThis (tr (
"Exported file will have simple header line"));
260 layoutHeader->addWidget (m_btnHeaderSimple, row++, COLUMN_RADIO_BUTTONS, 1, 1);
261 connect (m_btnHeaderSimple, SIGNAL (released ()),
this, SLOT (slotHeaderSimple()));
263 m_btnHeaderGnuplot =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_GNUPLOT));
264 m_btnHeaderGnuplot->setWhatsThis (tr (
"Exported file will have gnuplot header line"));
265 layoutHeader->addWidget (m_btnHeaderGnuplot, row++, COLUMN_RADIO_BUTTONS, 1, 1);
266 connect (m_btnHeaderGnuplot, SIGNAL (released()),
this, SLOT (slotHeaderGnuplot()));
268 createXLabel (layoutHeader,
274 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createOptionalSaveDefault";
276 m_btnSaveDefault =
new QPushButton (tr (
"Save As Default"));
277 m_btnSaveDefault->setWhatsThis (tr (
"Save the settings for use as future defaults."));
278 connect (m_btnSaveDefault, SIGNAL (released ()),
this, SLOT (slotSaveDefault ()));
279 layout->addWidget (m_btnSaveDefault, 0, Qt::AlignLeft);
282 void DlgSettingsExportFormat::createPreview(QGridLayout *layout,
int &row)
284 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createPreview";
286 QLabel *label =
new QLabel (tr (
"Preview"));
287 layout->addWidget (label, row++, 0, 1, 3);
289 m_editPreview =
new QTextEdit;
290 m_editPreview->setReadOnly (
true);
291 m_editPreview->setWhatsThis (tr (
"Preview window shows how current settings affect the exported file"));
294 layout->addWidget (m_editPreview, row++, 0, 1, 3);
297 void DlgSettingsExportFormat::createRelationsPointsSelection (QHBoxLayout *layoutRelations)
299 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createRelationsPointsSelection";
301 QGroupBox *groupPointsSelection =
new QGroupBox (tr (
"Points Selection"));
302 layoutRelations->addWidget (groupPointsSelection);
304 QGridLayout *layoutPointsSelections =
new QGridLayout;
305 groupPointsSelection->setLayout (layoutPointsSelections);
307 layoutPointsSelections->setColumnMinimumWidth(0, MIN_INDENT_COLUMN_WIDTH);
308 layoutPointsSelections->setColumnStretch (0, 0);
309 layoutPointsSelections->setColumnStretch (1, 0);
310 layoutPointsSelections->setColumnStretch (2, 0);
311 layoutPointsSelections->setColumnStretch (3, 1);
314 m_btnRelationsPointsEvenlySpaced =
new QRadioButton (tr (
"Interpolate Xs and Ys at evenly spaced intervals."));
315 m_btnRelationsPointsEvenlySpaced->setWhatsThis (tr (
"Exported file will have points evenly spaced along each relation, separated by the interval " 316 "selected below. If the last interval does not end at the last point, then a shorter last interval " 317 "is added that ends on the last point."));
318 layoutPointsSelections->addWidget (m_btnRelationsPointsEvenlySpaced, row++, 0, 1, 4);
319 connect (m_btnRelationsPointsEvenlySpaced, SIGNAL (released()),
this, SLOT (slotRelationsPointsEvenlySpaced()));
321 QLabel *labelInterval =
new QLabel (tr (
"Interval:"));
322 layoutPointsSelections->addWidget (labelInterval, row, 1, 1, 1, Qt::AlignRight);
324 m_editRelationsPointsEvenlySpacing =
new QLineEdit;
325 m_validatorRelationsPointsEvenlySpacing =
new QDoubleValidator;
326 m_editRelationsPointsEvenlySpacing->setValidator (m_validatorRelationsPointsEvenlySpacing);
327 m_editRelationsPointsEvenlySpacing->setMinimumWidth (MIN_EDIT_WIDTH);
328 m_editRelationsPointsEvenlySpacing->setMaximumWidth (MAX_EDIT_WIDTH);
329 m_editRelationsPointsEvenlySpacing->setWhatsThis (tr (
"Interval between successive points when " 330 "exporting at evenly spaced (X,Y) coordinates."));
331 layoutPointsSelections->addWidget (m_editRelationsPointsEvenlySpacing, row, 2, 1, 1, Qt::AlignLeft);
332 connect (m_editRelationsPointsEvenlySpacing, SIGNAL (textChanged(
const QString &)),
this, SLOT (slotRelationsPointsEvenlySpacedInterval(
const QString &)));
334 m_cmbRelationsPointsEvenlySpacingUnits =
new QComboBox;
335 m_cmbRelationsPointsEvenlySpacingUnits->setWhatsThis (tr (
"Units for spacing interval.\n\n" 336 "Pixel units are preferred when the spacing is to be independent of the X and Y scales. The spacing will be " 337 "consistent across the graph, even if a scale is logarithmic or the X and Y scales are different.\n\n" 338 "Graph units are usually preferred when the X and Y scales are identical."));
339 m_cmbRelationsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_GRAPH),
340 QVariant (EXPORT_POINTS_INTERVAL_UNITS_GRAPH));
341 m_cmbRelationsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_SCREEN),
342 QVariant (EXPORT_POINTS_INTERVAL_UNITS_SCREEN));
343 connect (m_cmbRelationsPointsEvenlySpacingUnits, SIGNAL (activated (
const QString &)),
344 this, SLOT (slotRelationsPointsEvenlySpacedIntervalUnits (
const QString &)));
345 layoutPointsSelections->addWidget (m_cmbRelationsPointsEvenlySpacingUnits, row++, 3, 1, 1, Qt::AlignLeft);
347 m_btnRelationsPointsRaw =
new QRadioButton (tr (
"Raw Xs and Ys"));
348 m_btnRelationsPointsRaw->setWhatsThis (tr (
"Exported file will have only original X and Y values"));
349 layoutPointsSelections->addWidget (m_btnRelationsPointsRaw, row++, 0, 1, 4);
350 connect (m_btnRelationsPointsRaw, SIGNAL (released()),
this, SLOT (slotRelationsPointsRaw()));
355 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createSubPanel";
357 QWidget *subPanel =
new QWidget ();
358 QGridLayout *layout =
new QGridLayout (subPanel);
359 subPanel->setLayout (layout);
362 createCurveSelection (layout, row);
364 createTabWidget (layout,
367 QWidget *widgetMisc =
new QWidget;
368 layout->addWidget (widgetMisc, row++, 0, 1, 3);
369 QHBoxLayout *layoutMisc =
new QHBoxLayout;
370 widgetMisc->setLayout (layoutMisc);
372 createDelimiters (layoutMisc);
373 createHeader (layoutMisc);
374 createFileLayout (layoutMisc);
376 createPreview (layout, row);
381 void DlgSettingsExportFormat::createTabWidget (QGridLayout *layout,
384 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createTabWidget";
386 m_tabWidget =
new QTabWidget;
388 layout->addWidget (m_tabWidget, row++, 0, 1, 3);
390 QWidget *widgetFunctions =
new QWidget;
391 int indexFunctions = m_tabWidget->addTab (widgetFunctions, tr (
"Functions"));
392 QWidget *tabFunctions = m_tabWidget->widget (indexFunctions);
393 tabFunctions->setWhatsThis (tr (
"Functions Tab\n\n" 394 "Controls for specifying the format of functions during export"));
395 QHBoxLayout *layoutFunctions =
new QHBoxLayout;
396 widgetFunctions->setLayout (layoutFunctions);
398 QWidget *widgetRelations =
new QWidget;
399 int indexRelations = m_tabWidget->addTab (widgetRelations, tr (
"Relations"));
400 QWidget *tabRelations = m_tabWidget->widget (indexRelations);
401 tabRelations->setWhatsThis (tr (
"Relations Tab\n\n" 402 "Controls for specifying the format of relations during export"));
403 QHBoxLayout *layoutRelations =
new QHBoxLayout;
404 widgetRelations->setLayout (layoutRelations);
407 connect (m_tabWidget, SIGNAL (currentChanged (
int)),
this, SLOT (slotTabChanged (
int)));
409 createFunctionsPointsSelection (layoutFunctions);
410 createRelationsPointsSelection (layoutRelations);
413 void DlgSettingsExportFormat::createXLabel (QGridLayout *layoutHeader,
416 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createXLabel";
422 title =
new QLabel (tr (
"X Label:"));
424 title =
new QLabel (tr (
"Theta Label:"));
426 layoutHeader->addWidget (title, row++, colLabel, 1, 1);
428 m_editXLabel =
new QLineEdit;
430 m_editXLabel->setWhatsThis (tr (
"Label in the header for x values"));
432 m_editXLabel->setWhatsThis (tr (
"Label in the header for theta values"));
434 layoutHeader->addWidget (m_editXLabel, row++, colLabel, 1, 1);
435 connect (m_editXLabel, SIGNAL (textChanged (
const QString &)),
this, SLOT (slotXLabel(
const QString &)));
438 bool DlgSettingsExportFormat::goodIntervalFunctions()
const 442 QString textFunctions = m_editFunctionsPointsEvenlySpacing->text();
445 bool isGood = (m_validatorFunctionsPointsEvenlySpacing->validate (textFunctions, posFunctions) == QValidator::Acceptable);
447 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::goodIntervalFunctions" 448 <<
" text=" << textFunctions.toLatin1().data()
449 <<
" good=" << (isGood ?
"true" :
"false")
450 <<
" bottom=" << m_validatorFunctionsPointsEvenlySpacing->bottom()
451 <<
" top=" << m_validatorFunctionsPointsEvenlySpacing->top();
456 bool DlgSettingsExportFormat::goodIntervalRelations()
const 460 QString textRelations = m_editRelationsPointsEvenlySpacing->text();
463 bool isGood = (m_validatorRelationsPointsEvenlySpacing->validate (textRelations, posRelations) == QValidator::Acceptable);
465 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::goodIntervalRelations" 466 <<
" text=" << textRelations.toLatin1().data()
467 <<
" good=" << (isGood ?
"true" :
"false")
468 <<
" bottom=" << m_validatorRelationsPointsEvenlySpacing->bottom()
469 <<
" top=" << m_validatorRelationsPointsEvenlySpacing->top();
476 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::handleOk";
480 *m_modelExportBefore,
481 *m_modelExportAfter);
487 void DlgSettingsExportFormat::initializeIntervalConstraints ()
489 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::initializeIntervalConstraints";
491 const int MAX_POINTS_ACROSS_RANGE = 5000;
496 Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
506 m_minIntervalGraph = maxSizeGraph / MAX_POINTS_ACROSS_RANGE;
507 m_minIntervalScreen = maxSizeScreen / MAX_POINTS_ACROSS_RANGE;
512 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::load";
517 if (m_modelExportBefore != 0) {
518 delete m_modelExportBefore;
520 if (m_modelExportAfter != 0) {
521 delete m_modelExportAfter;
529 m_listExcluded->clear();
531 QStringList::const_iterator itr;
532 for (itr = curveNamesExcluded.begin (); itr != curveNamesExcluded.end(); ++itr) {
533 QString curveNameNotExported = *itr;
534 m_listExcluded->addItem (curveNameNotExported);
538 m_listIncluded->clear();
540 for (itr = curveNamesAll.begin (); itr != curveNamesAll.end(); itr++) {
541 QString curveName = *itr;
542 if (!curveNamesExcluded.contains (curveName)) {
543 m_listIncluded->addItem (curveName);
548 m_btnFunctionsPointsAllCurves->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_ALL_CURVES);
549 m_btnFunctionsPointsFirstCurve->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_FIRST_CURVE);
550 m_btnFunctionsPointsEvenlySpaced->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_PERIODIC);
551 m_btnFunctionsPointsRaw->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_RAW);
553 ExportLayoutFunctions layoutFunctions = m_modelExportAfter->
layoutFunctions ();
554 m_btnFunctionsLayoutAllCurves->setChecked (layoutFunctions == EXPORT_LAYOUT_ALL_PER_LINE);
555 m_btnFunctionsLayoutOneCurve->setChecked (layoutFunctions == EXPORT_LAYOUT_ONE_PER_LINE);
558 m_btnRelationsPointsEvenlySpaced->setChecked (pointsSelectionRelations == EXPORT_POINTS_SELECTION_RELATIONS_INTERPOLATE);
559 m_btnRelationsPointsRaw->setChecked (pointsSelectionRelations == EXPORT_POINTS_SELECTION_RELATIONS_RAW);
561 ExportDelimiter delimiter = m_modelExportAfter->
delimiter ();
562 m_btnDelimitersCommas->setChecked (delimiter == EXPORT_DELIMITER_COMMA);
563 m_btnDelimitersSpaces->setChecked (delimiter == EXPORT_DELIMITER_SPACE);
564 m_btnDelimitersTabs->setChecked (delimiter == EXPORT_DELIMITER_TAB);
565 m_btnDelimitersSemicolons->setChecked (delimiter == EXPORT_DELIMITER_SEMICOLON);
567 m_chkOverrideCsvTsv->setChecked (m_modelExportAfter->
overrideCsvTsv());
569 ExportHeader header = m_modelExportAfter->
header ();
570 m_btnHeaderNone->setChecked (header == EXPORT_HEADER_NONE);
571 m_btnHeaderSimple->setChecked (header == EXPORT_HEADER_SIMPLE);
572 m_btnHeaderGnuplot->setChecked (header == EXPORT_HEADER_GNUPLOT);
574 m_editXLabel->setText (m_modelExportAfter->
xLabel());
581 int indexFunctions = m_cmbFunctionsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsFunctions));
582 int indexRelations = m_cmbRelationsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsRelations));
583 m_cmbFunctionsPointsEvenlySpacingUnits->setCurrentIndex (indexFunctions);
584 m_cmbRelationsPointsEvenlySpacingUnits->setCurrentIndex (indexRelations);
586 initializeIntervalConstraints ();
589 updateIntervalConstraints();
594 void DlgSettingsExportFormat::slotDelimitersCommas()
596 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersCommas";
598 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_COMMA);
603 void DlgSettingsExportFormat::slotDelimitersSemicolons()
605 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersSemicolons";
607 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_SEMICOLON);
612 void DlgSettingsExportFormat::slotDelimitersSpaces()
614 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersSpaces";
616 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_SPACE);
621 void DlgSettingsExportFormat::slotDelimitersTabs()
623 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersTabs";
630 void DlgSettingsExportFormat::slotExclude ()
632 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotExclude";
636 QStringList excluded;
637 for (i = 0; i < m_listIncluded->count(); i++) {
638 if (m_listIncluded->item(i)->isSelected()) {
639 excluded += m_listIncluded->item(i)->text();
644 for (i = 0; i < excluded.count(); i++) {
645 QString curveName = excluded.at (i);
646 m_listExcluded->addItem (curveName);
650 for (i = m_listIncluded->count() - 1; i>= 0; i--) {
651 QString curveName = m_listIncluded->item(i)->text();
652 if (excluded.contains (curveName)) {
653 QListWidgetItem *item = m_listIncluded->item (i);
654 m_listIncluded->removeItemWidget (item);
664 void DlgSettingsExportFormat::slotFunctionsLayoutAllCurves()
666 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsLayoutAllCurves";
673 void DlgSettingsExportFormat::slotFunctionsLayoutOneCurve()
675 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsLayoutOneCurve";
682 void DlgSettingsExportFormat::slotFunctionsPointsAllCurves()
684 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsAllCurves";
691 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced()
693 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced";
700 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval(
const QString &)
702 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval";
705 if (goodIntervalFunctions()) {
710 m_editPreview->setText(EMPTY_PREVIEW);
714 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits(
const QString &)
716 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits";
718 int index = m_cmbFunctionsPointsEvenlySpacingUnits->currentIndex();
719 ExportPointsIntervalUnits units = (ExportPointsIntervalUnits) m_cmbFunctionsPointsEvenlySpacingUnits->itemData (index).toInt();
722 updateIntervalConstraints();
727 void DlgSettingsExportFormat::slotFunctionsPointsFirstCurve()
729 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsFirstCurve";
736 void DlgSettingsExportFormat::slotFunctionsPointsRaw()
738 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsRaw";
745 void DlgSettingsExportFormat::slotHeaderGnuplot()
747 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderGnuplot";
749 m_modelExportAfter->
setHeader(EXPORT_HEADER_GNUPLOT);
754 void DlgSettingsExportFormat::slotHeaderNone()
756 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderNone";
758 m_modelExportAfter->
setHeader(EXPORT_HEADER_NONE);
763 void DlgSettingsExportFormat::slotHeaderSimple()
765 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderSimple";
767 m_modelExportAfter->
setHeader(EXPORT_HEADER_SIMPLE);
772 void DlgSettingsExportFormat::slotInclude ()
774 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotInclude";
778 QStringList included;
779 for (i = 0; i < m_listExcluded->count(); i++) {
780 if (m_listExcluded->item(i)->isSelected()) {
781 included += m_listExcluded->item(i)->text();
786 for (i = 0; i < included.count(); i++) {
787 QString curveName = included.at (i);
788 m_listIncluded->addItem (curveName);
792 QStringList excluded;
793 for (i = m_listExcluded->count() - 1; i>= 0; i--) {
794 QString curveName = m_listExcluded->item(i)->text();
795 QListWidgetItem *item = m_listExcluded->item (i);
796 if (included.contains (curveName)) {
797 m_listExcluded->removeItemWidget (item);
800 excluded += item->text();
809 void DlgSettingsExportFormat::slotListExcluded()
811 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotListExcluded";
817 void DlgSettingsExportFormat::slotListIncluded()
819 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotListIncluded";
825 void DlgSettingsExportFormat::slotOverrideCsvTsv(
int)
827 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotOverrideCsvTsv";
834 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced()
836 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced";
843 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval(
const QString &)
845 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval";
852 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits(
const QString &)
854 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits";
856 int index = m_cmbRelationsPointsEvenlySpacingUnits->currentIndex();
857 ExportPointsIntervalUnits units = (ExportPointsIntervalUnits) m_cmbRelationsPointsEvenlySpacingUnits->itemData (index).toInt();
860 updateIntervalConstraints();
865 void DlgSettingsExportFormat::slotRelationsPointsRaw()
867 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsRaw";
874 void DlgSettingsExportFormat::slotSaveDefault()
876 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotSaveDefault";
878 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
879 settings.beginGroup (SETTINGS_GROUP_EXPORT);
881 settings.setValue (SETTINGS_EXPORT_DELIMITER,
882 QVariant (m_modelExportAfter->
delimiter()));
883 settings.setValue (SETTINGS_EXPORT_HEADER,
884 QVariant (m_modelExportAfter->
header()));
885 settings.setValue (SETTINGS_EXPORT_LAYOUT_FUNCTIONS,
887 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_FUNCTIONS,
889 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_RELATIONS,
891 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_FUNCTIONS,
893 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_RELATIONS,
895 settings.setValue (SETTINGS_EXPORT_POINTS_SELECTION_FUNCTIONS,
897 settings.setValue (SETTINGS_EXPORT_POINTS_SELECTION_RELATIONS,
899 settings.setValue (SETTINGS_EXPORT_X_LABEL,
900 QVariant (m_modelExportAfter->
xLabel()));
902 settings.endGroup ();
905 void DlgSettingsExportFormat::slotTabChanged (
int)
907 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotTabChanged";
912 void DlgSettingsExportFormat::slotXLabel(
const QString &)
914 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotXLabel";
916 m_modelExportAfter->
setXLabel (m_editXLabel->text());
921 void DlgSettingsExportFormat::updateControls ()
923 bool isGoodState = goodIntervalFunctions() &&
924 goodIntervalRelations();
927 int selectedForInclude = m_listExcluded->selectedItems().count();
928 int selectedForExclude = m_listIncluded->selectedItems().count();
929 int inInclude = m_listIncluded->count();
931 m_btnInclude->setEnabled (selectedForInclude > 0);
932 m_btnExclude->setEnabled ((selectedForExclude > 0) && (inInclude - selectedForExclude > 0));
934 m_editFunctionsPointsEvenlySpacing->setEnabled (m_btnFunctionsPointsEvenlySpaced->isChecked ());
935 m_editRelationsPointsEvenlySpacing->setEnabled (m_btnRelationsPointsEvenlySpaced->isChecked ());
937 m_editXLabel->setEnabled (!m_btnHeaderNone->isChecked());
940 void DlgSettingsExportFormat::updateIntervalConstraints ()
944 m_minIntervalScreen);
947 m_minIntervalScreen);
949 if (m_tabWidget->currentIndex() == TAB_WIDGET_INDEX_FUNCTIONS) {
953 m_editFunctionsPointsEvenlySpacing->setText (QString::number (functionsMin));
957 m_validatorFunctionsPointsEvenlySpacing->setBottom (functionsMin);
963 m_editRelationsPointsEvenlySpacing->setText (QString::number (relationsMin));
967 m_validatorRelationsPointsEvenlySpacing->setBottom (relationsMin);
971 void DlgSettingsExportFormat::updatePreview()
974 int scrollPosition = m_editPreview->verticalScrollBar()->value();
976 QString exportedText;
977 QTextStream str (&exportedText);
979 if (
mainWindow().transformation().transformIsDefined()) {
982 if (m_tabWidget->currentIndex() == TAB_WIDGET_INDEX_FUNCTIONS) {
1003 str <<
"Preview is unavailable until axis points are defined.";
1006 m_editPreview->setText (exportedText);
1009 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...
QRectF boundingRectGraph(bool &isEmpty) const
Graph coordinate bounding rectangle.
QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
void finishPanel(QWidget *subPanel)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
QRectF boundingRectScreen(bool &isEmpty) const
Screen coordinate bounding rectangle.
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.