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"
11 #include <QDoubleValidator>
12 #include <QGridLayout>
14 #include <QHBoxLayout>
17 #include <QListWidget>
18 #include <QPushButton>
19 #include <QRadioButton>
23 #include <QTextStream>
24 #include <QVBoxLayout>
25 #include "Transformation.h"
27 const int MIN_INDENT_COLUMN_WIDTH = 20;
28 const int MIN_HEADER_EMPTY_COLUMN_WIDTH = 10;
29 const int MIN_EDIT_WIDTH = 110;
30 const int MAX_EDIT_WIDTH = 180;
32 const int TAB_WIDGET_INDEX_FUNCTIONS = 0;
33 const int TAB_WIDGET_INDEX_RELATIONS = 1;
35 const QString EMPTY_PREVIEW;
39 "DlgSettingsExportFormat",
41 m_modelExportBefore (0),
42 m_modelExportAfter (0)
44 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::DlgSettingsExportFormat";
50 DlgSettingsExportFormat::~DlgSettingsExportFormat()
52 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::~DlgSettingsExportFormat";
55 void DlgSettingsExportFormat::createCurveSelection (QGridLayout *layout,
int &row)
57 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createCurveSelection";
59 QLabel *labelIncluded =
new QLabel (tr (
"Included"));
60 layout->addWidget (labelIncluded, row, 0);
62 QLabel *labelExcluded =
new QLabel (tr (
"Not included"));
63 layout->addWidget (labelExcluded, row++, 2);
65 m_listIncluded =
new QListWidget;
66 m_listIncluded->setWhatsThis (tr (
"List of curves to be included in the exported file.\n\n"
67 "The order of the curves here does not affect the order in the exported file. That "
68 "order is determined by the Curves settings."));
69 m_listIncluded->setSelectionMode (QAbstractItemView::MultiSelection);
70 layout->addWidget (m_listIncluded, row, 0, 4, 1);
71 connect (m_listIncluded, SIGNAL (itemSelectionChanged ()),
this, SLOT (slotListIncluded()));
73 m_listExcluded =
new QListWidget;
74 m_listExcluded->setWhatsThis (tr (
"List of curves to be excluded from the exported file"));
75 m_listExcluded->setSelectionMode (QAbstractItemView::MultiSelection);
76 layout->addWidget (m_listExcluded, row++, 2, 4, 1);
77 connect (m_listExcluded, SIGNAL (itemSelectionChanged ()),
this, SLOT (slotListExcluded()));
79 m_btnInclude =
new QPushButton (tr (
"<<Include"));
80 m_btnInclude->setEnabled (
false);
81 m_btnInclude->setWhatsThis (tr (
"Move the currently selected curve(s) from the excluded list"));
82 layout->addWidget (m_btnInclude, row++, 1);
83 connect (m_btnInclude, SIGNAL (released ()),
this, SLOT (slotInclude()));
85 m_btnExclude =
new QPushButton (tr (
"Exclude>"));
86 m_btnExclude->setEnabled (
false);
87 m_btnExclude->setWhatsThis (tr (
"Move the currently selected curve(s) from the included list"));
88 layout->addWidget (m_btnExclude, row++, 1);
89 connect (m_btnExclude, SIGNAL (released ()),
this, SLOT (slotExclude()));
94 void DlgSettingsExportFormat::createDelimiters (QHBoxLayout *layoutMisc)
96 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createDelimiters";
98 QGroupBox *groupDelimiters =
new QGroupBox (tr (
"Delimiters"));
99 layoutMisc->addWidget (groupDelimiters, 1);
101 QVBoxLayout *layoutDelimiters =
new QVBoxLayout;
102 groupDelimiters->setLayout (layoutDelimiters);
104 m_btnDelimitersCommas =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_COMMA));
105 m_btnDelimitersCommas->setWhatsThis (tr (
"Exported file will have commas between adjacent values"));
106 layoutDelimiters->addWidget (m_btnDelimitersCommas);
107 connect (m_btnDelimitersCommas, SIGNAL (released ()),
this, SLOT (slotDelimitersCommas()));
109 m_btnDelimitersSpaces =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_SPACE));
110 m_btnDelimitersSpaces->setWhatsThis (tr (
"Exported file will have spaces between adjacent values"));
111 layoutDelimiters->addWidget (m_btnDelimitersSpaces);
112 connect (m_btnDelimitersSpaces, SIGNAL (released ()),
this, SLOT (slotDelimitersSpaces()));
114 m_btnDelimitersTabs =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_TAB));
115 m_btnDelimitersTabs->setWhatsThis (tr (
"Exported file will have tabs between adjacent values"));
116 layoutDelimiters->addWidget (m_btnDelimitersTabs);
117 connect (m_btnDelimitersTabs, SIGNAL (released ()),
this, SLOT (slotDelimitersTabs()));
120 void DlgSettingsExportFormat::createFileLayout (QHBoxLayout *layoutMisc)
122 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createFileLayout";
124 QGroupBox *groupLayout =
new QGroupBox (tr (
"Layout"));
125 layoutMisc->addWidget (groupLayout, 1);
127 QVBoxLayout *layoutLayout =
new QVBoxLayout;
128 groupLayout->setLayout (layoutLayout);
130 m_btnFunctionsLayoutAllCurves =
new QRadioButton (tr (
"All curves on each line"));
131 m_btnFunctionsLayoutAllCurves->setWhatsThis (tr (
"Exported file will have, on each line, "
132 "an X value, the Y value for the first curve, the Y value for the second curve,..."));
133 layoutLayout->addWidget (m_btnFunctionsLayoutAllCurves);
134 connect (m_btnFunctionsLayoutAllCurves, SIGNAL (released()),
this, SLOT (slotFunctionsLayoutAllCurves ()));
136 m_btnFunctionsLayoutOneCurve =
new QRadioButton (tr (
"One curve on each line"));
137 m_btnFunctionsLayoutOneCurve->setWhatsThis (tr (
"Exported file will have all the points for "
138 "the first curve, with one X-Y pair on each line, then the points for the second curve,..."));
139 layoutLayout->addWidget (m_btnFunctionsLayoutOneCurve);
140 connect (m_btnFunctionsLayoutOneCurve, SIGNAL (released()),
this, SLOT (slotFunctionsLayoutOneCurve ()));
143 void DlgSettingsExportFormat::createFunctionsPointsSelection (QHBoxLayout *layoutFunctions)
145 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createFunctionsPointsSelection";
147 QGroupBox *groupPointsSelection =
new QGroupBox (tr (
"Points Selection"));
148 layoutFunctions->addWidget (groupPointsSelection, 1);
150 QGridLayout *layoutPointsSelections =
new QGridLayout;
151 groupPointsSelection->setLayout (layoutPointsSelections);
153 layoutPointsSelections->setColumnMinimumWidth(0, MIN_INDENT_COLUMN_WIDTH);
154 layoutPointsSelections->setColumnStretch (0, 0);
155 layoutPointsSelections->setColumnStretch (1, 0);
156 layoutPointsSelections->setColumnStretch (2, 0);
157 layoutPointsSelections->setColumnStretch (3, 1);
160 m_btnFunctionsPointsAllCurves =
new QRadioButton (tr (
"Interpolate Ys at Xs from all curves"));
161 m_btnFunctionsPointsAllCurves->setWhatsThis (tr (
"Exported file will have values at every unique X "
162 "value from every curve. Y values will be linearly interpolated if necessary"));
163 layoutPointsSelections->addWidget (m_btnFunctionsPointsAllCurves, row++, 0, 1, 4);
164 connect (m_btnFunctionsPointsAllCurves, SIGNAL (released()),
this, SLOT (slotFunctionsPointsAllCurves()));
166 m_btnFunctionsPointsFirstCurve =
new QRadioButton (tr (
"Interpolate Ys at Xs from first curve"));
167 m_btnFunctionsPointsFirstCurve->setWhatsThis (tr (
"Exported file will have values at every unique X "
168 "value from the first curve. Y values will be linearly interpolated if necessary"));
169 layoutPointsSelections->addWidget (m_btnFunctionsPointsFirstCurve, row++, 0, 1, 4);
170 connect (m_btnFunctionsPointsFirstCurve, SIGNAL (released()),
this, SLOT (slotFunctionsPointsFirstCurve()));
172 m_btnFunctionsPointsEvenlySpaced =
new QRadioButton (tr (
"Interpolate Ys at evenly spaced X values."));
173 m_btnFunctionsPointsEvenlySpaced->setWhatsThis (tr (
"Exported file will have values at evenly spaced X values, separated by the interval selected below."));
174 layoutPointsSelections->addWidget (m_btnFunctionsPointsEvenlySpaced, row++, 0, 1, 4);
175 connect (m_btnFunctionsPointsEvenlySpaced, SIGNAL (released()),
this, SLOT (slotFunctionsPointsEvenlySpaced()));
177 QLabel *labelInterval =
new QLabel (
"Interval:");
178 layoutPointsSelections->addWidget (labelInterval, row, 1, 1, 1, Qt::AlignRight);
180 m_editFunctionsPointsEvenlySpacing =
new QLineEdit;
181 m_validatorFunctionsPointsEvenlySpacing =
new QDoubleValidator;
182 m_editFunctionsPointsEvenlySpacing->setValidator (m_validatorFunctionsPointsEvenlySpacing);
183 m_editFunctionsPointsEvenlySpacing->setMinimumWidth (MIN_EDIT_WIDTH);
184 m_editFunctionsPointsEvenlySpacing->setMaximumWidth (MAX_EDIT_WIDTH);
185 m_editFunctionsPointsEvenlySpacing->setWhatsThis (tr (
"Interval, in the units of X, between successive points in the X direction.\n\n"
186 "If the scale is linear, then this interval is added to successive X values. If the scale is "
187 "logarithmic, then this interval is multiplied to successive X values.\n\n"
188 "The X values will be automatically aligned along simple numbers. If the first and/or last "
189 "points are not along the aligned X values, then one or two additional points are added "
191 layoutPointsSelections->addWidget (m_editFunctionsPointsEvenlySpacing, row, 2, 1, 1, Qt::AlignLeft);
192 connect (m_editFunctionsPointsEvenlySpacing, SIGNAL (textChanged(
const QString &)),
this, SLOT (slotFunctionsPointsEvenlySpacedInterval(
const QString &)));
194 m_cmbFunctionsPointsEvenlySpacingUnits =
new QComboBox;
195 m_cmbFunctionsPointsEvenlySpacingUnits->setWhatsThis (
"Units for spacing interval.\n\n"
196 "Pixel units are preferred when the spacing is to be independent of the X scale. The spacing will be "
197 "consistent across the graph, even if the X scale is logarithmic.\n\n"
198 "Graph units are preferred when the spacing is to depend on the X scale.");
199 m_cmbFunctionsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_GRAPH),
200 QVariant (EXPORT_POINTS_INTERVAL_UNITS_GRAPH));
201 m_cmbFunctionsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_SCREEN),
202 QVariant (EXPORT_POINTS_INTERVAL_UNITS_SCREEN));
203 connect (m_cmbFunctionsPointsEvenlySpacingUnits, SIGNAL (activated (
const QString &)),
204 this, SLOT (slotFunctionsPointsEvenlySpacedIntervalUnits (
const QString &)));
205 layoutPointsSelections->addWidget (m_cmbFunctionsPointsEvenlySpacingUnits, row++, 3, 1, 1, Qt::AlignLeft);
207 m_btnFunctionsPointsRaw =
new QRadioButton (tr (
"Raw Xs and Ys"));
208 m_btnFunctionsPointsRaw->setWhatsThis (tr (
"Exported file will have only original X and Y values"));
209 layoutPointsSelections->addWidget (m_btnFunctionsPointsRaw, row++, 0, 1, 4);
210 connect (m_btnFunctionsPointsRaw, SIGNAL (released()),
this, SLOT (slotFunctionsPointsRaw()));
213 void DlgSettingsExportFormat::createHeader (QHBoxLayout *layoutMisc)
215 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createHeader";
217 const int COLUMN_RADIO_BUTTONS = 0, COLUMN_EMPTY = 1, COLUMN_LABEL = 2;
219 QGroupBox *groupHeader =
new QGroupBox (tr (
"Header"));
220 layoutMisc->addWidget (groupHeader, 1);
222 QGridLayout *layoutHeader =
new QGridLayout;
223 layoutHeader->setColumnMinimumWidth(COLUMN_EMPTY,
224 MIN_HEADER_EMPTY_COLUMN_WIDTH);
225 groupHeader->setLayout (layoutHeader);
228 m_btnHeaderNone =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_NONE));
229 m_btnHeaderNone->setWhatsThis (tr (
"Exported file will have no header line"));
230 layoutHeader->addWidget (m_btnHeaderNone, row++, COLUMN_RADIO_BUTTONS, 1, 1);
231 connect (m_btnHeaderNone, SIGNAL (released ()),
this, SLOT (slotHeaderNone()));
233 m_btnHeaderSimple =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_SIMPLE));
234 m_btnHeaderSimple->setWhatsThis (tr (
"Exported file will have simple header line"));
235 layoutHeader->addWidget (m_btnHeaderSimple, row++, COLUMN_RADIO_BUTTONS, 1, 1);
236 connect (m_btnHeaderSimple, SIGNAL (released ()),
this, SLOT (slotHeaderSimple()));
238 m_btnHeaderGnuplot =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_GNUPLOT));
239 m_btnHeaderGnuplot->setWhatsThis (tr (
"Exported file will have gnuplot header line"));
240 layoutHeader->addWidget (m_btnHeaderGnuplot, row++, COLUMN_RADIO_BUTTONS, 1, 1);
241 connect (m_btnHeaderGnuplot, SIGNAL (released()),
this, SLOT (slotHeaderGnuplot()));
243 createXLabel (layoutHeader,
247 void DlgSettingsExportFormat::createPreview(QGridLayout *layout,
int &row)
249 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createPreview";
251 QLabel *label =
new QLabel (tr (
"Preview"));
252 layout->addWidget (label, row++, 0, 1, 3);
254 m_editPreview =
new QTextEdit;
255 m_editPreview->setReadOnly (
true);
256 m_editPreview->setWhatsThis (tr (
"Preview window shows how current settings affect the exported file"));
259 layout->addWidget (m_editPreview, row++, 0, 1, 3);
262 void DlgSettingsExportFormat::createRelationsPointsSelection (QHBoxLayout *layoutRelations)
264 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createRelationsPointsSelection";
266 QGroupBox *groupPointsSelection =
new QGroupBox (tr (
"Points Selection"));
267 layoutRelations->addWidget (groupPointsSelection);
269 QGridLayout *layoutPointsSelections =
new QGridLayout;
270 groupPointsSelection->setLayout (layoutPointsSelections);
272 layoutPointsSelections->setColumnMinimumWidth(0, MIN_INDENT_COLUMN_WIDTH);
273 layoutPointsSelections->setColumnStretch (0, 0);
274 layoutPointsSelections->setColumnStretch (1, 0);
275 layoutPointsSelections->setColumnStretch (2, 0);
276 layoutPointsSelections->setColumnStretch (3, 1);
279 m_btnRelationsPointsEvenlySpaced =
new QRadioButton (tr (
"Interpolate Xs and Ys at evenly spaced intervals."));
280 m_btnRelationsPointsEvenlySpaced->setWhatsThis (tr (
"Exported file will have points evenly spaced along each relation, separated by the interval "
281 "selected below. If the last interval does not end at the last point, then a shorter last interval "
282 "is added that ends on the last point."));
283 layoutPointsSelections->addWidget (m_btnRelationsPointsEvenlySpaced, row++, 0, 1, 4);
284 connect (m_btnRelationsPointsEvenlySpaced, SIGNAL (released()),
this, SLOT (slotRelationsPointsEvenlySpaced()));
286 QLabel *labelInterval =
new QLabel (
"Interval:");
287 layoutPointsSelections->addWidget (labelInterval, row, 1, 1, 1, Qt::AlignRight);
289 m_editRelationsPointsEvenlySpacing =
new QLineEdit;
290 m_validatorRelationsPointsEvenlySpacing =
new QDoubleValidator;
291 m_editRelationsPointsEvenlySpacing->setValidator (m_validatorRelationsPointsEvenlySpacing);
292 m_editRelationsPointsEvenlySpacing->setMinimumWidth (MIN_EDIT_WIDTH);
293 m_editRelationsPointsEvenlySpacing->setMaximumWidth (MAX_EDIT_WIDTH);
294 m_editRelationsPointsEvenlySpacing->setWhatsThis (tr (
"Interval between successive points when "
295 "exporting at evenly spaced (X,Y) coordinates."));
296 layoutPointsSelections->addWidget (m_editRelationsPointsEvenlySpacing, row, 2, 1, 1, Qt::AlignLeft);
297 connect (m_editRelationsPointsEvenlySpacing, SIGNAL (textChanged(
const QString &)),
this, SLOT (slotRelationsPointsEvenlySpacedInterval(
const QString &)));
299 m_cmbRelationsPointsEvenlySpacingUnits =
new QComboBox;
300 m_cmbRelationsPointsEvenlySpacingUnits->setWhatsThis (
"Units for spacing interval.\n\n"
301 "Pixel units are preferred when the spacing is to be independent of the X and Y scales. The spacing will be "
302 "consistent across the graph, even if a scale is logarithmic or the X and Y scales are different.\n\n"
303 "Graph units are usually preferred when the X and Y scales are identical.");
304 m_cmbRelationsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_GRAPH),
305 QVariant (EXPORT_POINTS_INTERVAL_UNITS_GRAPH));
306 m_cmbRelationsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_SCREEN),
307 QVariant (EXPORT_POINTS_INTERVAL_UNITS_SCREEN));
308 connect (m_cmbRelationsPointsEvenlySpacingUnits, SIGNAL (activated (
const QString &)),
309 this, SLOT (slotRelationsPointsEvenlySpacedIntervalUnits (
const QString &)));
310 layoutPointsSelections->addWidget (m_cmbRelationsPointsEvenlySpacingUnits, row++, 3, 1, 1, Qt::AlignLeft);
312 m_btnRelationsPointsRaw =
new QRadioButton (tr (
"Raw Xs and Ys"));
313 m_btnRelationsPointsRaw->setWhatsThis (tr (
"Exported file will have only original X and Y values"));
314 layoutPointsSelections->addWidget (m_btnRelationsPointsRaw, row++, 0, 1, 4);
315 connect (m_btnRelationsPointsRaw, SIGNAL (released()),
this, SLOT (slotRelationsPointsRaw()));
320 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createSubPanel";
322 QWidget *subPanel =
new QWidget ();
323 QGridLayout *layout =
new QGridLayout (subPanel);
324 subPanel->setLayout (layout);
327 createCurveSelection (layout, row);
329 createTabWidget (layout,
332 QWidget *widgetMisc =
new QWidget;
333 layout->addWidget (widgetMisc, row++, 0, 1, 3);
334 QHBoxLayout *layoutMisc =
new QHBoxLayout;
335 widgetMisc->setLayout (layoutMisc);
337 createDelimiters (layoutMisc);
338 createHeader (layoutMisc);
339 createFileLayout (layoutMisc);
341 createPreview (layout, row);
346 void DlgSettingsExportFormat::createTabWidget (QGridLayout *layout,
349 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createTabWidget";
351 m_tabWidget =
new QTabWidget;
353 layout->addWidget (m_tabWidget, row++, 0, 1, 3);
355 QWidget *widgetFunctions =
new QWidget;
356 int indexFunctions = m_tabWidget->addTab (widgetFunctions, tr (
"Functions"));
357 QWidget *tabFunctions = m_tabWidget->widget (indexFunctions);
358 tabFunctions->setWhatsThis (tr (
"Functions Tab\n\n"
359 "Controls for specifying the format of functions during export"));
360 QHBoxLayout *layoutFunctions =
new QHBoxLayout;
361 widgetFunctions->setLayout (layoutFunctions);
363 QWidget *widgetRelations =
new QWidget;
364 int indexRelations = m_tabWidget->addTab (widgetRelations, tr (
"Relations"));
365 QWidget *tabRelations = m_tabWidget->widget (indexRelations);
366 tabRelations->setWhatsThis (tr (
"Relations Tab\n\n"
367 "Controls for specifying the format of relations during export"));
368 QHBoxLayout *layoutRelations =
new QHBoxLayout;
369 widgetRelations->setLayout (layoutRelations);
372 connect (m_tabWidget, SIGNAL (currentChanged (
int)),
this, SLOT (slotTabChanged (
int)));
374 createFunctionsPointsSelection (layoutFunctions);
375 createRelationsPointsSelection (layoutRelations);
378 void DlgSettingsExportFormat::createXLabel (QGridLayout *layoutHeader,
381 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createXLabel";
387 title =
new QLabel (tr (
"X Label:"));
389 title =
new QLabel (tr (
"Theta Label:"));
391 layoutHeader->addWidget (title, row++, colLabel, 1, 1);
393 m_editXLabel =
new QLineEdit;
395 m_editXLabel->setWhatsThis (tr (
"Label in the header for x values"));
397 m_editXLabel->setWhatsThis (tr (
"Label in the header for theta values"));
399 layoutHeader->addWidget (m_editXLabel, row++, colLabel, 1, 1);
400 connect (m_editXLabel, SIGNAL (textChanged (
const QString &)),
this, SLOT (slotXLabel(
const QString &)));
403 bool DlgSettingsExportFormat::goodIntervalFunctions()
const
405 QString textFunctions = m_editFunctionsPointsEvenlySpacing->text();
408 bool isGood = (m_validatorFunctionsPointsEvenlySpacing->validate (textFunctions, posFunctions) == QValidator::Acceptable);
413 bool DlgSettingsExportFormat::goodIntervalRelations()
const
415 QString textRelations = m_editRelationsPointsEvenlySpacing->text();
418 return (m_validatorRelationsPointsEvenlySpacing->validate (textRelations, posRelations) == QValidator::Acceptable);
423 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::handleOk";
427 *m_modelExportBefore,
428 *m_modelExportAfter);
434 void DlgSettingsExportFormat::initializeIntervalConstraints ()
436 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::initializeIntervalConstraints";
438 const int MAX_POINTS_ACROSS_RANGE = 1000;
443 Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
449 double maxSizeGraph = qMax (ftor.boundingRectGraph(isEmpty).width(),
450 ftor.boundingRectGraph(isEmpty).height());
451 double maxSizeScreen = qMax (ftor.boundingRectScreen(isEmpty).width(),
452 ftor.boundingRectScreen(isEmpty).height());
453 m_minIntervalGraph = maxSizeGraph / MAX_POINTS_ACROSS_RANGE;
454 m_minIntervalScreen = maxSizeScreen / MAX_POINTS_ACROSS_RANGE;
459 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::load";
464 if (m_modelExportBefore != 0) {
465 delete m_modelExportBefore;
467 if (m_modelExportAfter != 0) {
468 delete m_modelExportAfter;
476 m_listExcluded->clear();
478 QStringList::const_iterator itr;
479 for (itr = curveNamesExcluded.begin (); itr != curveNamesExcluded.end(); ++itr) {
480 QString curveNameNotExported = *itr;
481 m_listExcluded->addItem (curveNameNotExported);
485 m_listIncluded->clear();
487 for (itr = curveNamesAll.begin (); itr != curveNamesAll.end(); itr++) {
488 QString curveName = *itr;
489 if (!curveNamesExcluded.contains (curveName)) {
490 m_listIncluded->addItem (curveName);
495 m_btnFunctionsPointsAllCurves->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_ALL_CURVES);
496 m_btnFunctionsPointsFirstCurve->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_FIRST_CURVE);
497 m_btnFunctionsPointsEvenlySpaced->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_PERIODIC);
498 m_btnFunctionsPointsRaw->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_RAW);
500 ExportLayoutFunctions layoutFunctions = m_modelExportAfter->
layoutFunctions ();
501 m_btnFunctionsLayoutAllCurves->setChecked (layoutFunctions == EXPORT_LAYOUT_ALL_PER_LINE);
502 m_btnFunctionsLayoutOneCurve->setChecked (layoutFunctions == EXPORT_LAYOUT_ONE_PER_LINE);
505 m_btnRelationsPointsEvenlySpaced->setChecked (pointsSelectionRelations == EXPORT_POINTS_SELECTION_RELATIONS_INTERPOLATE);
506 m_btnRelationsPointsRaw->setChecked (pointsSelectionRelations == EXPORT_POINTS_SELECTION_RELATIONS_RAW);
508 ExportDelimiter delimiter = m_modelExportAfter->
delimiter ();
509 m_btnDelimitersCommas->setChecked (delimiter == EXPORT_DELIMITER_COMMA);
510 m_btnDelimitersSpaces->setChecked (delimiter == EXPORT_DELIMITER_SPACE);
511 m_btnDelimitersTabs->setChecked (delimiter == EXPORT_DELIMITER_TAB);
513 ExportHeader header = m_modelExportAfter->
header ();
514 m_btnHeaderNone->setChecked (header == EXPORT_HEADER_NONE);
515 m_btnHeaderSimple->setChecked (header == EXPORT_HEADER_SIMPLE);
516 m_btnHeaderGnuplot->setChecked (header == EXPORT_HEADER_GNUPLOT);
518 m_editXLabel->setText (m_modelExportAfter->
xLabel());
524 int indexFunctions = m_cmbRelationsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsFunctions));
525 int indexRelations = m_cmbRelationsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsRelations));
526 m_cmbFunctionsPointsEvenlySpacingUnits->setCurrentIndex (indexFunctions);
527 m_cmbRelationsPointsEvenlySpacingUnits->setCurrentIndex (indexRelations);
529 initializeIntervalConstraints ();
532 updateIntervalConstraints();
537 void DlgSettingsExportFormat::slotDelimitersCommas()
539 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersCommas";
541 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_COMMA);
546 void DlgSettingsExportFormat::slotDelimitersSpaces()
548 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersSpaces";
550 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_SPACE);
555 void DlgSettingsExportFormat::slotDelimitersTabs()
557 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersTabs";
564 void DlgSettingsExportFormat::slotExclude ()
566 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotExclude";
570 QStringList excluded;
571 for (i = 0; i < m_listIncluded->count(); i++) {
572 if (m_listIncluded->item(i)->isSelected()) {
573 excluded += m_listIncluded->item(i)->text();
578 for (i = 0; i < excluded.count(); i++) {
579 QString curveName = excluded.at (i);
580 m_listExcluded->addItem (curveName);
584 for (i = m_listIncluded->count() - 1; i>= 0; i--) {
585 QString curveName = m_listIncluded->item(i)->text();
586 if (excluded.contains (curveName)) {
587 QListWidgetItem *item = m_listIncluded->item (i);
588 m_listIncluded->removeItemWidget (item);
598 void DlgSettingsExportFormat::slotFunctionsLayoutAllCurves()
600 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsLayoutAllCurves";
607 void DlgSettingsExportFormat::slotFunctionsLayoutOneCurve()
609 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsLayoutOneCurve";
616 void DlgSettingsExportFormat::slotFunctionsPointsAllCurves()
618 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsAllCurves";
625 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced()
627 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced";
634 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval(
const QString &)
636 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval";
639 if (goodIntervalFunctions()) {
644 m_editPreview->setText(EMPTY_PREVIEW);
648 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits(
const QString &)
650 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits";
652 int index = m_cmbFunctionsPointsEvenlySpacingUnits->currentIndex();
653 ExportPointsIntervalUnits units = (ExportPointsIntervalUnits) m_cmbFunctionsPointsEvenlySpacingUnits->itemData (index).toInt();
656 updateIntervalConstraints();
661 void DlgSettingsExportFormat::slotFunctionsPointsFirstCurve()
663 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsFirstCurve";
670 void DlgSettingsExportFormat::slotFunctionsPointsRaw()
672 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsRaw";
679 void DlgSettingsExportFormat::slotHeaderGnuplot()
681 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderGnuplot";
683 m_modelExportAfter->
setHeader(EXPORT_HEADER_GNUPLOT);
688 void DlgSettingsExportFormat::slotHeaderNone()
690 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderNone";
692 m_modelExportAfter->
setHeader(EXPORT_HEADER_NONE);
697 void DlgSettingsExportFormat::slotHeaderSimple()
699 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderSimple";
701 m_modelExportAfter->
setHeader(EXPORT_HEADER_SIMPLE);
706 void DlgSettingsExportFormat::slotInclude ()
708 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotInclude";
712 QStringList included;
713 for (i = 0; i < m_listExcluded->count(); i++) {
714 if (m_listExcluded->item(i)->isSelected()) {
715 included += m_listExcluded->item(i)->text();
720 for (i = 0; i < included.count(); i++) {
721 QString curveName = included.at (i);
722 m_listIncluded->addItem (curveName);
726 QStringList excluded;
727 for (i = m_listExcluded->count() - 1; i>= 0; i--) {
728 QString curveName = m_listExcluded->item(i)->text();
729 QListWidgetItem *item = m_listExcluded->item (i);
730 if (included.contains (curveName)) {
731 m_listExcluded->removeItemWidget (item);
734 excluded += item->text();
743 void DlgSettingsExportFormat::slotListExcluded()
745 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotListExcluded";
751 void DlgSettingsExportFormat::slotListIncluded()
753 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotListIncluded";
759 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced()
761 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced";
768 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval(
const QString &)
770 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval";
777 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits(
const QString &)
779 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits";
781 int index = m_cmbRelationsPointsEvenlySpacingUnits->currentIndex();
782 ExportPointsIntervalUnits units = (ExportPointsIntervalUnits) m_cmbRelationsPointsEvenlySpacingUnits->itemData (index).toInt();
785 updateIntervalConstraints();
790 void DlgSettingsExportFormat::slotRelationsPointsRaw()
792 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsRaw";
799 void DlgSettingsExportFormat::slotTabChanged (
int)
801 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotTabChanged";
806 void DlgSettingsExportFormat::slotXLabel(
const QString &)
808 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotXLabel";
810 m_modelExportAfter->
setXLabel (m_editXLabel->text());
815 void DlgSettingsExportFormat::updateControls ()
817 bool isGoodState = goodIntervalFunctions() &&
818 goodIntervalRelations();
821 m_listIncluded->sortItems (Qt::AscendingOrder);
822 m_listExcluded->sortItems (Qt::AscendingOrder);
824 int selectedForInclude = m_listExcluded->selectedItems().count();
825 int selectedForExclude = m_listIncluded->selectedItems().count();
826 int inInclude = m_listIncluded->count();
828 m_btnInclude->setEnabled (selectedForInclude > 0);
829 m_btnExclude->setEnabled ((selectedForExclude > 0) && (inInclude - selectedForExclude > 0));
831 m_editFunctionsPointsEvenlySpacing->setEnabled (m_btnFunctionsPointsEvenlySpaced->isChecked ());
832 m_editRelationsPointsEvenlySpacing->setEnabled (m_btnRelationsPointsEvenlySpaced->isChecked ());
834 m_editXLabel->setEnabled (!m_btnHeaderNone->isChecked());
837 void DlgSettingsExportFormat::updateIntervalConstraints ()
841 m_minIntervalScreen);
844 m_minIntervalScreen);
846 if (m_tabWidget->currentIndex() == TAB_WIDGET_INDEX_FUNCTIONS) {
850 m_editFunctionsPointsEvenlySpacing->setText (QString::number (functionsMin));
854 m_validatorFunctionsPointsEvenlySpacing->setBottom (functionsMin);
860 m_editRelationsPointsEvenlySpacing->setText (QString::number (relationsMin));
861 m_validatorFunctionsPointsEvenlySpacing->setBottom (relationsMin);
865 m_validatorRelationsPointsEvenlySpacing->setBottom (relationsMin);
869 void DlgSettingsExportFormat::updatePreview()
872 int scrollPosition = m_editPreview->verticalScrollBar()->value();
874 QString exportedText;
875 QTextStream str (&exportedText);
877 if (
mainWindow().transformation().transformIsDefined()) {
880 if (m_tabWidget->currentIndex() == TAB_WIDGET_INDEX_FUNCTIONS) {
899 str <<
"Preview is unavailable until axis points are defined.";
902 m_editPreview->setText (exportedText);
905 m_editPreview->verticalScrollBar()->setValue (scrollPosition);
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
void exportToFile(const DocumentModelExportFormat &modelExportOverride, const Document &document, 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...
void exportToFile(const DocumentModelExportFormat &modelExportOverride, const Document &document, const Transformation &transformation, QTextStream &str) const
Export Document points according to the settings.
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.