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"
18#include <QDoubleValidator>
26#include <QRadioButton>
34#include "Transformation.h"
36const int MIN_INDENT_COLUMN_WIDTH = 20;
37const int MIN_HEADER_EMPTY_COLUMN_WIDTH = 10;
38const int MIN_EDIT_WIDTH = 110;
39const int MAX_EDIT_WIDTH = 180;
41const int TAB_WIDGET_INDEX_FUNCTIONS = 0;
44const QString EMPTY_PREVIEW;
48 "DlgSettingsExportFormat",
50 m_modelExportBefore (0),
51 m_modelExportAfter (0)
53 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::DlgSettingsExportFormat";
59DlgSettingsExportFormat::~DlgSettingsExportFormat()
61 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::~DlgSettingsExportFormat";
64void DlgSettingsExportFormat::createCurveSelection (QGridLayout *layout,
int &row)
66 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createCurveSelection";
68 QLabel *labelIncluded =
new QLabel (tr (
"Included"));
69 layout->addWidget (labelIncluded, row, 0);
71 QLabel *labelExcluded =
new QLabel (tr (
"Not included"));
72 layout->addWidget (labelExcluded, row++, 2);
74 m_listIncluded =
new QListWidget;
75 m_listIncluded->setWhatsThis (tr (
"List of curves to be included in the exported file.\n\n"
76 "The order of the curves here does not affect the order in the exported file. That "
77 "order is determined by the Curves settings."));
78 m_listIncluded->setSelectionMode (QAbstractItemView::MultiSelection);
79 layout->addWidget (m_listIncluded, row, 0, 4, 1);
80 connect (m_listIncluded, SIGNAL (itemSelectionChanged ()),
this, SLOT (slotListIncluded()));
82 m_listExcluded =
new QListWidget;
83 m_listExcluded->setWhatsThis (tr (
"List of curves to be excluded from the exported file"));
84 m_listExcluded->setSelectionMode (QAbstractItemView::MultiSelection);
85 layout->addWidget (m_listExcluded, row++, 2, 4, 1);
86 connect (m_listExcluded, SIGNAL (itemSelectionChanged ()),
this, SLOT (slotListExcluded()));
88 m_btnInclude =
new QPushButton (tr (
"<<Include"));
89 m_btnInclude->setEnabled (
false);
90 m_btnInclude->setWhatsThis (tr (
"Move the currently selected curve(s) from the excluded list"));
91 layout->addWidget (m_btnInclude, row++, 1);
92 connect (m_btnInclude, SIGNAL (released ()),
this, SLOT (slotInclude()));
94 m_btnExclude =
new QPushButton (tr (
"Exclude>>"));
95 m_btnExclude->setEnabled (
false);
96 m_btnExclude->setWhatsThis (tr (
"Move the currently selected curve(s) from the included list"));
97 layout->addWidget (m_btnExclude, row++, 1);
98 connect (m_btnExclude, SIGNAL (released ()),
this, SLOT (slotExclude()));
103void DlgSettingsExportFormat::createDelimiters (QHBoxLayout *layoutMisc)
105 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createDelimiters";
107 QGroupBox *groupDelimiters =
new QGroupBox (tr (
"Default Delimiters"));
108 layoutMisc->addWidget (groupDelimiters, 1);
110 QVBoxLayout *layoutDelimiters =
new QVBoxLayout;
111 groupDelimiters->setLayout (layoutDelimiters);
113 m_btnDelimitersCommas =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_COMMA));
114 m_btnDelimitersCommas->setWhatsThis (tr (
"Exported file will have commas between adjacent values.\n\n"
115 "This setting is overridden for TSV files"));
116 layoutDelimiters->addWidget (m_btnDelimitersCommas);
117 connect (m_btnDelimitersCommas, SIGNAL (released ()),
this, SLOT (slotDelimitersCommas()));
119 m_btnDelimitersSpaces =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_SPACE));
120 m_btnDelimitersSpaces->setWhatsThis (tr (
"Exported file will have spaces between adjacent values.\n\n"
121 "This setting is overridden for CSV and TSV files"));
122 layoutDelimiters->addWidget (m_btnDelimitersSpaces);
123 connect (m_btnDelimitersSpaces, SIGNAL (released ()),
this, SLOT (slotDelimitersSpaces()));
125 m_btnDelimitersTabs =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_TAB));
126 m_btnDelimitersTabs->setWhatsThis (tr (
"Exported file will have tabs between adjacent values.\n\n"
127 "This setting is overridden for CSV files"));
128 layoutDelimiters->addWidget (m_btnDelimitersTabs);
129 connect (m_btnDelimitersTabs, SIGNAL (released ()),
this, SLOT (slotDelimitersTabs()));
132void DlgSettingsExportFormat::createFileLayout (QHBoxLayout *layoutMisc)
134 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createFileLayout";
136 QGroupBox *groupLayout =
new QGroupBox (tr (
"Layout"));
137 layoutMisc->addWidget (groupLayout, 1);
139 QVBoxLayout *layoutLayout =
new QVBoxLayout;
140 groupLayout->setLayout (layoutLayout);
142 m_btnFunctionsLayoutAllCurves =
new QRadioButton (tr (
"All curves on each line"));
143 m_btnFunctionsLayoutAllCurves->setWhatsThis (tr (
"Exported file will have, on each line, "
144 "an X value, the Y value for the first curve, the Y value for the second curve,..."));
145 layoutLayout->addWidget (m_btnFunctionsLayoutAllCurves);
146 connect (m_btnFunctionsLayoutAllCurves, SIGNAL (released()),
this, SLOT (slotFunctionsLayoutAllCurves ()));
148 m_btnFunctionsLayoutOneCurve =
new QRadioButton (tr (
"One curve on each line"));
149 m_btnFunctionsLayoutOneCurve->setWhatsThis (tr (
"Exported file will have all the points for "
150 "the first curve, with one X-Y pair on each line, then the points for the second curve,..."));
151 layoutLayout->addWidget (m_btnFunctionsLayoutOneCurve);
152 connect (m_btnFunctionsLayoutOneCurve, SIGNAL (released()),
this, SLOT (slotFunctionsLayoutOneCurve ()));
155void DlgSettingsExportFormat::createFunctionsPointsSelection (QHBoxLayout *layoutFunctions)
157 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createFunctionsPointsSelection";
159 QGroupBox *groupPointsSelection =
new QGroupBox (tr (
"Points Selection"));
160 layoutFunctions->addWidget (groupPointsSelection, 1);
162 QGridLayout *layoutPointsSelections =
new QGridLayout;
163 groupPointsSelection->setLayout (layoutPointsSelections);
165 layoutPointsSelections->setColumnMinimumWidth(0, MIN_INDENT_COLUMN_WIDTH);
166 layoutPointsSelections->setColumnStretch (0, 0);
167 layoutPointsSelections->setColumnStretch (1, 0);
168 layoutPointsSelections->setColumnStretch (2, 0);
169 layoutPointsSelections->setColumnStretch (3, 1);
172 m_btnFunctionsPointsAllCurves =
new QRadioButton (tr (
"Interpolate Ys at Xs from all curves"));
173 m_btnFunctionsPointsAllCurves->setWhatsThis (tr (
"Exported file will have values at every unique X "
174 "value from every curve. Y values will be linearly interpolated if necessary"));
175 layoutPointsSelections->addWidget (m_btnFunctionsPointsAllCurves, row++, 0, 1, 4);
176 connect (m_btnFunctionsPointsAllCurves, SIGNAL (released()),
this, SLOT (slotFunctionsPointsAllCurves()));
178 m_btnFunctionsPointsFirstCurve =
new QRadioButton (tr (
"Interpolate Ys at Xs from first curve"));
179 m_btnFunctionsPointsFirstCurve->setWhatsThis (tr (
"Exported file will have values at every unique X "
180 "value from the first curve. Y values will be linearly interpolated if necessary"));
181 layoutPointsSelections->addWidget (m_btnFunctionsPointsFirstCurve, row++, 0, 1, 4);
182 connect (m_btnFunctionsPointsFirstCurve, SIGNAL (released()),
this, SLOT (slotFunctionsPointsFirstCurve()));
184 m_btnFunctionsPointsEvenlySpaced =
new QRadioButton (tr (
"Interpolate Ys at evenly spaced X values."));
185 m_btnFunctionsPointsEvenlySpaced->setWhatsThis (tr (
"Exported file will have values at evenly spaced X values, separated by the interval selected below."));
186 layoutPointsSelections->addWidget (m_btnFunctionsPointsEvenlySpaced, row++, 0, 1, 4);
187 connect (m_btnFunctionsPointsEvenlySpaced, SIGNAL (released()),
this, SLOT (slotFunctionsPointsEvenlySpaced()));
189 QLabel *labelInterval =
new QLabel (tr (
"Interval:"));
190 layoutPointsSelections->addWidget (labelInterval, row, 1, 1, 1, Qt::AlignRight);
192 m_editFunctionsPointsEvenlySpacing =
new QLineEdit;
193 m_validatorFunctionsPointsEvenlySpacing =
new QDoubleValidator;
194 m_editFunctionsPointsEvenlySpacing->setValidator (m_validatorFunctionsPointsEvenlySpacing);
195 m_editFunctionsPointsEvenlySpacing->setMinimumWidth (MIN_EDIT_WIDTH);
196 m_editFunctionsPointsEvenlySpacing->setMaximumWidth (MAX_EDIT_WIDTH);
197 m_editFunctionsPointsEvenlySpacing->setWhatsThis (tr (
"Interval, in the units of X, between successive points in the X direction.\n\n"
198 "If the scale is linear, then this interval is added to successive X values. If the scale is "
199 "logarithmic, then this interval is multiplied to successive X values.\n\n"
200 "The X values will be automatically aligned along simple numbers. If the first and/or last "
201 "points are not along the aligned X values, then one or two additional points are added "
203 layoutPointsSelections->addWidget (m_editFunctionsPointsEvenlySpacing, row, 2, 1, 1, Qt::AlignLeft);
204 connect (m_editFunctionsPointsEvenlySpacing, SIGNAL (textChanged(
const QString &)),
this, SLOT (slotFunctionsPointsEvenlySpacedInterval(
const QString &)));
206 m_cmbFunctionsPointsEvenlySpacingUnits =
new QComboBox;
207 m_cmbFunctionsPointsEvenlySpacingUnits->setWhatsThis (tr (
"Units for spacing interval.\n\n"
208 "Pixel units are preferred when the spacing is to be independent of the X scale. The spacing will be "
209 "consistent across the graph, even if the X scale is logarithmic.\n\n"
210 "Graph units are preferred when the spacing is to depend on the X scale."));
211 m_cmbFunctionsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_GRAPH),
212 QVariant (EXPORT_POINTS_INTERVAL_UNITS_GRAPH));
213 m_cmbFunctionsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_SCREEN),
214 QVariant (EXPORT_POINTS_INTERVAL_UNITS_SCREEN));
215 connect (m_cmbFunctionsPointsEvenlySpacingUnits, SIGNAL (activated (
const QString &)),
216 this, SLOT (slotFunctionsPointsEvenlySpacedIntervalUnits (
const QString &)));
217 layoutPointsSelections->addWidget (m_cmbFunctionsPointsEvenlySpacingUnits, row++, 3, 1, 1, Qt::AlignLeft);
219 m_btnFunctionsPointsRaw =
new QRadioButton (tr (
"Raw Xs and Ys"));
220 m_btnFunctionsPointsRaw->setWhatsThis (tr (
"Exported file will have only original X and Y values"));
221 layoutPointsSelections->addWidget (m_btnFunctionsPointsRaw, row++, 0, 1, 4);
222 connect (m_btnFunctionsPointsRaw, SIGNAL (released()),
this, SLOT (slotFunctionsPointsRaw()));
225void DlgSettingsExportFormat::createHeader (QHBoxLayout *layoutMisc)
227 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createHeader";
229 const int COLUMN_RADIO_BUTTONS = 0, COLUMN_EMPTY = 1, COLUMN_LABEL = 2;
231 QGroupBox *groupHeader =
new QGroupBox (tr (
"Header"));
232 layoutMisc->addWidget (groupHeader, 1);
234 QGridLayout *layoutHeader =
new QGridLayout;
235 layoutHeader->setColumnMinimumWidth(COLUMN_EMPTY,
236 MIN_HEADER_EMPTY_COLUMN_WIDTH);
237 groupHeader->setLayout (layoutHeader);
240 m_btnHeaderNone =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_NONE));
241 m_btnHeaderNone->setWhatsThis (tr (
"Exported file will have no header line"));
242 layoutHeader->addWidget (m_btnHeaderNone, row++, COLUMN_RADIO_BUTTONS, 1, 1);
243 connect (m_btnHeaderNone, SIGNAL (released ()),
this, SLOT (slotHeaderNone()));
245 m_btnHeaderSimple =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_SIMPLE));
246 m_btnHeaderSimple->setWhatsThis (tr (
"Exported file will have simple header line"));
247 layoutHeader->addWidget (m_btnHeaderSimple, row++, COLUMN_RADIO_BUTTONS, 1, 1);
248 connect (m_btnHeaderSimple, SIGNAL (released ()),
this, SLOT (slotHeaderSimple()));
250 m_btnHeaderGnuplot =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_GNUPLOT));
251 m_btnHeaderGnuplot->setWhatsThis (tr (
"Exported file will have gnuplot header line"));
252 layoutHeader->addWidget (m_btnHeaderGnuplot, row++, COLUMN_RADIO_BUTTONS, 1, 1);
253 connect (m_btnHeaderGnuplot, SIGNAL (released()),
this, SLOT (slotHeaderGnuplot()));
255 createXLabel (layoutHeader,
261 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createOptionalSaveDefault";
263 m_btnSaveDefault =
new QPushButton (tr (
"Save As Default"));
264 m_btnSaveDefault->setWhatsThis (tr (
"Save the settings for use as future defaults."));
265 connect (m_btnSaveDefault, SIGNAL (released ()),
this, SLOT (slotSaveDefault ()));
266 layout->addWidget (m_btnSaveDefault, 0, Qt::AlignLeft);
269void DlgSettingsExportFormat::createPreview(QGridLayout *layout,
int &row)
271 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createPreview";
273 QLabel *label =
new QLabel (tr (
"Preview"));
274 layout->addWidget (label, row++, 0, 1, 3);
276 m_editPreview =
new QTextEdit;
277 m_editPreview->setReadOnly (
true);
278 m_editPreview->setWhatsThis (tr (
"Preview window shows how current settings affect the exported file"));
281 layout->addWidget (m_editPreview, row++, 0, 1, 3);
284void DlgSettingsExportFormat::createRelationsPointsSelection (QHBoxLayout *layoutRelations)
286 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createRelationsPointsSelection";
288 QGroupBox *groupPointsSelection =
new QGroupBox (tr (
"Points Selection"));
289 layoutRelations->addWidget (groupPointsSelection);
291 QGridLayout *layoutPointsSelections =
new QGridLayout;
292 groupPointsSelection->setLayout (layoutPointsSelections);
294 layoutPointsSelections->setColumnMinimumWidth(0, MIN_INDENT_COLUMN_WIDTH);
295 layoutPointsSelections->setColumnStretch (0, 0);
296 layoutPointsSelections->setColumnStretch (1, 0);
297 layoutPointsSelections->setColumnStretch (2, 0);
298 layoutPointsSelections->setColumnStretch (3, 1);
301 m_btnRelationsPointsEvenlySpaced =
new QRadioButton (tr (
"Interpolate Xs and Ys at evenly spaced intervals."));
302 m_btnRelationsPointsEvenlySpaced->setWhatsThis (tr (
"Exported file will have points evenly spaced along each relation, separated by the interval "
303 "selected below. If the last interval does not end at the last point, then a shorter last interval "
304 "is added that ends on the last point."));
305 layoutPointsSelections->addWidget (m_btnRelationsPointsEvenlySpaced, row++, 0, 1, 4);
306 connect (m_btnRelationsPointsEvenlySpaced, SIGNAL (released()),
this, SLOT (slotRelationsPointsEvenlySpaced()));
308 QLabel *labelInterval =
new QLabel (tr (
"Interval:"));
309 layoutPointsSelections->addWidget (labelInterval, row, 1, 1, 1, Qt::AlignRight);
311 m_editRelationsPointsEvenlySpacing =
new QLineEdit;
312 m_validatorRelationsPointsEvenlySpacing =
new QDoubleValidator;
313 m_editRelationsPointsEvenlySpacing->setValidator (m_validatorRelationsPointsEvenlySpacing);
314 m_editRelationsPointsEvenlySpacing->setMinimumWidth (MIN_EDIT_WIDTH);
315 m_editRelationsPointsEvenlySpacing->setMaximumWidth (MAX_EDIT_WIDTH);
316 m_editRelationsPointsEvenlySpacing->setWhatsThis (tr (
"Interval between successive points when "
317 "exporting at evenly spaced (X,Y) coordinates."));
318 layoutPointsSelections->addWidget (m_editRelationsPointsEvenlySpacing, row, 2, 1, 1, Qt::AlignLeft);
319 connect (m_editRelationsPointsEvenlySpacing, SIGNAL (textChanged(
const QString &)),
this, SLOT (slotRelationsPointsEvenlySpacedInterval(
const QString &)));
321 m_cmbRelationsPointsEvenlySpacingUnits =
new QComboBox;
322 m_cmbRelationsPointsEvenlySpacingUnits->setWhatsThis (tr (
"Units for spacing interval.\n\n"
323 "Pixel units are preferred when the spacing is to be independent of the X and Y scales. The spacing will be "
324 "consistent across the graph, even if a scale is logarithmic or the X and Y scales are different.\n\n"
325 "Graph units are usually preferred when the X and Y scales are identical."));
326 m_cmbRelationsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_GRAPH),
327 QVariant (EXPORT_POINTS_INTERVAL_UNITS_GRAPH));
328 m_cmbRelationsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_SCREEN),
329 QVariant (EXPORT_POINTS_INTERVAL_UNITS_SCREEN));
330 connect (m_cmbRelationsPointsEvenlySpacingUnits, SIGNAL (activated (
const QString &)),
331 this, SLOT (slotRelationsPointsEvenlySpacedIntervalUnits (
const QString &)));
332 layoutPointsSelections->addWidget (m_cmbRelationsPointsEvenlySpacingUnits, row++, 3, 1, 1, Qt::AlignLeft);
334 m_btnRelationsPointsRaw =
new QRadioButton (tr (
"Raw Xs and Ys"));
335 m_btnRelationsPointsRaw->setWhatsThis (tr (
"Exported file will have only original X and Y values"));
336 layoutPointsSelections->addWidget (m_btnRelationsPointsRaw, row++, 0, 1, 4);
337 connect (m_btnRelationsPointsRaw, SIGNAL (released()),
this, SLOT (slotRelationsPointsRaw()));
342 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createSubPanel";
344 QWidget *subPanel =
new QWidget ();
345 QGridLayout *layout =
new QGridLayout (subPanel);
346 subPanel->setLayout (layout);
349 createCurveSelection (layout, row);
351 createTabWidget (layout,
354 QWidget *widgetMisc =
new QWidget;
355 layout->addWidget (widgetMisc, row++, 0, 1, 3);
356 QHBoxLayout *layoutMisc =
new QHBoxLayout;
357 widgetMisc->setLayout (layoutMisc);
359 createDelimiters (layoutMisc);
360 createHeader (layoutMisc);
361 createFileLayout (layoutMisc);
363 createPreview (layout, row);
368void DlgSettingsExportFormat::createTabWidget (QGridLayout *layout,
371 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createTabWidget";
373 m_tabWidget =
new QTabWidget;
375 layout->addWidget (m_tabWidget, row++, 0, 1, 3);
377 QWidget *widgetFunctions =
new QWidget;
378 int indexFunctions = m_tabWidget->addTab (widgetFunctions, tr (
"Functions"));
379 QWidget *tabFunctions = m_tabWidget->widget (indexFunctions);
380 tabFunctions->setWhatsThis (tr (
"Functions Tab\n\n"
381 "Controls for specifying the format of functions during export"));
382 QHBoxLayout *layoutFunctions =
new QHBoxLayout;
383 widgetFunctions->setLayout (layoutFunctions);
385 QWidget *widgetRelations =
new QWidget;
386 int indexRelations = m_tabWidget->addTab (widgetRelations, tr (
"Relations"));
387 QWidget *tabRelations = m_tabWidget->widget (indexRelations);
388 tabRelations->setWhatsThis (tr (
"Relations Tab\n\n"
389 "Controls for specifying the format of relations during export"));
390 QHBoxLayout *layoutRelations =
new QHBoxLayout;
391 widgetRelations->setLayout (layoutRelations);
394 connect (m_tabWidget, SIGNAL (currentChanged (
int)),
this, SLOT (slotTabChanged (
int)));
396 createFunctionsPointsSelection (layoutFunctions);
397 createRelationsPointsSelection (layoutRelations);
400void DlgSettingsExportFormat::createXLabel (QGridLayout *layoutHeader,
403 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createXLabel";
409 title =
new QLabel (tr (
"X Label:"));
411 title =
new QLabel (tr (
"Theta Label:"));
413 layoutHeader->addWidget (title, row++, colLabel, 1, 1);
415 m_editXLabel =
new QLineEdit;
417 m_editXLabel->setWhatsThis (tr (
"Label in the header for x values"));
419 m_editXLabel->setWhatsThis (tr (
"Label in the header for theta values"));
421 layoutHeader->addWidget (m_editXLabel, row++, colLabel, 1, 1);
422 connect (m_editXLabel, SIGNAL (textChanged (
const QString &)),
this, SLOT (slotXLabel(
const QString &)));
425bool DlgSettingsExportFormat::goodIntervalFunctions()
const
427 QString textFunctions = m_editFunctionsPointsEvenlySpacing->text();
430 bool isGood = (m_validatorFunctionsPointsEvenlySpacing->validate (textFunctions, posFunctions) == QValidator::Acceptable);
435bool DlgSettingsExportFormat::goodIntervalRelations()
const
437 QString textRelations = m_editRelationsPointsEvenlySpacing->text();
440 return (m_validatorRelationsPointsEvenlySpacing->validate (textRelations, posRelations) == QValidator::Acceptable);
445 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::handleOk";
449 *m_modelExportBefore,
450 *m_modelExportAfter);
456void DlgSettingsExportFormat::initializeIntervalConstraints ()
458 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::initializeIntervalConstraints";
460 const int MAX_POINTS_ACROSS_RANGE = 1000;
465 Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
471 double maxSizeGraph = qMax (ftor.boundingRectGraph(isEmpty).width(),
472 ftor.boundingRectGraph(isEmpty).height());
473 double maxSizeScreen = qMax (ftor.boundingRectScreen(isEmpty).width(),
474 ftor.boundingRectScreen(isEmpty).height());
475 m_minIntervalGraph = maxSizeGraph / MAX_POINTS_ACROSS_RANGE;
476 m_minIntervalScreen = maxSizeScreen / MAX_POINTS_ACROSS_RANGE;
481 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::load";
486 if (m_modelExportBefore != 0) {
487 delete m_modelExportBefore;
489 if (m_modelExportAfter != 0) {
490 delete m_modelExportAfter;
498 m_listExcluded->clear();
500 QStringList::const_iterator itr;
501 for (itr = curveNamesExcluded.begin (); itr != curveNamesExcluded.end(); ++itr) {
502 QString curveNameNotExported = *itr;
503 m_listExcluded->addItem (curveNameNotExported);
507 m_listIncluded->clear();
509 for (itr = curveNamesAll.begin (); itr != curveNamesAll.end(); itr++) {
510 QString curveName = *itr;
511 if (!curveNamesExcluded.contains (curveName)) {
512 m_listIncluded->addItem (curveName);
517 m_btnFunctionsPointsAllCurves->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_ALL_CURVES);
518 m_btnFunctionsPointsFirstCurve->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_FIRST_CURVE);
519 m_btnFunctionsPointsEvenlySpaced->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_PERIODIC);
520 m_btnFunctionsPointsRaw->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_RAW);
522 ExportLayoutFunctions layoutFunctions = m_modelExportAfter->
layoutFunctions ();
523 m_btnFunctionsLayoutAllCurves->setChecked (layoutFunctions == EXPORT_LAYOUT_ALL_PER_LINE);
524 m_btnFunctionsLayoutOneCurve->setChecked (layoutFunctions == EXPORT_LAYOUT_ONE_PER_LINE);
527 m_btnRelationsPointsEvenlySpaced->setChecked (pointsSelectionRelations == EXPORT_POINTS_SELECTION_RELATIONS_INTERPOLATE);
528 m_btnRelationsPointsRaw->setChecked (pointsSelectionRelations == EXPORT_POINTS_SELECTION_RELATIONS_RAW);
530 ExportDelimiter delimiter = m_modelExportAfter->
delimiter ();
531 m_btnDelimitersCommas->setChecked (delimiter == EXPORT_DELIMITER_COMMA);
532 m_btnDelimitersSpaces->setChecked (delimiter == EXPORT_DELIMITER_SPACE);
533 m_btnDelimitersTabs->setChecked (delimiter == EXPORT_DELIMITER_TAB);
535 ExportHeader header = m_modelExportAfter->
header ();
536 m_btnHeaderNone->setChecked (header == EXPORT_HEADER_NONE);
537 m_btnHeaderSimple->setChecked (header == EXPORT_HEADER_SIMPLE);
538 m_btnHeaderGnuplot->setChecked (header == EXPORT_HEADER_GNUPLOT);
540 m_editXLabel->setText (m_modelExportAfter->
xLabel());
546 int indexFunctions = m_cmbRelationsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsFunctions));
547 int indexRelations = m_cmbRelationsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsRelations));
548 m_cmbFunctionsPointsEvenlySpacingUnits->setCurrentIndex (indexFunctions);
549 m_cmbRelationsPointsEvenlySpacingUnits->setCurrentIndex (indexRelations);
551 initializeIntervalConstraints ();
554 updateIntervalConstraints();
559void DlgSettingsExportFormat::slotDelimitersCommas()
561 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersCommas";
563 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_COMMA);
568void DlgSettingsExportFormat::slotDelimitersSpaces()
570 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersSpaces";
572 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_SPACE);
577void DlgSettingsExportFormat::slotDelimitersTabs()
579 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersTabs";
586void DlgSettingsExportFormat::slotExclude ()
588 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotExclude";
592 QStringList excluded;
593 for (i = 0; i < m_listIncluded->count(); i++) {
594 if (m_listIncluded->item(i)->isSelected()) {
595 excluded += m_listIncluded->item(i)->text();
600 for (i = 0; i < excluded.count(); i++) {
601 QString curveName = excluded.at (i);
602 m_listExcluded->addItem (curveName);
606 for (i = m_listIncluded->count() - 1; i>= 0; i--) {
607 QString curveName = m_listIncluded->item(i)->text();
608 if (excluded.contains (curveName)) {
609 QListWidgetItem *item = m_listIncluded->item (i);
610 m_listIncluded->removeItemWidget (item);
620void DlgSettingsExportFormat::slotFunctionsLayoutAllCurves()
622 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsLayoutAllCurves";
629void DlgSettingsExportFormat::slotFunctionsLayoutOneCurve()
631 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsLayoutOneCurve";
638void DlgSettingsExportFormat::slotFunctionsPointsAllCurves()
640 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsAllCurves";
647void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced()
649 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced";
656void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval(
const QString &)
658 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval";
661 if (goodIntervalFunctions()) {
666 m_editPreview->setText(EMPTY_PREVIEW);
670void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits(
const QString &)
672 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits";
674 int index = m_cmbFunctionsPointsEvenlySpacingUnits->currentIndex();
675 ExportPointsIntervalUnits units = (ExportPointsIntervalUnits) m_cmbFunctionsPointsEvenlySpacingUnits->itemData (index).toInt();
678 updateIntervalConstraints();
683void DlgSettingsExportFormat::slotFunctionsPointsFirstCurve()
685 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsFirstCurve";
692void DlgSettingsExportFormat::slotFunctionsPointsRaw()
694 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsRaw";
701void DlgSettingsExportFormat::slotHeaderGnuplot()
703 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderGnuplot";
705 m_modelExportAfter->
setHeader(EXPORT_HEADER_GNUPLOT);
710void DlgSettingsExportFormat::slotHeaderNone()
712 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderNone";
714 m_modelExportAfter->
setHeader(EXPORT_HEADER_NONE);
719void DlgSettingsExportFormat::slotHeaderSimple()
721 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderSimple";
723 m_modelExportAfter->
setHeader(EXPORT_HEADER_SIMPLE);
728void DlgSettingsExportFormat::slotInclude ()
730 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotInclude";
734 QStringList included;
735 for (i = 0; i < m_listExcluded->count(); i++) {
736 if (m_listExcluded->item(i)->isSelected()) {
737 included += m_listExcluded->item(i)->text();
742 for (i = 0; i < included.count(); i++) {
743 QString curveName = included.at (i);
744 m_listIncluded->addItem (curveName);
748 QStringList excluded;
749 for (i = m_listExcluded->count() - 1; i>= 0; i--) {
750 QString curveName = m_listExcluded->item(i)->text();
751 QListWidgetItem *item = m_listExcluded->item (i);
752 if (included.contains (curveName)) {
753 m_listExcluded->removeItemWidget (item);
756 excluded += item->text();
765void DlgSettingsExportFormat::slotListExcluded()
767 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotListExcluded";
773void DlgSettingsExportFormat::slotListIncluded()
775 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotListIncluded";
781void DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced()
783 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced";
790void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval(
const QString &)
792 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval";
799void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits(
const QString &)
801 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits";
803 int index = m_cmbRelationsPointsEvenlySpacingUnits->currentIndex();
804 ExportPointsIntervalUnits units = (ExportPointsIntervalUnits) m_cmbRelationsPointsEvenlySpacingUnits->itemData (index).toInt();
807 updateIntervalConstraints();
812void DlgSettingsExportFormat::slotRelationsPointsRaw()
814 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsRaw";
821void DlgSettingsExportFormat::slotSaveDefault()
823 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotSaveDefault";
825 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
826 settings.beginGroup (SETTINGS_GROUP_EXPORT);
828 settings.setValue (SETTINGS_EXPORT_DELIMITER,
829 QVariant (m_modelExportAfter->
delimiter()));
830 settings.setValue (SETTINGS_EXPORT_HEADER,
831 QVariant (m_modelExportAfter->
header()));
832 settings.setValue (SETTINGS_EXPORT_LAYOUT_FUNCTIONS,
834 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_FUNCTIONS,
836 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_RELATIONS,
838 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_FUNCTIONS,
840 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_RELATIONS,
842 settings.setValue (SETTINGS_EXPORT_POINTS_SELECTION_FUNCTIONS,
844 settings.setValue (SETTINGS_EXPORT_POINTS_SELECTION_RELATIONS,
846 settings.setValue (SETTINGS_EXPORT_X_LABEL,
847 QVariant (m_modelExportAfter->
xLabel()));
849 settings.endGroup ();
852void DlgSettingsExportFormat::slotTabChanged (
int)
854 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotTabChanged";
859void DlgSettingsExportFormat::slotXLabel(
const QString &)
861 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotXLabel";
863 m_modelExportAfter->
setXLabel (m_editXLabel->text());
868void DlgSettingsExportFormat::updateControls ()
870 bool isGoodState = goodIntervalFunctions() &&
871 goodIntervalRelations();
874 m_listIncluded->sortItems (Qt::AscendingOrder);
875 m_listExcluded->sortItems (Qt::AscendingOrder);
877 int selectedForInclude = m_listExcluded->selectedItems().count();
878 int selectedForExclude = m_listIncluded->selectedItems().count();
879 int inInclude = m_listIncluded->count();
881 m_btnInclude->setEnabled (selectedForInclude > 0);
882 m_btnExclude->setEnabled ((selectedForExclude > 0) && (inInclude - selectedForExclude > 0));
884 m_editFunctionsPointsEvenlySpacing->setEnabled (m_btnFunctionsPointsEvenlySpaced->isChecked ());
885 m_editRelationsPointsEvenlySpacing->setEnabled (m_btnRelationsPointsEvenlySpaced->isChecked ());
887 m_editXLabel->setEnabled (!m_btnHeaderNone->isChecked());
890void DlgSettingsExportFormat::updateIntervalConstraints ()
894 m_minIntervalScreen);
897 m_minIntervalScreen);
899 if (m_tabWidget->currentIndex() == TAB_WIDGET_INDEX_FUNCTIONS) {
903 m_editFunctionsPointsEvenlySpacing->setText (QString::number (functionsMin));
907 m_validatorFunctionsPointsEvenlySpacing->setBottom (functionsMin);
913 m_editRelationsPointsEvenlySpacing->setText (QString::number (relationsMin));
914 m_validatorFunctionsPointsEvenlySpacing->setBottom (relationsMin);
918 m_validatorRelationsPointsEvenlySpacing->setBottom (relationsMin);
922void DlgSettingsExportFormat::updatePreview()
925 int scrollPosition = m_editPreview->verticalScrollBar()->value();
927 QString exportedText;
928 QTextStream str (&exportedText);
930 if (
mainWindow().transformation().transformIsDefined()) {
933 if (m_tabWidget->currentIndex() == TAB_WIDGET_INDEX_FUNCTIONS) {
954 str <<
"Preview is unavailable until axis points are defined.";
957 m_editPreview->setText (exportedText);
960 m_editPreview->verticalScrollBar()->setValue (scrollPosition);
Callback for computing the bounding rectangles of the screen and graph coordinates of the points in t...
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
Abstract base class for all Settings dialogs.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.
void enableOk(bool enable)
Let leaf subclass control the Ok button.
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.
MainWindow & mainWindow()
Get method for MainWindow.
QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
Strategy class for exporting to a file. This strategy is external to the Document class so that class...
void exportToFile(const DocumentModelExportFormat &modelExportOverride, const Document &document, const MainWindowModel &modelMainWindow, const Transformation &transformation, QTextStream &str) const
Export Document points according to the settings.
Strategy class for exporting to a file. This strategy is external to the Document class so that class...
void exportToFile(const DocumentModelExportFormat &modelExportOverride, const Document &document, const MainWindowModel &modelMainWindow, const Transformation &transformation, QTextStream &str) const
Export Document points according to the settings.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...