00001
00002
00003
00004
00005
00006
00007 #include "CallbackBoundingRects.h"
00008 #include "CmdMediator.h"
00009 #include "CmdSettingsExportFormat.h"
00010 #include "DocumentModelExportFormat.h"
00011 #include "DlgSettingsExportFormat.h"
00012 #include "ExportFileFunctions.h"
00013 #include "ExportFileRelations.h"
00014 #include "Logger.h"
00015 #include "MainWindow.h"
00016 #include "MainWindowModel.h"
00017 #include <QCheckBox>
00018 #include <QComboBox>
00019 #include <QDoubleValidator>
00020 #include <QGridLayout>
00021 #include <QGroupBox>
00022 #include <QHBoxLayout>
00023 #include <QLabel>
00024 #include <QLineEdit>
00025 #include <QListWidget>
00026 #include <QPushButton>
00027 #include <QRadioButton>
00028 #include <QScrollBar>
00029 #include <QSettings>
00030 #include <QTabWidget>
00031 #include <QTextEdit>
00032 #include <QTextStream>
00033 #include <QVBoxLayout>
00034 #include "Settings.h"
00035 #include "Transformation.h"
00036
00037 const int MIN_INDENT_COLUMN_WIDTH = 20;
00038 const int MIN_HEADER_EMPTY_COLUMN_WIDTH = 10;
00039 const int MIN_EDIT_WIDTH = 110;
00040 const int MAX_EDIT_WIDTH = 180;
00041
00042 const int TAB_WIDGET_INDEX_FUNCTIONS = 0;
00043
00044
00045 const QString EMPTY_PREVIEW;
00046
00047 DlgSettingsExportFormat::DlgSettingsExportFormat(MainWindow &mainWindow) :
00048 DlgSettingsAbstractBase (tr ("Export Format"),
00049 "DlgSettingsExportFormat",
00050 mainWindow),
00051 m_modelExportBefore (0),
00052 m_modelExportAfter (0)
00053 {
00054 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::DlgSettingsExportFormat";
00055
00056 QWidget *subPanel = createSubPanel ();
00057 finishPanel (subPanel);
00058 }
00059
00060 DlgSettingsExportFormat::~DlgSettingsExportFormat()
00061 {
00062 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::~DlgSettingsExportFormat";
00063 }
00064
00065 void DlgSettingsExportFormat::createCurveSelection (QGridLayout *layout, int &row)
00066 {
00067 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::createCurveSelection";
00068
00069 QLabel *labelIncluded = new QLabel (tr ("Included"));
00070 layout->addWidget (labelIncluded, row, 0);
00071
00072 QLabel *labelExcluded = new QLabel (tr ("Not included"));
00073 layout->addWidget (labelExcluded, row++, 2);
00074
00075 m_listIncluded = new QListWidget;
00076 m_listIncluded->setWhatsThis (tr ("List of curves to be included in the exported file.\n\n"
00077 "The order of the curves here does not affect the order in the exported file. That "
00078 "order is determined by the Curves settings."));
00079 m_listIncluded->setSelectionMode (QAbstractItemView::MultiSelection);
00080 layout->addWidget (m_listIncluded, row, 0, 4, 1);
00081 connect (m_listIncluded, SIGNAL (itemSelectionChanged ()), this, SLOT (slotListIncluded()));
00082
00083 m_listExcluded = new QListWidget;
00084 m_listExcluded->setWhatsThis (tr ("List of curves to be excluded from the exported file"));
00085 m_listExcluded->setSelectionMode (QAbstractItemView::MultiSelection);
00086 layout->addWidget (m_listExcluded, row++, 2, 4, 1);
00087 connect (m_listExcluded, SIGNAL (itemSelectionChanged ()), this, SLOT (slotListExcluded()));
00088
00089 m_btnInclude = new QPushButton (tr ("<<Include"));
00090 m_btnInclude->setEnabled (false);
00091 m_btnInclude->setWhatsThis (tr ("Move the currently selected curve(s) from the excluded list"));
00092 layout->addWidget (m_btnInclude, row++, 1);
00093 connect (m_btnInclude, SIGNAL (released ()), this, SLOT (slotInclude()));
00094
00095 m_btnExclude = new QPushButton (tr ("Exclude>>"));
00096 m_btnExclude->setEnabled (false);
00097 m_btnExclude->setWhatsThis (tr ("Move the currently selected curve(s) from the included list"));
00098 layout->addWidget (m_btnExclude, row++, 1);
00099 connect (m_btnExclude, SIGNAL (released ()), this, SLOT (slotExclude()));
00100
00101 row++;
00102 }
00103
00104 void DlgSettingsExportFormat::createDelimiters (QHBoxLayout *layoutMisc)
00105 {
00106 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::createDelimiters";
00107
00108 QGroupBox *groupDelimiters = new QGroupBox (tr ("Delimiters"));
00109 layoutMisc->addWidget (groupDelimiters, 1);
00110
00111 QVBoxLayout *layoutDelimiters = new QVBoxLayout;
00112 groupDelimiters->setLayout (layoutDelimiters);
00113
00114 m_btnDelimitersCommas = new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_COMMA));
00115 m_btnDelimitersCommas->setWhatsThis (tr ("Exported file will have commas between adjacent values, unless overridden by tabs in TSV files."));
00116 layoutDelimiters->addWidget (m_btnDelimitersCommas);
00117 connect (m_btnDelimitersCommas, SIGNAL (released ()), this, SLOT (slotDelimitersCommas()));
00118
00119 m_btnDelimitersSpaces = new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_SPACE));
00120 m_btnDelimitersSpaces->setWhatsThis (tr ("Exported file will have spaces between adjacent values, unless overridden by commas in CSV files, "
00121 "or tabs in TSV files."));
00122 layoutDelimiters->addWidget (m_btnDelimitersSpaces);
00123 connect (m_btnDelimitersSpaces, SIGNAL (released ()), this, SLOT (slotDelimitersSpaces()));
00124
00125 m_btnDelimitersTabs = new QRadioButton (exportDelimiterToString (EXPORT_DELIMITER_TAB));
00126 m_btnDelimitersTabs->setWhatsThis (tr ("Exported file will have tabs between adjacent values, unless overridden by commas in CSV files."));
00127 layoutDelimiters->addWidget (m_btnDelimitersTabs);
00128 connect (m_btnDelimitersTabs, SIGNAL (released ()), this, SLOT (slotDelimitersTabs()));
00129
00130 m_chkOverrideCsvTsv = new QCheckBox (tr ("Override in CSV/TSV files"));
00131 m_chkOverrideCsvTsv->setWhatsThis (tr ("Comma-separated value (CSV) files and tab-separated value (TSV) files will use commas and tabs "
00132 "respectively, unless this setting is selected. Selecting this setting will apply the delimiter setting "
00133 "to every file."));
00134 connect (m_chkOverrideCsvTsv, SIGNAL (stateChanged (int)), this, SLOT (slotOverrideCsvTsv(int)));
00135 layoutDelimiters->addWidget (m_chkOverrideCsvTsv);
00136 }
00137
00138 void DlgSettingsExportFormat::createFileLayout (QHBoxLayout *layoutMisc)
00139 {
00140 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::createFileLayout";
00141
00142 QGroupBox *groupLayout = new QGroupBox (tr ("Layout"));
00143 layoutMisc->addWidget (groupLayout, 1);
00144
00145 QVBoxLayout *layoutLayout = new QVBoxLayout;
00146 groupLayout->setLayout (layoutLayout);
00147
00148 m_btnFunctionsLayoutAllCurves = new QRadioButton (tr ("All curves on each line"));
00149 m_btnFunctionsLayoutAllCurves->setWhatsThis (tr ("Exported file will have, on each line, "
00150 "an X value, the Y value for the first curve, the Y value for the second curve,..."));
00151 layoutLayout->addWidget (m_btnFunctionsLayoutAllCurves);
00152 connect (m_btnFunctionsLayoutAllCurves, SIGNAL (released()), this, SLOT (slotFunctionsLayoutAllCurves ()));
00153
00154 m_btnFunctionsLayoutOneCurve = new QRadioButton (tr ("One curve on each line"));
00155 m_btnFunctionsLayoutOneCurve->setWhatsThis (tr ("Exported file will have all the points for "
00156 "the first curve, with one X-Y pair on each line, then the points for the second curve,..."));
00157 layoutLayout->addWidget (m_btnFunctionsLayoutOneCurve);
00158 connect (m_btnFunctionsLayoutOneCurve, SIGNAL (released()), this, SLOT (slotFunctionsLayoutOneCurve ()));
00159 }
00160
00161 void DlgSettingsExportFormat::createFunctionsPointsSelection (QHBoxLayout *layoutFunctions)
00162 {
00163 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::createFunctionsPointsSelection";
00164
00165 QGroupBox *groupPointsSelection = new QGroupBox (tr ("Points Selection"));
00166 layoutFunctions->addWidget (groupPointsSelection, 1);
00167
00168 QGridLayout *layoutPointsSelections = new QGridLayout;
00169 groupPointsSelection->setLayout (layoutPointsSelections);
00170
00171 layoutPointsSelections->setColumnMinimumWidth(0, MIN_INDENT_COLUMN_WIDTH);
00172 layoutPointsSelections->setColumnStretch (0, 0);
00173 layoutPointsSelections->setColumnStretch (1, 0);
00174 layoutPointsSelections->setColumnStretch (2, 0);
00175 layoutPointsSelections->setColumnStretch (3, 1);
00176
00177 int row = 0;
00178 m_btnFunctionsPointsAllCurves = new QRadioButton (tr ("Interpolate Ys at Xs from all curves"));
00179 m_btnFunctionsPointsAllCurves->setWhatsThis (tr ("Exported file will have values at every unique X "
00180 "value from every curve. Y values will be linearly interpolated if necessary"));
00181 layoutPointsSelections->addWidget (m_btnFunctionsPointsAllCurves, row++, 0, 1, 4);
00182 connect (m_btnFunctionsPointsAllCurves, SIGNAL (released()), this, SLOT (slotFunctionsPointsAllCurves()));
00183
00184 m_btnFunctionsPointsFirstCurve = new QRadioButton (tr ("Interpolate Ys at Xs from first curve"));
00185 m_btnFunctionsPointsFirstCurve->setWhatsThis (tr ("Exported file will have values at every unique X "
00186 "value from the first curve. Y values will be linearly interpolated if necessary"));
00187 layoutPointsSelections->addWidget (m_btnFunctionsPointsFirstCurve, row++, 0, 1, 4);
00188 connect (m_btnFunctionsPointsFirstCurve, SIGNAL (released()), this, SLOT (slotFunctionsPointsFirstCurve()));
00189
00190 m_btnFunctionsPointsEvenlySpaced = new QRadioButton (tr ("Interpolate Ys at evenly spaced X values."));
00191 m_btnFunctionsPointsEvenlySpaced->setWhatsThis (tr ("Exported file will have values at evenly spaced X values, separated by the interval selected below."));
00192 layoutPointsSelections->addWidget (m_btnFunctionsPointsEvenlySpaced, row++, 0, 1, 4);
00193 connect (m_btnFunctionsPointsEvenlySpaced, SIGNAL (released()), this, SLOT (slotFunctionsPointsEvenlySpaced()));
00194
00195 QLabel *labelInterval = new QLabel (tr ("Interval:"));
00196 layoutPointsSelections->addWidget (labelInterval, row, 1, 1, 1, Qt::AlignRight);
00197
00198 m_editFunctionsPointsEvenlySpacing = new QLineEdit;
00199 m_validatorFunctionsPointsEvenlySpacing = new QDoubleValidator;
00200 m_editFunctionsPointsEvenlySpacing->setValidator (m_validatorFunctionsPointsEvenlySpacing);
00201 m_editFunctionsPointsEvenlySpacing->setMinimumWidth (MIN_EDIT_WIDTH);
00202 m_editFunctionsPointsEvenlySpacing->setMaximumWidth (MAX_EDIT_WIDTH);
00203 m_editFunctionsPointsEvenlySpacing->setWhatsThis (tr ("Interval, in the units of X, between successive points in the X direction.\n\n"
00204 "If the scale is linear, then this interval is added to successive X values. If the scale is "
00205 "logarithmic, then this interval is multiplied to successive X values.\n\n"
00206 "The X values will be automatically aligned along simple numbers. If the first and/or last "
00207 "points are not along the aligned X values, then one or two additional points are added "
00208 "as necessary."));
00209 layoutPointsSelections->addWidget (m_editFunctionsPointsEvenlySpacing, row, 2, 1, 1, Qt::AlignLeft);
00210 connect (m_editFunctionsPointsEvenlySpacing, SIGNAL (textChanged(const QString &)), this, SLOT (slotFunctionsPointsEvenlySpacedInterval(const QString &)));
00211
00212 m_cmbFunctionsPointsEvenlySpacingUnits = new QComboBox;
00213 m_cmbFunctionsPointsEvenlySpacingUnits->setWhatsThis (tr ("Units for spacing interval.\n\n"
00214 "Pixel units are preferred when the spacing is to be independent of the X scale. The spacing will be "
00215 "consistent across the graph, even if the X scale is logarithmic.\n\n"
00216 "Graph units are preferred when the spacing is to depend on the X scale."));
00217 m_cmbFunctionsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_GRAPH),
00218 QVariant (EXPORT_POINTS_INTERVAL_UNITS_GRAPH));
00219 m_cmbFunctionsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_SCREEN),
00220 QVariant (EXPORT_POINTS_INTERVAL_UNITS_SCREEN));
00221 connect (m_cmbFunctionsPointsEvenlySpacingUnits, SIGNAL (activated (const QString &)),
00222 this, SLOT (slotFunctionsPointsEvenlySpacedIntervalUnits (const QString &)));
00223 layoutPointsSelections->addWidget (m_cmbFunctionsPointsEvenlySpacingUnits, row++, 3, 1, 1, Qt::AlignLeft);
00224
00225 m_btnFunctionsPointsRaw = new QRadioButton (tr ("Raw Xs and Ys"));
00226 m_btnFunctionsPointsRaw->setWhatsThis (tr ("Exported file will have only original X and Y values"));
00227 layoutPointsSelections->addWidget (m_btnFunctionsPointsRaw, row++, 0, 1, 4);
00228 connect (m_btnFunctionsPointsRaw, SIGNAL (released()), this, SLOT (slotFunctionsPointsRaw()));
00229 }
00230
00231 void DlgSettingsExportFormat::createHeader (QHBoxLayout *layoutMisc)
00232 {
00233 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::createHeader";
00234
00235 const int COLUMN_RADIO_BUTTONS = 0, COLUMN_EMPTY = 1, COLUMN_LABEL = 2;
00236
00237 QGroupBox *groupHeader = new QGroupBox (tr ("Header"));
00238 layoutMisc->addWidget (groupHeader, 1);
00239
00240 QGridLayout *layoutHeader = new QGridLayout;
00241 layoutHeader->setColumnMinimumWidth(COLUMN_EMPTY,
00242 MIN_HEADER_EMPTY_COLUMN_WIDTH);
00243 groupHeader->setLayout (layoutHeader);
00244 int row = 0;
00245
00246 m_btnHeaderNone = new QRadioButton (exportHeaderToString (EXPORT_HEADER_NONE));
00247 m_btnHeaderNone->setWhatsThis (tr ("Exported file will have no header line"));
00248 layoutHeader->addWidget (m_btnHeaderNone, row++, COLUMN_RADIO_BUTTONS, 1, 1);
00249 connect (m_btnHeaderNone, SIGNAL (released ()), this, SLOT (slotHeaderNone()));
00250
00251 m_btnHeaderSimple = new QRadioButton (exportHeaderToString (EXPORT_HEADER_SIMPLE));
00252 m_btnHeaderSimple->setWhatsThis (tr ("Exported file will have simple header line"));
00253 layoutHeader->addWidget (m_btnHeaderSimple, row++, COLUMN_RADIO_BUTTONS, 1, 1);
00254 connect (m_btnHeaderSimple, SIGNAL (released ()), this, SLOT (slotHeaderSimple()));
00255
00256 m_btnHeaderGnuplot = new QRadioButton (exportHeaderToString (EXPORT_HEADER_GNUPLOT));
00257 m_btnHeaderGnuplot->setWhatsThis (tr ("Exported file will have gnuplot header line"));
00258 layoutHeader->addWidget (m_btnHeaderGnuplot, row++, COLUMN_RADIO_BUTTONS, 1, 1);
00259 connect (m_btnHeaderGnuplot, SIGNAL (released()), this, SLOT (slotHeaderGnuplot()));
00260
00261 createXLabel (layoutHeader,
00262 COLUMN_LABEL);
00263 }
00264
00265 void DlgSettingsExportFormat::createOptionalSaveDefault (QHBoxLayout *layout)
00266 {
00267 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::createOptionalSaveDefault";
00268
00269 m_btnSaveDefault = new QPushButton (tr ("Save As Default"));
00270 m_btnSaveDefault->setWhatsThis (tr ("Save the settings for use as future defaults."));
00271 connect (m_btnSaveDefault, SIGNAL (released ()), this, SLOT (slotSaveDefault ()));
00272 layout->addWidget (m_btnSaveDefault, 0, Qt::AlignLeft);
00273 }
00274
00275 void DlgSettingsExportFormat::createPreview(QGridLayout *layout, int &row)
00276 {
00277 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::createPreview";
00278
00279 QLabel *label = new QLabel (tr ("Preview"));
00280 layout->addWidget (label, row++, 0, 1, 3);
00281
00282 m_editPreview = new QTextEdit;
00283 m_editPreview->setReadOnly (true);
00284 m_editPreview->setWhatsThis (tr ("Preview window shows how current settings affect the exported file"));
00285 m_editPreview->setMinimumHeight (MINIMUM_PREVIEW_HEIGHT);
00286
00287 layout->addWidget (m_editPreview, row++, 0, 1, 3);
00288 }
00289
00290 void DlgSettingsExportFormat::createRelationsPointsSelection (QHBoxLayout *layoutRelations)
00291 {
00292 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::createRelationsPointsSelection";
00293
00294 QGroupBox *groupPointsSelection = new QGroupBox (tr ("Points Selection"));
00295 layoutRelations->addWidget (groupPointsSelection);
00296
00297 QGridLayout *layoutPointsSelections = new QGridLayout;
00298 groupPointsSelection->setLayout (layoutPointsSelections);
00299
00300 layoutPointsSelections->setColumnMinimumWidth(0, MIN_INDENT_COLUMN_WIDTH);
00301 layoutPointsSelections->setColumnStretch (0, 0);
00302 layoutPointsSelections->setColumnStretch (1, 0);
00303 layoutPointsSelections->setColumnStretch (2, 0);
00304 layoutPointsSelections->setColumnStretch (3, 1);
00305
00306 int row = 0;
00307 m_btnRelationsPointsEvenlySpaced = new QRadioButton (tr ("Interpolate Xs and Ys at evenly spaced intervals."));
00308 m_btnRelationsPointsEvenlySpaced->setWhatsThis (tr ("Exported file will have points evenly spaced along each relation, separated by the interval "
00309 "selected below. If the last interval does not end at the last point, then a shorter last interval "
00310 "is added that ends on the last point."));
00311 layoutPointsSelections->addWidget (m_btnRelationsPointsEvenlySpaced, row++, 0, 1, 4);
00312 connect (m_btnRelationsPointsEvenlySpaced, SIGNAL (released()), this, SLOT (slotRelationsPointsEvenlySpaced()));
00313
00314 QLabel *labelInterval = new QLabel (tr ("Interval:"));
00315 layoutPointsSelections->addWidget (labelInterval, row, 1, 1, 1, Qt::AlignRight);
00316
00317 m_editRelationsPointsEvenlySpacing = new QLineEdit;
00318 m_validatorRelationsPointsEvenlySpacing = new QDoubleValidator;
00319 m_editRelationsPointsEvenlySpacing->setValidator (m_validatorRelationsPointsEvenlySpacing);
00320 m_editRelationsPointsEvenlySpacing->setMinimumWidth (MIN_EDIT_WIDTH);
00321 m_editRelationsPointsEvenlySpacing->setMaximumWidth (MAX_EDIT_WIDTH);
00322 m_editRelationsPointsEvenlySpacing->setWhatsThis (tr ("Interval between successive points when "
00323 "exporting at evenly spaced (X,Y) coordinates."));
00324 layoutPointsSelections->addWidget (m_editRelationsPointsEvenlySpacing, row, 2, 1, 1, Qt::AlignLeft);
00325 connect (m_editRelationsPointsEvenlySpacing, SIGNAL (textChanged(const QString &)), this, SLOT (slotRelationsPointsEvenlySpacedInterval(const QString &)));
00326
00327 m_cmbRelationsPointsEvenlySpacingUnits = new QComboBox;
00328 m_cmbRelationsPointsEvenlySpacingUnits->setWhatsThis (tr ("Units for spacing interval.\n\n"
00329 "Pixel units are preferred when the spacing is to be independent of the X and Y scales. The spacing will be "
00330 "consistent across the graph, even if a scale is logarithmic or the X and Y scales are different.\n\n"
00331 "Graph units are usually preferred when the X and Y scales are identical."));
00332 m_cmbRelationsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_GRAPH),
00333 QVariant (EXPORT_POINTS_INTERVAL_UNITS_GRAPH));
00334 m_cmbRelationsPointsEvenlySpacingUnits->addItem(exportPointsIntervalUnitsToString (EXPORT_POINTS_INTERVAL_UNITS_SCREEN),
00335 QVariant (EXPORT_POINTS_INTERVAL_UNITS_SCREEN));
00336 connect (m_cmbRelationsPointsEvenlySpacingUnits, SIGNAL (activated (const QString &)),
00337 this, SLOT (slotRelationsPointsEvenlySpacedIntervalUnits (const QString &)));
00338 layoutPointsSelections->addWidget (m_cmbRelationsPointsEvenlySpacingUnits, row++, 3, 1, 1, Qt::AlignLeft);
00339
00340 m_btnRelationsPointsRaw = new QRadioButton (tr ("Raw Xs and Ys"));
00341 m_btnRelationsPointsRaw->setWhatsThis (tr ("Exported file will have only original X and Y values"));
00342 layoutPointsSelections->addWidget (m_btnRelationsPointsRaw, row++, 0, 1, 4);
00343 connect (m_btnRelationsPointsRaw, SIGNAL (released()), this, SLOT (slotRelationsPointsRaw()));
00344 }
00345
00346 QWidget *DlgSettingsExportFormat::createSubPanel ()
00347 {
00348 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::createSubPanel";
00349
00350 QWidget *subPanel = new QWidget ();
00351 QGridLayout *layout = new QGridLayout (subPanel);
00352 subPanel->setLayout (layout);
00353
00354 int row = 0;
00355 createCurveSelection (layout, row);
00356
00357 createTabWidget (layout,
00358 row);
00359
00360 QWidget *widgetMisc = new QWidget;
00361 layout->addWidget (widgetMisc, row++, 0, 1, 3);
00362 QHBoxLayout *layoutMisc = new QHBoxLayout;
00363 widgetMisc->setLayout (layoutMisc);
00364
00365 createDelimiters (layoutMisc);
00366 createHeader (layoutMisc);
00367 createFileLayout (layoutMisc);
00368
00369 createPreview (layout, row);
00370
00371 return subPanel;
00372 }
00373
00374 void DlgSettingsExportFormat::createTabWidget (QGridLayout *layout,
00375 int &row)
00376 {
00377 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::createTabWidget";
00378
00379 m_tabWidget = new QTabWidget;
00380
00381 layout->addWidget (m_tabWidget, row++, 0, 1, 3);
00382
00383 QWidget *widgetFunctions = new QWidget;
00384 int indexFunctions = m_tabWidget->addTab (widgetFunctions, tr ("Functions"));
00385 QWidget *tabFunctions = m_tabWidget->widget (indexFunctions);
00386 tabFunctions->setWhatsThis (tr ("Functions Tab\n\n"
00387 "Controls for specifying the format of functions during export"));
00388 QHBoxLayout *layoutFunctions = new QHBoxLayout;
00389 widgetFunctions->setLayout (layoutFunctions);
00390
00391 QWidget *widgetRelations = new QWidget;
00392 int indexRelations = m_tabWidget->addTab (widgetRelations, tr ("Relations"));
00393 QWidget *tabRelations = m_tabWidget->widget (indexRelations);
00394 tabRelations->setWhatsThis (tr ("Relations Tab\n\n"
00395 "Controls for specifying the format of relations during export"));
00396 QHBoxLayout *layoutRelations = new QHBoxLayout;
00397 widgetRelations->setLayout (layoutRelations);
00398
00399
00400 connect (m_tabWidget, SIGNAL (currentChanged (int)), this, SLOT (slotTabChanged (int)));
00401
00402 createFunctionsPointsSelection (layoutFunctions);
00403 createRelationsPointsSelection (layoutRelations);
00404 }
00405
00406 void DlgSettingsExportFormat::createXLabel (QGridLayout *layoutHeader,
00407 int colLabel)
00408 {
00409 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::createXLabel";
00410
00411 int row = 1;
00412
00413 QLabel *title;
00414 if (true) {
00415 title = new QLabel (tr ("X Label:"));
00416 } else {
00417 title = new QLabel (tr ("Theta Label:"));
00418 }
00419 layoutHeader->addWidget (title, row++, colLabel, 1, 1);
00420
00421 m_editXLabel = new QLineEdit;
00422 if (true) {
00423 m_editXLabel->setWhatsThis (tr ("Label in the header for x values"));
00424 } else {
00425 m_editXLabel->setWhatsThis (tr ("Label in the header for theta values"));
00426 }
00427 layoutHeader->addWidget (m_editXLabel, row++, colLabel, 1, 1);
00428 connect (m_editXLabel, SIGNAL (textChanged (const QString &)), this, SLOT (slotXLabel(const QString &)));
00429 }
00430
00431 bool DlgSettingsExportFormat::goodIntervalFunctions() const
00432 {
00433
00434
00435 QString textFunctions = m_editFunctionsPointsEvenlySpacing->text();
00436 int posFunctions;
00437
00438 bool isGood = (m_validatorFunctionsPointsEvenlySpacing->validate (textFunctions, posFunctions) == QValidator::Acceptable);
00439
00440 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::goodIntervalFunctions"
00441 << " text=" << textFunctions.toLatin1().data()
00442 << " good=" << (isGood ? "true" : "false")
00443 << " bottom=" << m_validatorFunctionsPointsEvenlySpacing->bottom()
00444 << " top=" << m_validatorFunctionsPointsEvenlySpacing->top();
00445
00446 return isGood;
00447 }
00448
00449 bool DlgSettingsExportFormat::goodIntervalRelations() const
00450 {
00451
00452
00453 QString textRelations = m_editRelationsPointsEvenlySpacing->text();
00454 int posRelations;
00455
00456 bool isGood = (m_validatorRelationsPointsEvenlySpacing->validate (textRelations, posRelations) == QValidator::Acceptable);
00457
00458 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::goodIntervalRelations"
00459 << " text=" << textRelations.toLatin1().data()
00460 << " good=" << (isGood ? "true" : "false")
00461 << " bottom=" << m_validatorRelationsPointsEvenlySpacing->bottom()
00462 << " top=" << m_validatorRelationsPointsEvenlySpacing->top();
00463
00464 return isGood;
00465 }
00466
00467 void DlgSettingsExportFormat::handleOk ()
00468 {
00469 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::handleOk";
00470
00471 CmdSettingsExportFormat *cmd = new CmdSettingsExportFormat (mainWindow (),
00472 cmdMediator ().document(),
00473 *m_modelExportBefore,
00474 *m_modelExportAfter);
00475 cmdMediator ().push (cmd);
00476
00477 hide ();
00478 }
00479
00480 void DlgSettingsExportFormat::initializeIntervalConstraints ()
00481 {
00482 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::initializeIntervalConstraints";
00483
00484 const int MAX_POINTS_ACROSS_RANGE = 5000;
00485
00486
00487 CallbackBoundingRects ftor (mainWindow().transformation());
00488
00489 Functor2wRet<const QString &, const Point &, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
00490 &CallbackBoundingRects::callback);
00491 cmdMediator().iterateThroughCurvesPointsGraphs (ftorWithCallback);
00492
00493
00494 bool isEmpty;
00495 double maxSizeGraph = qMax (ftor.boundingRectGraph(isEmpty).width(),
00496 ftor.boundingRectGraph(isEmpty).height());
00497 double maxSizeScreen = qMax (ftor.boundingRectScreen(isEmpty).width(),
00498 ftor.boundingRectScreen(isEmpty).height());
00499 m_minIntervalGraph = maxSizeGraph / MAX_POINTS_ACROSS_RANGE;
00500 m_minIntervalScreen = maxSizeScreen / MAX_POINTS_ACROSS_RANGE;
00501 }
00502
00503 void DlgSettingsExportFormat::load (CmdMediator &cmdMediator)
00504 {
00505 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::load";
00506
00507 setCmdMediator (cmdMediator);
00508
00509
00510 if (m_modelExportBefore != 0) {
00511 delete m_modelExportBefore;
00512 }
00513 if (m_modelExportAfter != 0) {
00514 delete m_modelExportAfter;
00515 }
00516
00517
00518 m_modelExportBefore = new DocumentModelExportFormat (cmdMediator.document());
00519 m_modelExportAfter = new DocumentModelExportFormat (cmdMediator.document());
00520
00521
00522 m_listExcluded->clear();
00523 QStringList curveNamesExcluded = m_modelExportAfter->curveNamesNotExported();
00524 QStringList::const_iterator itr;
00525 for (itr = curveNamesExcluded.begin (); itr != curveNamesExcluded.end(); ++itr) {
00526 QString curveNameNotExported = *itr;
00527 m_listExcluded->addItem (curveNameNotExported);
00528 }
00529
00530
00531 m_listIncluded->clear();
00532 QStringList curveNamesAll = cmdMediator.document().curvesGraphsNames();
00533 for (itr = curveNamesAll.begin (); itr != curveNamesAll.end(); itr++) {
00534 QString curveName = *itr;
00535 if (!curveNamesExcluded.contains (curveName)) {
00536 m_listIncluded->addItem (curveName);
00537 }
00538 }
00539
00540 ExportPointsSelectionFunctions pointsSelectionFunctions = m_modelExportAfter->pointsSelectionFunctions();
00541 m_btnFunctionsPointsAllCurves->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_ALL_CURVES);
00542 m_btnFunctionsPointsFirstCurve->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_FIRST_CURVE);
00543 m_btnFunctionsPointsEvenlySpaced->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_PERIODIC);
00544 m_btnFunctionsPointsRaw->setChecked (pointsSelectionFunctions == EXPORT_POINTS_SELECTION_FUNCTIONS_RAW);
00545
00546 ExportLayoutFunctions layoutFunctions = m_modelExportAfter->layoutFunctions ();
00547 m_btnFunctionsLayoutAllCurves->setChecked (layoutFunctions == EXPORT_LAYOUT_ALL_PER_LINE);
00548 m_btnFunctionsLayoutOneCurve->setChecked (layoutFunctions == EXPORT_LAYOUT_ONE_PER_LINE);
00549
00550 ExportPointsSelectionRelations pointsSelectionRelations = m_modelExportAfter->pointsSelectionRelations();
00551 m_btnRelationsPointsEvenlySpaced->setChecked (pointsSelectionRelations == EXPORT_POINTS_SELECTION_RELATIONS_INTERPOLATE);
00552 m_btnRelationsPointsRaw->setChecked (pointsSelectionRelations == EXPORT_POINTS_SELECTION_RELATIONS_RAW);
00553
00554 ExportDelimiter delimiter = m_modelExportAfter->delimiter ();
00555 m_btnDelimitersCommas->setChecked (delimiter == EXPORT_DELIMITER_COMMA);
00556 m_btnDelimitersSpaces->setChecked (delimiter == EXPORT_DELIMITER_SPACE);
00557 m_btnDelimitersTabs->setChecked (delimiter == EXPORT_DELIMITER_TAB);
00558
00559 m_chkOverrideCsvTsv->setChecked (m_modelExportAfter->overrideCsvTsv());
00560
00561 ExportHeader header = m_modelExportAfter->header ();
00562 m_btnHeaderNone->setChecked (header == EXPORT_HEADER_NONE);
00563 m_btnHeaderSimple->setChecked (header == EXPORT_HEADER_SIMPLE);
00564 m_btnHeaderGnuplot->setChecked (header == EXPORT_HEADER_GNUPLOT);
00565
00566 m_editXLabel->setText (m_modelExportAfter->xLabel());
00567
00568 m_editFunctionsPointsEvenlySpacing->setText (QString::number (m_modelExportAfter->pointsIntervalFunctions()));
00569 m_editRelationsPointsEvenlySpacing->setText (QString::number (m_modelExportAfter->pointsIntervalRelations()));
00570
00571 ExportPointsIntervalUnits pointsIntervalUnitsFunctions = m_modelExportAfter->pointsIntervalUnitsFunctions();
00572 ExportPointsIntervalUnits pointsIntervalUnitsRelations = m_modelExportAfter->pointsIntervalUnitsRelations();
00573 int indexFunctions = m_cmbFunctionsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsFunctions));
00574 int indexRelations = m_cmbRelationsPointsEvenlySpacingUnits->findData (QVariant (pointsIntervalUnitsRelations));
00575 m_cmbFunctionsPointsEvenlySpacingUnits->setCurrentIndex (indexFunctions);
00576 m_cmbRelationsPointsEvenlySpacingUnits->setCurrentIndex (indexRelations);
00577
00578 initializeIntervalConstraints ();
00579
00580 updateControls();
00581 updateIntervalConstraints();
00582 enableOk (false);
00583 updatePreview();
00584 }
00585
00586 void DlgSettingsExportFormat::slotDelimitersCommas()
00587 {
00588 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotDelimitersCommas";
00589
00590 m_modelExportAfter->setDelimiter(EXPORT_DELIMITER_COMMA);
00591 updateControls();
00592 updatePreview();
00593 }
00594
00595 void DlgSettingsExportFormat::slotDelimitersSpaces()
00596 {
00597 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotDelimitersSpaces";
00598
00599 m_modelExportAfter->setDelimiter(EXPORT_DELIMITER_SPACE);
00600 updateControls();
00601 updatePreview();
00602 }
00603
00604 void DlgSettingsExportFormat::slotDelimitersTabs()
00605 {
00606 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotDelimitersTabs";
00607
00608 m_modelExportAfter->setDelimiter(EXPORT_DELIMITER_TAB);
00609 updateControls();
00610 updatePreview();
00611 }
00612
00613 void DlgSettingsExportFormat::slotExclude ()
00614 {
00615 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotExclude";
00616
00617
00618 int i;
00619 QStringList excluded;
00620 for (i = 0; i < m_listIncluded->count(); i++) {
00621 if (m_listIncluded->item(i)->isSelected()) {
00622 excluded += m_listIncluded->item(i)->text();
00623 }
00624 }
00625
00626
00627 for (i = 0; i < excluded.count(); i++) {
00628 QString curveName = excluded.at (i);
00629 m_listExcluded->addItem (curveName);
00630 }
00631
00632
00633 for (i = m_listIncluded->count() - 1; i>= 0; i--) {
00634 QString curveName = m_listIncluded->item(i)->text();
00635 if (excluded.contains (curveName)) {
00636 QListWidgetItem *item = m_listIncluded->item (i);
00637 m_listIncluded->removeItemWidget (item);
00638 delete item;
00639 }
00640 }
00641
00642 m_modelExportAfter->setCurveNamesNotExported(excluded);
00643 updateControls();
00644 updatePreview();
00645 }
00646
00647 void DlgSettingsExportFormat::slotFunctionsLayoutAllCurves()
00648 {
00649 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotFunctionsLayoutAllCurves";
00650
00651 m_modelExportAfter->setLayoutFunctions(EXPORT_LAYOUT_ALL_PER_LINE);
00652 updateControls();
00653 updatePreview();
00654 }
00655
00656 void DlgSettingsExportFormat::slotFunctionsLayoutOneCurve()
00657 {
00658 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotFunctionsLayoutOneCurve";
00659
00660 m_modelExportAfter->setLayoutFunctions(EXPORT_LAYOUT_ONE_PER_LINE);
00661 updateControls();
00662 updatePreview();
00663 }
00664
00665 void DlgSettingsExportFormat::slotFunctionsPointsAllCurves()
00666 {
00667 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotFunctionsPointsAllCurves";
00668
00669 m_modelExportAfter->setPointsSelectionFunctions(EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_ALL_CURVES);
00670 updateControls();
00671 updatePreview();
00672 }
00673
00674 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced()
00675 {
00676 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotFunctionsPointsEvenlySpaced";
00677
00678 m_modelExportAfter->setPointsSelectionFunctions(EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_PERIODIC);
00679 updateControls();
00680 updatePreview();
00681 }
00682
00683 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval(const QString &)
00684 {
00685 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedInterval";
00686
00687
00688 if (goodIntervalFunctions()) {
00689 m_modelExportAfter->setPointsIntervalFunctions(m_editFunctionsPointsEvenlySpacing->text().toDouble());
00690 updateControls();
00691 updatePreview();
00692 } else {
00693 m_editPreview->setText(EMPTY_PREVIEW);
00694 }
00695 }
00696
00697 void DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits(const QString &)
00698 {
00699 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotFunctionsPointsEvenlySpacedIntervalUnits";
00700
00701 int index = m_cmbFunctionsPointsEvenlySpacingUnits->currentIndex();
00702 ExportPointsIntervalUnits units = (ExportPointsIntervalUnits) m_cmbFunctionsPointsEvenlySpacingUnits->itemData (index).toInt();
00703
00704 m_modelExportAfter->setPointsIntervalUnitsFunctions(units);
00705 updateIntervalConstraints();
00706 updateControls();
00707 updatePreview();
00708 }
00709
00710 void DlgSettingsExportFormat::slotFunctionsPointsFirstCurve()
00711 {
00712 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotFunctionsPointsFirstCurve";
00713
00714 m_modelExportAfter->setPointsSelectionFunctions(EXPORT_POINTS_SELECTION_FUNCTIONS_INTERPOLATE_FIRST_CURVE);
00715 updateControls();
00716 updatePreview();
00717 }
00718
00719 void DlgSettingsExportFormat::slotFunctionsPointsRaw()
00720 {
00721 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotFunctionsPointsRaw";
00722
00723 m_modelExportAfter->setPointsSelectionFunctions(EXPORT_POINTS_SELECTION_FUNCTIONS_RAW);
00724 updateControls();
00725 updatePreview();
00726 }
00727
00728 void DlgSettingsExportFormat::slotHeaderGnuplot()
00729 {
00730 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotHeaderGnuplot";
00731
00732 m_modelExportAfter->setHeader(EXPORT_HEADER_GNUPLOT);
00733 updateControls();
00734 updatePreview();
00735 }
00736
00737 void DlgSettingsExportFormat::slotHeaderNone()
00738 {
00739 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotHeaderNone";
00740
00741 m_modelExportAfter->setHeader(EXPORT_HEADER_NONE);
00742 updateControls();
00743 updatePreview();
00744 }
00745
00746 void DlgSettingsExportFormat::slotHeaderSimple()
00747 {
00748 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotHeaderSimple";
00749
00750 m_modelExportAfter->setHeader(EXPORT_HEADER_SIMPLE);
00751 updateControls();
00752 updatePreview();
00753 }
00754
00755 void DlgSettingsExportFormat::slotInclude ()
00756 {
00757 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotInclude";
00758
00759
00760 int i;
00761 QStringList included;
00762 for (i = 0; i < m_listExcluded->count(); i++) {
00763 if (m_listExcluded->item(i)->isSelected()) {
00764 included += m_listExcluded->item(i)->text();
00765 }
00766 }
00767
00768
00769 for (i = 0; i < included.count(); i++) {
00770 QString curveName = included.at (i);
00771 m_listIncluded->addItem (curveName);
00772 }
00773
00774
00775 QStringList excluded;
00776 for (i = m_listExcluded->count() - 1; i>= 0; i--) {
00777 QString curveName = m_listExcluded->item(i)->text();
00778 QListWidgetItem *item = m_listExcluded->item (i);
00779 if (included.contains (curveName)) {
00780 m_listExcluded->removeItemWidget (item);
00781 delete item;
00782 } else {
00783 excluded += item->text();
00784 }
00785 }
00786
00787 m_modelExportAfter->setCurveNamesNotExported(excluded);
00788 updateControls();
00789 updatePreview();
00790 }
00791
00792 void DlgSettingsExportFormat::slotListExcluded()
00793 {
00794 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotListExcluded";
00795
00796 updateControls();
00797
00798 }
00799
00800 void DlgSettingsExportFormat::slotListIncluded()
00801 {
00802 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotListIncluded";
00803
00804 updateControls();
00805
00806 }
00807
00808 void DlgSettingsExportFormat::slotOverrideCsvTsv(int)
00809 {
00810 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotOverrideCsvTsv";
00811
00812 m_modelExportAfter->setOverrideCsvTsv(m_chkOverrideCsvTsv->isChecked());
00813 updateControls();
00814 updatePreview();
00815 }
00816
00817 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced()
00818 {
00819 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotRelationsPointsEvenlySpaced";
00820
00821 m_modelExportAfter->setPointsSelectionRelations(EXPORT_POINTS_SELECTION_RELATIONS_INTERPOLATE);
00822 updateControls();
00823 updatePreview();
00824 }
00825
00826 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval(const QString &)
00827 {
00828 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedInterval";
00829
00830 m_modelExportAfter->setPointsIntervalRelations(m_editRelationsPointsEvenlySpacing->text().toDouble());
00831 updateControls();
00832 updatePreview();
00833 }
00834
00835 void DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits(const QString &)
00836 {
00837 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotRelationsPointsEvenlySpacedIntervalUnits";
00838
00839 int index = m_cmbRelationsPointsEvenlySpacingUnits->currentIndex();
00840 ExportPointsIntervalUnits units = (ExportPointsIntervalUnits) m_cmbRelationsPointsEvenlySpacingUnits->itemData (index).toInt();
00841
00842 m_modelExportAfter->setPointsIntervalUnitsRelations(units);
00843 updateIntervalConstraints();
00844 updateControls();
00845 updatePreview();
00846 }
00847
00848 void DlgSettingsExportFormat::slotRelationsPointsRaw()
00849 {
00850 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotRelationsPointsRaw";
00851
00852 m_modelExportAfter->setPointsSelectionRelations(EXPORT_POINTS_SELECTION_RELATIONS_RAW);
00853 updateControls();
00854 updatePreview();
00855 }
00856
00857 void DlgSettingsExportFormat::slotSaveDefault()
00858 {
00859 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotSaveDefault";
00860
00861 QSettings settings (SETTINGS_ENGAUGE, SETTINGS_DIGITIZER);
00862 settings.beginGroup (SETTINGS_GROUP_EXPORT);
00863
00864 settings.setValue (SETTINGS_EXPORT_DELIMITER,
00865 QVariant (m_modelExportAfter->delimiter()));
00866 settings.setValue (SETTINGS_EXPORT_HEADER,
00867 QVariant (m_modelExportAfter->header()));
00868 settings.setValue (SETTINGS_EXPORT_LAYOUT_FUNCTIONS,
00869 QVariant (m_modelExportAfter->layoutFunctions()));
00870 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_FUNCTIONS,
00871 QVariant (m_modelExportAfter->pointsIntervalFunctions()));
00872 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_RELATIONS,
00873 QVariant (m_modelExportAfter->pointsIntervalUnitsRelations()));
00874 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_FUNCTIONS,
00875 QVariant (m_modelExportAfter->pointsIntervalUnitsFunctions()));
00876 settings.setValue (SETTINGS_EXPORT_POINTS_INTERVAL_UNITS_RELATIONS,
00877 QVariant (m_modelExportAfter->pointsIntervalUnitsRelations()));
00878 settings.setValue (SETTINGS_EXPORT_POINTS_SELECTION_FUNCTIONS,
00879 QVariant (m_modelExportAfter->pointsSelectionFunctions()));
00880 settings.setValue (SETTINGS_EXPORT_POINTS_SELECTION_RELATIONS,
00881 QVariant (m_modelExportAfter->pointsSelectionFunctions()));
00882 settings.setValue (SETTINGS_EXPORT_X_LABEL,
00883 QVariant (m_modelExportAfter->xLabel()));
00884
00885 settings.endGroup ();
00886 }
00887
00888 void DlgSettingsExportFormat::slotTabChanged (int)
00889 {
00890 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotTabChanged";
00891
00892 updatePreview();
00893 }
00894
00895 void DlgSettingsExportFormat::slotXLabel(const QString &)
00896 {
00897 LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsExportFormat::slotXLabel";
00898
00899 m_modelExportAfter->setXLabel (m_editXLabel->text());
00900 updateControls();
00901 updatePreview();
00902 }
00903
00904 void DlgSettingsExportFormat::updateControls ()
00905 {
00906 bool isGoodState = goodIntervalFunctions() &&
00907 goodIntervalRelations();
00908 enableOk (isGoodState);
00909
00910 m_listIncluded->sortItems (Qt::AscendingOrder);
00911 m_listExcluded->sortItems (Qt::AscendingOrder);
00912
00913 int selectedForInclude = m_listExcluded->selectedItems().count();
00914 int selectedForExclude = m_listIncluded->selectedItems().count();
00915 int inInclude = m_listIncluded->count();
00916
00917 m_btnInclude->setEnabled (selectedForInclude > 0);
00918 m_btnExclude->setEnabled ((selectedForExclude > 0) && (inInclude - selectedForExclude > 0));
00919
00920 m_editFunctionsPointsEvenlySpacing->setEnabled (m_btnFunctionsPointsEvenlySpaced->isChecked ());
00921 m_editRelationsPointsEvenlySpacing->setEnabled (m_btnRelationsPointsEvenlySpaced->isChecked ());
00922
00923 m_editXLabel->setEnabled (!m_btnHeaderNone->isChecked());
00924 }
00925
00926 void DlgSettingsExportFormat::updateIntervalConstraints ()
00927 {
00928 double functionsMin = (m_modelExportAfter->pointsIntervalUnitsFunctions() == EXPORT_POINTS_INTERVAL_UNITS_GRAPH ?
00929 m_minIntervalGraph :
00930 m_minIntervalScreen);
00931 double relationsMin = (m_modelExportAfter->pointsIntervalUnitsRelations() == EXPORT_POINTS_INTERVAL_UNITS_GRAPH ?
00932 m_minIntervalGraph :
00933 m_minIntervalScreen);
00934
00935 if (m_tabWidget->currentIndex() == TAB_WIDGET_INDEX_FUNCTIONS) {
00936
00937 if (m_modelExportAfter->pointsIntervalFunctions() < functionsMin) {
00938
00939 m_editFunctionsPointsEvenlySpacing->setText (QString::number (functionsMin));
00940
00941 }
00942
00943 m_validatorFunctionsPointsEvenlySpacing->setBottom (functionsMin);
00944
00945 } else {
00946
00947 if (m_modelExportAfter->pointsIntervalRelations() < relationsMin) {
00948
00949 m_editRelationsPointsEvenlySpacing->setText (QString::number (relationsMin));
00950 m_validatorFunctionsPointsEvenlySpacing->setBottom (relationsMin);
00951
00952 }
00953
00954 m_validatorRelationsPointsEvenlySpacing->setBottom (relationsMin);
00955 }
00956 }
00957
00958 void DlgSettingsExportFormat::updatePreview()
00959 {
00960
00961 int scrollPosition = m_editPreview->verticalScrollBar()->value();
00962
00963 QString exportedText;
00964 QTextStream str (&exportedText);
00965
00966 if (mainWindow().transformation().transformIsDefined()) {
00967
00968
00969 if (m_tabWidget->currentIndex() == TAB_WIDGET_INDEX_FUNCTIONS) {
00970
00971 ExportFileFunctions exportStrategy;
00972 exportStrategy.exportToFile (*m_modelExportAfter,
00973 cmdMediator().document(),
00974 mainWindow().modelMainWindow(),
00975 mainWindow().transformation(),
00976 str);
00977
00978 } else {
00979
00980 ExportFileRelations exportStrategy;
00981 exportStrategy.exportToFile (*m_modelExportAfter,
00982 cmdMediator().document(),
00983 mainWindow().modelMainWindow(),
00984 mainWindow().transformation(),
00985 str);
00986
00987 }
00988 } else {
00989
00990 str << "Preview is unavailable until axis points are defined.";
00991 }
00992
00993 m_editPreview->setText (exportedText);
00994
00995
00996 m_editPreview->verticalScrollBar()->setValue (scrollPosition);
00997 }