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;
48 const int MINIMUM_HEIGHT = 780;
52 "DlgSettingsExportFormat",
54 m_modelExportBefore (0),
55 m_modelExportAfter (0)
57 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::DlgSettingsExportFormat";
61 MINIMUM_DIALOG_WIDTH_EXPORT_FORMAT);
64 DlgSettingsExportFormat::~DlgSettingsExportFormat()
66 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::~DlgSettingsExportFormat";
69 void DlgSettingsExportFormat::createCurveSelection (QGridLayout *layout,
int &row)
71 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createCurveSelection";
73 QLabel *labelIncluded =
new QLabel (tr (
"Included"));
74 layout->addWidget (labelIncluded, row, 0);
76 QLabel *labelExcluded =
new QLabel (tr (
"Not included"));
77 layout->addWidget (labelExcluded, row++, 2);
79 m_listIncluded =
new QListWidget;
80 m_listIncluded->setSortingEnabled (
false);
81 m_listIncluded->setWhatsThis (tr (
"List of curves to be included in the exported file.\n\n" 82 "The order of the curves here does not affect the order in the exported file. That " 83 "order is determined by the Curves settings."));
84 m_listIncluded->setSelectionMode (QAbstractItemView::MultiSelection);
85 layout->addWidget (m_listIncluded, row, 0, 4, 1);
86 connect (m_listIncluded, SIGNAL (itemSelectionChanged ()),
this, SLOT (slotListIncluded()));
88 m_listExcluded =
new QListWidget;
89 m_listExcluded->setSortingEnabled (
false);
90 m_listExcluded->setWhatsThis (tr (
"List of curves to be excluded from the exported file"));
91 m_listExcluded->setSelectionMode (QAbstractItemView::MultiSelection);
92 layout->addWidget (m_listExcluded, row++, 2, 4, 1);
93 connect (m_listExcluded, SIGNAL (itemSelectionChanged ()),
this, SLOT (slotListExcluded()));
95 m_btnInclude =
new QPushButton (tr (
"<<Include"));
96 m_btnInclude->setEnabled (
false);
97 m_btnInclude->setWhatsThis (tr (
"Move the currently selected curve(s) from the excluded list"));
98 layout->addWidget (m_btnInclude, row++, 1);
99 connect (m_btnInclude, SIGNAL (released ()),
this, SLOT (slotInclude()));
101 m_btnExclude =
new QPushButton (tr (
"Exclude>>"));
102 m_btnExclude->setEnabled (
false);
103 m_btnExclude->setWhatsThis (tr (
"Move the currently selected curve(s) from the included list"));
104 layout->addWidget (m_btnExclude, row++, 1);
105 connect (m_btnExclude, SIGNAL (released ()),
this, SLOT (slotExclude()));
110 void DlgSettingsExportFormat::createDelimiters (QHBoxLayout *layoutMisc)
112 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createDelimiters";
114 QGroupBox *groupDelimiters =
new QGroupBox (tr (
"Delimiters"));
115 layoutMisc->addWidget (groupDelimiters, 1);
117 QVBoxLayout *layoutDelimiters =
new QVBoxLayout;
118 groupDelimiters->setLayout (layoutDelimiters);
120 m_btnDelimitersCommas =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_COMMA));
121 m_btnDelimitersCommas->setWhatsThis (tr (
"Exported file will have commas between adjacent values, unless overridden by tabs in TSV files."));
122 layoutDelimiters->addWidget (m_btnDelimitersCommas);
123 connect (m_btnDelimitersCommas, SIGNAL (released ()),
this, SLOT (slotDelimitersCommas()));
125 m_btnDelimitersSpaces =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_SPACE));
126 m_btnDelimitersSpaces->setWhatsThis (tr (
"Exported file will have spaces between adjacent values, unless overridden by commas in CSV files, " 127 "or tabs in TSV files."));
128 layoutDelimiters->addWidget (m_btnDelimitersSpaces);
129 connect (m_btnDelimitersSpaces, SIGNAL (released ()),
this, SLOT (slotDelimitersSpaces()));
131 m_btnDelimitersTabs =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_TAB));
132 m_btnDelimitersTabs->setWhatsThis (tr (
"Exported file will have tabs between adjacent values, unless overridden by commas in CSV files."));
133 layoutDelimiters->addWidget (m_btnDelimitersTabs);
134 connect (m_btnDelimitersTabs, SIGNAL (released ()),
this, SLOT (slotDelimitersTabs()));
136 m_btnDelimitersSemicolons =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_SEMICOLON));
137 m_btnDelimitersSemicolons->setWhatsThis (tr (
"Exported file will have semicolons between adjacent values, unless overridden by commas in CSV files."));
138 layoutDelimiters->addWidget (m_btnDelimitersSemicolons);
139 connect (m_btnDelimitersSemicolons, SIGNAL (released ()),
this, SLOT (slotDelimitersSemicolons()));
141 m_chkOverrideCsvTsv =
new QCheckBox (tr (
"Override in CSV/TSV files"));
142 m_chkOverrideCsvTsv->setWhatsThis (tr (
"Comma-separated value (CSV) files and tab-separated value (TSV) files will use commas and tabs " 143 "respectively, unless this setting is selected. Selecting this setting will apply the delimiter setting " 145 connect (m_chkOverrideCsvTsv, SIGNAL (stateChanged (
int)),
this, SLOT (slotOverrideCsvTsv(
int)));
146 layoutDelimiters->addWidget (m_chkOverrideCsvTsv);
149 void DlgSettingsExportFormat::createFileLayout (QHBoxLayout *layoutMisc)
151 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createFileLayout";
153 QGroupBox *groupLayout =
new QGroupBox (tr (
"Layout"));
154 layoutMisc->addWidget (groupLayout, 1);
156 QVBoxLayout *layoutLayout =
new QVBoxLayout;
157 groupLayout->setLayout (layoutLayout);
159 m_btnFunctionsLayoutAllCurves =
new QRadioButton (tr (
"All curves on each line"));
160 m_btnFunctionsLayoutAllCurves->setWhatsThis (tr (
"Exported file will have, on each line, " 161 "an X value, the Y value for the first curve, the Y value for the second curve,..."));
162 layoutLayout->addWidget (m_btnFunctionsLayoutAllCurves);
163 connect (m_btnFunctionsLayoutAllCurves, SIGNAL (released()),
this, SLOT (slotFunctionsLayoutAllCurves ()));
165 m_btnFunctionsLayoutOneCurve =
new QRadioButton (tr (
"One curve on each line"));
166 m_btnFunctionsLayoutOneCurve->setWhatsThis (tr (
"Exported file will have all the points for " 167 "the first curve, with one X-Y pair on each line, then the points for the second curve,..."));
168 layoutLayout->addWidget (m_btnFunctionsLayoutOneCurve);
169 connect (m_btnFunctionsLayoutOneCurve, SIGNAL (released()),
this, SLOT (slotFunctionsLayoutOneCurve ()));
172 void DlgSettingsExportFormat::createFunctionsPointsSelection (QHBoxLayout *layoutFunctions)
174 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createFunctionsPointsSelection";
176 QGroupBox *groupPointsSelection =
new QGroupBox (tr (
"Points Selection"));
177 layoutFunctions->addWidget (groupPointsSelection, 1);
179 QGridLayout *layoutPointsSelections =
new QGridLayout;
180 groupPointsSelection->setLayout (layoutPointsSelections);
182 layoutPointsSelections->setColumnMinimumWidth(0, MIN_INDENT_COLUMN_WIDTH);
183 layoutPointsSelections->setColumnStretch (0, 0);
184 layoutPointsSelections->setColumnStretch (1, 0);
185 layoutPointsSelections->setColumnStretch (2, 0);
186 layoutPointsSelections->setColumnStretch (3, 1);
189 m_btnFunctionsPointsAllCurves =
new QRadioButton (tr (
"Interpolate Ys at Xs from all curves"));
190 m_btnFunctionsPointsAllCurves->setWhatsThis (tr (
"Exported file will have values at every unique X " 191 "value from every curve. Y values will be linearly interpolated if necessary"));
192 layoutPointsSelections->addWidget (m_btnFunctionsPointsAllCurves, row++, 0, 1, 4);
193 connect (m_btnFunctionsPointsAllCurves, SIGNAL (released()),
this, SLOT (slotFunctionsPointsAllCurves()));
195 m_btnFunctionsPointsFirstCurve =
new QRadioButton (tr (
"Interpolate Ys at Xs from first curve"));
196 m_btnFunctionsPointsFirstCurve->setWhatsThis (tr (
"Exported file will have values at every unique X " 197 "value from the first curve. Y values will be linearly interpolated if necessary"));
198 layoutPointsSelections->addWidget (m_btnFunctionsPointsFirstCurve, row++, 0, 1, 4);
199 connect (m_btnFunctionsPointsFirstCurve, SIGNAL (released()),
this, SLOT (slotFunctionsPointsFirstCurve()));
201 m_btnFunctionsPointsEvenlySpaced =
new QRadioButton (tr (
"Interpolate Ys at evenly spaced X values."));
202 m_btnFunctionsPointsEvenlySpaced->setWhatsThis (tr (
"Exported file will have values at evenly spaced X values, separated by the interval selected below."));
203 layoutPointsSelections->addWidget (m_btnFunctionsPointsEvenlySpaced, row++, 0, 1, 4);
204 connect (m_btnFunctionsPointsEvenlySpaced, SIGNAL (released()),
this, SLOT (slotFunctionsPointsEvenlySpaced()));
206 QLabel *labelInterval =
new QLabel (tr (
"Interval:"));
207 layoutPointsSelections->addWidget (labelInterval, row, 1, 1, 1, Qt::AlignRight);
209 m_editFunctionsPointsEvenlySpacing =
new QLineEdit;
210 m_validatorFunctionsPointsEvenlySpacing =
new QDoubleValidator;
211 m_editFunctionsPointsEvenlySpacing->setValidator (m_validatorFunctionsPointsEvenlySpacing);
212 m_editFunctionsPointsEvenlySpacing->setMinimumWidth (MIN_EDIT_WIDTH);
213 m_editFunctionsPointsEvenlySpacing->setMaximumWidth (MAX_EDIT_WIDTH);
214 m_editFunctionsPointsEvenlySpacing->setWhatsThis (tr (
"Interval, in the units of X, between successive points in the X direction.\n\n" 215 "If the scale is linear, then this interval is added to successive X values. If the scale is " 216 "logarithmic, then this interval is multiplied to successive X values.\n\n" 217 "The X values will be automatically aligned along simple numbers. If the first and/or last " 218 "points are not along the aligned X values, then one or two additional points are added " 220 layoutPointsSelections->addWidget (m_editFunctionsPointsEvenlySpacing, row, 2, 1, 1, Qt::AlignLeft);
221 connect (m_editFunctionsPointsEvenlySpacing, SIGNAL (textChanged(
const QString &)),
this, SLOT (slotFunctionsPointsEvenlySpacedInterval(
const QString &)));
223 m_cmbFunctionsPointsEvenlySpacingUnits =
new QComboBox;
224 m_cmbFunctionsPointsEvenlySpacingUnits->setWhatsThis (tr (
"Units for spacing interval.\n\n" 225 "Pixel units are preferred when the spacing is to be independent of the X scale. The spacing will be " 226 "consistent across the graph, even if the X scale is logarithmic.\n\n" 227 "Graph units are preferred when the spacing is to depend on the X scale."));
228 m_cmbFunctionsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_GRAPH),
229 QVariant (EXPORT_POINTS_INTERVAL_UNITS_GRAPH));
230 m_cmbFunctionsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_SCREEN),
231 QVariant (EXPORT_POINTS_INTERVAL_UNITS_SCREEN));
232 connect (m_cmbFunctionsPointsEvenlySpacingUnits, SIGNAL (activated (
const QString &)),
233 this, SLOT (slotFunctionsPointsEvenlySpacedIntervalUnits (
const QString &)));
234 layoutPointsSelections->addWidget (m_cmbFunctionsPointsEvenlySpacingUnits, row++, 3, 1, 1, Qt::AlignLeft);
236 m_btnFunctionsPointsRaw =
new QRadioButton (tr (
"Raw Xs and Ys"));
237 m_btnFunctionsPointsRaw->setWhatsThis (tr (
"Exported file will have only original X and Y values"));
238 layoutPointsSelections->addWidget (m_btnFunctionsPointsRaw, row++, 0, 1, 4);
239 connect (m_btnFunctionsPointsRaw, SIGNAL (released()),
this, SLOT (slotFunctionsPointsRaw()));
242 void DlgSettingsExportFormat::createHeader (QHBoxLayout *layoutMisc)
244 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createHeader";
246 const int COLUMN_RADIO_BUTTONS = 0, COLUMN_EMPTY = 1, COLUMN_LABEL = 2;
248 QGroupBox *groupHeader =
new QGroupBox (tr (
"Header"));
249 layoutMisc->addWidget (groupHeader, 1);
251 QGridLayout *layoutHeader =
new QGridLayout;
252 layoutHeader->setColumnMinimumWidth(COLUMN_EMPTY,
253 MIN_HEADER_EMPTY_COLUMN_WIDTH);
254 groupHeader->setLayout (layoutHeader);
257 m_btnHeaderNone =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_NONE));
258 m_btnHeaderNone->setWhatsThis (tr (
"Exported file will have no header line"));
259 layoutHeader->addWidget (m_btnHeaderNone, row++, COLUMN_RADIO_BUTTONS, 1, 1);
260 connect (m_btnHeaderNone, SIGNAL (released ()),
this, SLOT (slotHeaderNone()));
262 m_btnHeaderSimple =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_SIMPLE));
263 m_btnHeaderSimple->setWhatsThis (tr (
"Exported file will have simple header line"));
264 layoutHeader->addWidget (m_btnHeaderSimple, row++, COLUMN_RADIO_BUTTONS, 1, 1);
265 connect (m_btnHeaderSimple, SIGNAL (released ()),
this, SLOT (slotHeaderSimple()));
267 m_btnHeaderGnuplot =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_GNUPLOT));
268 m_btnHeaderGnuplot->setWhatsThis (tr (
"Exported file will have gnuplot header line"));
269 layoutHeader->addWidget (m_btnHeaderGnuplot, row++, COLUMN_RADIO_BUTTONS, 1, 1);
270 connect (m_btnHeaderGnuplot, SIGNAL (released()),
this, SLOT (slotHeaderGnuplot()));
272 createXLabel (layoutHeader,
278 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createOptionalSaveDefault";
280 m_btnSaveDefault =
new QPushButton (tr (
"Save As Default"));
281 m_btnSaveDefault->setWhatsThis (tr (
"Save the settings for use as future defaults."));
282 connect (m_btnSaveDefault, SIGNAL (released ()),
this, SLOT (slotSaveDefault ()));
283 layout->addWidget (m_btnSaveDefault, 0, Qt::AlignLeft);
286 void DlgSettingsExportFormat::createPreview(QGridLayout *layout,
int &row)
288 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createPreview";
290 QLabel *label =
new QLabel (tr (
"Preview"));
291 layout->addWidget (label, row++, 0, 1, 3);
293 m_editPreview =
new QTextEdit;
294 m_editPreview->setReadOnly (
true);
295 m_editPreview->setWhatsThis (tr (
"Preview window shows how current settings affect the exported file"));
298 layout->addWidget (m_editPreview, row++, 0, 1, 3);
301 void DlgSettingsExportFormat::createRelationsPointsSelection (QHBoxLayout *layoutRelations)
303 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createRelationsPointsSelection";
305 QGroupBox *groupPointsSelection =
new QGroupBox (tr (
"Points Selection"));
306 layoutRelations->addWidget (groupPointsSelection);
308 QGridLayout *layoutPointsSelections =
new QGridLayout;
309 groupPointsSelection->setLayout (layoutPointsSelections);
311 layoutPointsSelections->setColumnMinimumWidth(0, MIN_INDENT_COLUMN_WIDTH);
312 layoutPointsSelections->setColumnStretch (0, 0);
313 layoutPointsSelections->setColumnStretch (1, 0);
314 layoutPointsSelections->setColumnStretch (2, 0);
315 layoutPointsSelections->setColumnStretch (3, 1);
318 m_btnRelationsPointsEvenlySpaced =
new QRadioButton (tr (
"Interpolate Xs and Ys at evenly spaced intervals."));
319 m_btnRelationsPointsEvenlySpaced->setWhatsThis (tr (
"Exported file will have points evenly spaced along each relation, separated by the interval " 320 "selected below. If the last interval does not end at the last point, then a shorter last interval " 321 "is added that ends on the last point."));
322 layoutPointsSelections->addWidget (m_btnRelationsPointsEvenlySpaced, row++, 0, 1, 4);
323 connect (m_btnRelationsPointsEvenlySpaced, SIGNAL (released()),
this, SLOT (slotRelationsPointsEvenlySpaced()));
325 QLabel *labelInterval =
new QLabel (tr (
"Interval:"));
326 layoutPointsSelections->addWidget (labelInterval, row, 1, 1, 1, Qt::AlignRight);
328 m_editRelationsPointsEvenlySpacing =
new QLineEdit;
329 m_validatorRelationsPointsEvenlySpacing =
new QDoubleValidator;
330 m_editRelationsPointsEvenlySpacing->setValidator (m_validatorRelationsPointsEvenlySpacing);
331 m_editRelationsPointsEvenlySpacing->setMinimumWidth (MIN_EDIT_WIDTH);
332 m_editRelationsPointsEvenlySpacing->setMaximumWidth (MAX_EDIT_WIDTH);
333 m_editRelationsPointsEvenlySpacing->setWhatsThis (tr (
"Interval between successive points when " 334 "exporting at evenly spaced (X,Y) coordinates."));
335 layoutPointsSelections->addWidget (m_editRelationsPointsEvenlySpacing, row, 2, 1, 1, Qt::AlignLeft);
336 connect (m_editRelationsPointsEvenlySpacing, SIGNAL (textChanged(
const QString &)),
this, SLOT (slotRelationsPointsEvenlySpacedInterval(
const QString &)));
338 m_cmbRelationsPointsEvenlySpacingUnits =
new QComboBox;
339 m_cmbRelationsPointsEvenlySpacingUnits->setWhatsThis (tr (
"Units for spacing interval.\n\n" 340 "Pixel units are preferred when the spacing is to be independent of the X and Y scales. The spacing will be " 341 "consistent across the graph, even if a scale is logarithmic or the X and Y scales are different.\n\n" 342 "Graph units are usually preferred when the X and Y scales are identical."));
343 m_cmbRelationsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_GRAPH),
344 QVariant (EXPORT_POINTS_INTERVAL_UNITS_GRAPH));
345 m_cmbRelationsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_SCREEN),
346 QVariant (EXPORT_POINTS_INTERVAL_UNITS_SCREEN));
347 connect (m_cmbRelationsPointsEvenlySpacingUnits, SIGNAL (activated (
const QString &)),
348 this, SLOT (slotRelationsPointsEvenlySpacedIntervalUnits (
const QString &)));
349 layoutPointsSelections->addWidget (m_cmbRelationsPointsEvenlySpacingUnits, row++, 3, 1, 1, Qt::AlignLeft);
351 m_btnRelationsPointsRaw =
new QRadioButton (tr (
"Raw Xs and Ys"));
352 m_btnRelationsPointsRaw->setWhatsThis (tr (
"Exported file will have only original X and Y values"));
353 layoutPointsSelections->addWidget (m_btnRelationsPointsRaw, row++, 0, 1, 4);
354 connect (m_btnRelationsPointsRaw, SIGNAL (released()),
this, SLOT (slotRelationsPointsRaw()));
359 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createSubPanel";
361 QWidget *subPanel =
new QWidget ();
362 QGridLayout *layout =
new QGridLayout (subPanel);
363 subPanel->setLayout (layout);
366 createCurveSelection (layout, row);
368 createTabWidget (layout,
371 QWidget *widgetMisc =
new QWidget;
372 layout->addWidget (widgetMisc, row++, 0, 1, 3);
373 QHBoxLayout *layoutMisc =
new QHBoxLayout;
374 widgetMisc->setLayout (layoutMisc);
376 createDelimiters (layoutMisc);
377 createHeader (layoutMisc);
378 createFileLayout (layoutMisc);
380 createPreview (layout, row);
385 void DlgSettingsExportFormat::createTabWidget (QGridLayout *layout,
388 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createTabWidget";
390 m_tabWidget =
new QTabWidget;
392 layout->addWidget (m_tabWidget, row++, 0, 1, 3);
394 QWidget *widgetFunctions =
new QWidget;
395 int indexFunctions = m_tabWidget->addTab (widgetFunctions, tr (
"Functions"));
396 QWidget *tabFunctions = m_tabWidget->widget (indexFunctions);
397 tabFunctions->setWhatsThis (tr (
"Functions Tab\n\n" 398 "Controls for specifying the format of functions during export"));
399 QHBoxLayout *layoutFunctions =
new QHBoxLayout;
400 widgetFunctions->setLayout (layoutFunctions);
402 QWidget *widgetRelations =
new QWidget;
403 int indexRelations = m_tabWidget->addTab (widgetRelations, tr (
"Relations"));
404 QWidget *tabRelations = m_tabWidget->widget (indexRelations);
405 tabRelations->setWhatsThis (tr (
"Relations Tab\n\n" 406 "Controls for specifying the format of relations during export"));
407 QHBoxLayout *layoutRelations =
new QHBoxLayout;
408 widgetRelations->setLayout (layoutRelations);
411 connect (m_tabWidget, SIGNAL (currentChanged (
int)),
this, SLOT (slotTabChanged (
int)));
413 createFunctionsPointsSelection (layoutFunctions);
414 createRelationsPointsSelection (layoutRelations);
417 void DlgSettingsExportFormat::createXLabel (QGridLayout *layoutHeader,
420 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createXLabel";
426 title =
new QLabel (tr (
"X Label:"));
428 title =
new QLabel (tr (
"Theta Label:"));
430 layoutHeader->addWidget (title, row++, colLabel, 1, 1);
432 m_editXLabel =
new QLineEdit;
434 m_editXLabel->setWhatsThis (tr (
"Label in the header for x values"));
436 m_editXLabel->setWhatsThis (tr (
"Label in the header for theta values"));
438 layoutHeader->addWidget (m_editXLabel, row++, colLabel, 1, 1);
439 connect (m_editXLabel, SIGNAL (textChanged (
const QString &)),
this, SLOT (slotXLabel(
const QString &)));
442 bool DlgSettingsExportFormat::goodIntervalFunctions()
const 446 QString textFunctions = m_editFunctionsPointsEvenlySpacing->text();
449 bool isGood = (m_validatorFunctionsPointsEvenlySpacing->validate (textFunctions, posFunctions) == QValidator::Acceptable);
451 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::goodIntervalFunctions" 452 <<
" text=" << textFunctions.toLatin1().data()
453 <<
" good=" << (isGood ?
"true" :
"false")
454 <<
" bottom=" << m_validatorFunctionsPointsEvenlySpacing->bottom()
455 <<
" top=" << m_validatorFunctionsPointsEvenlySpacing->top();
460 bool DlgSettingsExportFormat::goodIntervalRelations()
const 464 QString textRelations = m_editRelationsPointsEvenlySpacing->text();
467 bool isGood = (m_validatorRelationsPointsEvenlySpacing->validate (textRelations, posRelations) == QValidator::Acceptable);
469 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::goodIntervalRelations" 470 <<
" text=" << textRelations.toLatin1().data()
471 <<
" good=" << (isGood ?
"true" :
"false")
472 <<
" bottom=" << m_validatorRelationsPointsEvenlySpacing->bottom()
473 <<
" top=" << m_validatorRelationsPointsEvenlySpacing->top();
480 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::handleOk";
484 *m_modelExportBefore,
485 *m_modelExportAfter);
491 void DlgSettingsExportFormat::initializeIntervalConstraints ()
493 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::initializeIntervalConstraints";
495 const int MAX_POINTS_ACROSS_RANGE = 5000;
500 Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
510 m_minIntervalGraph = maxSizeGraph / MAX_POINTS_ACROSS_RANGE;
511 m_minIntervalScreen = maxSizeScreen / MAX_POINTS_ACROSS_RANGE;
516 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::load";
521 if (m_modelExportBefore != 0) {
522 delete m_modelExportBefore;
524 if (m_modelExportAfter != 0) {
525 delete m_modelExportAfter;
533 m_listExcluded->clear();
535 QStringList::const_iterator itr;
536 for (itr = curveNamesExcluded.begin (); itr != curveNamesExcluded.end(); ++itr) {
537 QString curveNameNotExported = *itr;
538 m_listExcluded->addItem (curveNameNotExported);
542 m_listIncluded->clear();
544 for (itr = curveNamesAll.begin (); itr != curveNamesAll.end(); itr++) {
545 QString curveName = *itr;
546 if (!curveNamesExcluded.contains (curveName)) {
547 m_listIncluded->addItem (curveName);
552 m_btnFunctionsPointsAllCurves->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_ALL_CURVES);
553 m_btnFunctionsPointsFirstCurve->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_FIRST_CURVE);
554 m_btnFunctionsPointsEvenlySpaced->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_PERIODIC);
555 m_btnFunctionsPointsRaw->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_RAW);
557 ExportLayoutFunctions layoutFunctions = m_modelExportAfter->
layoutFunctions ();
558 m_btnFunctionsLayoutAllCurves->setChecked (layoutFunctions == EXPORT_LAYOUT_ALL_PER_LINE);
559 m_btnFunctionsLayoutOneCurve->setChecked (layoutFunctions == EXPORT_LAYOUT_ONE_PER_LINE);
562 m_btnRelationsPointsEvenlySpaced->setChecked (pointsSelectionRelations == EXPORT_POINTS_SELECTION_RELATIONS_INTERPOLATE);
563 m_btnRelationsPointsRaw->setChecked (pointsSelectionRelations == EXPORT_POINTS_SELECTION_RELATIONS_RAW);
565 ExportDelimiter delimiter = m_modelExportAfter->
delimiter ();
566 m_btnDelimitersCommas->setChecked (delimiter == EXPORT_DELIMITER_COMMA);
567 m_btnDelimitersSpaces->setChecked (delimiter == EXPORT_DELIMITER_SPACE);
568 m_btnDelimitersTabs->setChecked (delimiter == EXPORT_DELIMITER_TAB);
569 m_btnDelimitersSemicolons->setChecked (delimiter == EXPORT_DELIMITER_SEMICOLON);
571 m_chkOverrideCsvTsv->setChecked (m_modelExportAfter->
overrideCsvTsv());
573 ExportHeader header = m_modelExportAfter->
header ();
574 m_btnHeaderNone->setChecked (header == EXPORT_HEADER_NONE);
575 m_btnHeaderSimple->setChecked (header == EXPORT_HEADER_SIMPLE);
576 m_btnHeaderGnuplot->setChecked (header == EXPORT_HEADER_GNUPLOT);
578 m_editXLabel->setText (m_modelExportAfter->
xLabel());
585 int indexFunctions = m_cmbFunctionsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsFunctions));
586 int indexRelations = m_cmbRelationsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsRelations));
587 m_cmbFunctionsPointsEvenlySpacingUnits->setCurrentIndex (indexFunctions);
588 m_cmbRelationsPointsEvenlySpacingUnits->setCurrentIndex (indexRelations);
590 initializeIntervalConstraints ();
593 updateIntervalConstraints();
601 setMinimumHeight (MINIMUM_HEIGHT);
605 void DlgSettingsExportFormat::slotDelimitersCommas()
607 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersCommas";
609 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_COMMA);
614 void DlgSettingsExportFormat::slotDelimitersSemicolons()
616 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersSemicolons";
618 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_SEMICOLON);
623 void DlgSettingsExportFormat::slotDelimitersSpaces()
625 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersSpaces";
627 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_SPACE);
632 void DlgSettingsExportFormat::slotDelimitersTabs()
634 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersTabs";
641 void DlgSettingsExportFormat::slotExclude ()
643 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotExclude";
647 QStringList excluded;
648 for (i = 0; i < m_listIncluded->count(); i++) {
649 if (m_listIncluded->item(i)->isSelected()) {
650 excluded += m_listIncluded->item(i)->text();
655 for (i = 0; i < excluded.count(); i++) {
656 QString curveName = excluded.at (i);
657 m_listExcluded->addItem (curveName);
661 for (i = m_listIncluded->count() - 1; i>= 0; i--) {
662 QString curveName = m_listIncluded->item(i)->text();
663 if (excluded.contains (curveName)) {
664 QListWidgetItem *item = m_listIncluded->item (i);
665 m_listIncluded->removeItemWidget (item);
675 void DlgSettingsExportFormat::slotFunctionsLayoutAllCurves()
677 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsLayoutAllCurves";
684 void DlgSettingsExportFormat::slotFunctionsLayoutOneCurve()
686 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsLayoutOneCurve";
693 void DlgSettingsExportFormat::slotFunctionsPointsAllCurves()
695 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsAllCurves";
702 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced()
704 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced";
711 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval(
const QString &)
713 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval";
716 if (goodIntervalFunctions()) {
721 m_editPreview->setText(EMPTY_PREVIEW);
725 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits(
const QString &)
727 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits";
729 int index = m_cmbFunctionsPointsEvenlySpacingUnits->currentIndex();
730 ExportPointsIntervalUnits units = (ExportPointsIntervalUnits) m_cmbFunctionsPointsEvenlySpacingUnits->itemData (index).toInt();
733 updateIntervalConstraints();
738 void DlgSettingsExportFormat::slotFunctionsPointsFirstCurve()
740 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsFirstCurve";
747 void DlgSettingsExportFormat::slotFunctionsPointsRaw()
749 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsRaw";
756 void DlgSettingsExportFormat::slotHeaderGnuplot()
758 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderGnuplot";
760 m_modelExportAfter->
setHeader(EXPORT_HEADER_GNUPLOT);
765 void DlgSettingsExportFormat::slotHeaderNone()
767 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderNone";
769 m_modelExportAfter->
setHeader(EXPORT_HEADER_NONE);
774 void DlgSettingsExportFormat::slotHeaderSimple()
776 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderSimple";
778 m_modelExportAfter->
setHeader(EXPORT_HEADER_SIMPLE);
783 void DlgSettingsExportFormat::slotInclude ()
785 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotInclude";
789 QStringList included;
790 for (i = 0; i < m_listExcluded->count(); i++) {
791 if (m_listExcluded->item(i)->isSelected()) {
792 included += m_listExcluded->item(i)->text();
797 for (i = 0; i < included.count(); i++) {
798 QString curveName = included.at (i);
799 m_listIncluded->addItem (curveName);
803 QStringList excluded;
804 for (i = m_listExcluded->count() - 1; i>= 0; i--) {
805 QString curveName = m_listExcluded->item(i)->text();
806 QListWidgetItem *item = m_listExcluded->item (i);
807 if (included.contains (curveName)) {
808 m_listExcluded->removeItemWidget (item);
811 excluded += item->text();
820 void DlgSettingsExportFormat::slotListExcluded()
822 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotListExcluded";
828 void DlgSettingsExportFormat::slotListIncluded()
830 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotListIncluded";
836 void DlgSettingsExportFormat::slotOverrideCsvTsv(
int)
838 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotOverrideCsvTsv";
845 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced()
847 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced";
854 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval(
const QString &)
856 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval";
863 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits(
const QString &)
865 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits";
867 int index = m_cmbRelationsPointsEvenlySpacingUnits->currentIndex();
868 ExportPointsIntervalUnits units = (ExportPointsIntervalUnits) m_cmbRelationsPointsEvenlySpacingUnits->itemData (index).toInt();
871 updateIntervalConstraints();
876 void DlgSettingsExportFormat::slotRelationsPointsRaw()
878 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsRaw";
885 void DlgSettingsExportFormat::slotSaveDefault()
887 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotSaveDefault";
889 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
890 settings.beginGroup (SETTINGS_GROUP_EXPORT);
892 settings.setValue (SETTINGS_EXPORT_DELIMITER,
893 QVariant (m_modelExportAfter->
delimiter()));
894 settings.setValue (SETTINGS_EXPORT_HEADER,
895 QVariant (m_modelExportAfter->
header()));
896 settings.setValue (SETTINGS_EXPORT_LAYOUT_FUNCTIONS,
898 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_FUNCTIONS,
900 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_RELATIONS,
902 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_FUNCTIONS,
904 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_RELATIONS,
906 settings.setValue (SETTINGS_EXPORT_POINTS_SELECTION_FUNCTIONS,
908 settings.setValue (SETTINGS_EXPORT_POINTS_SELECTION_RELATIONS,
910 settings.setValue (SETTINGS_EXPORT_X_LABEL,
911 QVariant (m_modelExportAfter->
xLabel()));
913 settings.endGroup ();
916 void DlgSettingsExportFormat::slotTabChanged (
int)
918 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotTabChanged";
923 void DlgSettingsExportFormat::slotXLabel(
const QString &)
925 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotXLabel";
927 m_modelExportAfter->
setXLabel (m_editXLabel->text());
932 void DlgSettingsExportFormat::updateControls ()
934 bool isGoodState = goodIntervalFunctions() &&
935 goodIntervalRelations();
938 int selectedForInclude = m_listExcluded->selectedItems().count();
939 int selectedForExclude = m_listIncluded->selectedItems().count();
940 int inInclude = m_listIncluded->count();
942 m_btnInclude->setEnabled (selectedForInclude > 0);
943 m_btnExclude->setEnabled ((selectedForExclude > 0) && (inInclude - selectedForExclude > 0));
945 m_editFunctionsPointsEvenlySpacing->setEnabled (m_btnFunctionsPointsEvenlySpaced->isChecked ());
946 m_editRelationsPointsEvenlySpacing->setEnabled (m_btnRelationsPointsEvenlySpaced->isChecked ());
948 m_editXLabel->setEnabled (!m_btnHeaderNone->isChecked());
951 void DlgSettingsExportFormat::updateIntervalConstraints ()
955 m_minIntervalScreen);
958 m_minIntervalScreen);
960 if (m_tabWidget->currentIndex() == TAB_WIDGET_INDEX_FUNCTIONS) {
964 m_editFunctionsPointsEvenlySpacing->setText (QString::number (functionsMin));
968 m_validatorFunctionsPointsEvenlySpacing->setBottom (functionsMin);
974 m_editRelationsPointsEvenlySpacing->setText (QString::number (relationsMin));
978 m_validatorRelationsPointsEvenlySpacing->setBottom (relationsMin);
982 void DlgSettingsExportFormat::updatePreview()
985 int scrollPosition = m_editPreview->verticalScrollBar()->value();
987 QString exportedText;
988 QTextStream str (&exportedText);
990 if (
mainWindow().transformation().transformIsDefined()) {
993 if (m_tabWidget->currentIndex() == TAB_WIDGET_INDEX_FUNCTIONS) {
1014 str <<
"Preview is unavailable until axis points are defined.";
1017 m_editPreview->setText (exportedText);
1020 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.
void finishPanel(QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
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...
QRectF boundingRectGraph(bool &isEmpty) const
Graph coordinate bounding rectangle.
QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
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.