1 #include "CallbackBoundingRects.h"
2 #include "CmdMediator.h"
3 #include "CmdSettingsExportFormat.h"
4 #include "DocumentModelExportFormat.h"
5 #include "DlgSettingsExportFormat.h"
6 #include "ExportFileFunctions.h"
7 #include "ExportFileRelations.h"
9 #include "MainWindow.h"
10 #include "MainWindowModel.h"
12 #include <QDoubleValidator>
13 #include <QGridLayout>
15 #include <QHBoxLayout>
18 #include <QListWidget>
19 #include <QPushButton>
20 #include <QRadioButton>
25 #include <QTextStream>
26 #include <QVBoxLayout>
28 #include "Transformation.h"
30 const int MIN_INDENT_COLUMN_WIDTH = 20;
31 const int MIN_HEADER_EMPTY_COLUMN_WIDTH = 10;
32 const int MIN_EDIT_WIDTH = 110;
33 const int MAX_EDIT_WIDTH = 180;
35 const int TAB_WIDGET_INDEX_FUNCTIONS = 0;
36 const int TAB_WIDGET_INDEX_RELATIONS = 1;
38 const QString EMPTY_PREVIEW;
42 "DlgSettingsExportFormat",
44 m_modelExportBefore (0),
45 m_modelExportAfter (0)
47 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::DlgSettingsExportFormat";
53 DlgSettingsExportFormat::~DlgSettingsExportFormat()
55 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::~DlgSettingsExportFormat";
58 void DlgSettingsExportFormat::createCurveSelection (QGridLayout *layout,
int &row)
60 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createCurveSelection";
62 QLabel *labelIncluded =
new QLabel (tr (
"Included"));
63 layout->addWidget (labelIncluded, row, 0);
65 QLabel *labelExcluded =
new QLabel (tr (
"Not included"));
66 layout->addWidget (labelExcluded, row++, 2);
68 m_listIncluded =
new QListWidget;
69 m_listIncluded->setWhatsThis (tr (
"List of curves to be included in the exported file.\n\n"
70 "The order of the curves here does not affect the order in the exported file. That "
71 "order is determined by the Curves settings."));
72 m_listIncluded->setSelectionMode (QAbstractItemView::MultiSelection);
73 layout->addWidget (m_listIncluded, row, 0, 4, 1);
74 connect (m_listIncluded, SIGNAL (itemSelectionChanged ()),
this, SLOT (slotListIncluded()));
76 m_listExcluded =
new QListWidget;
77 m_listExcluded->setWhatsThis (tr (
"List of curves to be excluded from the exported file"));
78 m_listExcluded->setSelectionMode (QAbstractItemView::MultiSelection);
79 layout->addWidget (m_listExcluded, row++, 2, 4, 1);
80 connect (m_listExcluded, SIGNAL (itemSelectionChanged ()),
this, SLOT (slotListExcluded()));
82 m_btnInclude =
new QPushButton (tr (
"<<Include"));
83 m_btnInclude->setEnabled (
false);
84 m_btnInclude->setWhatsThis (tr (
"Move the currently selected curve(s) from the excluded list"));
85 layout->addWidget (m_btnInclude, row++, 1);
86 connect (m_btnInclude, SIGNAL (released ()),
this, SLOT (slotInclude()));
88 m_btnExclude =
new QPushButton (tr (
"Exclude>>"));
89 m_btnExclude->setEnabled (
false);
90 m_btnExclude->setWhatsThis (tr (
"Move the currently selected curve(s) from the included list"));
91 layout->addWidget (m_btnExclude, row++, 1);
92 connect (m_btnExclude, SIGNAL (released ()),
this, SLOT (slotExclude()));
97 void DlgSettingsExportFormat::createDelimiters (QHBoxLayout *layoutMisc)
99 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createDelimiters";
101 QGroupBox *groupDelimiters =
new QGroupBox (tr (
"Default Delimiters"));
102 layoutMisc->addWidget (groupDelimiters, 1);
104 QVBoxLayout *layoutDelimiters =
new QVBoxLayout;
105 groupDelimiters->setLayout (layoutDelimiters);
107 m_btnDelimitersCommas =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_COMMA));
108 m_btnDelimitersCommas->setWhatsThis (tr (
"Exported file will have commas between adjacent values.\n\n"
109 "This setting is overridden for TSV files"));
110 layoutDelimiters->addWidget (m_btnDelimitersCommas);
111 connect (m_btnDelimitersCommas, SIGNAL (released ()),
this, SLOT (slotDelimitersCommas()));
113 m_btnDelimitersSpaces =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_SPACE));
114 m_btnDelimitersSpaces->setWhatsThis (tr (
"Exported file will have spaces between adjacent values.\n\n"
115 "This setting is overridden for CSV and TSV files"));
116 layoutDelimiters->addWidget (m_btnDelimitersSpaces);
117 connect (m_btnDelimitersSpaces, SIGNAL (released ()),
this, SLOT (slotDelimitersSpaces()));
119 m_btnDelimitersTabs =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_TAB));
120 m_btnDelimitersTabs->setWhatsThis (tr (
"Exported file will have tabs between adjacent values.\n\n"
121 "This setting is overridden for CSV files"));
122 layoutDelimiters->addWidget (m_btnDelimitersTabs);
123 connect (m_btnDelimitersTabs, SIGNAL (released ()),
this, SLOT (slotDelimitersTabs()));
126 void DlgSettingsExportFormat::createFileLayout (QHBoxLayout *layoutMisc)
128 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createFileLayout";
130 QGroupBox *groupLayout =
new QGroupBox (tr (
"Layout"));
131 layoutMisc->addWidget (groupLayout, 1);
133 QVBoxLayout *layoutLayout =
new QVBoxLayout;
134 groupLayout->setLayout (layoutLayout);
136 m_btnFunctionsLayoutAllCurves =
new QRadioButton (tr (
"All curves on each line"));
137 m_btnFunctionsLayoutAllCurves->setWhatsThis (tr (
"Exported file will have, on each line, "
138 "an X value, the Y value for the first curve, the Y value for the second curve,..."));
139 layoutLayout->addWidget (m_btnFunctionsLayoutAllCurves);
140 connect (m_btnFunctionsLayoutAllCurves, SIGNAL (released()),
this, SLOT (slotFunctionsLayoutAllCurves ()));
142 m_btnFunctionsLayoutOneCurve =
new QRadioButton (tr (
"One curve on each line"));
143 m_btnFunctionsLayoutOneCurve->setWhatsThis (tr (
"Exported file will have all the points for "
144 "the first curve, with one X-Y pair on each line, then the points for the second curve,..."));
145 layoutLayout->addWidget (m_btnFunctionsLayoutOneCurve);
146 connect (m_btnFunctionsLayoutOneCurve, SIGNAL (released()),
this, SLOT (slotFunctionsLayoutOneCurve ()));
149 void DlgSettingsExportFormat::createFunctionsPointsSelection (QHBoxLayout *layoutFunctions)
151 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createFunctionsPointsSelection";
153 QGroupBox *groupPointsSelection =
new QGroupBox (tr (
"Points Selection"));
154 layoutFunctions->addWidget (groupPointsSelection, 1);
156 QGridLayout *layoutPointsSelections =
new QGridLayout;
157 groupPointsSelection->setLayout (layoutPointsSelections);
159 layoutPointsSelections->setColumnMinimumWidth(0, MIN_INDENT_COLUMN_WIDTH);
160 layoutPointsSelections->setColumnStretch (0, 0);
161 layoutPointsSelections->setColumnStretch (1, 0);
162 layoutPointsSelections->setColumnStretch (2, 0);
163 layoutPointsSelections->setColumnStretch (3, 1);
166 m_btnFunctionsPointsAllCurves =
new QRadioButton (tr (
"Interpolate Ys at Xs from all curves"));
167 m_btnFunctionsPointsAllCurves->setWhatsThis (tr (
"Exported file will have values at every unique X "
168 "value from every curve. Y values will be linearly interpolated if necessary"));
169 layoutPointsSelections->addWidget (m_btnFunctionsPointsAllCurves, row++, 0, 1, 4);
170 connect (m_btnFunctionsPointsAllCurves, SIGNAL (released()),
this, SLOT (slotFunctionsPointsAllCurves()));
172 m_btnFunctionsPointsFirstCurve =
new QRadioButton (tr (
"Interpolate Ys at Xs from first curve"));
173 m_btnFunctionsPointsFirstCurve->setWhatsThis (tr (
"Exported file will have values at every unique X "
174 "value from the first curve. Y values will be linearly interpolated if necessary"));
175 layoutPointsSelections->addWidget (m_btnFunctionsPointsFirstCurve, row++, 0, 1, 4);
176 connect (m_btnFunctionsPointsFirstCurve, SIGNAL (released()),
this, SLOT (slotFunctionsPointsFirstCurve()));
178 m_btnFunctionsPointsEvenlySpaced =
new QRadioButton (tr (
"Interpolate Ys at evenly spaced X values."));
179 m_btnFunctionsPointsEvenlySpaced->setWhatsThis (tr (
"Exported file will have values at evenly spaced X values, separated by the interval selected below."));
180 layoutPointsSelections->addWidget (m_btnFunctionsPointsEvenlySpaced, row++, 0, 1, 4);
181 connect (m_btnFunctionsPointsEvenlySpaced, SIGNAL (released()),
this, SLOT (slotFunctionsPointsEvenlySpaced()));
183 QLabel *labelInterval =
new QLabel (
"Interval:");
184 layoutPointsSelections->addWidget (labelInterval, row, 1, 1, 1, Qt::AlignRight);
186 m_editFunctionsPointsEvenlySpacing =
new QLineEdit;
187 m_validatorFunctionsPointsEvenlySpacing =
new QDoubleValidator;
188 m_editFunctionsPointsEvenlySpacing->setValidator (m_validatorFunctionsPointsEvenlySpacing);
189 m_editFunctionsPointsEvenlySpacing->setMinimumWidth (MIN_EDIT_WIDTH);
190 m_editFunctionsPointsEvenlySpacing->setMaximumWidth (MAX_EDIT_WIDTH);
191 m_editFunctionsPointsEvenlySpacing->setWhatsThis (tr (
"Interval, in the units of X, between successive points in the X direction.\n\n"
192 "If the scale is linear, then this interval is added to successive X values. If the scale is "
193 "logarithmic, then this interval is multiplied to successive X values.\n\n"
194 "The X values will be automatically aligned along simple numbers. If the first and/or last "
195 "points are not along the aligned X values, then one or two additional points are added "
197 layoutPointsSelections->addWidget (m_editFunctionsPointsEvenlySpacing, row, 2, 1, 1, Qt::AlignLeft);
198 connect (m_editFunctionsPointsEvenlySpacing, SIGNAL (textChanged(
const QString &)),
this, SLOT (slotFunctionsPointsEvenlySpacedInterval(
const QString &)));
200 m_cmbFunctionsPointsEvenlySpacingUnits =
new QComboBox;
201 m_cmbFunctionsPointsEvenlySpacingUnits->setWhatsThis (
"Units for spacing interval.\n\n"
202 "Pixel units are preferred when the spacing is to be independent of the X scale. The spacing will be "
203 "consistent across the graph, even if the X scale is logarithmic.\n\n"
204 "Graph units are preferred when the spacing is to depend on the X scale.");
205 m_cmbFunctionsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_GRAPH),
206 QVariant (EXPORT_POINTS_INTERVAL_UNITS_GRAPH));
207 m_cmbFunctionsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_SCREEN),
208 QVariant (EXPORT_POINTS_INTERVAL_UNITS_SCREEN));
209 connect (m_cmbFunctionsPointsEvenlySpacingUnits, SIGNAL (activated (
const QString &)),
210 this, SLOT (slotFunctionsPointsEvenlySpacedIntervalUnits (
const QString &)));
211 layoutPointsSelections->addWidget (m_cmbFunctionsPointsEvenlySpacingUnits, row++, 3, 1, 1, Qt::AlignLeft);
213 m_btnFunctionsPointsRaw =
new QRadioButton (tr (
"Raw Xs and Ys"));
214 m_btnFunctionsPointsRaw->setWhatsThis (tr (
"Exported file will have only original X and Y values"));
215 layoutPointsSelections->addWidget (m_btnFunctionsPointsRaw, row++, 0, 1, 4);
216 connect (m_btnFunctionsPointsRaw, SIGNAL (released()),
this, SLOT (slotFunctionsPointsRaw()));
219 void DlgSettingsExportFormat::createHeader (QHBoxLayout *layoutMisc)
221 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createHeader";
223 const int COLUMN_RADIO_BUTTONS = 0, COLUMN_EMPTY = 1, COLUMN_LABEL = 2;
225 QGroupBox *groupHeader =
new QGroupBox (tr (
"Header"));
226 layoutMisc->addWidget (groupHeader, 1);
228 QGridLayout *layoutHeader =
new QGridLayout;
229 layoutHeader->setColumnMinimumWidth(COLUMN_EMPTY,
230 MIN_HEADER_EMPTY_COLUMN_WIDTH);
231 groupHeader->setLayout (layoutHeader);
234 m_btnHeaderNone =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_NONE));
235 m_btnHeaderNone->setWhatsThis (tr (
"Exported file will have no header line"));
236 layoutHeader->addWidget (m_btnHeaderNone, row++, COLUMN_RADIO_BUTTONS, 1, 1);
237 connect (m_btnHeaderNone, SIGNAL (released ()),
this, SLOT (slotHeaderNone()));
239 m_btnHeaderSimple =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_SIMPLE));
240 m_btnHeaderSimple->setWhatsThis (tr (
"Exported file will have simple header line"));
241 layoutHeader->addWidget (m_btnHeaderSimple, row++, COLUMN_RADIO_BUTTONS, 1, 1);
242 connect (m_btnHeaderSimple, SIGNAL (released ()),
this, SLOT (slotHeaderSimple()));
244 m_btnHeaderGnuplot =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_GNUPLOT));
245 m_btnHeaderGnuplot->setWhatsThis (tr (
"Exported file will have gnuplot header line"));
246 layoutHeader->addWidget (m_btnHeaderGnuplot, row++, COLUMN_RADIO_BUTTONS, 1, 1);
247 connect (m_btnHeaderGnuplot, SIGNAL (released()),
this, SLOT (slotHeaderGnuplot()));
249 createXLabel (layoutHeader,
255 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createOptionalSaveDefault";
257 m_btnSaveDefault =
new QPushButton (
"Save As Default");
258 m_btnSaveDefault->setWhatsThis (tr (
"Save the settings for use as future defaults."));
259 connect (m_btnSaveDefault, SIGNAL (released ()),
this, SLOT (slotSaveDefault ()));
260 layout->addWidget (m_btnSaveDefault, 0, Qt::AlignLeft);
263 void DlgSettingsExportFormat::createPreview(QGridLayout *layout,
int &row)
265 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createPreview";
267 QLabel *label =
new QLabel (tr (
"Preview"));
268 layout->addWidget (label, row++, 0, 1, 3);
270 m_editPreview =
new QTextEdit;
271 m_editPreview->setReadOnly (
true);
272 m_editPreview->setWhatsThis (tr (
"Preview window shows how current settings affect the exported file"));
275 layout->addWidget (m_editPreview, row++, 0, 1, 3);
278 void DlgSettingsExportFormat::createRelationsPointsSelection (QHBoxLayout *layoutRelations)
280 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createRelationsPointsSelection";
282 QGroupBox *groupPointsSelection =
new QGroupBox (tr (
"Points Selection"));
283 layoutRelations->addWidget (groupPointsSelection);
285 QGridLayout *layoutPointsSelections =
new QGridLayout;
286 groupPointsSelection->setLayout (layoutPointsSelections);
288 layoutPointsSelections->setColumnMinimumWidth(0, MIN_INDENT_COLUMN_WIDTH);
289 layoutPointsSelections->setColumnStretch (0, 0);
290 layoutPointsSelections->setColumnStretch (1, 0);
291 layoutPointsSelections->setColumnStretch (2, 0);
292 layoutPointsSelections->setColumnStretch (3, 1);
295 m_btnRelationsPointsEvenlySpaced =
new QRadioButton (tr (
"Interpolate Xs and Ys at evenly spaced intervals."));
296 m_btnRelationsPointsEvenlySpaced->setWhatsThis (tr (
"Exported file will have points evenly spaced along each relation, separated by the interval "
297 "selected below. If the last interval does not end at the last point, then a shorter last interval "
298 "is added that ends on the last point."));
299 layoutPointsSelections->addWidget (m_btnRelationsPointsEvenlySpaced, row++, 0, 1, 4);
300 connect (m_btnRelationsPointsEvenlySpaced, SIGNAL (released()),
this, SLOT (slotRelationsPointsEvenlySpaced()));
302 QLabel *labelInterval =
new QLabel (
"Interval:");
303 layoutPointsSelections->addWidget (labelInterval, row, 1, 1, 1, Qt::AlignRight);
305 m_editRelationsPointsEvenlySpacing =
new QLineEdit;
306 m_validatorRelationsPointsEvenlySpacing =
new QDoubleValidator;
307 m_editRelationsPointsEvenlySpacing->setValidator (m_validatorRelationsPointsEvenlySpacing);
308 m_editRelationsPointsEvenlySpacing->setMinimumWidth (MIN_EDIT_WIDTH);
309 m_editRelationsPointsEvenlySpacing->setMaximumWidth (MAX_EDIT_WIDTH);
310 m_editRelationsPointsEvenlySpacing->setWhatsThis (tr (
"Interval between successive points when "
311 "exporting at evenly spaced (X,Y) coordinates."));
312 layoutPointsSelections->addWidget (m_editRelationsPointsEvenlySpacing, row, 2, 1, 1, Qt::AlignLeft);
313 connect (m_editRelationsPointsEvenlySpacing, SIGNAL (textChanged(
const QString &)),
this, SLOT (slotRelationsPointsEvenlySpacedInterval(
const QString &)));
315 m_cmbRelationsPointsEvenlySpacingUnits =
new QComboBox;
316 m_cmbRelationsPointsEvenlySpacingUnits->setWhatsThis (
"Units for spacing interval.\n\n"
317 "Pixel units are preferred when the spacing is to be independent of the X and Y scales. The spacing will be "
318 "consistent across the graph, even if a scale is logarithmic or the X and Y scales are different.\n\n"
319 "Graph units are usually preferred when the X and Y scales are identical.");
320 m_cmbRelationsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_GRAPH),
321 QVariant (EXPORT_POINTS_INTERVAL_UNITS_GRAPH));
322 m_cmbRelationsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_SCREEN),
323 QVariant (EXPORT_POINTS_INTERVAL_UNITS_SCREEN));
324 connect (m_cmbRelationsPointsEvenlySpacingUnits, SIGNAL (activated (
const QString &)),
325 this, SLOT (slotRelationsPointsEvenlySpacedIntervalUnits (
const QString &)));
326 layoutPointsSelections->addWidget (m_cmbRelationsPointsEvenlySpacingUnits, row++, 3, 1, 1, Qt::AlignLeft);
328 m_btnRelationsPointsRaw =
new QRadioButton (tr (
"Raw Xs and Ys"));
329 m_btnRelationsPointsRaw->setWhatsThis (tr (
"Exported file will have only original X and Y values"));
330 layoutPointsSelections->addWidget (m_btnRelationsPointsRaw, row++, 0, 1, 4);
331 connect (m_btnRelationsPointsRaw, SIGNAL (released()),
this, SLOT (slotRelationsPointsRaw()));
336 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createSubPanel";
338 QWidget *subPanel =
new QWidget ();
339 QGridLayout *layout =
new QGridLayout (subPanel);
340 subPanel->setLayout (layout);
343 createCurveSelection (layout, row);
345 createTabWidget (layout,
348 QWidget *widgetMisc =
new QWidget;
349 layout->addWidget (widgetMisc, row++, 0, 1, 3);
350 QHBoxLayout *layoutMisc =
new QHBoxLayout;
351 widgetMisc->setLayout (layoutMisc);
353 createDelimiters (layoutMisc);
354 createHeader (layoutMisc);
355 createFileLayout (layoutMisc);
357 createPreview (layout, row);
362 void DlgSettingsExportFormat::createTabWidget (QGridLayout *layout,
365 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createTabWidget";
367 m_tabWidget =
new QTabWidget;
369 layout->addWidget (m_tabWidget, row++, 0, 1, 3);
371 QWidget *widgetFunctions =
new QWidget;
372 int indexFunctions = m_tabWidget->addTab (widgetFunctions, tr (
"Functions"));
373 QWidget *tabFunctions = m_tabWidget->widget (indexFunctions);
374 tabFunctions->setWhatsThis (tr (
"Functions Tab\n\n"
375 "Controls for specifying the format of functions during export"));
376 QHBoxLayout *layoutFunctions =
new QHBoxLayout;
377 widgetFunctions->setLayout (layoutFunctions);
379 QWidget *widgetRelations =
new QWidget;
380 int indexRelations = m_tabWidget->addTab (widgetRelations, tr (
"Relations"));
381 QWidget *tabRelations = m_tabWidget->widget (indexRelations);
382 tabRelations->setWhatsThis (tr (
"Relations Tab\n\n"
383 "Controls for specifying the format of relations during export"));
384 QHBoxLayout *layoutRelations =
new QHBoxLayout;
385 widgetRelations->setLayout (layoutRelations);
388 connect (m_tabWidget, SIGNAL (currentChanged (
int)),
this, SLOT (slotTabChanged (
int)));
390 createFunctionsPointsSelection (layoutFunctions);
391 createRelationsPointsSelection (layoutRelations);
394 void DlgSettingsExportFormat::createXLabel (QGridLayout *layoutHeader,
397 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createXLabel";
403 title =
new QLabel (tr (
"X Label:"));
405 title =
new QLabel (tr (
"Theta Label:"));
407 layoutHeader->addWidget (title, row++, colLabel, 1, 1);
409 m_editXLabel =
new QLineEdit;
411 m_editXLabel->setWhatsThis (tr (
"Label in the header for x values"));
413 m_editXLabel->setWhatsThis (tr (
"Label in the header for theta values"));
415 layoutHeader->addWidget (m_editXLabel, row++, colLabel, 1, 1);
416 connect (m_editXLabel, SIGNAL (textChanged (
const QString &)),
this, SLOT (slotXLabel(
const QString &)));
419 bool DlgSettingsExportFormat::goodIntervalFunctions()
const
421 QString textFunctions = m_editFunctionsPointsEvenlySpacing->text();
424 bool isGood = (m_validatorFunctionsPointsEvenlySpacing->validate (textFunctions, posFunctions) == QValidator::Acceptable);
429 bool DlgSettingsExportFormat::goodIntervalRelations()
const
431 QString textRelations = m_editRelationsPointsEvenlySpacing->text();
434 return (m_validatorRelationsPointsEvenlySpacing->validate (textRelations, posRelations) == QValidator::Acceptable);
439 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::handleOk";
443 *m_modelExportBefore,
444 *m_modelExportAfter);
450 void DlgSettingsExportFormat::initializeIntervalConstraints ()
452 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::initializeIntervalConstraints";
454 const int MAX_POINTS_ACROSS_RANGE = 1000;
459 Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
465 double maxSizeGraph = qMax (ftor.boundingRectGraph(isEmpty).width(),
466 ftor.boundingRectGraph(isEmpty).height());
467 double maxSizeScreen = qMax (ftor.boundingRectScreen(isEmpty).width(),
468 ftor.boundingRectScreen(isEmpty).height());
469 m_minIntervalGraph = maxSizeGraph / MAX_POINTS_ACROSS_RANGE;
470 m_minIntervalScreen = maxSizeScreen / MAX_POINTS_ACROSS_RANGE;
475 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::load";
480 if (m_modelExportBefore != 0) {
481 delete m_modelExportBefore;
483 if (m_modelExportAfter != 0) {
484 delete m_modelExportAfter;
492 m_listExcluded->clear();
494 QStringList::const_iterator itr;
495 for (itr = curveNamesExcluded.begin (); itr != curveNamesExcluded.end(); ++itr) {
496 QString curveNameNotExported = *itr;
497 m_listExcluded->addItem (curveNameNotExported);
501 m_listIncluded->clear();
503 for (itr = curveNamesAll.begin (); itr != curveNamesAll.end(); itr++) {
504 QString curveName = *itr;
505 if (!curveNamesExcluded.contains (curveName)) {
506 m_listIncluded->addItem (curveName);
511 m_btnFunctionsPointsAllCurves->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_ALL_CURVES);
512 m_btnFunctionsPointsFirstCurve->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_FIRST_CURVE);
513 m_btnFunctionsPointsEvenlySpaced->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_PERIODIC);
514 m_btnFunctionsPointsRaw->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_RAW);
516 ExportLayoutFunctions layoutFunctions = m_modelExportAfter->
layoutFunctions ();
517 m_btnFunctionsLayoutAllCurves->setChecked (layoutFunctions == EXPORT_LAYOUT_ALL_PER_LINE);
518 m_btnFunctionsLayoutOneCurve->setChecked (layoutFunctions == EXPORT_LAYOUT_ONE_PER_LINE);
521 m_btnRelationsPointsEvenlySpaced->setChecked (pointsSelectionRelations == EXPORT_POINTS_SELECTION_RELATIONS_INTERPOLATE);
522 m_btnRelationsPointsRaw->setChecked (pointsSelectionRelations == EXPORT_POINTS_SELECTION_RELATIONS_RAW);
524 ExportDelimiter delimiter = m_modelExportAfter->
delimiter ();
525 m_btnDelimitersCommas->setChecked (delimiter == EXPORT_DELIMITER_COMMA);
526 m_btnDelimitersSpaces->setChecked (delimiter == EXPORT_DELIMITER_SPACE);
527 m_btnDelimitersTabs->setChecked (delimiter == EXPORT_DELIMITER_TAB);
529 ExportHeader header = m_modelExportAfter->
header ();
530 m_btnHeaderNone->setChecked (header == EXPORT_HEADER_NONE);
531 m_btnHeaderSimple->setChecked (header == EXPORT_HEADER_SIMPLE);
532 m_btnHeaderGnuplot->setChecked (header == EXPORT_HEADER_GNUPLOT);
534 m_editXLabel->setText (m_modelExportAfter->
xLabel());
540 int indexFunctions = m_cmbRelationsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsFunctions));
541 int indexRelations = m_cmbRelationsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsRelations));
542 m_cmbFunctionsPointsEvenlySpacingUnits->setCurrentIndex (indexFunctions);
543 m_cmbRelationsPointsEvenlySpacingUnits->setCurrentIndex (indexRelations);
545 initializeIntervalConstraints ();
548 updateIntervalConstraints();
553 void DlgSettingsExportFormat::slotDelimitersCommas()
555 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersCommas";
557 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_COMMA);
562 void DlgSettingsExportFormat::slotDelimitersSpaces()
564 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersSpaces";
566 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_SPACE);
571 void DlgSettingsExportFormat::slotDelimitersTabs()
573 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersTabs";
580 void DlgSettingsExportFormat::slotExclude ()
582 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotExclude";
586 QStringList excluded;
587 for (i = 0; i < m_listIncluded->count(); i++) {
588 if (m_listIncluded->item(i)->isSelected()) {
589 excluded += m_listIncluded->item(i)->text();
594 for (i = 0; i < excluded.count(); i++) {
595 QString curveName = excluded.at (i);
596 m_listExcluded->addItem (curveName);
600 for (i = m_listIncluded->count() - 1; i>= 0; i--) {
601 QString curveName = m_listIncluded->item(i)->text();
602 if (excluded.contains (curveName)) {
603 QListWidgetItem *item = m_listIncluded->item (i);
604 m_listIncluded->removeItemWidget (item);
614 void DlgSettingsExportFormat::slotFunctionsLayoutAllCurves()
616 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsLayoutAllCurves";
623 void DlgSettingsExportFormat::slotFunctionsLayoutOneCurve()
625 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsLayoutOneCurve";
632 void DlgSettingsExportFormat::slotFunctionsPointsAllCurves()
634 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsAllCurves";
641 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced()
643 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced";
650 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval(
const QString &)
652 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval";
655 if (goodIntervalFunctions()) {
660 m_editPreview->setText(EMPTY_PREVIEW);
664 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits(
const QString &)
666 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits";
668 int index = m_cmbFunctionsPointsEvenlySpacingUnits->currentIndex();
669 ExportPointsIntervalUnits units = (ExportPointsIntervalUnits) m_cmbFunctionsPointsEvenlySpacingUnits->itemData (index).toInt();
672 updateIntervalConstraints();
677 void DlgSettingsExportFormat::slotFunctionsPointsFirstCurve()
679 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsFirstCurve";
686 void DlgSettingsExportFormat::slotFunctionsPointsRaw()
688 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsRaw";
695 void DlgSettingsExportFormat::slotHeaderGnuplot()
697 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderGnuplot";
699 m_modelExportAfter->
setHeader(EXPORT_HEADER_GNUPLOT);
704 void DlgSettingsExportFormat::slotHeaderNone()
706 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderNone";
708 m_modelExportAfter->
setHeader(EXPORT_HEADER_NONE);
713 void DlgSettingsExportFormat::slotHeaderSimple()
715 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderSimple";
717 m_modelExportAfter->
setHeader(EXPORT_HEADER_SIMPLE);
722 void DlgSettingsExportFormat::slotInclude ()
724 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotInclude";
728 QStringList included;
729 for (i = 0; i < m_listExcluded->count(); i++) {
730 if (m_listExcluded->item(i)->isSelected()) {
731 included += m_listExcluded->item(i)->text();
736 for (i = 0; i < included.count(); i++) {
737 QString curveName = included.at (i);
738 m_listIncluded->addItem (curveName);
742 QStringList excluded;
743 for (i = m_listExcluded->count() - 1; i>= 0; i--) {
744 QString curveName = m_listExcluded->item(i)->text();
745 QListWidgetItem *item = m_listExcluded->item (i);
746 if (included.contains (curveName)) {
747 m_listExcluded->removeItemWidget (item);
750 excluded += item->text();
759 void DlgSettingsExportFormat::slotListExcluded()
761 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotListExcluded";
767 void DlgSettingsExportFormat::slotListIncluded()
769 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotListIncluded";
775 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced()
777 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced";
784 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval(
const QString &)
786 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval";
793 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits(
const QString &)
795 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits";
797 int index = m_cmbRelationsPointsEvenlySpacingUnits->currentIndex();
798 ExportPointsIntervalUnits units = (ExportPointsIntervalUnits) m_cmbRelationsPointsEvenlySpacingUnits->itemData (index).toInt();
801 updateIntervalConstraints();
806 void DlgSettingsExportFormat::slotRelationsPointsRaw()
808 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsRaw";
815 void DlgSettingsExportFormat::slotSaveDefault()
817 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotSaveDefault";
819 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
820 settings.beginGroup (SETTINGS_GROUP_EXPORT);
822 settings.setValue (SETTINGS_EXPORT_DELIMITER,
823 QVariant (m_modelExportAfter->
delimiter()));
824 settings.setValue (SETTINGS_EXPORT_HEADER,
825 QVariant (m_modelExportAfter->
header()));
826 settings.setValue (SETTINGS_EXPORT_LAYOUT_FUNCTIONS,
828 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_FUNCTIONS,
830 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_RELATIONS,
832 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_FUNCTIONS,
834 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_RELATIONS,
836 settings.setValue (SETTINGS_EXPORT_POINTS_SELECTION_FUNCTIONS,
838 settings.setValue (SETTINGS_EXPORT_POINTS_SELECTION_RELATIONS,
840 settings.setValue (SETTINGS_EXPORT_X_LABEL,
841 QVariant (m_modelExportAfter->
xLabel()));
843 settings.endGroup ();
846 void DlgSettingsExportFormat::slotTabChanged (
int)
848 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotTabChanged";
853 void DlgSettingsExportFormat::slotXLabel(
const QString &)
855 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotXLabel";
857 m_modelExportAfter->
setXLabel (m_editXLabel->text());
862 void DlgSettingsExportFormat::updateControls ()
864 bool isGoodState = goodIntervalFunctions() &&
865 goodIntervalRelations();
868 m_listIncluded->sortItems (Qt::AscendingOrder);
869 m_listExcluded->sortItems (Qt::AscendingOrder);
871 int selectedForInclude = m_listExcluded->selectedItems().count();
872 int selectedForExclude = m_listIncluded->selectedItems().count();
873 int inInclude = m_listIncluded->count();
875 m_btnInclude->setEnabled (selectedForInclude > 0);
876 m_btnExclude->setEnabled ((selectedForExclude > 0) && (inInclude - selectedForExclude > 0));
878 m_editFunctionsPointsEvenlySpacing->setEnabled (m_btnFunctionsPointsEvenlySpaced->isChecked ());
879 m_editRelationsPointsEvenlySpacing->setEnabled (m_btnRelationsPointsEvenlySpaced->isChecked ());
881 m_editXLabel->setEnabled (!m_btnHeaderNone->isChecked());
884 void DlgSettingsExportFormat::updateIntervalConstraints ()
888 m_minIntervalScreen);
891 m_minIntervalScreen);
893 if (m_tabWidget->currentIndex() == TAB_WIDGET_INDEX_FUNCTIONS) {
897 m_editFunctionsPointsEvenlySpacing->setText (QString::number (functionsMin));
901 m_validatorFunctionsPointsEvenlySpacing->setBottom (functionsMin);
907 m_editRelationsPointsEvenlySpacing->setText (QString::number (relationsMin));
908 m_validatorFunctionsPointsEvenlySpacing->setBottom (relationsMin);
912 m_validatorRelationsPointsEvenlySpacing->setBottom (relationsMin);
916 void DlgSettingsExportFormat::updatePreview()
919 int scrollPosition = m_editPreview->verticalScrollBar()->value();
921 QString exportedText;
922 QTextStream str (&exportedText);
924 if (
mainWindow().transformation().transformIsDefined()) {
927 if (m_tabWidget->currentIndex() == TAB_WIDGET_INDEX_FUNCTIONS) {
948 str <<
"Preview is unavailable until axis points are defined.";
951 m_editPreview->setText (exportedText);
954 m_editPreview->verticalScrollBar()->setValue (scrollPosition);
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
void exportToFile(const DocumentModelExportFormat &modelExportOverride, const Document &document, const MainWindowModel &modelMainWindow, const Transformation &transformation, QTextStream &str) const
Export Document points according to the settings.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
Strategy class for exporting to a file. This strategy is external to the Document class so that class...
QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
void finishPanel(QWidget *subPanel)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
static int MINIMUM_PREVIEW_HEIGHT
Dialog layout constant that guarantees preview has sufficent room.
void enableOk(bool enable)
Let leaf subclass control the Ok button.
Strategy class for exporting to a file. This strategy is external to the Document class so that class...
Abstract base class for all Settings dialogs.
Callback for computing the bounding rectangles of the screen and graph coordinates of the points in t...
MainWindow & mainWindow()
Get method for MainWindow.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.
void exportToFile(const DocumentModelExportFormat &modelExportOverride, const Document &document, const MainWindowModel &modelMainWindow, const Transformation &transformation, QTextStream &str) const
Export Document points according to the settings.