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