scidavis  2.3.0
About: SciDAVis is a free application for Scientific Data Analysis and Visualization (a fork off of QtiPlot).
  Fossies Dox: scidavis-2.3.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

AxesDialog.cpp
Go to the documentation of this file.
1 
11 
29 #include "ApplicationWindow.h"
30 #include "AxesDialog.h"
31 #include "TextDialog.h"
32 #include "Graph.h"
33 #include "Grid.h"
34 #include "Plot.h"
35 #include "MyParser.h"
36 #include "ColorButton.h"
37 #include "TextFormatButtons.h"
38 
39 #include <QColorDialog>
40 #include <QCheckBox>
41 #include <QComboBox>
42 #include <QLabel>
43 #include <QLineEdit>
44 #include <QPushButton>
45 #include <QSpinBox>
46 #include <QTabWidget>
47 #include <QLayout>
48 #include <QMessageBox>
49 #include <QFontDialog>
50 #include <QDate>
51 #include <QList>
52 #include <QListWidget>
53 #include <QVector>
54 #include <QGroupBox>
55 #include <QRadioButton>
56 
57 #include <qwt_plot.h>
58 #include <qwt_scale_widget.h>
59 #include <qwt_scale_engine.h>
60 
61 #ifndef M_PI
62 #define M_PI 3.141592653589793238462643
63 #endif
64 
66 {
67  QPixmap image4( ":/image4.xpm" );
68  QPixmap image5( ":/image5.xpm" );
69  QPixmap image6( ":/image6.xpm" );
70  QPixmap image7( ":/image7.xpm" );
71  setWindowTitle( tr( "General Plot Options" ) );
72 
74  initGridPage();
75  initAxesPage();
76  initFramePage();
77 
78  auto bottomButtons = new QHBoxLayout();
79  bottomButtons->addStretch();
80 
81  buttonApply = new QPushButton();
82  buttonApply->setText( tr( "&Apply" ) );
83  bottomButtons->addWidget( buttonApply );
84 
85  buttonOk = new QPushButton();
86  buttonOk->setText( tr( "&OK" ) );
87  buttonOk->setDefault( true );
88  bottomButtons->addWidget( buttonOk );
89 
90  buttonCancel = new QPushButton();
91  buttonCancel->setText( tr( "&Cancel" ) );
92  bottomButtons->addWidget( buttonCancel );
93 
94  QVBoxLayout* mainLayout = new QVBoxLayout(this);
95  mainLayout->addWidget(&generalDialog);
96  mainLayout->addLayout(bottomButtons);
97 
99 
100  connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
101  connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
102  connect( buttonApply, SIGNAL( clicked() ), this, SLOT(updatePlot() ) );
103  connect( &generalDialog, SIGNAL( currentChanged ( int ) ),
104  this, SLOT(pageChanged ( int ) ) );
105 }
106 
108 {
109  scalesPage = new QWidget();
110 
111  QGroupBox * middleBox = new QGroupBox(QString());
112  QGridLayout * middleLayout = new QGridLayout(middleBox);
113 
114  middleLayout->addWidget(new QLabel(tr( "From" )), 0, 0);
115  boxStart = new QLineEdit();
116  middleLayout->addWidget( boxStart, 0, 1 );
117 
118  middleLayout->addWidget(new QLabel(tr( "To" )), 1, 0);
119  boxEnd = new QLineEdit();
120  middleLayout->addWidget( boxEnd, 1, 1);
121 
122  boxScaleTypeLabel = new QLabel(tr( "Type" ));
123  boxScaleType = new QComboBox();
124  boxScaleType->addItem(tr( "linear" ) );
125  boxScaleType->addItem(tr( "logarithmic" ) );
126  middleLayout->addWidget( boxScaleTypeLabel, 2, 0);
127  middleLayout->addWidget( boxScaleType, 2, 1);
128 
129  btnInvert = new QCheckBox();
130  btnInvert->setText( tr( "Inverted" ) );
131  btnInvert->setChecked(false);
132  middleLayout->addWidget( btnInvert, 3, 1 );
133 
134  middleLayout->setRowStretch( 4, 1 );
135 
136  QGroupBox * rightBox = new QGroupBox(QString());
137  QGridLayout * rightLayout = new QGridLayout(rightBox);
138  QWidget * stepWidget = new QWidget();
139  QVBoxLayout * stepWidgetLayout = new QVBoxLayout( stepWidget );
140 
141  btnStep = new QRadioButton(rightBox);
142  btnStep->setText( tr( "Step" ) );
143  btnStep->setChecked(true);
144  rightLayout->addWidget( btnStep, 0, 0 );
145 
146  boxStep = new QLineEdit();
147  stepWidgetLayout->addWidget( boxStep );
148  boxUnit = new QComboBox();
149  boxUnit->hide();
150  stepWidgetLayout->addWidget( boxUnit );
151 
152  rightLayout->addWidget( stepWidget, 0, 1 );
153 
154  btnMajor = new QRadioButton(rightBox);
155  btnMajor->setText( tr( "Major Ticks" ) );
156  rightLayout->addWidget( btnMajor, 1, 0);
157 
158  boxMajorValue = new QSpinBox();
159  boxMajorValue->setDisabled(true);
160  rightLayout->addWidget( boxMajorValue, 1, 1);
161 
162  minorBoxLabel = new QLabel( tr( "Minor Ticks" ));
163  rightLayout->addWidget( minorBoxLabel, 2, 0);
164 
165  boxMinorValue = new QComboBox();
166  boxMinorValue->setEditable(true);
167  boxMinorValue->addItems(QStringList()<<"0"<<"1"<<"4"<<"9"<<"14"<<"19");
168  rightLayout->addWidget( boxMinorValue, 2, 1);
169 
170  rightLayout->setRowStretch( 3, 1 );
171 
172  QPixmap image0(":/bottom_scl.xpm" );
173  QPixmap image1(":/left_scl.xpm" );
174  QPixmap image2(":/top_scl.xpm" );
175  QPixmap image3(":/right_scl.xpm" );
176 
177  axesList = new QListWidget();
178  axesList->addItem( new QListWidgetItem(image0, tr( "Bottom" )));
179  axesList->addItem( new QListWidgetItem(image1, tr( "Left" )));
180  axesList->addItem( new QListWidgetItem(image2, tr( "Top" )));
181  axesList->addItem( new QListWidgetItem(image3, tr( "Right" )));
182  axesList->setIconSize(image0.size());
183  axesList->setCurrentRow(-1);
184 
185  // calculate a sensible width for the items list
186  // (default QListWidget size is 256 which looks too big)
187  QFontMetrics fm(axesList->font());
188  int width = 32,i;
189  for(i=0 ; i<axesList->count() ; i++)
190  if( fm.width(axesList->item(i)->text()) > width)
191  width = fm.width(axesList->item(i)->text());
192 
193  axesList->setMaximumWidth( axesList->iconSize().width() + width + 50 );
194  // resize the list to the maximum width
195  axesList->resize(axesList->maximumWidth(),axesList->height());
196 
197  QHBoxLayout* mainLayout = new QHBoxLayout(scalesPage);
198  mainLayout->addWidget(axesList);
199  mainLayout->addWidget(middleBox);
200  mainLayout->addWidget(rightBox);
201 
202  generalDialog.addTab(scalesPage, tr( "Scale" ));
203 
204  connect(btnInvert,SIGNAL(clicked()), this, SLOT(updatePlot()));
205  connect(axesList,SIGNAL(currentRowChanged(int)), this, SLOT(updateScale()));
206  connect(boxScaleType,SIGNAL(activated(int)), this, SLOT(updateMinorTicksList(int)));
207 
208  connect(btnStep, SIGNAL(toggled(bool)), boxStep, SLOT(setEnabled(bool)));
209  connect(btnStep, SIGNAL(toggled(bool)), boxUnit, SLOT(setEnabled(bool)));
210  connect(btnMajor, SIGNAL(toggled(bool)), boxMajorValue, SLOT(setEnabled(bool)));
211 }
212 
214 {
215  gridPage = new QWidget();
216 
217  QGroupBox * rightBox = new QGroupBox(QString());
218  QGridLayout * rightLayout = new QGridLayout(rightBox);
219 
220  boxMajorGrid = new QCheckBox();
221  boxMajorGrid->setText( tr( "Major Grids" ) );
222  boxMajorGrid->setChecked(true);
223  rightLayout->addWidget( boxMajorGrid, 0, 1);
224 
225  boxMinorGrid = new QCheckBox();
226  boxMinorGrid->setText( tr( "Minor Grids" ) );
227  boxMinorGrid->setChecked(false);
228  rightLayout->addWidget( boxMinorGrid, 0, 2);
229 
230  rightLayout->addWidget( new QLabel(tr( "Line Color" )), 1, 0 );
231 
232  boxColorMajor = new ColorButton();
233  rightLayout->addWidget( boxColorMajor, 1, 1);
234 
235  boxColorMinor = new ColorButton();
236  boxColorMinor->setDisabled(true);
237  rightLayout->addWidget( boxColorMinor, 1, 2);
238 
239  rightLayout->addWidget( new QLabel(tr( "Line Type" )), 2, 0 );
240 
241  boxTypeMajor = new QComboBox();
242  boxTypeMajor->addItem("_____");
243  boxTypeMajor->addItem("- - -");
244  boxTypeMajor->addItem(".....");
245  boxTypeMajor->addItem("_._._");
246  boxTypeMajor->addItem("_.._..");
247  rightLayout->addWidget( boxTypeMajor, 2, 1);
248 
249  boxTypeMinor = new QComboBox();
250  boxTypeMinor->addItem("_____");
251  boxTypeMinor->addItem("- - -");
252  boxTypeMinor->addItem(".....");
253  boxTypeMinor->addItem("_._._");
254  boxTypeMinor->addItem("_.._..");
255  boxTypeMinor->setDisabled(true);
256  rightLayout->addWidget( boxTypeMinor, 2, 2);
257 
258  rightLayout->addWidget( new QLabel(tr( "Thickness" )), 3, 0 );
259 
260  boxWidthMajor = new QSpinBox();
261  boxWidthMajor->setRange(1,20);
262  boxWidthMajor->setValue(1);
263  rightLayout->addWidget( boxWidthMajor, 3, 1);
264 
265  boxWidthMinor = new QSpinBox();
266  boxWidthMinor->setRange(1,20);
267  boxWidthMinor->setValue(1);
268  boxWidthMinor->setDisabled(true);
269  rightLayout->addWidget( boxWidthMinor, 3, 2);
270 
271  rightLayout->addWidget( new QLabel(tr( "Axes" )), 4, 0 );
272 
273  boxGridXAxis = new QComboBox();
274  boxGridXAxis->addItem(tr("Bottom"));
275  boxGridXAxis->addItem(tr("Top"));
276  rightLayout->addWidget( boxGridXAxis, 4, 1);
277 
278  boxGridYAxis = new QComboBox();
279  boxGridYAxis->addItem(tr("Left"));
280  boxGridYAxis->addItem(tr("Right"));
281  rightLayout->addWidget( boxGridYAxis, 4, 2);
282 
283  rightLayout->addWidget( new QLabel(tr( "Additional lines" )), 5, 0);
284 
285  boxXLine = new QCheckBox();
286  boxXLine->setText( tr( "X=0" ) );
287  boxXLine->setDisabled(true);
288  rightLayout->addWidget( boxXLine, 5, 1);
289 
290  boxYLine = new QCheckBox();
291  boxYLine->setText( tr( "Y=0" ) );
292  rightLayout->addWidget( boxYLine, 5, 2);
293 
294  rightLayout->setRowStretch( 6, 1 );
295  rightLayout->setColumnStretch( 4, 1 );
296 
297  QPixmap image2(":/image2.xpm" );
298  QPixmap image3(":/image3.xpm" );
299 
300  axesGridList = new QListWidget();
301  axesGridList->addItem( new QListWidgetItem(image3, tr( "Horizontal" )) );
302  axesGridList->addItem( new QListWidgetItem(image2, tr( "Vertical" )) );
303  axesGridList->setIconSize(image3.size());
304  axesGridList->setCurrentRow(-1);
305 
306  // calculate a sensible width for the items list
307  // (default QListWidget size is 256 which looks too big)
308  QFontMetrics fm(axesGridList->font());
309  int width = 32,i;
310  for(i=0 ; i<axesGridList->count() ; i++)
311  if( fm.width(axesGridList->item(i)->text()) > width)
312  width = fm.width(axesGridList->item(i)->text());
313  axesGridList->setMaximumWidth( axesGridList->iconSize().width() + width + 50 );
314  // resize the list to the maximum width
315  axesGridList->resize(axesGridList->maximumWidth(),axesGridList->height());
316 
317  QHBoxLayout* mainLayout2 = new QHBoxLayout(gridPage);
318  mainLayout2->addWidget(axesGridList);
319  mainLayout2->addWidget(rightBox);
320 
321  generalDialog.addTab( gridPage, tr( "Grid" ) );
322 
323  //grid page slot connections
324  connect(axesGridList, SIGNAL(currentRowChanged(int)), this, SLOT(showGridOptions(int)));
325 
326  connect(boxMajorGrid,SIGNAL(toggled(bool)), this, SLOT(majorGridEnabled(bool)));
327  connect(boxMinorGrid,SIGNAL(toggled(bool)), this, SLOT(minorGridEnabled(bool)));
328  connect(boxColorMajor,SIGNAL(changed(QColor)),this, SLOT(updateGrid()));
329  connect(boxColorMinor,SIGNAL(changed(QColor)),this, SLOT(updateGrid()));
330  connect(boxTypeMajor,SIGNAL(activated(int)),this, SLOT(updateGrid()));
331  connect(boxTypeMinor,SIGNAL(activated(int)),this, SLOT(updateGrid()));
332  connect(boxWidthMajor,SIGNAL(valueChanged (int)),this, SLOT(updateGrid()));
333  connect(boxWidthMinor,SIGNAL(valueChanged (int)),this, SLOT(updateGrid()));
334  connect(boxXLine,SIGNAL(clicked()),this, SLOT(updatePlot()));
335  connect(boxYLine,SIGNAL(clicked()),this, SLOT(updatePlot()));
336 }
337 
339 {
340  //axes page
341  QPixmap image4(":/image4.xpm" );
342  QPixmap image5(":/image5.xpm" );
343  QPixmap image6(":/image6.xpm" );
344  QPixmap image7(":/image7.xpm" );
345 
346  axesPage = new QWidget();
347 
348  boxAxisType= new QComboBox();
349  boxAxisType->addItem(tr("Numeric"), (int)Graph::Numeric);
350  boxAxisType->addItem(tr("Text from table"), (int)Graph::Txt);
351  boxAxisType->addItem(tr("Day of the week"), (int)Graph::Day);
352  boxAxisType->addItem(tr("Month"), (int)Graph::Month);
353  boxAxisType->addItem(tr("Time"), (int)Graph::Time);
354  boxAxisType->addItem(tr("Date"), (int)Graph::Date);
355  boxAxisType->addItem(tr("Date & Time"), (int)Graph::DateTime);
356  boxAxisType->addItem(tr("Column Headings"), (int)Graph::ColHeader);
357 
358  axesTitlesList = new QListWidget();
359  axesTitlesList->addItem( new QListWidgetItem(image4, tr("Bottom")));
360  axesTitlesList->addItem( new QListWidgetItem(image5, tr("Left")));
361  axesTitlesList->addItem( new QListWidgetItem(image6, tr("Top")));
362  axesTitlesList->addItem( new QListWidgetItem(image7, tr("Right")));
363  axesTitlesList->setIconSize(image6.size());
364  axesTitlesList->setMaximumWidth((int)(image6.width()*1.5));
365  axesTitlesList->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding));
366  axesTitlesList->setCurrentRow(-1);
367 
368  // calculate a sensible width for the items list
369  // (default QListWidget size is 256 which looks too big)
370  QFontMetrics fm(axesTitlesList->font());
371  int width = 32,i;
372  for(i=0 ; i<axesTitlesList->count() ; i++)
373  if( fm.width(axesTitlesList->item(i)->text()) > width)
374  width = fm.width(axesTitlesList->item(i)->text());
375  axesTitlesList->setMaximumWidth( axesTitlesList->iconSize().width() + width + 50 );
376  // resize the list to the maximum width
377  axesTitlesList->resize(axesTitlesList->maximumWidth(),axesTitlesList->height());
378 
379  QHBoxLayout * topLayout = new QHBoxLayout();
380 
381  boxShowAxis = new QCheckBox(tr("Show"));
382  boxShowAxis->setChecked(true);
383  topLayout->addWidget( boxShowAxis );
384 
385  labelBox = new QGroupBox(tr( "Title"));
386  topLayout->addWidget( labelBox );
387 
388  QVBoxLayout *labelBoxLayout = new QVBoxLayout( labelBox );
389  labelBoxLayout->setSpacing(2);
390 
391  boxTitle = new QTextEdit();
392  boxTitle->setAcceptRichText(false);
393  QFontMetrics metrics(this->font());
394  boxTitle->setMaximumHeight(3*metrics.height());
395  labelBoxLayout->addWidget(boxTitle);
396 
397  QHBoxLayout *hl = new QHBoxLayout();
398  hl->setMargin(0);
399  hl->setSpacing(2);
400  buttonLabelFont = new QPushButton(tr("&Font"));
401  hl->addWidget(buttonLabelFont);
402 
405  hl->addWidget(formatButtons);
406  hl->addStretch();
407 
408  boxTitle->setMaximumWidth(buttonLabelFont->width() + formatButtons->width());
409  labelBoxLayout->addLayout(hl);
410 
411  QHBoxLayout * bottomLayout = new QHBoxLayout();
412 
413  QGroupBox *leftBox = new QGroupBox(QString());
414  bottomLayout->addWidget( leftBox );
415  QGridLayout * leftBoxLayout = new QGridLayout( leftBox );
416 
417  leftBoxLayout->addWidget( new QLabel(tr( "Type" )), 0, 0 );
418 
419  leftBoxLayout->addWidget( boxAxisType, 0, 1 );
420 
421  leftBoxLayout->addWidget( new QLabel(tr( "Font" )), 1, 0 );
422 
423  btnAxesFont = new QPushButton();
424  btnAxesFont->setText( tr( "Axis &Font" ) );
425  leftBoxLayout->addWidget( btnAxesFont, 1, 1 );
426 
427  leftBoxLayout->addWidget( new QLabel(tr( "Color" )), 2, 0 );
428  boxAxisColor= new ColorButton();
429  leftBoxLayout->addWidget( boxAxisColor, 2, 1 );
430 
431  leftBoxLayout->addWidget( new QLabel(tr( "Major Ticks" )), 3, 0 );
432 
433  boxMajorTicksType= new QComboBox();
434  boxMajorTicksType->addItem(tr( "None" ) );
435  boxMajorTicksType->addItem(tr( "Out" ) );
436  boxMajorTicksType->addItem(tr( "In & Out" ) );
437  boxMajorTicksType->addItem(tr( "In" ) );
438  leftBoxLayout->addWidget( boxMajorTicksType, 3, 1 );
439 
440  leftBoxLayout->addWidget( new QLabel(tr( "Minor Ticks" )), 4, 0 );
441 
442  boxMinorTicksType= new QComboBox();
443  boxMinorTicksType->addItem(tr( "None" ) );
444  boxMinorTicksType->addItem(tr( "Out" ) );
445  boxMinorTicksType->addItem(tr( "In & Out" ) );
446  boxMinorTicksType->addItem(tr( "In" ) );
447  leftBoxLayout->addWidget( boxMinorTicksType, 4, 1);
448 
449  leftBoxLayout->addWidget( new QLabel(tr("Stand-off")), 5, 0);
450  boxBaseline = new QSpinBox();
451  boxBaseline->setRange( 0, 1000 );
452  leftBoxLayout->addWidget( boxBaseline );
453 
454  boxShowLabels = new QGroupBox(tr("Show Labels"));
455  boxShowLabels->setCheckable(true);
456  boxShowLabels->setChecked(true);
457 
458  bottomLayout->addWidget( boxShowLabels );
459  QGridLayout *rightBoxLayout = new QGridLayout( boxShowLabels );
460 
461  label1 = new QLabel(tr("Column"));
462  rightBoxLayout->addWidget( label1, 0, 0 );
463 
464  boxColName = new QComboBox();
465  rightBoxLayout->addWidget( boxColName, 0, 1 );
466 
467  labelTable = new QLabel(tr("Table"));
468  rightBoxLayout->addWidget( labelTable, 1, 0 );
469 
470  boxTableName = new QComboBox();
471  rightBoxLayout->addWidget( boxTableName, 1, 1 );
472 
473  label2 = new QLabel(tr( "Format" ));
474  rightBoxLayout->addWidget( label2, 2, 0 );
475 
476  boxFormat = new QComboBox();
477  boxFormat->setDuplicatesEnabled(false);
478  rightBoxLayout->addWidget( boxFormat, 2, 1 );
479 
480  label3 = new QLabel(tr( "Precision" ));
481  rightBoxLayout->addWidget( label3, 3, 0 );
482  boxPrecision = new QSpinBox();
483  boxPrecision->setRange( 0, 10 );
484  rightBoxLayout->addWidget( boxPrecision, 3, 1 );
485 
486  rightBoxLayout->addWidget( new QLabel(tr( "Angle" )), 4, 0 );
487 
488  boxAngle = new QSpinBox();
489  boxAngle->setRange( -90, 90 );
490  boxAngle->setSingleStep(5);
491  rightBoxLayout->addWidget( boxAngle, 4, 1 );
492 
493  rightBoxLayout->addWidget(new QLabel(tr( "Color" )), 5, 0);
495  rightBoxLayout->addWidget( boxAxisNumColor, 5, 1 );
496 
497  boxShowFormula = new QCheckBox(tr( "For&mula" ));
498  rightBoxLayout->addWidget( boxShowFormula, 6, 0 );
499 
500  boxFormula = new QTextEdit();
501  boxFormula->setAcceptRichText(false);
502  boxFormula->setMaximumHeight(3*metrics.height());
503  boxFormula->hide();
504  rightBoxLayout->addWidget( boxFormula, 6, 1 );
505  rightBoxLayout->setRowStretch(7, 1);
506 
507  QVBoxLayout * rightLayout = new QVBoxLayout();
508  rightLayout->addLayout( topLayout );
509  rightLayout->addLayout( bottomLayout );
510  rightLayout->addStretch(1);
511 
512  QHBoxLayout * mainLayout3 = new QHBoxLayout( axesPage );
513  mainLayout3->addWidget( axesTitlesList );
514  mainLayout3->addLayout( rightLayout );
515 
516  generalDialog.addTab( axesPage, tr( "Axis" ) );
517 
518  connect(buttonLabelFont, SIGNAL(clicked()), this, SLOT(customAxisLabelFont()));
519 
520  connect(axesTitlesList,SIGNAL(currentRowChanged(int)), this, SLOT(updateShowBox(int)));
521  connect(axesTitlesList,SIGNAL(currentRowChanged(int)), this, SLOT(updateAxisColor(int)));
522  connect(axesTitlesList,SIGNAL(currentRowChanged(int)), this, SLOT(updateTitleBox(int)));
523  connect(axesTitlesList,SIGNAL(currentRowChanged(int)), this, SLOT(setTicksType(int)));
524  connect(axesTitlesList,SIGNAL(currentRowChanged(int)), this, SLOT(setAxisType(int)));
525  connect(axesTitlesList,SIGNAL(currentRowChanged(int)), this, SLOT(setBaselineDist(int)));
526  connect(axesTitlesList,SIGNAL(currentRowChanged(int)), this, SLOT(updateLabelsFormat(int)));
527 
528  connect(boxShowLabels,SIGNAL(clicked(bool)), this, SLOT(updateTickLabelsList(bool)));
529 
530  connect(boxAxisColor, SIGNAL(clicked()), this, SLOT(pickAxisColor()));
531  connect(boxAxisNumColor, SIGNAL(clicked()), this, SLOT(pickAxisNumColor()));
532  connect(boxShowFormula, SIGNAL(clicked()), this, SLOT(showFormulaBox()));
533 
534  connect(boxMajorTicksType, SIGNAL(activated(int)), this, SLOT(updateMajTicksType(int)));
535  connect(boxMinorTicksType, SIGNAL(activated(int)), this, SLOT(updateMinTicksType(int)));
536 
537  connect(boxShowAxis,SIGNAL(clicked()), this, SLOT(showAxis()));
538  connect(boxFormat, SIGNAL(activated(int) ), this, SLOT(setLabelsNumericFormat(int)));
539 
540  connect(btnAxesFont, SIGNAL(clicked()), this, SLOT(customAxisFont()));
541  connect(boxBaseline, SIGNAL(valueChanged(int)), this, SLOT(changeBaselineDist(int)));
542  connect(boxAxisType, SIGNAL(activated(int)), this, SLOT(showAxisFormatOptions(int)));
543  connect(boxPrecision, SIGNAL(valueChanged(int)), this, SLOT(setLabelsNumericFormat(int)));
544 }
545 
547 {
548  frame = new QWidget();
549 
550  boxFramed = new QGroupBox(tr("Canvas frame"));
551  boxFramed->setCheckable (true);
552 
553  QGridLayout * boxFramedLayout = new QGridLayout( boxFramed );
554  boxFramedLayout->addWidget( new QLabel(tr( "Color" )), 0, 0 );
556  boxFramedLayout->addWidget( boxFrameColor, 0, 1 );
557 
558  boxFramedLayout->addWidget( new QLabel(tr( "Width" )), 1, 0 );
559  boxFrameWidth= new QSpinBox();
560  boxFrameWidth->setMinimum(1);
561  boxFramedLayout->addWidget( boxFrameWidth, 1, 1 );
562 
563  boxFramedLayout->setRowStretch( 2, 1 );
564 
565  QGroupBox * boxAxes = new QGroupBox(tr("Axes"));
566  QGridLayout * boxAxesLayout = new QGridLayout( boxAxes );
567  boxBackbones = new QCheckBox();
568  boxBackbones->setText( tr( "Draw backbones" ) );
569  boxAxesLayout->addWidget( boxBackbones, 0, 0 );
570 
571  boxAxesLayout->addWidget( new QLabel(tr( "Line Width" )), 1, 0 );
572  boxAxesLinewidth = new QSpinBox();
573  boxAxesLinewidth->setRange( 1, 100 );
574  boxAxesLayout->addWidget( boxAxesLinewidth, 1, 1 );
575 
576  boxAxesLayout->addWidget( new QLabel(tr( "Major ticks length" )), 2, 0 );
577  boxMajorTicksLength = new QSpinBox();
578  boxMajorTicksLength->setRange( 0, 1000 );
579  boxAxesLayout->addWidget( boxMajorTicksLength, 2, 1 );
580 
581  boxAxesLayout->addWidget( new QLabel(tr( "Minor ticks length" )), 3, 0 );
582  boxMinorTicksLength = new QSpinBox();
583  boxMinorTicksLength->setRange( 0, 1000 );
584  boxAxesLayout->addWidget( boxMinorTicksLength, 3, 1 );
585 
586  boxAxesLayout->setRowStretch( 4, 1 );
587 
588  QHBoxLayout * mainLayout = new QHBoxLayout( frame );
589  mainLayout->addWidget(boxFramed);
590  mainLayout->addWidget(boxAxes);
591 
592  generalDialog.addTab(frame, tr( "General" ) );
593 
594  connect(boxFrameColor, SIGNAL(clicked()), this, SLOT(pickCanvasFrameColor()));
595  connect(boxBackbones, SIGNAL(toggled(bool)), this, SLOT(drawAxesBackbones(bool)));
596  connect(boxFramed, SIGNAL(toggled(bool)), this, SLOT(drawFrame(bool)));
597  connect(boxFrameWidth, SIGNAL(valueChanged (int)), this, SLOT(updateFrame(int)));
598  connect(boxAxesLinewidth, SIGNAL(valueChanged (int)), this, SLOT(changeAxesLinewidth(int)));
599  connect(boxMajorTicksLength, SIGNAL(valueChanged (int)), this, SLOT(changeMajorTicksLength(int)));
600  connect(boxMinorTicksLength, SIGNAL(valueChanged (int)), this, SLOT(changeMinorTicksLength(int)));
601 }
602 
604 {
605  if (generalDialog.currentWidget() != frame)
606  return;
607 
608  d_graph->changeTicksLength(minLength, boxMajorTicksLength->value());
609  boxMajorTicksLength->setMinimum(minLength);
610 }
611 
613 {
614  if (generalDialog.currentWidget() != frame)
615  return;
616 
617  d_graph->changeTicksLength(boxMinorTicksLength->value(), majLength);
618  boxMinorTicksLength->setMaximum(majLength);
619 }
620 
622 {
623  if (generalDialog.currentWidget() != frame)
624  return;
625 
626  d_graph->drawAxesBackbones(draw);
627 }
628 
630 {
631  if (generalDialog.currentWidget() != frame)
632  return;
633 
634  d_graph->setAxesLinewidth(width);
635 }
636 
637 void AxesDialog::drawFrame(bool framed)
638 {
639  if (generalDialog.currentWidget() != frame)
640  return;
641 
643 }
644 
645 void AxesDialog::updateFrame(int width)
646 {
647  if (generalDialog.currentWidget() != frame)
648  return;
649 
650  d_graph->drawCanvasFrame(boxFramed->isChecked(), width, boxFrameColor->color());
651 }
652 
654 {
655  QColor c = QColorDialog::getColor(boxFrameColor->color(), this);
656  if ( !c.isValid() || c == boxFrameColor->color() )
657  return;
658 
659  boxFrameColor->setColor ( c ) ;
660  d_graph->drawCanvasFrame(boxFramed->isChecked(), boxFrameWidth->value(), c);
661 }
662 
664 {
665  int axis=mapToQwtAxisId();
666 
667  boxFormat->clear();
668  boxFormat->setEditable(false);
669  boxFormat->hide();
670  boxPrecision->hide();
671  boxColName->hide();
672  label1->hide();
673  label2->hide();
674  label3->hide();
675  boxShowFormula->hide();
676  boxFormula->hide();
677  boxTableName->hide();
678  labelTable->hide();
679 
680  switch (static_cast<Graph::AxisType>(boxAxisType->itemData(format).toInt())) {
681  case Graph::Numeric:
682  label2->show();
683  boxFormat->show();
684  boxFormat->addItem(tr( "Automatic" ) );
685  boxFormat->addItem(tr( "Decimal: 100.0" ) );
686  boxFormat->addItem(tr( "Scientific: 1e2" ) );
687  boxFormat->addItem(tr( "Scientific: 10^2" ) );
688  boxFormat->setCurrentIndex(d_graph->plotWidget()->axisLabelFormat(axis));
689 
690  label3->show();
691  boxPrecision->show();
692  boxShowFormula->show();
693 
695  break;
696 
697  case Graph::Txt:
698  label1->show();
699  boxColName->show();
700  break;
701 
702  case Graph::Day:
703  {
704  int day = (QDate::currentDate()).dayOfWeek();
705  label2->show();
706  boxFormat->show();
707  boxFormat->addItem(QDate::shortDayName(day));
708  boxFormat->addItem(QDate::longDayName(day));
709  boxFormat->addItem((QDate::shortDayName(day)).left(1));
710  boxFormat->setCurrentIndex (formatInfo[axis].toInt());
711  }
712  break;
713 
714  case Graph::Month:
715  {
716  int month = (QDate::currentDate()).month();
717  label2->show();
718  boxFormat->show();
719  boxFormat->addItem(QDate::shortMonthName(month));
720  boxFormat->addItem(QDate::longMonthName(month));
721  boxFormat->addItem((QDate::shortMonthName(month)).left(1));
722  boxFormat->setCurrentIndex (formatInfo[axis].toInt());
723  }
724  break;
725 
726  case Graph::Time:
727  {
728  label2->show();
729  boxFormat->show();
730  boxFormat->setEditable(true);
731 
732  QStringList lst = formatInfo[axis].split(";", QString::KeepEmptyParts);
733  if (lst.count() == 2)
734  {
735  boxFormat->addItem(lst[1]);
736  boxFormat->setItemText(boxFormat->currentIndex(), lst[1]);
737  }
738 
739  boxFormat->addItem("h");
740  boxFormat->addItem("h ap");
741  boxFormat->addItem("h AP");
742  boxFormat->addItem("h:mm");
743  boxFormat->addItem("h:mm ap");
744  boxFormat->addItem("hh:mm");
745  boxFormat->addItem("h:mm:ss");
746  boxFormat->addItem("h:mm:ss.zzz");
747  boxFormat->addItem("mm:ss");
748  boxFormat->addItem("mm:ss.zzz");
749  boxFormat->addItem("hmm");
750  boxFormat->addItem("hmmss");
751  boxFormat->addItem("hhmmss");
752  }
753  break;
754 
755  case Graph::Date:
756  {
757  label2->show();
758  boxFormat->show();
759  boxFormat->setEditable(true);
760 
761  QStringList lst = formatInfo[axis].split(";", QString::KeepEmptyParts);
762  if (lst.count() == 2)
763  {
764  boxFormat->addItem(lst[1]);
765  boxFormat->setItemText(boxFormat->currentIndex(), lst[1]);
766  }
767  boxFormat->addItem("yyyy-MM-dd");
768  boxFormat->addItem("dd.MM.yyyy");
769  boxFormat->addItem("ddd MMMM d yy");
770  boxFormat->addItem("dd/MM/yyyy");
771  }
772  break;
773 
774  case Graph::DateTime:
775  {
776  label2->show();
777  boxFormat->show();
778  boxFormat->setEditable(true);
779 
780  QStringList lst = formatInfo[axis].split(";", QString::KeepEmptyParts);
781  if (lst.count() == 2)
782  {
783  boxFormat->addItem(lst[1]);
784  boxFormat->setItemText(boxFormat->currentIndex(), lst[1]);
785  }
786 
787  const char * date_strings[] = {
788  "yyyy-MM-dd",
789  "yyyy/MM/dd",
790  "dd/MM/yyyy",
791  "dd/MM/yy",
792  "dd.MM.yyyy",
793  "dd.MM.yy",
794  "MM/yyyy",
795  "dd.MM.",
796  "yyyyMMdd",
797  0
798  };
799 
800  const char * time_strings[] = {
801  "hh",
802  "hh ap",
803  "hh:mm",
804  "hh:mm ap",
805  "hh:mm:ss",
806  "hh:mm:ss.zzz",
807  "hh:mm:ss:zzz",
808  "mm:ss.zzz",
809  "hhmmss",
810  0
811  };
812  int j,i;
813  for(i=0; date_strings[i] != 0; i++)
814  for(j=0; time_strings[j] != 0; j++)
815  boxFormat->addItem(QString("%1 %2").arg(date_strings[i]).arg(time_strings[j]),
816  QVariant(QString(date_strings[i]) + " " + QString(time_strings[j])));
817  }
818  break;
819 
820  case Graph::ColHeader:
821  {
822  labelTable->show();
823  if (tablesList.contains(formatInfo[axis]))
824  boxTableName->setItemText(boxTableName->currentIndex(), formatInfo[axis]);
825  boxTableName->show();
826  }
827  break;
828  }
829 }
830 
831 void AxesDialog::insertColList(const QStringList& cols)
832 {
833  boxColName-> addItems(cols);
834 }
835 
837 {
838  bool ok=boxShowAxis->isChecked();
839  boxTitle->setEnabled(ok);
840  boxAxisColor->setEnabled(ok);
841  boxAxisNumColor->setEnabled(ok);
842  btnAxesFont->setEnabled(ok);
843  boxShowLabels->setEnabled(ok);
844  boxMajorTicksType->setEnabled(ok);
845  boxMinorTicksType->setEnabled(ok);
846  boxAxisType->setEnabled(ok);
847  boxBaseline->setEnabled(ok);
848  labelBox->setEnabled(ok);
849 
850  int axis=-1;
851  int a=axesTitlesList->currentRow();
852  switch(a)
853  {
854  case 0:
855  {
856  axis = QwtPlot::xBottom;
857  xAxisOn=ok;
858  break;
859  }
860  case 1:
861  {
862  axis = QwtPlot::yLeft;
863  yAxisOn=ok;
864  break;
865  }
866  case 2:
867  {
868  axis = QwtPlot::xTop;
869  topAxisOn=ok;
870  break;
871  }
872  case 3:
873  {
874  axis = QwtPlot::yRight;
875  rightAxisOn=ok;
876  break;
877  }
878  }
879 
880  bool labels=false;
881  if (tickLabelsOn[axis] == "1")
882  labels=true;
883 
884  boxFormat->setEnabled(labels && ok);
885  boxColName->setEnabled(labels && ok);
886  boxShowFormula->setEnabled(labels && ok);
887  boxFormula->setEnabled(labels && ok);
888 
889  if (axis == QwtPlot::xBottom || axis == QwtPlot::xTop)
890  boxAngle->setEnabled(labels && ok);
891  else
892  boxAngle->setDisabled(true);
893 
894  bool userFormat=true;
895  if (boxFormat->currentIndex() == 0)
896  userFormat=false;
897  boxPrecision->setEnabled(labels && ok && userFormat);
898 
899  QString formula = boxFormula->toPlainText();
900  if (!boxShowFormula->isChecked())
901  formula = QString();
902 
903  showAxis(axis, currentSelectedAxisType(), boxColName->currentText(),ok, boxMajorTicksType->currentIndex(), boxMinorTicksType->currentIndex(),
904  boxShowLabels->isChecked(), boxAxisColor->color(), boxFormat->currentIndex(),
905  boxPrecision->value(), boxAngle->value(), boxBaseline->value(), formula, boxAxisNumColor->color());
906 }
907 
909 {
910  switch(axis)
911  {
912  case 0:
913  {
914  boxShowAxis->setChecked(xAxisOn);
915  int labelsOn=tickLabelsOn[2].toInt();
916  boxShowLabels->setChecked(labelsOn);
917  boxAngle->setEnabled(labelsOn && xAxisOn);
918  boxFormat->setEnabled(labelsOn && xAxisOn);
919  boxAngle->setValue(xBottomLabelsRotation);
920  break;
921  }
922  case 1:
923  {
924  boxShowAxis->setChecked(yAxisOn);
925  int labelsOn=tickLabelsOn[0].toInt();
926  boxShowLabels->setChecked(labelsOn);
927  boxFormat->setEnabled(labelsOn && yAxisOn);
928  boxAngle->setEnabled(false);
929  boxAngle->setValue(0);
930  break;
931  }
932  case 2:
933  {
934  boxShowAxis->setChecked(topAxisOn);
935 
936  int labelsOn=tickLabelsOn[3].toInt();
937  boxShowLabels->setChecked(labelsOn);
938  boxFormat->setEnabled(labelsOn && topAxisOn);
939  boxAngle->setEnabled(labelsOn && topAxisOn);
940  boxAngle->setValue(xTopLabelsRotation);
941  break;
942  }
943  case 3:
944  {
945  boxShowAxis->setChecked(rightAxisOn);
946  int labelsOn=tickLabelsOn[1].toInt();
947  boxShowLabels->setChecked(labelsOn );
948  boxFormat->setEnabled(labelsOn && rightAxisOn);
949  boxAngle->setEnabled(false);
950  boxAngle->setValue(0);
951  break;
952  }
953  }
954 
955  bool ok=boxShowAxis->isChecked();
956  boxTitle->setEnabled(ok);
957  boxAxisColor->setEnabled(ok);
958  boxAxisNumColor->setEnabled(ok);
959  btnAxesFont->setEnabled(ok);
960  boxShowLabels->setEnabled(ok);
961  boxMajorTicksType->setEnabled(ok);
962  boxMinorTicksType->setEnabled(ok);
963  boxAxisType->setEnabled(ok);
964  boxBaseline->setEnabled(ok);
965  labelBox->setEnabled(ok);
966 }
967 
969 {
970  bool okF;
971  int axis=-1;
972  QFont fnt;
973  switch(axesTitlesList->currentRow())
974  {
975  case 0:
976  {
977  axis = QwtPlot::xBottom;
978  fnt = QFontDialog::getFont( &okF, xBottomFont,this);
979  if (okF)
980  xBottomFont=fnt;
981  break;
982  }
983  case 1:
984  {
985  axis = QwtPlot::yLeft;
986  fnt = QFontDialog::getFont( &okF, yLeftFont,this);
987  if (okF)
988  yLeftFont=fnt;
989  break;
990  }
991  case 2:
992  {
993  axis = QwtPlot::xTop;
994  fnt = QFontDialog::getFont( &okF, xTopFont, this);
995  if (okF)
996  xTopFont=fnt;
997  break;
998  }
999  case 3:
1000  {
1001  axis = QwtPlot::yRight;
1002  fnt = QFontDialog::getFont( &okF, yRightFont, this);
1003  if (okF)
1004  yRightFont=fnt;
1005  break;
1006  }
1007  }
1008 
1009  d_graph->setAxisFont(axis,fnt);
1010 }
1011 
1013 {
1014  if (updatePlot())
1015  close();
1016 }
1017 
1019 {
1020  boxTypeMajor->setEnabled(on);
1021  boxColorMajor->setEnabled(on);
1022  boxWidthMajor->setEnabled(on);
1023 
1024  updateGrid();
1025 }
1026 
1028 {
1029  boxTypeMinor->setEnabled(on);
1030  boxColorMinor->setEnabled(on);
1031  boxWidthMinor->setEnabled(on);
1032 
1033  updateGrid();
1034 }
1035 
1037 {
1038  if (generalDialog.currentWidget() != gridPage)
1039  return;
1040 
1041  Grid *grid = (Grid *)d_graph->plotWidget()->grid();
1042  if (!grid)
1043  return;
1044 
1045  if (axesGridList->currentRow()==1){
1046  grid->enableX(boxMajorGrid->isChecked());
1047  grid->enableXMin(boxMinorGrid->isChecked());
1048 
1049  grid->setMajPenX(QPen(boxColorMajor->color(), boxWidthMajor->value(),
1050  Graph::getPenStyle(boxTypeMajor->currentIndex())));
1051  grid->setMinPenX(QPen(boxColorMinor->color(), boxWidthMinor->value(),
1052  Graph::getPenStyle(boxTypeMinor->currentIndex())));
1053  } else {
1054  grid->enableY(boxMajorGrid->isChecked());
1055  grid->enableYMin(boxMinorGrid->isChecked());
1056 
1057  grid->setMajPenY(QPen(boxColorMajor->color(), boxWidthMajor->value(),
1058  Graph::getPenStyle(boxTypeMajor->currentIndex())));
1059  grid->setMinPenY(QPen(boxColorMinor->color(), boxWidthMinor->value(),
1060  Graph::getPenStyle(boxTypeMinor->currentIndex())));
1061  }
1062 
1063  grid->enableZeroLineX(boxXLine->isChecked());
1064  grid->enableZeroLineY(boxYLine->isChecked());
1065 
1066  grid->setAxis(boxGridXAxis->currentIndex() + 2, boxGridYAxis->currentIndex());
1067  d_graph->replot();
1069 }
1070 
1072 {
1073  Grid *grd = (Grid *)d_graph->plotWidget()->grid();
1074  if (!grd)
1075  return;
1076 
1077  disconnect(boxMajorGrid, SIGNAL(toggled(bool)), this, SLOT(majorGridEnabled(bool)));
1078  disconnect(boxMinorGrid, SIGNAL(toggled(bool)), this, SLOT(minorGridEnabled(bool)));
1079 
1080  if (axis == 1) {
1081  boxMajorGrid->setChecked(grd->xEnabled());
1082  boxMinorGrid->setChecked(grd->xMinEnabled());
1083 
1084  boxXLine->setEnabled(true);
1085  boxYLine->setDisabled(true);
1086 
1087  boxGridXAxis->setEnabled(true);
1088  boxGridYAxis->setDisabled(true);
1089 
1090  QPen majPenX = grd->majPenX();
1091  boxTypeMajor->setCurrentIndex(majPenX.style() - 1);
1092  boxColorMajor->setColor(majPenX.color());
1093  boxWidthMajor->setValue(majPenX.width());
1094 
1095  QPen minPenX = grd->minPenX();
1096  boxTypeMinor->setCurrentIndex(minPenX.style() - 1);
1097  boxColorMinor->setColor(minPenX.color());
1098  boxWidthMinor->setValue(minPenX.width());
1099  } else if (axis == 0) {
1100  boxMajorGrid->setChecked(grd->yEnabled());
1101  boxMinorGrid->setChecked(grd->yMinEnabled());
1102 
1103  boxXLine->setDisabled(true);
1104  boxYLine->setEnabled(true);
1105 
1106  boxGridXAxis->setDisabled(true);
1107  boxGridYAxis->setEnabled(true);
1108 
1109  QPen majPenY = grd->majPenY();
1110  boxTypeMajor->setCurrentIndex(majPenY.style() - 1);
1111  boxColorMajor->setColor(majPenY.color());
1112  boxWidthMajor->setValue(majPenY.width());
1113 
1114  QPen minPenY = grd->minPenY();
1115  boxTypeMinor->setCurrentIndex(minPenY.style() - 1);
1116  boxColorMinor->setColor(minPenY.color());
1117  boxWidthMinor->setValue(minPenY.width());
1118  }
1119 
1120  bool majorOn = boxMajorGrid->isChecked();
1121  boxTypeMajor->setEnabled(majorOn);
1122  boxColorMajor->setEnabled(majorOn);
1123  boxWidthMajor->setEnabled(majorOn);
1124 
1125  bool minorOn = boxMinorGrid->isChecked();
1126  boxTypeMinor->setEnabled(minorOn);
1127  boxColorMinor->setEnabled(minorOn);
1128  boxWidthMinor->setEnabled(minorOn);
1129 
1130  boxGridXAxis->setCurrentIndex(grd->xAxis() - 2);
1131  boxGridYAxis->setCurrentIndex(grd->yAxis());
1132 
1133  boxXLine->setChecked(grd->xZeroLineEnabled());
1134  boxYLine->setChecked(grd->yZeroLineEnabled());
1135 
1136  connect(boxMajorGrid, SIGNAL(toggled(bool)), this, SLOT(majorGridEnabled(bool)));
1137  connect(boxMinorGrid, SIGNAL(toggled(bool)), this, SLOT(minorGridEnabled(bool)));
1138 }
1139 
1141 {
1142  boxStep->setEnabled(btnStep->isChecked ());
1143  boxUnit->setEnabled(btnStep->isChecked ());
1144  boxMajorValue->setDisabled(btnStep->isChecked ());
1145  btnMajor->setChecked(!btnStep->isChecked ());
1146 }
1147 
1149 {
1150  boxStep->setDisabled(btnMajor->isChecked ());
1151  boxUnit->setDisabled(btnMajor->isChecked ());
1152  boxMajorValue->setEnabled(btnMajor->isChecked ());
1153  btnStep->setChecked(!btnMajor->isChecked ());
1154 }
1155 
1157 {
1158  int a = mapToQwtAxisId();
1161 }
1162 
1164 {
1165  int axis=mapToQwtAxisId();
1166  axesBaseline[axis] = baseline;
1167 
1168  if (d_graph->axisTitle(axis) != boxTitle->toPlainText())
1169  d_graph->setAxisTitle(axis, boxTitle->toPlainText());
1170 
1171  QString formula = boxFormula->toPlainText();
1172  if (!boxShowFormula->isChecked())
1173  formula = QString();
1174  showAxis(axis, currentSelectedAxisType(), formatInfo[axis], boxShowAxis->isChecked(), boxMajorTicksType->currentIndex(), boxMinorTicksType->currentIndex(),
1175  boxShowLabels->isChecked(), boxAxisColor->color(), boxFormat->currentIndex(), boxPrecision->value(),
1176  boxAngle->value(), baseline, formula, boxAxisNumColor->color());
1177 }
1178 
1180 {
1181  if (generalDialog.currentWidget()==(QWidget*)scalesPage)
1182  {
1183  QString from=boxStart->text().toLower();
1184  QString to=boxEnd->text().toLower();
1185  QString step=boxStep->text().toLower();
1186  int a = Graph::mapToQwtAxis(axesList->currentRow());
1187  switch (axesType[a])
1188  {
1189  case Graph::Time:
1190  case Graph::Date:
1191  case Graph::DateTime:
1192  {
1193  QDateTime qdt = QDateTime::fromString(from, "yyyy-MM-dd hh:mm:ss");
1194  from = QString::number(qdt.toMSecsSinceEpoch()/86400000.+2440587.5,'f',16);
1195  qdt = QDateTime::fromString(to, "yyyy-MM-dd hh:mm:ss");
1196  to = QString::number(qdt.toMSecsSinceEpoch()/86400000.+2440587.5,'f',16);
1197  break;
1198  }
1199  default: {}
1200  }
1201 
1202  double start, end, stp = 0;
1203  try
1204  {
1205  MyParser parser;
1206  parser.SetExpr(from);
1207  start=parser.Eval();
1208  }
1209  catch(mu::ParserError &e)
1210  {
1211  QMessageBox::critical(0, tr("Start limit error"),QStringFromString(e.GetMsg()));
1212  boxStart->setFocus();
1213  return false;
1214  }
1215  try
1216  {
1217  MyParser parser;
1218  parser.SetExpr(to);
1219  end=parser.Eval();
1220  }
1221  catch(mu::ParserError &e)
1222  {
1223  QMessageBox::critical(0, tr("End limit error"),QStringFromString(e.GetMsg()));
1224  boxEnd->setFocus();
1225  return false;
1226  }
1227  if (btnStep->isChecked())
1228  {
1229  try
1230  {
1231  MyParser parser;
1232  parser.SetExpr(step.toUtf8().constData());
1233  stp=parser.Eval();
1234  }
1235  catch(mu::ParserError &e)
1236  {
1237  QMessageBox::critical(0, tr("Step input error"),QStringFromString(e.GetMsg()));
1238  boxStep->setFocus();
1239  return false;
1240  }
1241 
1242  if (stp <=0)
1243  {
1244  QMessageBox::critical(0,tr("Step input error"), tr("Please enter a positive step value!"));
1245  boxStep->setFocus();
1246  return false;
1247  }
1248 
1249  if (axesType[a] == Graph::Time)
1250  {
1251  switch (boxUnit->currentIndex())
1252  {
1253  case 0:
1254  break;
1255  case 1:
1256  stp *= 1e3;
1257  break;
1258  case 2:
1259  stp *= 6e4;
1260  break;
1261  case 3:
1262  stp *= 36e5;
1263  break;
1264  }
1265  }
1266  else if (axesType[a] == Graph::Date)
1267  {
1268  switch (boxUnit->currentIndex())
1269  {
1270  case 0:
1271  break;
1272  case 1:
1273  stp *= 7;
1274  break;
1275  }
1276  }
1277  else if (axesType[a] == Graph::DateTime)
1278  {
1279  switch (boxUnit->currentIndex())
1280  {
1281  case 0: // milliseconds
1282  stp *= 1./86400000.;
1283  break;
1284  case 1:
1285  stp *= 1./86400.;
1286  break;
1287  case 2:
1288  stp *= 1./1440.;
1289  break;
1290  case 3:
1291  stp *= 1./24.;
1292  break;
1293  case 4:
1294  break;
1295  case 5:
1296  stp *= 7;
1297  break;
1298  }
1299  }
1300  }
1301 
1302  d_graph->setScale(a, start, end, stp, boxMajorValue->value(), boxMinorValue->currentText().toInt(),
1303  boxScaleType->currentIndex(), btnInvert->isChecked());
1305  }
1306  else if (generalDialog.currentWidget()==gridPage)
1307  {
1308  updateGrid();
1309  }
1310  else if (generalDialog.currentWidget()==(QWidget*)axesPage)
1311  {
1312  int axis=mapToQwtAxisId();
1313  int format = currentSelectedAxisType();
1314  axesType[axis] = format;
1315 
1316  int baseline = boxBaseline->value();
1317  axesBaseline[axis] = baseline;
1318 
1319  if (format == Graph::Numeric)
1320  {
1321  if (boxShowFormula->isChecked())
1322  {
1323  QString formula = boxFormula->toPlainText().toLower();
1324  try
1325  {
1326  double value = 1.0;
1327  MyParser parser;
1328  if (formula.contains("x"))
1329  parser.DefineVar(_T("x"), &value);
1330  else if (formula.contains("y"))
1331  parser.DefineVar(_T("y"), &value);
1332  parser.SetExpr(formula.toUtf8().constData());
1333  parser.Eval();
1334  }
1335  catch(mu::ParserError &e)
1336  {
1337  QMessageBox::critical(0, tr("Formula input error"), QStringFromString(e.GetMsg())+"\n"+
1338  tr("Valid variables are 'x' for Top/Bottom axes and 'y' for Left/Right axes!"));
1339  boxFormula->setFocus();
1340  return false;
1341  }
1342  }
1343  }
1344  else if (format == Graph::Time || format == Graph::Date || format == Graph::DateTime)
1345  {
1346  QStringList lst = formatInfo[axis].split(";", QString::KeepEmptyParts);
1347  if (lst.size() < 2 || lst[0].isEmpty()) {
1348  lst = QStringList();
1349  if (format == Graph::Time)
1350  lst << QTime(0,0,0).toString();
1351  else if (format == Graph::Date)
1352  lst << QDate(1900,1,1).toString("yyyy-MM-dd");
1353  else
1354  lst << QDateTime(QDate(1900,1,1), QTime(0,0,0)).toString("yyyy-MM-ddThh:mm:ss");
1355  lst << boxFormat->currentText();
1356  } else
1357  lst[1] = boxFormat->currentText();
1358  formatInfo[axis] = lst.join(";");
1359  }
1360  else if (format == Graph::Day || format == Graph::Month)
1361  formatInfo[axis] = QString::number(boxFormat->currentIndex());
1362  else if (format == Graph::ColHeader)
1363  formatInfo[axis] = boxTableName->currentText();
1364  else
1365  formatInfo[axis] = boxColName->currentText();
1366 
1367  if (d_graph->axisTitle(axis) != boxTitle->toPlainText())
1368  d_graph->setAxisTitle(axis, boxTitle->toPlainText());
1369 
1370  if (axis == QwtPlot::xBottom)
1372  else if (axis == QwtPlot::xTop)
1373  xTopLabelsRotation=boxAngle->value();
1374 
1375  QString formula = boxFormula->toPlainText();
1376  if (!boxShowFormula->isChecked())
1377  formula = QString();
1378  showAxis(axis, format, formatInfo[axis], boxShowAxis->isChecked(), boxMajorTicksType->currentIndex(), boxMinorTicksType->currentIndex(),
1379  boxShowLabels->isChecked(), boxAxisColor->color(), boxFormat->currentIndex(),
1380  boxPrecision->value(), boxAngle->value(), baseline, formula, boxAxisNumColor->color());
1381  }
1382  else if (generalDialog.currentWidget()==(QWidget*)frame)
1383  {
1386  d_graph->drawCanvasFrame(boxFramed->isChecked(), boxFrameWidth->value(), boxFrameColor->color());
1387  d_graph->drawAxesBackbones(boxBackbones->isChecked());
1388  }
1389 
1390  return true;
1391 }
1392 
1394 {
1395  ApplicationWindow *app = qobject_cast<ApplicationWindow *>(parent());
1396 
1397  if (!app || !g)
1398  return;
1399 
1400  d_graph = g;
1401  Plot *p = d_graph->plotWidget();
1402 
1403  tablesList = app->tableWindows();
1404  boxTableName->addItems(tablesList);
1405 
1406  boxColName-> addItems(app->columnsList());
1407 
1408  xAxisOn = p->axisEnabled(QwtPlot::xBottom);
1409  yAxisOn = p->axisEnabled(QwtPlot::yLeft);
1410  topAxisOn = p->axisEnabled(QwtPlot::xTop);
1411  rightAxisOn = p->axisEnabled(QwtPlot::yRight);
1412 
1413  xBottomFont = p->axisFont(QwtPlot::xBottom);
1414  yLeftFont = p->axisFont(QwtPlot::yLeft);
1415  xTopFont = p->axisFont(QwtPlot::xTop);
1416  yRightFont = p->axisFont(QwtPlot::yRight);
1417 
1418  majTicks = p->getMajorTicksType();
1419  minTicks = p->getMinorTicksType();
1420 
1422  updateTitleBox(0);
1423 
1424  xBottomLabelsRotation = g->labelsRotation(QwtPlot::xBottom);
1425  xTopLabelsRotation = g->labelsRotation(QwtPlot::xTop);
1426 
1428 
1429  axesBaseline = g->axesBaseline();
1430 
1431  axesType = d_graph->axesType();
1432 
1433  boxAxesLinewidth->setValue(p->axesLinewidth());
1434  boxBackbones->setChecked (d_graph->axesBackbones());
1435 
1436  boxFramed->setChecked(d_graph->framed());
1438  boxFrameWidth->setValue(d_graph->canvasFrameWidth());
1439 
1440  boxMinorTicksLength->setValue(p->minorTickLength());
1441  boxMajorTicksLength->setValue(p->majorTickLength());
1442 
1443  showGridOptions(axesGridList->currentRow());
1444 }
1445 
1447 {
1448  return Graph::mapToQwtAxis(axesTitlesList->currentRow());
1449 }
1450 
1452 {
1453  int axis = axesList->currentRow();
1454 
1455  boxStart->clear();
1456  boxEnd->clear();
1457  boxStep->clear();
1458  boxUnit->hide();
1459  boxUnit->clear();
1460 
1461  Plot *d_plot = d_graph->plotWidget();
1462  int a = Graph::mapToQwtAxis(axis);
1463  const QwtScaleDiv *scDiv=d_plot->axisScaleDiv(a);
1464  double astart = std::min(scDiv->lowerBound(), scDiv->upperBound());
1465  double aend = std::max(scDiv->lowerBound(), scDiv->upperBound());
1466  double astep = d_graph->axisStep(a);
1467 
1468  switch (axesType[a])
1469  {
1470  case Graph::Time:
1471  case Graph::Date:
1472  case Graph::DateTime:
1473  {
1474  QDateTime qdt=QDateTime::fromMSecsSinceEpoch(round((astart-2440587.5)*86400000.));
1475  boxStart->setText(qdt.toString("yyyy-MM-dd hh:mm:ss"));
1476  qdt=QDateTime::fromMSecsSinceEpoch(round((aend-2440587.5)*86400000.));
1477  boxEnd->setText(qdt.toString("yyyy-MM-dd hh:mm:ss"));
1478  break;
1479  }
1480  default:
1481  {
1482  boxStart->setText(QString::number(astart));
1483  boxEnd->setText(QString::number(aend));
1484  }
1485  }
1486 
1487  QwtValueList lst = scDiv->ticks (QwtScaleDiv::MajorTick);
1488  boxStep->setText(QString::number(d_graph->axisStep(a)));
1489  boxMajorValue->setValue(lst.count());
1490 
1491  if (axesType[a] == Graph::Time)
1492  {
1493  boxUnit->show();
1494  boxUnit->addItem(tr("millisec."));
1495  boxUnit->addItem(tr("sec."));
1496  boxUnit->addItem(tr("min."));
1497  boxUnit->addItem(tr("hours"));
1498  }
1499  else if (axesType[a] == Graph::Date)
1500  {
1501  boxUnit->show();
1502  boxUnit->addItem(tr("days"));
1503  boxUnit->addItem(tr("weeks"));
1504  }
1505  else if (axesType[a] == Graph::DateTime)
1506  {
1507  boxUnit->show();
1508  boxUnit->addItem(tr("millisec."));
1509  boxUnit->addItem(tr("sec."));
1510  boxUnit->addItem(tr("min."));
1511  boxUnit->addItem(tr("hours"));
1512  boxUnit->addItem(tr("days"));
1513  boxUnit->addItem(tr("weeks"));
1514  boxUnit->setCurrentIndex(4); // days
1515  }
1516 
1517  if (d_graph->axisStep(a) != 0.0)
1518  {
1519  btnStep->setChecked(true);
1520  boxStep->setEnabled(true);
1521  boxUnit->setEnabled(true);
1522  if (axesType[a] == Graph::DateTime)
1523  {
1524  if (abs(astep*24.-round(astep*24.)) < 1e-6*astep)
1525  {
1526  astep *= 24;
1527  boxUnit->setCurrentIndex(3); // hours
1528  }
1529  else if (abs(astep*1440.-round(astep*1440.)) < 1e-6*astep)
1530  {
1531  astep *= 1440.;
1532  boxUnit->setCurrentIndex(2); // minutes
1533  }
1534  else if (abs(astep*86400.-round(astep*86400.)) < 1e-6*astep)
1535  {
1536  astep *= 86400.;
1537  boxUnit->setCurrentIndex(1); // seconds
1538  }
1539  boxStep->setText(QString::number(astep));
1540  }
1541 
1542  btnMajor->setChecked(false);
1543  boxMajorValue->setEnabled(false);
1544  }
1545  else
1546  {
1547  btnStep->setChecked(false);
1548  boxStep->setEnabled(false);
1549  boxUnit->setEnabled(false);
1550  btnMajor->setChecked(true);
1551  boxMajorValue->setEnabled(true);
1552  }
1553 
1554  const QwtScaleEngine *sc_eng = d_plot->axisScaleEngine(a);
1555  btnInvert->setChecked(sc_eng->testAttribute(QwtScaleEngine::Inverted));
1556 
1557  QwtScaleTransformation *tr = sc_eng->transformation();
1558  boxScaleType->setCurrentIndex((int)tr->type());
1559 
1560  boxMinorValue->clear();
1561  if (tr->type())//log scale
1562  boxMinorValue->addItems(QStringList()<<"0"<<"2"<<"4"<<"8");
1563  else
1564  boxMinorValue->addItems(QStringList()<<"0"<<"1"<<"4"<<"9"<<"14"<<"19");
1565 
1566  boxMinorValue->setEditText(QString::number(d_plot->axisMaxMinor(a)));
1567 }
1568 
1570 {
1571  int axisId = Graph::mapToQwtAxis(axis);
1572  boxTitle->setText(d_graph->axisTitle(axisId));
1573 }
1574 
1576 {
1577  QColor c = QColorDialog::getColor( boxAxisColor->color(), this);
1578  if ( !c.isValid() || c == boxAxisColor->color() )
1579  return;
1580 
1581  boxAxisColor->setColor ( c ) ;
1582 
1583  int axis=mapToQwtAxisId();
1584  QString formula = boxFormula->toPlainText();
1585  if (!boxShowFormula->isChecked())
1586  formula = QString();
1587 
1588  showAxis(axis, currentSelectedAxisType(), formatInfo[axis], boxShowAxis->isChecked(), boxMajorTicksType->currentIndex(), boxMinorTicksType->currentIndex(),
1589  boxShowLabels->isChecked(), c, boxFormat->currentIndex(), boxPrecision->value(),
1590  boxAngle->value(), boxBaseline->value(), formula, boxAxisNumColor->color());
1591 }
1592 
1594 {
1595  QColor c = QColorDialog::getColor( boxAxisNumColor->color(), this);
1596  if ( !c.isValid() || c == boxAxisNumColor->color() )
1597  return;
1598 
1599  boxAxisNumColor->setColor ( c ) ;
1600  int axis=mapToQwtAxisId();
1601  QString formula = boxFormula->toPlainText();
1602  if (!boxShowFormula->isChecked())
1603  formula = QString();
1604 
1605  showAxis(axis, currentSelectedAxisType(), formatInfo[axis], boxShowAxis->isChecked(), boxMajorTicksType->currentIndex(), boxMinorTicksType->currentIndex(),
1606  boxShowLabels->isChecked(), boxAxisColor->color(), boxFormat->currentIndex(), boxPrecision->value(),
1607  boxAngle->value(), boxBaseline->value(), formula, c);
1608 }
1609 
1611 {
1612  int a = mapToQwtAxisId();
1613  int type = d_graph->axesType()[a];
1614 
1615  boxAxisType->setCurrentIndex(boxAxisType->findData(type));
1616  showAxisFormatOptions(boxAxisType->findData(type));
1617 
1618  if (type == Graph::Txt)
1619  boxColName->setItemText(boxColName->currentIndex(), formatInfo[a]);
1620 }
1621 
1623 {
1624  int a=mapToQwtAxisId();
1625  boxBaseline->setValue(axesBaseline[a]);
1626 }
1627 
1629 {
1630  int a=mapToQwtAxisId();
1631  boxMajorTicksType->setCurrentIndex(majTicks[a]);
1632  boxMinorTicksType->setCurrentIndex(minTicks[a]);
1633 }
1634 
1636 {
1637  int axis=mapToQwtAxisId();
1638  int type=boxMajorTicksType->currentIndex();
1639  if ( majTicks[axis] == type)
1640  return;
1641 
1642  majTicks[axis]=type;
1643  QString formula = boxFormula->toPlainText();
1644  if (!boxShowFormula->isChecked())
1645  formula = QString();
1646 
1647  showAxis(axis, currentSelectedAxisType(), formatInfo[axis], boxShowAxis->isChecked(), type, boxMinorTicksType->currentIndex(),
1648  boxShowLabels->isChecked(), boxAxisColor->color(), boxFormat->currentIndex(),boxPrecision->value(),
1649  boxAngle->value(), boxBaseline->value(), formula, boxAxisNumColor->color());
1650 }
1651 
1653 {
1654  int axis=mapToQwtAxisId();
1655  int type=boxMinorTicksType->currentIndex();
1656  if ( minTicks[axis] == type)
1657  return;
1658 
1659  minTicks[axis]=type;
1660  QString formula = boxFormula->toPlainText();
1661 
1662  if (!boxShowFormula->isChecked())
1663  formula = QString();
1664 
1665  showAxis(axis, currentSelectedAxisType(), formatInfo[axis], boxShowAxis->isChecked(), boxMajorTicksType->currentIndex(), type,
1666  boxShowLabels->isChecked(), boxAxisColor->color(), boxFormat->currentIndex(),boxPrecision->value(),
1667  boxAngle->value(), boxBaseline->value(), formula, boxAxisNumColor->color());
1668 }
1669 
1671 {
1672  int axis = mapToQwtAxisId();
1673  if (axis == QwtPlot::xBottom || axis == QwtPlot::xTop)
1674  boxAngle->setEnabled(on);
1675 
1676  bool userFormat = true;
1677  if (boxFormat->currentIndex() == 0)
1678  userFormat = false;
1679  boxPrecision->setEnabled(on && userFormat);
1680 
1681  if (tickLabelsOn[axis] == QString::number(on))
1682  return;
1683  tickLabelsOn[axis]=QString::number(on);
1684 
1685  int type = currentSelectedAxisType();
1686  if (type == Graph::Day || type == Graph::Month)
1687  formatInfo[axis] = QString::number(boxFormat->currentIndex());
1688  else if (type == Graph::Time || type == Graph::Date || type == Graph::DateTime)
1689  {
1690  QStringList lst = formatInfo[axis].split(";", QString::SkipEmptyParts);
1691  if (lst.size() < 2 || lst[0].isEmpty()) {
1692  lst = QStringList();
1693  if (type == Graph::Time)
1694  lst << QTime(0,0,0).toString();
1695  else if (type == Graph::Date)
1696  lst << QDate(1900,1,1).toString("yyyy-MM-dd");
1697  else
1698  lst << QDateTime(QDate(1900,1,1), QTime(0,0,0)).toString("yyyy-MM-ddThh:mm:ss");
1699  lst << boxFormat->currentText();
1700  } else
1701  lst[1] = boxFormat->currentText();
1702  formatInfo[axis] = lst.join(";");
1703  }
1704  else
1705  formatInfo[axis] = boxColName->currentText();
1706 
1707  QString formula = boxFormula->toPlainText();
1708  if (!boxShowFormula->isChecked())
1709  formula = QString();
1710 
1711  showAxis(axis, type, formatInfo[axis], boxShowAxis->isChecked(), boxMajorTicksType->currentIndex(), boxMinorTicksType->currentIndex(),
1712  boxShowLabels->isChecked(), boxAxisColor->color(), boxFormat->currentIndex(), boxPrecision->value(),
1713  boxAngle->value(), boxBaseline->value(), formula, boxAxisNumColor->color());
1714 }
1715 
1717 {
1718  int axis = -1;
1719  switch (axisPos)
1720  {
1721  case QwtScaleDraw::LeftScale:
1722  axis = 1;
1723  break;
1724  case QwtScaleDraw::BottomScale:
1725  axis = 0;
1726  break;
1727  case QwtScaleDraw::RightScale:
1728  axis = 3;
1729  break;
1730  case QwtScaleDraw::TopScale:
1731  axis = 2;
1732  break;
1733  }
1734  if (generalDialog.currentWidget()==(QWidget*)scalesPage)
1735  axesList->setCurrentRow(axis);
1736  else if (generalDialog.currentWidget()==(QWidget*)axesPage)
1737  axesTitlesList->setCurrentRow(axis);
1738 }
1739 
1741 {
1742  if (generalDialog.currentWidget()!=(QWidget*)axesPage)
1743  generalDialog.setCurrentWidget(axesPage);
1744 }
1745 
1747 {
1748  if (generalDialog.currentWidget()!=(QWidget*)gridPage)
1749  generalDialog.setCurrentWidget(gridPage);
1750 }
1751 
1753 {
1754  int axis = mapToQwtAxisId();
1755  int type = currentSelectedAxisType();
1756  int prec = boxPrecision->value();
1757  int format = boxFormat->currentIndex();
1758 
1759  Plot *plot = d_graph->plotWidget();
1760 
1761  if (type == Graph::Numeric)
1762  {
1763  if (plot->axisLabelFormat(axis) == format &&
1764  plot->axisLabelPrecision(axis) == prec)
1765  return;
1766 
1767  if (format == 0)
1768  boxPrecision->setEnabled(false);
1769  else
1770  boxPrecision->setEnabled(true);
1771  }
1772  else if (type == Graph::Day || type == Graph::Month)
1773  formatInfo[axis] = QString::number(format);
1774  else if (type == Graph::Time || type == Graph::Date || type == Graph::DateTime)
1775  {
1776  QStringList lst = formatInfo[axis].split(";", QString::KeepEmptyParts);
1777  if (lst.size() < 2 || lst[0].isEmpty()) {
1778  lst = QStringList();
1779  if (type == Graph::Time)
1780  lst << QTime(0,0,0).toString();
1781  else if (type == Graph::Date)
1782  lst << QDate(1900,1,1).toString("yyyy-MM-dd");
1783  else
1784  lst << QDateTime(QDate(1900,1,1), QTime(0,0,0)).toString("yyyy-MM-ddThh:mm:ss");
1785  lst << boxFormat->currentText();
1786  } else
1787  lst[1] = boxFormat->currentText();
1788  formatInfo[axis] = lst.join(";");
1789  }
1790  else
1791  formatInfo[axis] = boxColName->currentText();
1792 
1793  QString formula = boxFormula->toPlainText();
1794  if (!boxShowFormula->isChecked())
1795  formula = QString();
1796 
1797  showAxis(axis, type, formatInfo[axis], boxShowAxis->isChecked(), boxMajorTicksType->currentIndex(),
1798  boxMinorTicksType->currentIndex(), boxShowLabels->isChecked(), boxAxisColor->color(),
1799  format, prec, boxAngle->value(), boxBaseline->value(), formula, boxAxisNumColor->color());
1800 
1801  axesType[axis] = type;
1802 }
1803 
1805 {
1806  QStringList l = d_graph->getAxesFormulas();
1807  QString formula = l[axis];
1808  if (!formula.isEmpty())
1809  {
1810  boxShowFormula->setChecked(true);
1811  boxFormula->show();
1812  boxFormula->setText(formula);
1813  }
1814  else
1815  {
1816  boxShowFormula->setChecked(false);
1817  boxFormula->clear();
1818  boxFormula->hide();
1819  }
1820 }
1821 
1823 {
1825  return;
1826 
1827  int a = mapToQwtAxisId();
1828  int format = d_graph->plotWidget()->axisLabelFormat(a);
1829  boxFormat->setCurrentIndex(format);
1831 
1832  if (format == 0)
1833  boxPrecision->setEnabled(false);
1834  else
1835  boxPrecision->setEnabled(true);
1836 
1837  QStringList l = d_graph->getAxesFormulas();
1838  QString formula = l[a];
1839  if (!formula.isEmpty())
1840  {
1841  boxShowFormula->setChecked(true);
1842  boxFormula->show();
1843  boxFormula->setText(formula);
1844  }
1845  else
1846  {
1847  boxShowFormula->setChecked(false);
1848  boxFormula->clear();
1849  boxFormula->hide();
1850  }
1851 }
1852 
1854 {
1855  generalDialog.setCurrentIndex(generalDialog.indexOf(frame));
1856 }
1857 
1859 {
1860  if (boxShowFormula->isChecked())
1861  boxFormula->show();
1862  else
1863  boxFormula->hide();
1864 }
1865 
1867 {
1868  int axis = mapToQwtAxisId();
1869  bool okF;
1870  QFont oldFont = d_graph->axisTitleFont(axis);
1871  QFont fnt = QFontDialog::getFont( &okF, oldFont,this);
1872  if (okF && fnt != oldFont)
1873  d_graph->setAxisTitleFont(axis, fnt);
1874 }
1875 
1876 void AxesDialog::pageChanged ( int page )
1877 {
1878  QWidget* pageWidget = generalDialog.widget(page);
1879  if (lastPage == scalesPage && pageWidget == axesPage)
1880  {
1881  axesTitlesList->setCurrentRow(axesList->currentRow());
1882  lastPage = pageWidget;
1883  }
1884  else if (lastPage == axesPage && pageWidget == scalesPage)
1885  {
1886  axesList->setCurrentRow(axesTitlesList->currentRow());
1887  lastPage = pageWidget;
1888  }
1889 }
1890 
1892 {
1893  axesList->setCurrentRow(0);
1894  axesGridList->setCurrentRow(0);
1895  axesTitlesList->setCurrentRow(0);
1896 
1897  setModal(true);
1898  show();
1899  return 0;
1900 }
1901 
1903 {
1904  updatePlot();
1905 
1906  boxMinorValue->clear();
1907  if (scaleType)//log scale
1908  boxMinorValue->addItems(QStringList()<<"0"<<"2"<<"4"<<"8");
1909  else
1910  boxMinorValue->addItems(QStringList()<<"0"<<"1"<<"4"<<"9"<<"14"<<"19");
1911 
1912  int a = Graph::mapToQwtAxis(axesList->currentRow());
1913  boxMinorValue->setEditText(QString::number(d_graph->plotWidget()->axisMaxMinor(a)));
1914 }
1915 
1916 void AxesDialog::showAxis(int axis, int type, const QString& labelsColName, bool axisOn,
1917  int majTicksType, int minTicksType, bool labelsOn, const QColor& c, int format,
1918  int prec, int rotation, int baselineDist, const QString& formula, const QColor& labelsColor)
1919 {
1920  ApplicationWindow *app = qobject_cast<ApplicationWindow *>(parent());
1921  if (!app)
1922  return;
1923 
1924  Table *w = app->table(labelsColName);
1925  if ((type == Graph::Txt || type == Graph::ColHeader) && !w)
1926  return;
1927 
1928  if (!d_graph)
1929  return;
1930  d_graph->showAxis(axis, type, labelsColName, w, axisOn, majTicksType, minTicksType, labelsOn,
1931  c, format, prec, rotation, baselineDist, formula, labelsColor);
1932 }
1933 
1935 {
1936  int index = boxAxisType->currentIndex();
1937  if (index < 0) return Graph::Numeric;
1938  return boxAxisType->itemData(index).toInt();
1939 }
AxesDialog::changeMajorTicksLength
void changeMajorTicksLength(int majLength)
Definition: AxesDialog.cpp:612
Grid::setMinPenY
void setMinPenY(const QPen &p)
Definition: Grid.h:60
Grid::setMinPenX
void setMinPenX(const QPen &p)
Definition: Grid.h:54
Plot.h
AxesDialog::btnAxesFont
QPushButton * btnAxesFont
Definition: AxesDialog.h:123
AxesDialog::pickAxisColor
void pickAxisColor()
Definition: AxesDialog.cpp:1575
MyParser.h
AxesDialog::topAxisOn
bool topAxisOn
Definition: AxesDialog.h:202
AxesDialog::boxMajorTicksType
QComboBox * boxMajorTicksType
Definition: AxesDialog.h:126
AxesDialog::updateLabelsFormat
void updateLabelsFormat(int)
Definition: AxesDialog.cpp:1822
AxesDialog::boxPrecision
QSpinBox * boxPrecision
Definition: AxesDialog.h:122
AxesDialog::labelBox
QGroupBox * labelBox
Definition: AxesDialog.h:132
AxesDialog::boxYLine
QCheckBox * boxYLine
Definition: AxesDialog.h:114
AxesDialog::insertColList
void insertColList(const QStringList &cols)
Definition: AxesDialog.cpp:831
AxesDialog::showAxisFormula
void showAxisFormula(int axis)
Definition: AxesDialog.cpp:1804
AxesDialog::gridPage
QWidget * gridPage
Definition: AxesDialog.h:103
AxesDialog::yRightFont
QFont yRightFont
Definition: AxesDialog.h:201
Graph::setAxisTitle
void setAxisTitle(int axis, const QString &text)
Definition: Graph.cpp:1164
AxesDialog::initScalesPage
void initScalesPage()
generate UI for the scales page
Definition: AxesDialog.cpp:107
AxesDialog::boxShowAxis
QCheckBox * boxShowAxis
Definition: AxesDialog.h:119
ColorButton
A button used for color selection.
Definition: ColorButton.h:54
Graph::canvasFrameColor
QColor canvasFrameColor()
Definition: Graph.cpp:1916
Graph::mapToQwtAxis
static int mapToQwtAxis(int axis)
Definition: Graph.cpp:5484
AxesDialog::showGridPage
void showGridPage()
Definition: AxesDialog.cpp:1746
AxesDialog::lastPage
QWidget * lastPage
Last selected tab.
Definition: AxesDialog.h:207
Plot::axesLinewidth
int axesLinewidth() const
Definition: Plot.cpp:379
AxesDialog::axesTitlesList
QListWidget * axesTitlesList
Definition: AxesDialog.h:117
AxesDialog::boxMinorGrid
QCheckBox * boxMinorGrid
Definition: AxesDialog.h:105
AxesDialog::initAxesPage
void initAxesPage()
generate UI for the axes page
Definition: AxesDialog.cpp:338
QStringFromString
QString QStringFromString(const std::string &x)
Definition: QStringStdString.h:15
AxesDialog::xTopFont
QFont xTopFont
Definition: AxesDialog.h:201
TextFormatButtons.h
ApplicationWindow::columnsList
QStringList columnsList(SciDAVis::PlotDesignation plotType)
Definition: ApplicationWindow.cpp:5197
AxesDialog::boxAngle
QSpinBox * boxAngle
Definition: AxesDialog.h:122
Grid::majPenY
const QPen & majPenY() const
Definition: Grid.h:58
Graph::setAxisTitleFont
void setAxisTitleFont(int axis, const QFont &fnt)
Definition: Graph.cpp:919
Graph::Date
@ Date
Definition: Graph.h:127
Grid::majPenX
const QPen & majPenX() const
Definition: Grid.h:52
Grid::yZeroLineEnabled
bool yZeroLineEnabled()
Definition: Grid.h:48
Graph::axesLabelsFormatInfo
QStringList axesLabelsFormatInfo()
Definition: Graph.h:526
AxesDialog::d_graph
Graph * d_graph
Definition: AxesDialog.h:205
AxesDialog::showAxisFormatOptions
void showAxisFormatOptions(int format)
Definition: AxesDialog.cpp:663
Graph::drawAxesBackbones
void drawAxesBackbones(bool yes)
Definition: Graph.cpp:1971
Graph::changeTicksLength
void changeTicksLength(int minLength, int majLength)
Definition: Graph.cpp:619
AxesDialog::label1
QLabel * label1
Definition: AxesDialog.h:128
AxesDialog::scalesPage
QWidget * scalesPage
Definition: AxesDialog.h:93
AxesDialog::mapToQwtAxisId
int mapToQwtAxisId()
Definition: AxesDialog.cpp:1446
Graph::drawCanvasFrame
void drawCanvasFrame(bool frameOn, int width)
Definition: Graph.cpp:1963
AxesDialog::updateTitleBox
void updateTitleBox(int axis)
Definition: AxesDialog.cpp:1569
Graph::axisNumbersColor
QColor axisNumbersColor(int axis)
Definition: Graph.cpp:1026
AxesDialog::boxTableName
QComboBox * boxTableName
Definition: AxesDialog.h:130
Graph::setAxisFont
void setAxisFont(int axis, const QFont &fnt)
Definition: Graph.cpp:281
Grid::minPenX
const QPen & minPenX() const
Definition: Grid.h:55
AxesDialog::customAxisLabelFont
void customAxisLabelFont()
Definition: AxesDialog.cpp:1866
AxesDialog::btnMajor
QRadioButton * btnMajor
Definition: AxesDialog.h:101
AxesDialog::updatePlot
bool updatePlot()
Definition: AxesDialog.cpp:1179
Graph::notifyChanges
void notifyChanges()
Definition: Graph.cpp:192
ColorButton.h
AxesDialog::setLabelsNumericFormat
void setLabelsNumericFormat(int)
Definition: AxesDialog.cpp:1752
MyParser
Mathematical parser class based on muParser.
Definition: MyParser.h:52
AxesDialog::labelTable
QLabel * labelTable
Definition: AxesDialog.h:128
AxesDialog::tablesList
QStringList tablesList
Definition: AxesDialog.h:199
Grid.h
Table
MDI window providing a spreadsheet table with column logic.
Definition: Table.h:51
Graph::Time
@ Time
Definition: Graph.h:127
Graph::axesType
QList< int > axesType()
Definition: Graph.cpp:378
MyParser::SetExpr
void SetExpr(const QString &x)
Definition: MyParser.h:56
Graph::DateTime
@ DateTime
Definition: Graph.h:127
AxesDialog::drawFrame
void drawFrame(bool framed)
Definition: AxesDialog.cpp:637
AxesDialog::boxTypeMajor
QComboBox * boxTypeMajor
Definition: AxesDialog.h:106
AxesDialog::showGridOptions
void showGridOptions(int axis)
Definition: AxesDialog.cpp:1071
AxesDialog::showGeneralPage
void showGeneralPage()
Definition: AxesDialog.cpp:1853
AxesDialog::changeBaselineDist
void changeBaselineDist(int baseline)
Definition: AxesDialog.cpp:1163
AxesDialog::setBaselineDist
void setBaselineDist(int)
Definition: AxesDialog.cpp:1622
AxesDialog::currentSelectedAxisType
int currentSelectedAxisType()
Definition: AxesDialog.cpp:1934
ColorButton::color
QColor color() const
Get the color of the display part.
Definition: ColorButton.cpp:140
AxesDialog::axesType
QList< int > axesType
Definition: AxesDialog.h:200
Graph::axisStep
double axisStep(int axis)
Definition: Graph.h:280
Graph::canvasFrameWidth
int canvasFrameWidth()
Definition: Graph.cpp:1923
AxesDialog::boxUnit
QComboBox * boxUnit
Definition: AxesDialog.h:130
AxesDialog::boxColName
QComboBox * boxColName
Definition: AxesDialog.h:126
AxesDialog::initGridPage
void initGridPage()
generate UI for the grid page
Definition: AxesDialog.cpp:213
AxesDialog::updateMajTicksType
void updateMajTicksType(int)
Definition: AxesDialog.cpp:1635
AxesDialog::xBottomLabelsRotation
int xBottomLabelsRotation
Definition: AxesDialog.h:203
Graph::ColHeader
@ ColHeader
Definition: Graph.h:127
Graph::axisTitleFont
QFont axisTitleFont(int axis)
Definition: Graph.cpp:928
AxesDialog::label3
QLabel * label3
Definition: AxesDialog.h:128
AxesDialog::setCurrentScale
void setCurrentScale(int axisPos)
Definition: AxesDialog.cpp:1716
AxesDialog::buttonOk
QPushButton * buttonOk
Definition: AxesDialog.h:90
Graph::setAxesLinewidth
void setAxesLinewidth(int width)
Definition: Graph.cpp:2012
AxesDialog::boxAxesLinewidth
QSpinBox * boxAxesLinewidth
Definition: AxesDialog.h:122
AxesDialog::btnInvert
QCheckBox * btnInvert
Definition: AxesDialog.h:99
AxesDialog::boxTitle
QTextEdit * boxTitle
Definition: AxesDialog.h:121
Plot::getMinorTicksType
QList< int > getMinorTicksType()
Definition: Plot.cpp:535
AxesDialog::minTicks
QList< int > minTicks
Definition: AxesDialog.h:200
AxesDialog::xTopLabelsRotation
int xTopLabelsRotation
Definition: AxesDialog.h:203
AxesDialog::axesGridList
QListWidget * axesGridList
Definition: AxesDialog.h:115
AxesDialog::showFormulaBox
void showFormulaBox()
Definition: AxesDialog.cpp:1858
AxesDialog::btnStep
QRadioButton * btnStep
Definition: AxesDialog.h:101
AxesDialog::axesList
QListWidget * axesList
Definition: AxesDialog.h:102
AxesDialog::boxStart
QLineEdit * boxStart
Definition: AxesDialog.h:95
Graph::replot
void replot()
Definition: Graph.h:249
AxesDialog::accept
void accept()
Definition: AxesDialog.cpp:1012
Plot::minorTickLength
int minorTickLength() const
Definition: Plot.cpp:390
Graph::plotWidget
Plot * plotWidget() const
Accessor method for d_plot.
Definition: Graph.h:155
AxesDialog::boxAxisColor
ColorButton * boxAxisColor
Definition: AxesDialog.h:125
AxesDialog::drawAxesBackbones
void drawAxesBackbones(bool)
Definition: AxesDialog.cpp:621
AxesDialog::minorGridEnabled
void minorGridEnabled(bool on)
Definition: AxesDialog.cpp:1027
ApplicationWindow::table
Table * table(const QString &name)
Definition: ApplicationWindow.cpp:2806
Graph::enabledTickLabels
QStringList enabledTickLabels()
Definition: Graph.cpp:462
AxesDialog::boxShowLabels
QGroupBox * boxShowLabels
Definition: AxesDialog.h:118
AxesDialog::stepDisabled
void stepDisabled()
Definition: AxesDialog.cpp:1148
Graph::getAxesFormulas
QStringList getAxesFormulas()
Definition: Graph.h:532
AxesDialog::formatButtons
TextFormatButtons * formatButtons
Definition: AxesDialog.h:134
AxesDialog::generalDialog
QTabWidget generalDialog
Definition: AxesDialog.h:92
AxesDialog::boxAxisNumColor
ColorButton * boxAxisNumColor
Definition: AxesDialog.h:131
AxesDialog::xBottomFont
QFont xBottomFont
Definition: AxesDialog.h:201
AxesDialog::setGraph
void setGraph(Graph *g)
Definition: AxesDialog.cpp:1393
Graph::Day
@ Day
Definition: Graph.h:127
AxesDialog::majTicks
QList< int > majTicks
Definition: AxesDialog.h:200
AxesDialog::boxStep
QLineEdit * boxStep
Definition: AxesDialog.h:98
AxesDialog::label2
QLabel * label2
Definition: AxesDialog.h:128
AxesDialog::setAxisType
void setAxisType(int axis)
Definition: AxesDialog.cpp:1610
Graph::AxisType
AxisType
Definition: Graph.h:127
Graph::getPenStyle
static Qt::PenStyle getPenStyle(const QString &s)
Definition: Graph.cpp:4329
Plot::axisLabelPrecision
int axisLabelPrecision(int axis)
Definition: Plot.cpp:581
Graph::axesBaseline
QList< int > axesBaseline()
Definition: Graph.cpp:343
AxesDialog::exec
int exec()
Shows the dialog as a modal dialog.
Definition: AxesDialog.cpp:1891
Plot::grid
Grid * grid()
Definition: Plot.h:54
AxesDialog::minorBoxLabel
QLabel * minorBoxLabel
Definition: AxesDialog.h:128
ApplicationWindow
SciDAVis's main window.
Definition: ApplicationWindow.h:122
AxesDialog::AxesDialog
AxesDialog()
Constructor.
Definition: AxesDialog.cpp:65
AxesDialog::boxFrameColor
ColorButton * boxFrameColor
Definition: AxesDialog.h:131
Plot::majorTickLength
int majorTickLength() const
Definition: Plot.cpp:395
AxesDialog::axesBaseline
QList< int > axesBaseline
Definition: AxesDialog.h:200
AxesDialog::updateScale
void updateScale()
Definition: AxesDialog.cpp:1451
Plot
Plot window class.
Definition: Plot.h:44
AxesDialog::updateGrid
void updateGrid()
Definition: AxesDialog.cpp:1036
AxesDialog::boxMajorValue
QSpinBox * boxMajorValue
Definition: AxesDialog.h:100
AxesDialog::updateFrame
void updateFrame(int)
Definition: AxesDialog.cpp:645
AxesDialog::buttonApply
QPushButton * buttonApply
Definition: AxesDialog.h:89
Graph::axesBackbones
bool axesBackbones()
Definition: Graph.h:497
AxesDialog::boxGridYAxis
QComboBox * boxGridYAxis
Definition: AxesDialog.h:130
Graph::axisTitle
QString axisTitle(int axis)
Definition: Graph.h:442
AxesDialog::boxFramed
QGroupBox * boxFramed
Definition: AxesDialog.h:127
AxesDialog::boxGridXAxis
QComboBox * boxGridXAxis
Definition: AxesDialog.h:130
Grid::setMajPenX
void setMajPenX(const QPen &p)
Definition: Grid.h:51
AxesDialog::buttonCancel
QPushButton * buttonCancel
Definition: AxesDialog.h:91
AxesDialog::changeMinorTicksLength
void changeMinorTicksLength(int minLength)
Definition: AxesDialog.cpp:603
AxesDialog::pageChanged
void pageChanged(int)
Definition: AxesDialog.cpp:1876
Graph.h
Graph::setScale
void setScale(int axis, double start, double end, double step=0.0, int majorTicks=5, int minorTicks=5, int type=0, bool inverted=false)
Set axis scale.
Definition: Graph.cpp:1269
Grid::minPenY
const QPen & minPenY() const
Definition: Grid.h:61
AxesDialog::setTicksType
void setTicksType(int)
Definition: AxesDialog.cpp:1628
Graph::labelsRotation
int labelsRotation(int axis)
Definition: Graph.cpp:877
AxesDialog::boxBackbones
QCheckBox * boxBackbones
Definition: AxesDialog.h:124
AxesDialog::boxMinorTicksType
QComboBox * boxMinorTicksType
Definition: AxesDialog.h:126
AxesDialog::updateAxisColor
void updateAxisColor(int)
Definition: AxesDialog.cpp:1156
AxesDialog::boxMinorTicksLength
QSpinBox * boxMinorTicksLength
Definition: AxesDialog.h:129
Graph::Month
@ Month
Definition: Graph.h:127
AxesDialog::boxScaleTypeLabel
QLabel * boxScaleTypeLabel
Definition: AxesDialog.h:128
AxesDialog::formatInfo
QStringList formatInfo
Definition: AxesDialog.h:198
AxesDialog::boxMajorTicksLength
QSpinBox * boxMajorTicksLength
Definition: AxesDialog.h:129
Grid
2D Grid class
Definition: Grid.h:38
AxesDialog::boxWidthMinor
QSpinBox * boxWidthMinor
Definition: AxesDialog.h:112
AxesDialog.h
AxesDialog::boxColorMajor
ColorButton * boxColorMajor
Definition: AxesDialog.h:108
AxesDialog::boxShowFormula
QCheckBox * boxShowFormula
Definition: AxesDialog.h:124
AxesDialog::boxFormula
QTextEdit * boxFormula
Definition: AxesDialog.h:121
AxesDialog::boxEnd
QLineEdit * boxEnd
Definition: AxesDialog.h:94
AxesDialog::updateMinTicksType
void updateMinTicksType(int)
Definition: AxesDialog.cpp:1652
Graph::Txt
@ Txt
Definition: Graph.h:127
AxesDialog::boxXLine
QCheckBox * boxXLine
Definition: AxesDialog.h:113
Grid::xZeroLineEnabled
bool xZeroLineEnabled()
Definition: Grid.h:46
AxesDialog::boxScaleType
QComboBox * boxScaleType
Definition: AxesDialog.h:96
Grid::setMajPenY
void setMajPenY(const QPen &p)
Definition: Grid.h:57
AxesDialog::updateShowBox
void updateShowBox(int axis)
Definition: AxesDialog.cpp:908
AxesDialog::boxWidthMajor
QSpinBox * boxWidthMajor
Definition: AxesDialog.h:110
Graph::showAxis
void showAxis(int axis, int type, const QString &formatInfo, Table *table, bool axisOn, int majTicksType, int minTicksType, bool labelsOn, const QColor &c, int format, int prec, int rotation, int baselineDist, const QString &formula, const QColor &labelsColor)
Definition: Graph.cpp:642
Graph
A 2D-plotting widget.
Definition: Graph.h:119
AxesDialog::updateMinorTicksList
void updateMinorTicksList(int scaleType)
Definition: AxesDialog.cpp:1902
Plot::getMajorTicksType
QList< int > getMajorTicksType()
Definition: Plot.cpp:512
Graph::framed
bool framed()
Definition: Graph.cpp:1911
AxesDialog::yAxisOn
bool yAxisOn
Definition: AxesDialog.h:202
AxesDialog::boxMajorGrid
QCheckBox * boxMajorGrid
Definition: AxesDialog.h:104
AxesDialog::rightAxisOn
bool rightAxisOn
Definition: AxesDialog.h:202
AxesDialog::boxColorMinor
ColorButton * boxColorMinor
Definition: AxesDialog.h:107
TextFormatButtons
Widget with text format buttons (connected to a QTextEdit)
Definition: TextFormatButtons.h:39
AxesDialog::initFramePage
void initFramePage()
generate UI for the general page
Definition: AxesDialog.cpp:546
AxesDialog::boxMinorValue
QComboBox * boxMinorValue
Definition: AxesDialog.h:97
AxesDialog::boxFrameWidth
QSpinBox * boxFrameWidth
Definition: AxesDialog.h:122
AxesDialog::customAxisFont
void customAxisFont()
Definition: AxesDialog.cpp:968
Plot::axisLabelFormat
void axisLabelFormat(int axis, char &f, int &prec) const
Definition: Plot.cpp:599
AxesDialog::pickAxisNumColor
void pickAxisNumColor()
Definition: AxesDialog.cpp:1593
AxesDialog::boxTypeMinor
QComboBox * boxTypeMinor
Definition: AxesDialog.h:111
AxesDialog::showAxis
void showAxis()
Definition: AxesDialog.cpp:836
AxesDialog::majorGridEnabled
void majorGridEnabled(bool on)
Definition: AxesDialog.cpp:1018
TextFormatButtons::toggleCurveButton
void toggleCurveButton(bool enable)
Show/Hide the "add curve" button.
Definition: TextFormatButtons.cpp:235
AxesDialog::pickCanvasFrameColor
void pickCanvasFrameColor()
Definition: AxesDialog.cpp:653
AxesDialog::frame
QWidget * frame
Definition: AxesDialog.h:116
AxesDialog::stepEnabled
void stepEnabled()
Definition: AxesDialog.cpp:1140
Grid::enableZeroLineY
void enableZeroLineY(bool enable=true)
Definition: Grid.cpp:204
ApplicationWindow.h
AxesDialog::showAxesPage
void showAxesPage()
Definition: AxesDialog.cpp:1740
ApplicationWindow::tableWindows
QStringList tableWindows()
Definition: ApplicationWindow.cpp:13950
AxesDialog::updateTickLabelsList
void updateTickLabelsList(bool)
Definition: AxesDialog.cpp:1670
AxesDialog::yLeftFont
QFont yLeftFont
Definition: AxesDialog.h:201
AxesDialog::boxBaseline
QSpinBox * boxBaseline
Definition: AxesDialog.h:122
AxesDialog::xAxisOn
bool xAxisOn
Definition: AxesDialog.h:202
TextDialog.h
Graph::axisColor
QColor axisColor(int axis)
Definition: Graph.cpp:1017
AxesDialog::axesPage
QWidget * axesPage
Definition: AxesDialog.h:116
Graph::Numeric
@ Numeric
Definition: Graph.h:127
AxesDialog::boxFormat
QComboBox * boxFormat
Definition: AxesDialog.h:126
Grid::enableZeroLineX
void enableZeroLineX(bool enable=true)
Definition: Grid.cpp:177
AxesDialog::changeAxesLinewidth
void changeAxesLinewidth(int)
Definition: AxesDialog.cpp:629
ColorButton::setColor
void setColor(const QColor &c)
Set the color of the display part.
Definition: ColorButton.cpp:132
AxesDialog::tickLabelsOn
QStringList tickLabelsOn
Definition: AxesDialog.h:198
AxesDialog::buttonLabelFont
QPushButton * buttonLabelFont
Definition: AxesDialog.h:133
AxesDialog::boxAxisType
QComboBox * boxAxisType
Definition: AxesDialog.h:126