7 #include "CallbackBoundingRects.h" 8 #include "CmdMediator.h" 9 #include "CmdSettingsExportFormat.h" 10 #include "DocumentModelExportFormat.h" 11 #include "DlgSettingsExportFormat.h" 12 #include "ExportFileFunctions.h" 13 #include "ExportFileRelations.h" 15 #include "MainWindow.h" 16 #include "MainWindowModel.h" 19 #include <QDoubleValidator> 20 #include <QGridLayout> 22 #include <QHBoxLayout> 25 #include <QListWidget> 26 #include <QPushButton> 27 #include <QRadioButton> 32 #include <QTextStream> 33 #include <QVBoxLayout> 35 #include "Transformation.h" 38 const QString COLOR_FUNCTIONS = (
"#DDDDFF");
39 const QString COLOR_RELATIONS = (
"#DDFFDD");
41 const int MIN_INDENT_COLUMN_WIDTH = 20;
42 const int MIN_HEADER_EMPTY_COLUMN_WIDTH = 10;
43 const int MIN_EDIT_WIDTH = 110;
44 const int MAX_EDIT_WIDTH = 180;
46 const int TAB_WIDGET_INDEX_FUNCTIONS = 0;
47 const int TAB_WIDGET_INDEX_RELATIONS = 1;
49 const QString EMPTY_PREVIEW;
51 const int MINIMUM_DIALOG_WIDTH_EXPORT_FORMAT = 600;
52 const int MINIMUM_HEIGHT = 780;
56 "DlgSettingsExportFormat",
58 m_validatorFunctionsPointsEvenlySpacing (nullptr),
59 m_validatorRelationsPointsEvenlySpacing (nullptr),
60 m_modelExportBefore (nullptr),
61 m_modelExportAfter (nullptr),
62 m_haveFunction (false),
63 m_haveRelation (false)
65 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::DlgSettingsExportFormat";
69 MINIMUM_DIALOG_WIDTH_EXPORT_FORMAT);
72 DlgSettingsExportFormat::~DlgSettingsExportFormat()
74 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::~DlgSettingsExportFormat";
76 delete m_validatorFunctionsPointsEvenlySpacing;
77 delete m_validatorRelationsPointsEvenlySpacing;
80 void DlgSettingsExportFormat::createCurveSelection (QGridLayout *layout,
int &row)
82 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createCurveSelection";
84 QLabel *labelIncluded =
new QLabel (tr (
"Included"));
85 layout->addWidget (labelIncluded, row, 0);
87 QLabel *labelExcluded =
new QLabel (tr (
"Not included"));
88 layout->addWidget (labelExcluded, row++, 2);
90 m_listIncluded =
new QListWidget;
91 m_listIncluded->setSortingEnabled (
false);
92 m_listIncluded->setWhatsThis (tr (
"List of curves to be included in the exported file.\n\n" 93 "The order of the curves here does not affect the order in the exported file. That " 94 "order is determined by the Curves settings."));
95 m_listIncluded->setSelectionMode (QAbstractItemView::MultiSelection);
96 layout->addWidget (m_listIncluded, row, 0, 4, 1);
97 connect (m_listIncluded, SIGNAL (itemSelectionChanged ()),
this, SLOT (slotListIncluded()));
99 m_listExcluded =
new QListWidget;
100 m_listExcluded->setSortingEnabled (
false);
101 m_listExcluded->setWhatsThis (tr (
"List of curves to be excluded from the exported file"));
102 m_listExcluded->setSelectionMode (QAbstractItemView::MultiSelection);
103 layout->addWidget (m_listExcluded, row++, 2, 4, 1);
104 connect (m_listExcluded, SIGNAL (itemSelectionChanged ()),
this, SLOT (slotListExcluded()));
106 m_btnInclude =
new QPushButton (QString (
"<<%1").arg (tr (
"Include")));
107 m_btnInclude->setEnabled (
false);
108 m_btnInclude->setWhatsThis (tr (
"Move the currently selected curve(s) from the excluded list"));
109 layout->addWidget (m_btnInclude, row++, 1);
110 connect (m_btnInclude, SIGNAL (released ()),
this, SLOT (slotInclude()));
112 m_btnExclude =
new QPushButton (QString (
"%1>>").arg (tr (
"Exclude")));
113 m_btnExclude->setEnabled (
false);
114 m_btnExclude->setWhatsThis (tr (
"Move the currently selected curve(s) from the included list"));
115 layout->addWidget (m_btnExclude, row++, 1);
116 connect (m_btnExclude, SIGNAL (released ()),
this, SLOT (slotExclude()));
121 void DlgSettingsExportFormat::createDelimiters (QHBoxLayout *layoutMisc)
123 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createDelimiters";
125 QGroupBox *groupDelimiters =
new QGroupBox (tr (
"Delimiters"));
126 layoutMisc->addWidget (groupDelimiters, 1);
128 QVBoxLayout *layoutDelimiters =
new QVBoxLayout;
129 groupDelimiters->setLayout (layoutDelimiters);
131 m_btnDelimitersCommas =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_COMMA));
132 m_btnDelimitersCommas->setWhatsThis (tr (
"Exported file will have commas between adjacent values, unless overridden by tabs in TSV files."));
133 layoutDelimiters->addWidget (m_btnDelimitersCommas);
134 connect (m_btnDelimitersCommas, SIGNAL (released ()),
this, SLOT (slotDelimitersCommas()));
136 m_btnDelimitersSpaces =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_SPACE));
137 m_btnDelimitersSpaces->setWhatsThis (tr (
"Exported file will have spaces between adjacent values, unless overridden by commas in CSV files, " 138 "or tabs in TSV files."));
139 layoutDelimiters->addWidget (m_btnDelimitersSpaces);
140 connect (m_btnDelimitersSpaces, SIGNAL (released ()),
this, SLOT (slotDelimitersSpaces()));
142 m_btnDelimitersTabs =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_TAB));
143 m_btnDelimitersTabs->setWhatsThis (tr (
"Exported file will have tabs between adjacent values, unless overridden by commas in CSV files."));
144 layoutDelimiters->addWidget (m_btnDelimitersTabs);
145 connect (m_btnDelimitersTabs, SIGNAL (released ()),
this, SLOT (slotDelimitersTabs()));
147 m_btnDelimitersSemicolons =
new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_SEMICOLON));
148 m_btnDelimitersSemicolons->setWhatsThis (tr (
"Exported file will have semicolons between adjacent values, unless overridden by commas in CSV files."));
149 layoutDelimiters->addWidget (m_btnDelimitersSemicolons);
150 connect (m_btnDelimitersSemicolons, SIGNAL (released ()),
this, SLOT (slotDelimitersSemicolons()));
152 m_chkOverrideCsvTsv =
new QCheckBox (tr (
"Override in CSV/TSV files"));
153 m_chkOverrideCsvTsv->setWhatsThis (tr (
"Comma-separated value (CSV) files and tab-separated value (TSV) files will use commas and tabs " 154 "respectively, unless this setting is selected. Selecting this setting will apply the delimiter setting " 156 connect (m_chkOverrideCsvTsv, SIGNAL (stateChanged (
int)),
this, SLOT (slotOverrideCsvTsv(
int)));
157 layoutDelimiters->addWidget (m_chkOverrideCsvTsv);
160 void DlgSettingsExportFormat::createFileLayout (QHBoxLayout *layoutMisc)
162 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createFileLayout";
164 QGroupBox *groupLayout =
new QGroupBox (tr (
"Layout"));
165 layoutMisc->addWidget (groupLayout, 1);
167 QVBoxLayout *layoutLayout =
new QVBoxLayout;
168 groupLayout->setLayout (layoutLayout);
170 m_btnCurvesLayoutAllCurves =
new QRadioButton (tr (
"All curves on each line"));
171 m_btnCurvesLayoutAllCurves->setWhatsThis (tr (
"Exported file will have, on each line, " 172 "an X value, the Y value for the first curve, the Y value for the second curve,..."));
173 layoutLayout->addWidget (m_btnCurvesLayoutAllCurves);
174 connect (m_btnCurvesLayoutAllCurves, SIGNAL (released()),
this, SLOT (slotFunctionsLayoutAllCurves ()));
176 m_btnCurvesLayoutOneCurve =
new QRadioButton (tr (
"One curve on each line"));
177 m_btnCurvesLayoutOneCurve->setWhatsThis (tr (
"Exported file will have all the points for " 178 "the first curve, with one X-Y pair on each line, then the points for the second curve,..."));
179 layoutLayout->addWidget (m_btnCurvesLayoutOneCurve);
180 connect (m_btnCurvesLayoutOneCurve, SIGNAL (released()),
this, SLOT (slotFunctionsLayoutOneCurve ()));
183 void DlgSettingsExportFormat::createFunctionsPointsSelection (QHBoxLayout *layoutFunctions)
185 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createFunctionsPointsSelection";
187 QGroupBox *groupPointsSelection =
new QGroupBox (tr (
"Function Points Selection"));
188 layoutFunctions->addWidget (groupPointsSelection, 1);
190 QGridLayout *layoutPointsSelections =
new QGridLayout;
191 groupPointsSelection->setLayout (layoutPointsSelections);
193 layoutPointsSelections->setColumnMinimumWidth(0, MIN_INDENT_COLUMN_WIDTH);
194 layoutPointsSelections->setColumnStretch (0, 0);
195 layoutPointsSelections->setColumnStretch (1, 0);
196 layoutPointsSelections->setColumnStretch (2, 0);
197 layoutPointsSelections->setColumnStretch (3, 1);
201 m_btnFunctionsPointsAllCurves =
new QRadioButton (tr (
"Interpolate Ys at Xs from all curves"));
202 m_btnFunctionsPointsAllCurves->setWhatsThis (tr (
"Exported file will have values at every unique X " 203 "value from every curve. Y values will be linearly interpolated if necessary"));
204 layoutPointsSelections->addWidget (m_btnFunctionsPointsAllCurves, row, 0, 1, 2);
205 connect (m_btnFunctionsPointsAllCurves, SIGNAL (released()),
this, SLOT (slotFunctionsPointsAllCurves()));
208 m_chkExtrapolateOutsideEndpoints =
new QCheckBox (tr (
"Extrapolate outside endpoints"));
209 m_chkExtrapolateOutsideEndpoints->setWhatsThis (tr (
"Enable or disable extrapolation outside of endpoints of each curve. If disabled, " 210 "only points between the endpoints of each curve are exported"));
211 layoutPointsSelections->addWidget (m_chkExtrapolateOutsideEndpoints, row++, 3, 1, 1, Qt::AlignRight);
212 connect (m_chkExtrapolateOutsideEndpoints, SIGNAL (stateChanged (
int)),
this, SLOT (slotFunctionsExtrapolateOutsideEndpoints(
int)));
214 m_btnFunctionsPointsFirstCurve =
new QRadioButton (tr (
"Interpolate Ys at Xs from first curve"));
215 m_btnFunctionsPointsFirstCurve->setWhatsThis (tr (
"Exported file will have values at every unique X " 216 "value from the first curve. Y values will be linearly interpolated if necessary"));
217 layoutPointsSelections->addWidget (m_btnFunctionsPointsFirstCurve, row++, 0, 1, 4);
218 connect (m_btnFunctionsPointsFirstCurve, SIGNAL (released()),
this, SLOT (slotFunctionsPointsFirstCurve()));
220 m_btnFunctionsPointsEvenlySpaced =
new QRadioButton (tr (
"Interpolate Ys at evenly spaced X values that are automatically selected"));
221 m_btnFunctionsPointsEvenlySpaced->setWhatsThis (tr (
"Exported file will have values at evenly spaced X values, separated by the interval selected below."));
222 layoutPointsSelections->addWidget (m_btnFunctionsPointsEvenlySpaced, row++, 0, 1, 4);
223 connect (m_btnFunctionsPointsEvenlySpaced, SIGNAL (released()),
this, SLOT (slotFunctionsPointsEvenlySpaced()));
225 QLabel *labelInterval =
new QLabel (QString (
"%1:").arg (tr (
"Interval")));
226 layoutPointsSelections->addWidget (labelInterval, row, 1, 1, 1, Qt::AlignRight);
228 m_editFunctionsPointsEvenlySpacing =
new QLineEdit;
229 m_validatorFunctionsPointsEvenlySpacing =
new QDoubleValidator;
230 m_editFunctionsPointsEvenlySpacing->setValidator (m_validatorFunctionsPointsEvenlySpacing);
231 m_editFunctionsPointsEvenlySpacing->setMinimumWidth (MIN_EDIT_WIDTH);
232 m_editFunctionsPointsEvenlySpacing->setMaximumWidth (MAX_EDIT_WIDTH);
233 m_editFunctionsPointsEvenlySpacing->setWhatsThis (tr (
"Interval, in the units of X, between successive points in the X direction.\n\n" 234 "If the scale is linear, then this interval is added to successive X values. If the scale is " 235 "logarithmic, then this interval is multiplied to successive X values.\n\n" 236 "The X values will be automatically aligned along simple numbers. If the first and/or last " 237 "points are not along the aligned X values, then one or two additional points are added " 239 layoutPointsSelections->addWidget (m_editFunctionsPointsEvenlySpacing, row, 2, 1, 1, Qt::AlignLeft);
240 connect (m_editFunctionsPointsEvenlySpacing, SIGNAL (textChanged(
const QString &)),
this, SLOT (slotFunctionsPointsEvenlySpacedInterval(
const QString &)));
242 m_cmbFunctionsPointsEvenlySpacingUnits =
new QComboBox;
243 m_cmbFunctionsPointsEvenlySpacingUnits->setWhatsThis (tr (
"Units for spacing interval.\n\n" 244 "Pixel units are preferred when the spacing is to be independent of the X scale. The spacing will be " 245 "consistent across the graph, even if the X scale is logarithmic.\n\n" 246 "Graph units are preferred when the spacing is to depend on the X scale."));
247 m_cmbFunctionsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_GRAPH),
248 QVariant (EXPORT_POINTS_INTERVAL_UNITS_GRAPH));
249 m_cmbFunctionsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_SCREEN),
250 QVariant (EXPORT_POINTS_INTERVAL_UNITS_SCREEN));
251 connect (m_cmbFunctionsPointsEvenlySpacingUnits, SIGNAL (activated (
const QString &)),
252 this, SLOT (slotFunctionsPointsEvenlySpacedIntervalUnits (
const QString &)));
253 layoutPointsSelections->addWidget (m_cmbFunctionsPointsEvenlySpacingUnits, row++, 3, 1, 1, Qt::AlignLeft);
255 m_btnFunctionsPointsGridLines =
new QRadioButton (tr (
"Interpolate Ys at evenly spaced X values on grid lines"));
256 m_btnFunctionsPointsGridLines->setWhatsThis (tr (
"Exported file will have values at evenly spaced X values at the vertical grid lines."));
257 layoutPointsSelections->addWidget (m_btnFunctionsPointsGridLines, row++, 0, 1, 4);
258 connect (m_btnFunctionsPointsGridLines, SIGNAL (released()),
this, SLOT (slotFunctionsPointsGridLines()));
260 m_btnFunctionsPointsRaw =
new QRadioButton (tr (
"Raw Xs and Ys"));
261 m_btnFunctionsPointsRaw->setWhatsThis (tr (
"Exported file will have only original X and Y values"));
262 layoutPointsSelections->addWidget (m_btnFunctionsPointsRaw, row++, 0, 1, 4);
263 connect (m_btnFunctionsPointsRaw, SIGNAL (released()),
this, SLOT (slotFunctionsPointsRaw()));
266 void DlgSettingsExportFormat::createHeader (QHBoxLayout *layoutMisc)
268 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createHeader";
270 const int COLUMN_RADIO_BUTTONS = 0, COLUMN_EMPTY = 1, COLUMN_LABEL = 2;
272 QGroupBox *groupHeader =
new QGroupBox (tr (
"Header"));
273 layoutMisc->addWidget (groupHeader, 1);
275 QGridLayout *layoutHeader =
new QGridLayout;
276 layoutHeader->setColumnMinimumWidth(COLUMN_EMPTY,
277 MIN_HEADER_EMPTY_COLUMN_WIDTH);
278 groupHeader->setLayout (layoutHeader);
281 m_btnHeaderNone =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_NONE));
282 m_btnHeaderNone->setWhatsThis (tr (
"Exported file will have no header line"));
283 layoutHeader->addWidget (m_btnHeaderNone, row++, COLUMN_RADIO_BUTTONS, 1, 1);
284 connect (m_btnHeaderNone, SIGNAL (released ()),
this, SLOT (slotHeaderNone()));
286 m_btnHeaderSimple =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_SIMPLE));
287 m_btnHeaderSimple->setWhatsThis (tr (
"Exported file will have simple header line"));
288 layoutHeader->addWidget (m_btnHeaderSimple, row++, COLUMN_RADIO_BUTTONS, 1, 1);
289 connect (m_btnHeaderSimple, SIGNAL (released ()),
this, SLOT (slotHeaderSimple()));
291 m_btnHeaderGnuplot =
new QRadioButton (exportHeaderToString (EXPORT_HEADER_GNUPLOT));
292 m_btnHeaderGnuplot->setWhatsThis (tr (
"Exported file will have gnuplot header line"));
293 layoutHeader->addWidget (m_btnHeaderGnuplot, row++, COLUMN_RADIO_BUTTONS, 1, 1);
294 connect (m_btnHeaderGnuplot, SIGNAL (released()),
this, SLOT (slotHeaderGnuplot()));
296 createXLabel (layoutHeader,
302 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createOptionalSaveDefault";
304 m_btnSaveDefault =
new QPushButton (tr (
"Save As Default"));
305 m_btnSaveDefault->setWhatsThis (tr (
"Save the settings for use as future defaults."));
306 connect (m_btnSaveDefault, SIGNAL (released ()),
this, SLOT (slotSaveDefault ()));
307 layout->addWidget (m_btnSaveDefault, 0, Qt::AlignLeft);
309 m_btnLoadDefault =
new QPushButton (tr (
"Load Default"));
310 m_btnLoadDefault->setWhatsThis (tr (
"Load the default settings."));
311 connect (m_btnLoadDefault, SIGNAL (released ()),
this, SLOT (slotLoadDefault ()));
312 layout->addWidget (m_btnLoadDefault, 0, Qt::AlignLeft);
315 void DlgSettingsExportFormat::createPreview(QGridLayout *layout,
int &row)
317 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createPreview";
319 QLabel *label =
new QLabel (tr (
"Preview"));
320 layout->addWidget (label, row, 0, 1, 3);
323 QLabel *labelLegend =
new QLabel;
324 labelLegend->setTextFormat (Qt::RichText);
325 QString legendHtml = QString (
"<span style=\"background-color: %1\"> Functions </span>" 327 "<span style=\"background-color: %2\"> Relations </span>")
328 .arg (COLOR_FUNCTIONS)
329 .arg (COLOR_RELATIONS);
330 labelLegend->setText (legendHtml);
331 layout->addWidget (labelLegend, row++, 1, 1, 2, Qt::AlignRight);
333 m_editPreview =
new QTextEdit;
334 m_editPreview->setReadOnly (
true);
335 m_editPreview->setWhatsThis (tr (
"Preview window shows how current settings affect the exported file.\n\n" 336 "Functions (shown here in blue) are output first, followed by relations " 337 "(shown here in green) if any exist."));
339 m_editPreview->document()->setDefaultStyleSheet(
"div { padding-left: 20px; }");
340 QPalette p = m_editPreview->palette();
341 p.setColor (QPalette::Base, QColor (240, 240, 240));
342 m_editPreview->setPalette (p);
344 layout->addWidget (m_editPreview, row++, 0, 1, 3);
347 void DlgSettingsExportFormat::createRelationsPointsSelection (QHBoxLayout *layoutRelations)
349 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createRelationsPointsSelection";
351 QGroupBox *groupPointsSelection =
new QGroupBox (tr (
"Relation Points Selection"));
352 layoutRelations->addWidget (groupPointsSelection);
354 QGridLayout *layoutPointsSelections =
new QGridLayout;
355 groupPointsSelection->setLayout (layoutPointsSelections);
357 layoutPointsSelections->setColumnMinimumWidth(0, MIN_INDENT_COLUMN_WIDTH);
358 layoutPointsSelections->setColumnStretch (0, 0);
359 layoutPointsSelections->setColumnStretch (1, 0);
360 layoutPointsSelections->setColumnStretch (2, 0);
361 layoutPointsSelections->setColumnStretch (3, 1);
365 m_btnRelationsPointsEvenlySpaced =
new QRadioButton (tr (
"Interpolate Xs and Ys at evenly spaced intervals."));
366 m_btnRelationsPointsEvenlySpaced->setWhatsThis (tr (
"Exported file will have points evenly spaced along each relation, separated by the interval " 367 "selected below. If the last interval does not end at the last point, then a shorter last interval " 368 "is added that ends on the last point."));
369 layoutPointsSelections->addWidget (m_btnRelationsPointsEvenlySpaced, row++, 0, 1, 4);
370 connect (m_btnRelationsPointsEvenlySpaced, SIGNAL (released()),
this, SLOT (slotRelationsPointsEvenlySpaced()));
372 QLabel *labelInterval =
new QLabel (QString (
"%1:").arg (tr (
"Interval")));
373 layoutPointsSelections->addWidget (labelInterval, row, 1, 1, 1, Qt::AlignRight);
375 m_editRelationsPointsEvenlySpacing =
new QLineEdit;
376 m_validatorRelationsPointsEvenlySpacing =
new QDoubleValidator;
377 m_editRelationsPointsEvenlySpacing->setValidator (m_validatorRelationsPointsEvenlySpacing);
378 m_editRelationsPointsEvenlySpacing->setMinimumWidth (MIN_EDIT_WIDTH);
379 m_editRelationsPointsEvenlySpacing->setMaximumWidth (MAX_EDIT_WIDTH);
380 m_editRelationsPointsEvenlySpacing->setWhatsThis (tr (
"Interval between successive points when " 381 "exporting at evenly spaced (X,Y) coordinates."));
382 layoutPointsSelections->addWidget (m_editRelationsPointsEvenlySpacing, row, 2, 1, 1, Qt::AlignLeft);
383 connect (m_editRelationsPointsEvenlySpacing, SIGNAL (textChanged(
const QString &)),
this, SLOT (slotRelationsPointsEvenlySpacedInterval(
const QString &)));
385 m_cmbRelationsPointsEvenlySpacingUnits =
new QComboBox;
386 m_cmbRelationsPointsEvenlySpacingUnits->setWhatsThis (tr (
"Units for spacing interval.\n\n" 387 "Pixel units are preferred when the spacing is to be independent of the X and Y scales. The spacing will be " 388 "consistent across the graph, even if a scale is logarithmic or the X and Y scales are different.\n\n" 389 "Graph units are usually preferred when the X and Y scales are identical."));
390 m_cmbRelationsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_GRAPH),
391 QVariant (EXPORT_POINTS_INTERVAL_UNITS_GRAPH));
392 m_cmbRelationsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_SCREEN),
393 QVariant (EXPORT_POINTS_INTERVAL_UNITS_SCREEN));
394 connect (m_cmbRelationsPointsEvenlySpacingUnits, SIGNAL (activated (
const QString &)),
395 this, SLOT (slotRelationsPointsEvenlySpacedIntervalUnits (
const QString &)));
396 layoutPointsSelections->addWidget (m_cmbRelationsPointsEvenlySpacingUnits, row++, 3, 1, 1, Qt::AlignLeft);
398 m_btnRelationsPointsRaw =
new QRadioButton (tr (
"Raw Xs and Ys"));
399 m_btnRelationsPointsRaw->setWhatsThis (tr (
"Exported file will have only original X and Y values"));
400 layoutPointsSelections->addWidget (m_btnRelationsPointsRaw, row++, 0, 1, 4);
401 connect (m_btnRelationsPointsRaw, SIGNAL (released()),
this, SLOT (slotRelationsPointsRaw()));
406 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createSubPanel";
408 QWidget *subPanel =
new QWidget ();
409 QGridLayout *layout =
new QGridLayout (subPanel);
410 subPanel->setLayout (layout);
413 createCurveSelection (layout, row);
415 createTabWidget (layout,
418 QWidget *widgetMisc =
new QWidget;
419 layout->addWidget (widgetMisc, row++, 0, 1, 3);
420 QHBoxLayout *layoutMisc =
new QHBoxLayout;
421 widgetMisc->setLayout (layoutMisc);
423 createDelimiters (layoutMisc);
424 createHeader (layoutMisc);
425 createFileLayout (layoutMisc);
427 createPreview (layout, row);
432 void DlgSettingsExportFormat::createTabWidget (QGridLayout *layout,
435 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createTabWidget";
437 m_tabWidget =
new QTabWidget;
439 layout->addWidget (m_tabWidget, row++, 0, 1, 3);
441 QWidget *widgetFunctions =
new QWidget;
442 int indexFunctions = m_tabWidget->addTab (widgetFunctions, tr (
"Functions"));
443 QWidget *tabFunctions = m_tabWidget->widget (indexFunctions);
444 tabFunctions->setWhatsThis (tr (
"Functions Tab\n\n" 445 "Controls for specifying the format of functions during export"));
446 QHBoxLayout *layoutFunctions =
new QHBoxLayout;
447 widgetFunctions->setLayout (layoutFunctions);
449 QWidget *widgetRelations =
new QWidget;
450 int indexRelations = m_tabWidget->addTab (widgetRelations, tr (
"Relations"));
451 QWidget *tabRelations = m_tabWidget->widget (indexRelations);
452 tabRelations->setWhatsThis (tr (
"Relations Tab\n\n" 453 "Controls for specifying the format of relations during export"));
454 QHBoxLayout *layoutRelations =
new QHBoxLayout;
455 widgetRelations->setLayout (layoutRelations);
458 connect (m_tabWidget, SIGNAL (currentChanged (
int)),
this, SLOT (slotTabChanged (
int)));
460 createFunctionsPointsSelection (layoutFunctions);
461 createRelationsPointsSelection (layoutRelations);
464 void DlgSettingsExportFormat::createXLabel (QGridLayout *layoutHeader,
467 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::createXLabel";
471 QLabel *title =
new QLabel (QString (
"%1:").arg (tr (
"X Label")));
472 layoutHeader->addWidget (title, row++, colLabel, 1, 1);
474 m_editXLabel =
new QLineEdit;
475 m_editXLabel->setWhatsThis (tr (
"Label in the header for x values"));
476 layoutHeader->addWidget (m_editXLabel, row++, colLabel, 1, 1);
477 connect (m_editXLabel, SIGNAL (textChanged (
const QString &)),
this, SLOT (slotXLabel(
const QString &)));
480 QString DlgSettingsExportFormat::exportedTextToExportedHtml (
const QString &text,
481 const QString &color)
const 483 QRegExp re (
"<br>$");
485 QString textCopy (text);
486 QString replaced = textCopy
487 .replace (
"\n",
"<br>")
488 .replace (
" ",
" ")
490 .replace (
"\t",
" ");
492 QString html = QString (
"<div style=\"display: inline; background-color: %1\">%2</div>")
499 bool DlgSettingsExportFormat::goodIntervalFunctions()
const 503 QString textFunctions = m_editFunctionsPointsEvenlySpacing->text();
506 bool isGood = (m_validatorFunctionsPointsEvenlySpacing->validate (textFunctions, posFunctions) == QValidator::Acceptable);
508 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::goodIntervalFunctions" 509 <<
" text=" << textFunctions.toLatin1().data()
510 <<
" good=" << (isGood ?
"true" :
"false")
511 <<
" bottom=" << m_validatorFunctionsPointsEvenlySpacing->bottom()
512 <<
" top=" << m_validatorFunctionsPointsEvenlySpacing->top();
517 bool DlgSettingsExportFormat::goodIntervalRelations()
const 521 QString textRelations = m_editRelationsPointsEvenlySpacing->text();
524 bool isGood = (m_validatorRelationsPointsEvenlySpacing->validate (textRelations, posRelations) == QValidator::Acceptable);
526 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::goodIntervalRelations" 527 <<
" text=" << textRelations.toLatin1().data()
528 <<
" good=" << (isGood ?
"true" :
"false")
529 <<
" bottom=" << m_validatorRelationsPointsEvenlySpacing->bottom()
530 <<
" top=" << m_validatorRelationsPointsEvenlySpacing->top();
537 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::handleOk";
541 *m_modelExportBefore,
542 *m_modelExportAfter);
548 void DlgSettingsExportFormat::initializeIntervalConstraints ()
550 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::initializeIntervalConstraints";
552 const int MAX_POINTS_ACROSS_RANGE = 5000;
558 Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
564 QPointF boundingRectGraphMin = ftor.boundingRectGraphMin (isEmpty);
565 QPointF boundingRectGraphMax = ftor.boundingRectGraphMax (isEmpty);
566 double maxSizeGraph = boundingRectGraphMax.x() - boundingRectGraphMin.x();
567 double maxSizeScreen = ftor.boundingRectScreen(isEmpty).width();
568 m_minIntervalGraph = maxSizeGraph / MAX_POINTS_ACROSS_RANGE;
569 m_minIntervalScreen = maxSizeScreen / MAX_POINTS_ACROSS_RANGE;
574 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::load";
579 delete m_modelExportBefore;
580 delete m_modelExportAfter;
587 m_listExcluded->clear();
589 QStringList::const_iterator itr;
590 for (itr = curveNamesExcluded.begin (); itr != curveNamesExcluded.end(); ++itr) {
591 QString curveNameNotExported = *itr;
592 m_listExcluded->addItem (curveNameNotExported);
596 m_listIncluded->clear();
598 for (itr = curveNamesAll.begin (); itr != curveNamesAll.end(); itr++) {
599 QString curveName = *itr;
600 if (!curveNamesExcluded.contains (curveName)) {
601 m_listIncluded->addItem (curveName);
606 m_btnFunctionsPointsAllCurves->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_ALL_CURVES);
607 m_btnFunctionsPointsFirstCurve->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_FIRST_CURVE);
608 m_btnFunctionsPointsEvenlySpaced->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_PERIODIC);
609 m_btnFunctionsPointsGridLines->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_GRID_LINES);
610 m_btnFunctionsPointsRaw->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_RAW);
612 ExportLayoutFunctions layoutFunctions = m_modelExportAfter->
layoutFunctions ();
613 m_btnCurvesLayoutAllCurves->setChecked (layoutFunctions == EXPORT_LAYOUT_ALL_PER_LINE);
614 m_btnCurvesLayoutOneCurve->setChecked (layoutFunctions == EXPORT_LAYOUT_ONE_PER_LINE);
617 m_btnRelationsPointsEvenlySpaced->setChecked (pointsSelectionRelations == EXPORT_POINTS_SELECTION_RELATIONS_INTERPOLATE);
618 m_btnRelationsPointsRaw->setChecked (pointsSelectionRelations == EXPORT_POINTS_SELECTION_RELATIONS_RAW);
620 ExportDelimiter delimiter = m_modelExportAfter->
delimiter ();
621 m_btnDelimitersCommas->setChecked (delimiter == EXPORT_DELIMITER_COMMA);
622 m_btnDelimitersSpaces->setChecked (delimiter == EXPORT_DELIMITER_SPACE);
623 m_btnDelimitersTabs->setChecked (delimiter == EXPORT_DELIMITER_TAB);
624 m_btnDelimitersSemicolons->setChecked (delimiter == EXPORT_DELIMITER_SEMICOLON);
628 m_chkOverrideCsvTsv->setChecked (m_modelExportAfter->
overrideCsvTsv());
630 ExportHeader header = m_modelExportAfter->
header ();
631 m_btnHeaderNone->setChecked (header == EXPORT_HEADER_NONE);
632 m_btnHeaderSimple->setChecked (header == EXPORT_HEADER_SIMPLE);
633 m_btnHeaderGnuplot->setChecked (header == EXPORT_HEADER_GNUPLOT);
635 m_editXLabel->setText (m_modelExportAfter->
xLabel());
642 int indexFunctions = m_cmbFunctionsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsFunctions));
643 int indexRelations = m_cmbRelationsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsRelations));
644 m_cmbFunctionsPointsEvenlySpacingUnits->setCurrentIndex (indexFunctions);
645 m_cmbRelationsPointsEvenlySpacingUnits->setCurrentIndex (indexRelations);
647 initializeIntervalConstraints ();
649 updateControlsUponLoad ();
651 updateIntervalConstraints();
659 setMinimumHeight (MINIMUM_HEIGHT);
663 void DlgSettingsExportFormat::slotDelimitersCommas()
665 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersCommas";
667 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_COMMA);
672 void DlgSettingsExportFormat::slotDelimitersSemicolons()
674 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersSemicolons";
676 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_SEMICOLON);
681 void DlgSettingsExportFormat::slotDelimitersSpaces()
683 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersSpaces";
685 m_modelExportAfter->
setDelimiter(EXPORT_DELIMITER_SPACE);
690 void DlgSettingsExportFormat::slotDelimitersTabs()
692 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotDelimitersTabs";
699 void DlgSettingsExportFormat::slotExclude ()
701 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotExclude";
705 QStringList excluded;
706 for (i = 0; i < m_listIncluded->count(); i++) {
707 if (m_listIncluded->item(i)->isSelected()) {
708 excluded += m_listIncluded->item(i)->text();
713 for (i = 0; i < excluded.count(); i++) {
714 QString curveName = excluded.at (i);
715 m_listExcluded->addItem (curveName);
719 for (i = m_listIncluded->count() - 1; i>= 0; i--) {
720 QString curveName = m_listIncluded->item(i)->text();
721 if (excluded.contains (curveName)) {
722 QListWidgetItem *item = m_listIncluded->item (i);
723 m_listIncluded->removeItemWidget (item);
733 void DlgSettingsExportFormat::slotFunctionsExtrapolateOutsideEndpoints(
int)
735 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsExtrapolateOutsideEndpoints";
742 void DlgSettingsExportFormat::slotFunctionsLayoutAllCurves()
744 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsLayoutAllCurves";
751 void DlgSettingsExportFormat::slotFunctionsLayoutOneCurve()
753 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsLayoutOneCurve";
760 void DlgSettingsExportFormat::slotFunctionsPointsAllCurves()
762 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsAllCurves";
769 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced()
771 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced";
778 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval(
const QString &)
780 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval";
783 if (goodIntervalFunctions()) {
788 m_editPreview->setText(EMPTY_PREVIEW);
792 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits(
const QString &)
794 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits";
796 int index = m_cmbFunctionsPointsEvenlySpacingUnits->currentIndex();
797 ExportPointsIntervalUnits units = static_cast<ExportPointsIntervalUnits> (m_cmbFunctionsPointsEvenlySpacingUnits->itemData (index).toInt());
800 updateIntervalConstraints();
805 void DlgSettingsExportFormat::slotFunctionsPointsFirstCurve()
807 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsFirstCurve";
814 void DlgSettingsExportFormat::slotFunctionsPointsGridLines()
816 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsGridLines";
823 void DlgSettingsExportFormat::slotFunctionsPointsRaw()
825 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotFunctionsPointsRaw";
832 void DlgSettingsExportFormat::slotHeaderGnuplot()
834 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderGnuplot";
836 m_modelExportAfter->
setHeader(EXPORT_HEADER_GNUPLOT);
841 void DlgSettingsExportFormat::slotHeaderNone()
843 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderNone";
845 m_modelExportAfter->
setHeader(EXPORT_HEADER_NONE);
850 void DlgSettingsExportFormat::slotHeaderSimple()
852 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotHeaderSimple";
854 m_modelExportAfter->
setHeader(EXPORT_HEADER_SIMPLE);
859 void DlgSettingsExportFormat::slotInclude ()
861 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotInclude";
865 QStringList included;
866 for (i = 0; i < m_listExcluded->count(); i++) {
867 if (m_listExcluded->item(i)->isSelected()) {
868 included += m_listExcluded->item(i)->text();
873 for (i = 0; i < included.count(); i++) {
874 QString curveName = included.at (i);
875 m_listIncluded->addItem (curveName);
879 QStringList excluded;
880 for (i = m_listExcluded->count() - 1; i>= 0; i--) {
881 QString curveName = m_listExcluded->item(i)->text();
882 QListWidgetItem *item = m_listExcluded->item (i);
883 if (included.contains (curveName)) {
884 m_listExcluded->removeItemWidget (item);
887 excluded += item->text();
896 void DlgSettingsExportFormat::slotListExcluded()
898 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotListExcluded";
904 void DlgSettingsExportFormat::slotListIncluded()
906 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotListIncluded";
912 void DlgSettingsExportFormat::slotLoadDefault()
914 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotLoadDefault";
921 m_btnHeaderGnuplot->setChecked (modelExportDefaults.
header() == EXPORT_HEADER_GNUPLOT);
922 m_btnHeaderNone->setChecked (modelExportDefaults.
header() == EXPORT_HEADER_NONE);
923 m_btnHeaderSimple->setChecked (modelExportDefaults.
header() == EXPORT_HEADER_SIMPLE);
925 m_editXLabel->setText (modelExportDefaults.
xLabel());
927 m_btnDelimitersCommas->setChecked (modelExportDefaults.
delimiter() == EXPORT_DELIMITER_COMMA);
928 m_btnDelimitersSemicolons->setChecked (modelExportDefaults.
delimiter() == EXPORT_DELIMITER_SEMICOLON);
929 m_btnDelimitersSpaces->setChecked (modelExportDefaults.
delimiter() == EXPORT_DELIMITER_SPACE);
930 m_btnDelimitersTabs->setChecked (modelExportDefaults.
delimiter() == EXPORT_DELIMITER_TAB);
932 m_chkOverrideCsvTsv->setChecked (modelExportDefaults.
overrideCsvTsv());
934 m_btnCurvesLayoutAllCurves->setChecked (modelExportDefaults.
layoutFunctions() == EXPORT_LAYOUT_ALL_PER_LINE);
935 m_btnCurvesLayoutOneCurve->setChecked (modelExportDefaults.
layoutFunctions() == EXPORT_LAYOUT_ONE_PER_LINE);
937 m_editFunctionsPointsEvenlySpacing->setText (QString::number (modelExportDefaults.
pointsIntervalFunctions ()));
938 m_editRelationsPointsEvenlySpacing->setText (QString::number (modelExportDefaults.
pointsIntervalRelations ()));
940 m_btnFunctionsPointsAllCurves->setChecked (modelExportDefaults.
pointsSelectionFunctions() == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_ALL_CURVES);
941 m_btnFunctionsPointsFirstCurve->setChecked (modelExportDefaults.
pointsSelectionFunctions() == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_FIRST_CURVE);
942 m_btnFunctionsPointsEvenlySpaced->setChecked (modelExportDefaults.
pointsSelectionFunctions() == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_PERIODIC);
943 m_btnFunctionsPointsGridLines->setChecked (modelExportDefaults.
pointsSelectionFunctions() == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_GRID_LINES);
944 m_btnFunctionsPointsRaw->setChecked (modelExportDefaults.
pointsSelectionFunctions() == EXPORT_POINTS_SELECTION_FUNCTIONS_RAW);
946 m_btnRelationsPointsEvenlySpaced->setChecked (modelExportDefaults.
pointsSelectionRelations() == EXPORT_POINTS_SELECTION_RELATIONS_INTERPOLATE);
947 m_btnRelationsPointsRaw->setChecked (modelExportDefaults.
pointsSelectionRelations() == EXPORT_POINTS_SELECTION_RELATIONS_RAW);
953 m_cmbFunctionsPointsEvenlySpacingUnits->setCurrentIndex (indexFunctions);
954 m_cmbRelationsPointsEvenlySpacingUnits->setCurrentIndex (indexRelations);
957 *m_modelExportAfter = modelExportDefaults;
963 void DlgSettingsExportFormat::slotOverrideCsvTsv(
int)
965 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotOverrideCsvTsv";
972 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced()
974 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced";
981 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval(
const QString &)
983 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval";
990 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits(
const QString &)
992 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits";
994 int index = m_cmbRelationsPointsEvenlySpacingUnits->currentIndex();
995 ExportPointsIntervalUnits units = static_cast<ExportPointsIntervalUnits> (m_cmbRelationsPointsEvenlySpacingUnits->itemData (index).toInt());
998 updateIntervalConstraints();
1003 void DlgSettingsExportFormat::slotRelationsPointsRaw()
1005 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotRelationsPointsRaw";
1012 void DlgSettingsExportFormat::slotSaveDefault()
1014 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotSaveDefault";
1016 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
1017 settings.beginGroup (SETTINGS_GROUP_EXPORT);
1021 settings.setValue (SETTINGS_EXPORT_DELIMITER,
1022 QVariant (m_modelExportAfter->
delimiter()));
1023 settings.setValue (SETTINGS_EXPORT_DELIMITER_OVERRIDE_CSV_TSV,
1025 settings.setValue (SETTINGS_EXPORT_EXTRAPOLATE_OUTSIDE_ENDPOINTS,
1027 settings.setValue (SETTINGS_EXPORT_HEADER,
1028 QVariant (m_modelExportAfter->
header()));
1029 settings.setValue (SETTINGS_EXPORT_LAYOUT_FUNCTIONS,
1031 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_FUNCTIONS,
1033 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_RELATIONS,
1035 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_FUNCTIONS,
1037 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_RELATIONS,
1039 settings.setValue (SETTINGS_EXPORT_POINTS_SELECTION_FUNCTIONS,
1041 settings.setValue (SETTINGS_EXPORT_POINTS_SELECTION_RELATIONS,
1043 settings.setValue (SETTINGS_EXPORT_X_LABEL,
1044 QVariant (m_modelExportAfter->
xLabel()));
1046 settings.endGroup ();
1049 void DlgSettingsExportFormat::slotTabChanged (
int)
1051 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotTabChanged";
1056 void DlgSettingsExportFormat::slotXLabel(
const QString &)
1058 LOG4CPP_INFO_S ((*mainCat)) <<
"DlgSettingsExportFormat::slotXLabel";
1060 m_modelExportAfter->
setXLabel (m_editXLabel->text());
1065 void DlgSettingsExportFormat::updateControls ()
1067 bool isGoodState = goodIntervalFunctions() &&
1068 goodIntervalRelations();
1072 m_chkExtrapolateOutsideEndpoints->setEnabled (!m_btnFunctionsPointsRaw->isChecked ());
1074 int selectedForInclude = m_listExcluded->selectedItems().count();
1075 int selectedForExclude = m_listIncluded->selectedItems().count();
1076 int inInclude = m_listIncluded->count();
1078 m_btnInclude->setEnabled (selectedForInclude > 0);
1079 m_btnExclude->setEnabled ((selectedForExclude > 0) && (inInclude - selectedForExclude > 0));
1081 m_editFunctionsPointsEvenlySpacing->setEnabled (m_haveFunction && m_btnFunctionsPointsEvenlySpaced->isChecked ());
1082 m_editRelationsPointsEvenlySpacing->setEnabled (m_haveRelation && m_btnRelationsPointsEvenlySpaced->isChecked ());
1084 m_editXLabel->setEnabled (!m_btnHeaderNone->isChecked());
1087 void DlgSettingsExportFormat::updateControlsUponLoad ()
1091 m_haveFunction =
false;
1092 m_haveRelation =
false;
1094 QStringList curveNames = curveStyles.
curveNames();
1096 QStringList::const_iterator itr;
1097 for (itr = curveNames.begin(); itr != curveNames.end (); itr++) {
1098 QString curveName = *itr;
1101 if (curveConnectAs == CONNECT_AS_FUNCTION_SMOOTH || curveConnectAs == CONNECT_AS_FUNCTION_STRAIGHT) {
1102 m_haveFunction =
true;
1103 }
else if (curveConnectAs == CONNECT_AS_RELATION_SMOOTH || curveConnectAs == CONNECT_AS_RELATION_STRAIGHT) {
1104 m_haveRelation =
true;
1109 m_btnFunctionsPointsAllCurves->setEnabled (m_haveFunction);
1110 m_btnFunctionsPointsFirstCurve->setEnabled (m_haveFunction);
1111 m_btnFunctionsPointsEvenlySpaced->setEnabled (m_haveFunction);
1112 m_editFunctionsPointsEvenlySpacing->setEnabled (m_haveFunction);
1113 m_cmbFunctionsPointsEvenlySpacingUnits->setEnabled (m_haveFunction);
1114 m_btnFunctionsPointsRaw->setEnabled (m_haveFunction);
1117 m_btnRelationsPointsEvenlySpaced->setEnabled (m_haveRelation);
1118 m_editRelationsPointsEvenlySpacing->setEnabled (m_haveRelation);
1119 m_cmbRelationsPointsEvenlySpacingUnits->setEnabled (m_haveRelation);
1120 m_btnRelationsPointsRaw->setEnabled (m_haveRelation);
1123 if (!m_haveRelation) {
1124 m_tabWidget->setCurrentIndex (TAB_WIDGET_INDEX_FUNCTIONS);
1125 }
else if (!m_haveFunction) {
1126 m_tabWidget->setCurrentIndex (TAB_WIDGET_INDEX_RELATIONS);
1130 void DlgSettingsExportFormat::updateIntervalConstraints ()
1133 m_minIntervalGraph :
1134 m_minIntervalScreen);
1136 m_minIntervalGraph :
1137 m_minIntervalScreen);
1142 functionsMin = qMax (1.00000001, functionsMin);
1145 if (m_tabWidget->currentIndex() == TAB_WIDGET_INDEX_FUNCTIONS) {
1149 m_editFunctionsPointsEvenlySpacing->setText (QString::number (functionsMin));
1153 m_validatorFunctionsPointsEvenlySpacing->setBottom (functionsMin);
1159 m_editRelationsPointsEvenlySpacing->setText (QString::number (relationsMin));
1163 m_validatorRelationsPointsEvenlySpacing->setBottom (relationsMin);
1167 void DlgSettingsExportFormat::updatePreview()
1170 int scrollPosition = m_editPreview->verticalScrollBar()->value();
1172 QString exportedTextFunctions, exportedTextRelations, exportedHtml;
1173 QTextStream strFunctions (&exportedTextFunctions);
1174 QTextStream strRelations (&exportedTextRelations);
1176 if (
mainWindow().transformation().transformIsDefined()) {
1178 unsigned int numWritesSoFar = 0;
1181 exportStrategyFunctions.
exportToFile (*m_modelExportAfter,
1189 exportStrategyRelations.
exportToFile (*m_modelExportAfter,
1200 QString exportedHtmlFunctions, exportedHtmlRelations;
1201 if (! exportedTextFunctions.isEmpty ()) {
1203 exportedHtmlFunctions = exportedTextToExportedHtml (exportedTextFunctions, COLOR_FUNCTIONS);
1205 if (! exportedTextRelations.isEmpty ()) {
1207 exportedHtmlRelations = exportedTextToExportedHtml (exportedTextRelations, COLOR_RELATIONS);
1210 exportedHtml = exportedHtmlFunctions + exportedHtmlRelations;
1214 exportedHtml = tr (
"Preview is unavailable until axis points are defined.");
1217 m_editPreview->setHtml (exportedHtml);
1220 m_editPreview->verticalScrollBar()->setValue (scrollPosition);
CurveStyle curveStyle(const QString &curveName) const
CurveStyle in specified curve.
CurveConnectAs curveConnectAs() const
Get method for connect type.
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
QStringList curveNames() const
List of all curve names.
Model for DlgSettingsCurveProperties and CmdSettingsCurveProperties.
void setCmdMediator(CmdMediator &cmdMediator)
Store CmdMediator for easy access by the leaf class.
void finishPanel(QWidget *subPanel, int minimumWidth=MINIMUM_DIALOG_WIDTH, int minimumHeightOrZero=0)
Add Ok and Cancel buttons to subpanel to get the whole dialog.
Strategy class for exporting to a file. This strategy is external to the Document class so that class...
LineStyle lineStyle() const
Get method for LineStyle.
void exportToFile(const DocumentModelExportFormat &modelExportOverride, const Document &document, const MainWindowModel &modelMainWindow, const Transformation &transformation, QTextStream &str, unsigned int &numWritesSoFar) const
Export Document points according to the settings.
Container for LineStyle and PointStyle for one Curve.
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
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.
CurveStyles modelCurveStyles() const
Get method for CurveStyles.
Callback for computing the bounding rectangles of the screen and graph coordinates of the points in t...
MainWindow & mainWindow()
Get method for MainWindow.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
QStringList curvesGraphsNames() const
See CurvesGraphs::curvesGraphsNames.
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, unsigned int &numWritesSoFar) const
Export Document points according to the settings.