1 /***************************************************************************
2 File : PlotDialog.cpp
3 Project : QtiPlot
4 --------------------------------------------------------------------
5 Copyright : (C) 2006-2011 by Ion Vasilief
6 Email (use @ for *) : ion_vasilief*yahoo.fr
7 Description : Custom curves dialog
8
9 ***************************************************************************/
10
11 /***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 * *
18 * This program is distributed in the hope that it will be useful, *
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21 * GNU General Public License for more details. *
22 * *
23 * You should have received a copy of the GNU General Public License *
24 * along with this program; if not, write to the Free Software *
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26 * Boston, MA 02110-1301 USA *
27 * *
28 ***************************************************************************/
29 #include "PlotDialog.h"
30 #include <ApplicationWindow.h>
31 #include <Table.h>
32 #include <MyParser.h>
33 #include <QwtHistogram.h>
34 #include <VectorCurve.h>
35 #include <ErrorBarsCurve.h>
36 #include <BoxCurve.h>
37 #include <FunctionCurve.h>
38 #include <Spectrogram.h>
39 #include <PieCurve.h>
40 #include <Folder.h>
41 #include <ColorMapEditor.h>
42 #include <DoubleSpinBox.h>
43 #include <PenStyleBox.h>
44 #include <ColorBox.h>
45 #include <ColorButton.h>
46 #include <PatternBox.h>
47 #include <SymbolBox.h>
48 #include <ContourLinesEditor.h>
49 #include <FunctionDialog.h>
50 #include <RectangleWidget.h>
51 #include <EllipseWidget.h>
52 #include <ImageWidget.h>
53 #include <TexWidget.h>
54 #include <EnrichmentDialog.h>
55 #include <ImageSymbol.h>
56 #include <CurveRangeDialog.h>
57
58 #include <QTreeWidget>
59 #include <QLineEdit>
60 #include <QLayout>
61 #include <QSpinBox>
62 #include <QCheckBox>
63 #include <QPushButton>
64 #include <QRadioButton>
65 #include <QLabel>
66 #include <QWidget>
67 #include <QMessageBox>
68 #include <QComboBox>
69 #include <QWidgetList>
70 #include <QFileDialog>
71 #include <QGroupBox>
72 #include <QFontDialog>
73 #include <QShortcut>
74 #include <QKeySequence>
75 #include <QDoubleSpinBox>
76 #include <QMenu>
77 #include <QDateTime>
78 #include <QSlider>
79 #include <QPainter>
80 #include <QCompleter>
81 #include <QDirModel>
82
83 #include <qwt_plot_canvas.h>
84
PlotDialog(bool showExtended,QWidget * parent,Qt::WFlags fl)85 PlotDialog::PlotDialog(bool showExtended, QWidget* parent, Qt::WFlags fl )
86 : QDialog(parent, fl),
87 d_ml(0)
88 {
89 setName( "PlotDialog" );
90 setWindowTitle( tr( "QtiPlot - Plot details" ) );
91 setModal(true);
92 setSizeGripEnabled(true);
93 setAttribute(Qt::WA_DeleteOnClose);
94
95 listBox = new QTreeWidget();
96 listBox->setColumnCount(1);
97 listBox->header()->hide();
98 listBox->setIndentation(15);
99
100 QGridLayout *gl = new QGridLayout(this);
101 gl->addWidget(listBox, 0, 0);
102
103 privateTabWidget = new QTabWidget();
104 gl->addWidget(privateTabWidget, 0, 1);
105
106 curvePlotTypeBox = new QWidget();
107 QHBoxLayout *hb1 = new QHBoxLayout(curvePlotTypeBox);
108 hb1->addWidget(new QLabel(tr("Plot type")));
109 boxPlotType = new QComboBox();
110 boxPlotType->setEditable(false);
111 hb1->addWidget(boxPlotType);
112
113 btnUp = new QPushButton();
114 btnUp->setIcon(QPixmap(":/arrow_up.png"));
115 btnUp->setToolTip(tr("Move upward"));
116 btnUp->setMaximumWidth(20);
117 btnUp->setEnabled(false);
118 hb1->addWidget(btnUp);
119
120 btnDown = new QPushButton();
121 btnDown->setIcon(QPixmap(":/arrow_down.png"));
122 btnDown->setToolTip(tr("Move downward"));
123 btnDown->setMaximumWidth(20);
124 btnDown->setEnabled(false);
125 hb1->addWidget(btnDown);
126 hb1->addStretch();
127
128 gl->addWidget(curvePlotTypeBox, 1, 0);
129
130 completer = new QCompleter(this);
131 completer->setModel(new QDirModel(completer));
132 completer->setModelSorting(QCompleter::CaseSensitivelySortedModel);
133 completer->setCompletionMode(QCompleter::InlineCompletion);
134
135 initAxesPage();
136 initLinePage();
137 initSymbolsPage();
138 initHistogramPage();
139 initErrorsPage();
140 initSpacingPage();
141 initVectPage();
142 initBoxPage();
143 initPercentilePage();
144 initSpectrogramValuesPage();
145 initSpectrogramPage();
146 initContourLinesPage();
147 initPiePage();
148 initPieGeometryPage();
149 initPieLabelsPage();
150 initLayerPage();
151 initCanvasPage();
152 initLayerGeometryPage();
153 initLayerSpeedPage();
154 initLayerDisplayPage();
155 initFontsPage();
156 initPrintPage();
157 initMiscPage();
158 initLabelsPage();
159 initFunctionPage();
160 initPlotGeometryPage();
161
162 enrichmentDialog = NULL;
163 clearTabWidget();
164
165 QHBoxLayout* hb2 = new QHBoxLayout();
166 btnMore = new QPushButton("&<<");
167 btnMore->setFixedWidth(30);
168 btnMore->setCheckable(true);
169 if (showExtended)
170 btnMore->toggle ();
171 hb2->addWidget(btnMore);
172 btnWorksheet = new QPushButton(tr( "&Worksheet" ) );
173 hb2->addWidget(btnWorksheet);
174 buttonOk = new QPushButton(tr( "&OK" ));
175 buttonOk->setDefault( true );
176 hb2->addWidget(buttonOk);
177 buttonCancel = new QPushButton(tr( "&Cancel" ));
178 hb2->addWidget(buttonCancel);
179 buttonApply = new QPushButton(tr( "&Apply" ));
180 hb2->addWidget(buttonApply);
181 btnEditCurve = new QPushButton(tr("&Plot Associations..."));
182 hb2->addWidget(btnEditCurve);
183 btnEditCurveRange = new QPushButton(tr("Edit &Range..."));
184 hb2->addWidget(btnEditCurveRange);
185 hb2->addStretch();
186 gl->addLayout(hb2, 1, 1);
187
188 connect(btnMore, SIGNAL(toggled(bool)), this, SLOT(showAll(bool)));
189 connect(btnUp, SIGNAL(clicked()), this, SLOT(raiseCurve()));
190 connect(btnDown, SIGNAL(clicked()), this, SLOT(shiftCurveBy()));
191
192 connect( buttonOk, SIGNAL(clicked()), this, SLOT(quit()));
193 connect( buttonCancel, SIGNAL(clicked()), this, SLOT(close()));
194 connect( buttonApply, SIGNAL(clicked() ), this, SLOT(acceptParams()));
195 connect( btnWorksheet, SIGNAL(clicked()), this, SLOT(showWorksheet()));
196 connect( btnEditCurve, SIGNAL(clicked()), this, SLOT(editCurve()));
197 connect( btnEditCurveRange, SIGNAL(clicked()), this, SLOT(editCurveRange()));
198 connect(listBox, SIGNAL(currentItemChanged (QTreeWidgetItem *, QTreeWidgetItem *)),
199 this, SLOT(updateTabWindow(QTreeWidgetItem *, QTreeWidgetItem *)));
200 connect(listBox, SIGNAL(itemCollapsed(QTreeWidgetItem *)), this, SLOT(updateTreeWidgetItem(QTreeWidgetItem *)));
201 connect(listBox, SIGNAL(itemExpanded(QTreeWidgetItem *)), this, SLOT(updateTreeWidgetItem(QTreeWidgetItem *)));
202 connect(listBox, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(updateVisibility(QTreeWidgetItem *, int)));
203 connect(boxPlotType, SIGNAL(currentIndexChanged(int)), this, SLOT(changePlotType(int)));
204
205 QShortcut *shortcut = new QShortcut(QKeySequence(Qt::Key_Delete), this);
206 connect(shortcut, SIGNAL(activated()), this, SLOT(removeSelectedObject()));
207 }
208
showAll(bool all)209 void PlotDialog::showAll(bool all)
210 {
211 if(all){
212 listBox->show();
213 listBox->setFocus();
214
215 QTreeWidgetItem *item = listBox->currentItem();
216 if (item->type() == CurveTreeItem::PlotCurveTreeItem)
217 curvePlotTypeBox->show();
218
219 btnMore->setText("&>>");
220 } else {
221 listBox->hide();
222 curvePlotTypeBox->hide();
223 btnMore->setText("&<<");
224 }
225 }
226
editCurveRange()227 void PlotDialog::editCurveRange()
228 {
229 CurveTreeItem *item = (CurveTreeItem *)listBox->currentItem();
230 if (!item)
231 return;
232 if (item->type() != CurveTreeItem::PlotCurveTreeItem)
233 return;
234
235 ApplicationWindow *app = (ApplicationWindow *)this->parent();
236 if (!app)
237 return;
238
239 hide();
240
241 CurveRangeDialog* rd = new CurveRangeDialog(app);
242 if (rd){
243 rd->setCurveToModify(item->graph(), item->plotItemIndex());
244 connect((QObject *)rd, SIGNAL(destroyed()), this, SLOT(show()));
245 }
246 rd->exec();
247 }
248
editCurve()249 void PlotDialog::editCurve()
250 {
251 ApplicationWindow *app = (ApplicationWindow *)this->parent();
252
253 CurveTreeItem *item = (CurveTreeItem *)listBox->currentItem();
254 if (!item)
255 return;
256 if (item->type() != CurveTreeItem::PlotCurveTreeItem)
257 return;
258
259 int index = item->plotItemIndex();
260 int curveType = ((PlotCurve *)item->plotItem())->type();
261
262 hide();
263
264 if (app){
265 if (curveType == Graph::Function){
266 FunctionDialog *fd = app->showFunctionDialog(item->graph(), index);
267 if (fd)
268 connect((QObject *)fd, SIGNAL(destroyed()), this, SLOT(show()));
269 } else {
270 AssociationsDialog* ad = app->showPlotAssociations(index);
271 if (ad)
272 connect((QObject *)ad, SIGNAL(destroyed()), this, SLOT(plotAssociationsDialogClosed()));
273 }
274 }
275 }
276
plotAssociationsDialogClosed()277 void PlotDialog::plotAssociationsDialogClosed()
278 {
279 show();
280
281 CurveTreeItem *item = (CurveTreeItem *)listBox->currentItem();
282 if (!item)
283 return;
284 if (item->type() != CurveTreeItem::PlotCurveTreeItem)
285 return;
286
287 QwtPlotItem *it = (QwtPlotItem *)item->plotItem();
288 if (!it || it->rtti() != QwtPlotItem::Rtti_PlotCurve)
289 return;
290
291 PlotCurve *c = (PlotCurve *)it;
292 if (c->type() != Graph::Function && ((DataCurve *)it)->table()){
293 QStringList lst = ((DataCurve *)it)->plotAssociation();
294 QString tableName = ((DataCurve *)it)->table()->name();
295 QString plotAssociation = tableName + ": " + lst.replaceInStrings(tableName + "_", "").join(", ");
296 if (item->text(0) != plotAssociation)
297 item->setText(0, plotAssociation);
298 }
299 }
300
changePlotType(int plotType)301 void PlotDialog::changePlotType(int plotType)
302 {
303 if (boxPlotType->count() == 1)
304 return;
305
306 CurveTreeItem *item = (CurveTreeItem *)listBox->currentItem();
307 if (!item)
308 return;
309 if (item->type() != CurveTreeItem::PlotCurveTreeItem)
310 return;
311 Graph *graph = item->graph();
312 if (!graph)
313 return;
314
315 int curveType = item->plotItemStyle();
316 if (curveType == Graph::ColorMap || curveType == Graph::Contour || curveType == Graph::GrayScale)
317 clearTabWidget();
318 else if (curveType == Graph::VectXYAM || curveType == Graph::VectXYXY){
319 if ((plotType && curveType == Graph::VectXYAM) ||
320 (!plotType && curveType == Graph::VectXYXY))
321 return;
322
323 clearTabWidget();
324 insertTabs(curveType);
325
326 VectorCurve *v = (VectorCurve*)item->plotItem();
327 if (plotType){
328 v->setVectorStyle(VectorCurve::XYAM);
329 v->setPlotStyle(Graph::VectXYAM);
330 } else {
331 v->setVectorStyle(VectorCurve::XYXY);
332 v->setPlotStyle(Graph::VectXYXY);
333 }
334 customVectorsPage(plotType);
335 } else {
336 clearTabWidget();
337 insertTabs(plotType);
338
339 boxConnect->setCurrentIndex(1);//show line for Line and LineSymbol plots
340
341 int size = 2*boxSymbolSize->value() + 1;
342
343 QBrush br = QBrush();
344 if (boxFillSymbol->isChecked()){
345 QColor fc = boxFillColor->color();
346 fc.setAlphaF(0.01*boxSymbolTransparency->value());
347 br = QBrush(fc, Qt::SolidPattern);
348 }
349
350 QPen pen = QPen(boxSymbolColor->color(), boxPenWidth->value(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
351 pen.setCosmetic(true);
352 QwtSymbol s = QwtSymbol(boxSymbolStyle->selectedSymbol(), br, pen, QSize(size, size));
353 if (s.style() == QwtSymbol::NoSymbol){
354 s.setStyle(QwtSymbol::Ellipse);
355 boxSymbolStyle->setCurrentIndex(1);
356 }
357
358 if (plotType == Graph::Line)
359 s.setStyle(QwtSymbol::NoSymbol);
360 else if (plotType == Graph::Scatter)
361 graph->setCurveStyle(item->plotItemIndex(), QwtPlotCurve::NoCurve);
362 else if (plotType == Graph::LineSymbols)
363 graph->setCurveStyle(item->plotItemIndex(), QwtPlotCurve::Lines);
364
365 PlotCurve *c = (PlotCurve*)item->plotItem();
366 c->setSymbol(s);
367 c->setPlotStyle(plotType);
368 }
369 acceptParams();
370 }
371
initMiscPage()372 void PlotDialog::initMiscPage()
373 {
374 miscPage = new QWidget();
375 QGridLayout *gl = new QGridLayout(miscPage);
376
377 boxLinkXAxes = new QCheckBox(tr( "Link &X axes"));
378 gl->addWidget(boxLinkXAxes, 0, 0);
379
380 QLabel *l = new QLabel(tr("Apply &to..."));
381
382 QHBoxLayout *hl = new QHBoxLayout();
383 hl->addWidget(l);
384
385 boxLinkAllXAxes = new QComboBox();
386 boxLinkAllXAxes->addItem(tr("Window"));
387 boxLinkAllXAxes->addItem(tr("All Windows"));
388 hl->addWidget(boxLinkAllXAxes);
389 hl->addStretch();
390
391 l->setBuddy(boxLinkAllXAxes);
392
393 gl->addLayout(hl, 0, 1);
394 gl->setRowStretch(1, 1);
395
396 privateTabWidget->addTab(miscPage, tr("Miscellaneous"));
397 }
398
initFontsPage()399 void PlotDialog::initFontsPage()
400 {
401 QGroupBox *boxFonts = new QGroupBox();
402 QGridLayout *fl = new QGridLayout(boxFonts);
403
404 btnTitle = new QPushButton(tr("Titles"));
405 btnAxesLabels = new QPushButton(tr("Axes Labels"));
406 btnAxesNumbers = new QPushButton(tr("Axes Numbers"));
407 btnLegend = new QPushButton(tr("Legends"));
408
409 fl->addWidget(btnTitle, 0, 0);
410 fl->addWidget(btnAxesLabels, 0, 1);
411 fl->addWidget(btnAxesNumbers, 0, 2);
412 fl->addWidget(btnLegend, 0, 3);
413 fl->setRowStretch(1, 1);
414 fl->setColumnStretch(4, 1);
415
416 fontsPage = new QWidget();
417 QVBoxLayout *vl = new QVBoxLayout(fontsPage);
418 vl->addWidget(boxFonts);
419
420 privateTabWidget->addTab(fontsPage, tr( "Fonts"));
421
422 connect( btnTitle, SIGNAL( clicked() ), this, SLOT( setTitlesFont() ) );
423 connect( btnAxesLabels, SIGNAL( clicked() ), this, SLOT( setAxesLabelsFont() ) );
424 connect( btnAxesNumbers, SIGNAL( clicked() ), this, SLOT( setAxesNumbersFont() ) );
425 connect( btnLegend, SIGNAL( clicked() ), this, SLOT( setLegendsFont() ) );
426 }
427
initLayerPage()428 void PlotDialog::initLayerPage()
429 {
430 layerPage = new QWidget();
431
432 QGroupBox * boxBkg = new QGroupBox();
433 QGridLayout * boxBkgLayout = new QGridLayout( boxBkg );
434
435 boxBkgLayout->addWidget( new QLabel(tr( "Background Color" )), 0, 0 );
436 boxBackgroundColor = new ColorButton();
437 boxBkgLayout->addWidget( boxBackgroundColor, 0, 1 );
438
439 boxBackgroundTransparency = new QSpinBox();
440 boxBackgroundTransparency->setRange(0, 100);
441 boxBackgroundTransparency->setWrapping(true);
442 boxBackgroundTransparency->setSuffix(" %");
443
444 bkgOpacitySlider = new QSlider();
445 bkgOpacitySlider->setOrientation(Qt::Horizontal);
446 bkgOpacitySlider->setRange(0, 100);
447
448 QLabel *l1 = new QLabel("&" + tr("Opacity"));
449 l1->setBuddy(bkgOpacitySlider);
450 boxBkgLayout->addWidget(l1, 0, 2 );
451
452 QHBoxLayout* hb = new QHBoxLayout();
453 hb->addWidget(bkgOpacitySlider);
454 hb->addWidget(boxBackgroundTransparency);
455 boxBkgLayout->addLayout(hb, 0, 3 );
456
457 boxBkgLayout->addWidget( new QLabel(tr("Border Color" )), 2, 0);
458 boxBorderColor = new ColorButton();
459 boxBkgLayout->addWidget( boxBorderColor, 2, 1);
460
461 boxBorderWidth = new QSpinBox();
462 boxBkgLayout->addWidget( boxBorderWidth, 2, 3);
463
464 QLabel *l2 = new QLabel("&" + tr("Width"));
465 l2->setBuddy(boxBorderWidth);
466 boxBkgLayout->addWidget(l2, 2, 2);
467
468 boxMargin = new QSpinBox();
469 boxMargin->setRange( 0, 1000 );
470 boxMargin->setSingleStep(5);
471 boxBkgLayout->addWidget( boxMargin, 3, 1);
472
473 QLabel *l3 = new QLabel("&" + tr("Margin"));
474 l3->setBuddy(boxMargin);
475 boxBkgLayout->addWidget(l3, 3, 0);
476
477 boxAntialiasing = new QCheckBox("&" + tr("Antialiasing"));
478 boxBkgLayout->addWidget( boxAntialiasing, 4, 0);
479
480 boxAutoscaling = new QCheckBox(tr("Auto&scaling"));
481 boxBkgLayout->addWidget(boxAutoscaling, 5, 0);
482
483 layerScaleFonts = new QCheckBox(tr("Scale &Fonts"));
484 boxBkgLayout->addWidget(layerScaleFonts, 6, 0);
485
486 boxBkgLayout->setRowStretch(7, 1);
487
488 QVBoxLayout *vl = new QVBoxLayout();
489
490 layerDefaultBtn = new QPushButton(tr("Set As &Default"));
491 connect(layerDefaultBtn, SIGNAL(clicked()), this, SLOT(setLayerDefaultValues()));
492 vl->addWidget(layerDefaultBtn);
493
494 QLabel *l = new QLabel(tr("Apply &to..."));
495 vl->addWidget(l);
496
497 backgroundApplyToBox = new QComboBox();
498 backgroundApplyToBox->insertItem(tr("Layer"));
499 backgroundApplyToBox->insertItem(tr("Window"));
500 backgroundApplyToBox->insertItem(tr("All Windows"));
501 vl->addWidget(backgroundApplyToBox);
502 vl->addStretch();
503
504 l->setBuddy(backgroundApplyToBox);
505
506 QHBoxLayout * hl = new QHBoxLayout( layerPage );
507 hl->addWidget(boxBkg);
508 hl->addLayout(vl);
509
510 privateTabWidget->addTab(layerPage, tr("Layer"));
511
512 connect(boxBackgroundTransparency, SIGNAL(valueChanged(int)), this, SLOT(updateBackgroundTransparency(int)));
513 connect(boxAntialiasing, SIGNAL(toggled(bool)), this, SLOT(applyLayerFormat()));
514 connect(boxMargin, SIGNAL(valueChanged (int)), this, SLOT(applyLayerFormat()));
515 connect(boxBorderColor, SIGNAL(colorChanged()), this, SLOT(applyLayerFormat()));
516 connect(boxBackgroundColor, SIGNAL(colorChanged()), this, SLOT(applyLayerFormat()));
517 connect(boxBorderWidth, SIGNAL(valueChanged (int)), this, SLOT(applyLayerFormat()));
518 connect(bkgOpacitySlider, SIGNAL(valueChanged(int)), boxBackgroundTransparency, SLOT(setValue(int)));
519 connect(boxBackgroundTransparency, SIGNAL(valueChanged(int)), bkgOpacitySlider, SLOT(setValue(int)));
520 }
521
522
initPlotGeometryPage()523 void PlotDialog::initPlotGeometryPage()
524 {
525 ApplicationWindow *app = (ApplicationWindow *)parent();
526 QLocale locale = QLocale();
527 if (app)
528 locale = app->locale();
529
530 plotUnitBox = new QComboBox();
531 plotUnitBox->insertItem(tr("inch"));
532 plotUnitBox->insertItem(tr("mm"));
533 plotUnitBox->insertItem(tr("cm"));
534 plotUnitBox->insertItem(tr("point"));
535 plotUnitBox->insertItem(tr("pixel"));
536 plotUnitBox->setCurrentIndex(app->d_layer_geometry_unit);
537
538 QHBoxLayout *bl1 = new QHBoxLayout();
539 bl1->addWidget(new QLabel(tr( "Unit" )));
540 bl1->addWidget(plotUnitBox);
541
542 QGroupBox *gb1 = new QGroupBox(tr("Origin"));
543 boxPlotX = new DoubleSpinBox();
544 boxPlotX->setLocale(locale);
545 boxPlotX->setDecimals(6);
546
547 boxPlotY = new DoubleSpinBox();
548 boxPlotY->setLocale(locale);
549 boxPlotY->setDecimals(6);
550
551 QGridLayout *gl1 = new QGridLayout(gb1);
552 gl1->addWidget(new QLabel( tr("X= ")), 0, 0);
553 gl1->addWidget(boxPlotX, 0, 1);
554 gl1->addWidget(new QLabel(tr("Y= ")), 1, 0);
555 gl1->addWidget(boxPlotY, 1, 1);
556 gl1->setRowStretch(2, 1);
557
558 QGroupBox *gb2 = new QGroupBox(tr("Size"));
559 boxPlotWidth = new DoubleSpinBox();
560 boxPlotWidth->setMinimum(0);
561 boxPlotWidth->setLocale(locale);
562 boxPlotWidth->setDecimals(6);
563
564 boxPlotHeight = new DoubleSpinBox();
565 boxPlotHeight->setMinimum(0);
566 boxPlotHeight->setLocale(locale);
567 boxPlotHeight->setDecimals(6);
568
569 QGridLayout *gl2 = new QGridLayout(gb2);
570 gl2->addWidget(new QLabel( tr("width= ")), 0, 0);
571 gl2->addWidget(boxPlotWidth, 0, 1);
572
573 gl2->addWidget(new QLabel(tr("height= ")), 1, 0);
574 gl2->addWidget(boxPlotHeight, 1, 1);
575
576 keepPlotRatioBox = new QCheckBox(tr("Keep aspect ratio"));
577 keepPlotRatioBox->setChecked(app->d_keep_aspect_ration);
578
579 connect(keepPlotRatioBox, SIGNAL(clicked (bool)), keepRatioBox, SLOT(setChecked(bool)));
580 connect(keepRatioBox, SIGNAL(clicked (bool)), keepPlotRatioBox, SLOT(setChecked(bool)));
581
582 gl2->addWidget(keepPlotRatioBox, 2, 1);
583
584 gl2->setRowStretch(3, 1);
585
586 QHBoxLayout *bl2 = new QHBoxLayout();
587 bl2->addWidget(gb1);
588 bl2->addWidget(gb2);
589
590 plotGeometryPage = new QWidget();
591 QVBoxLayout * vl = new QVBoxLayout(plotGeometryPage);
592 vl->addLayout(bl1);
593 vl->addLayout(bl2);
594
595 boxResizeLayers = new QCheckBox(tr("Do not &resize layers when window size changes"));
596 vl->addWidget(boxResizeLayers);
597
598 privateTabWidget->addTab(plotGeometryPage, tr("Dimensions"));
599
600 connect(boxPlotWidth, SIGNAL(valueChanged (double)), this, SLOT(adjustPlotHeight(double)));
601 connect(boxPlotHeight, SIGNAL(valueChanged (double)), this, SLOT(adjustPlotWidth(double)));
602 connect(plotUnitBox, SIGNAL(activated(int)), this, SLOT(displayPlotCoordinates(int)));
603 }
604
initCanvasPage()605 void PlotDialog::initCanvasPage()
606 {
607 canvasPage = new QWidget();
608
609 QHBoxLayout* hl1 = new QHBoxLayout();
610
611 colorBtn = new QRadioButton(tr("&Background Color"));
612 colorBtn->setChecked(true);
613 hl1->addWidget(colorBtn);
614
615 imageBtn = new QRadioButton(tr("Background &Image"));
616 hl1->addWidget(imageBtn);
617
618 canvasColorBox = new QGroupBox();
619 QGridLayout *gl1 = new QGridLayout(canvasColorBox);
620
621 boxCanvasColor = new ColorButton();
622 gl1->addWidget(boxCanvasColor, 0, 2);
623
624 QLabel *l4 = new QLabel("&" + tr("Color"));
625 l4->setBuddy(boxCanvasColor);
626 gl1->addWidget(l4, 0, 0);
627
628 boxCanvasTransparency = new QSpinBox();
629 boxCanvasTransparency->setRange(0, 100);
630 boxCanvasTransparency->setWrapping(true);
631 boxCanvasTransparency->setSpecialValueText(" " + tr("Transparent"));
632 boxCanvasTransparency->setSuffix(" %");
633
634 canvasOpacitySlider = new QSlider();
635 canvasOpacitySlider->setOrientation(Qt::Horizontal);
636 canvasOpacitySlider->setRange(0, 100);
637
638 QLabel *l1 = new QLabel("&" + tr("Opacity"));
639 l1->setBuddy(canvasOpacitySlider);
640 gl1->addWidget(l1, 1, 0);
641
642 QHBoxLayout* hb = new QHBoxLayout();
643 hb->addWidget(canvasOpacitySlider);
644 hb->addWidget(boxCanvasTransparency);
645 gl1->addLayout(hb, 1, 2);
646
647 gl1->setColumnStretch(1, 1);
648 gl1->setRowStretch(2, 1);
649
650 canvasImageBox = new QGroupBox();
651 canvasImageBox->hide();
652 QGridLayout *gl = new QGridLayout(canvasImageBox);
653 gl->addWidget(new QLabel( tr("File")), 0, 0);
654
655 imagePathBox = new QLineEdit();
656 imagePathBox->setCompleter(completer);
657 gl->addWidget(imagePathBox, 0, 1);
658
659 QPushButton *browseBtn = new QPushButton();
660 connect(browseBtn, SIGNAL(clicked()), this, SLOT(chooseBackgroundImageFile()));
661 browseBtn->setIcon(QIcon(":/folder_open.png"));
662 gl->addWidget(browseBtn, 0, 2);
663
664 QPushButton *buttonResizeCanvas = new QPushButton(tr("&Resize layer to fit original image size"));
665 connect(buttonResizeCanvas, SIGNAL(clicked()), this, SLOT(resizeCanvasToFitImage()));
666 gl->addWidget(buttonResizeCanvas, 1, 1);
667
668 gl->setColumnStretch(1, 1);
669 gl->setRowStretch(2, 1);
670
671 QVBoxLayout *vl = new QVBoxLayout();
672 vl->addWidget(canvasColorBox);
673 vl->addWidget(canvasImageBox);
674
675 boxFramed = new QGroupBox(tr("&Frame"));
676 boxFramed->setCheckable (true);
677
678 QGridLayout *boxFramedLayout = new QGridLayout(boxFramed);
679 boxFrameColor = new ColorButton(boxFramed);
680 boxFramedLayout->addWidget( boxFrameColor, 0, 1 );
681
682 QLabel *l3 = new QLabel("&" + tr("Color"));
683 l3->setBuddy(boxFrameColor);
684 boxFramedLayout->addWidget(l3, 0, 0);
685
686 boxFrameWidth = new QSpinBox();
687 boxFrameWidth->setMinimum(1);
688 boxFramedLayout->addWidget( boxFrameWidth, 1, 1 );
689
690 QLabel *l2 = new QLabel("&" + tr("Width"));
691 l2->setBuddy(boxFrameWidth);
692 boxFramedLayout->addWidget(l2, 1, 0);
693 boxFramedLayout->setRowStretch(2, 1);
694
695 QVBoxLayout *vl1 = new QVBoxLayout();
696 vl1->addLayout(hl1);
697 vl1->addLayout(vl);
698 vl1->addWidget(boxFramed);
699
700 QVBoxLayout *vl2 = new QVBoxLayout();
701
702 canvasDefaultBtn = new QPushButton(tr("Set As &Default"));
703 vl2->addWidget(canvasDefaultBtn);
704
705 QLabel *l = new QLabel(tr("Apply &to..."));
706 vl2->addWidget(l);
707
708 imageApplyToBox = new QComboBox();
709 imageApplyToBox->insertItem(tr("Layer"));
710 imageApplyToBox->insertItem(tr("Window"));
711 imageApplyToBox->insertItem(tr("All Windows"));
712 vl2->addWidget(imageApplyToBox);
713 vl2->addStretch();
714 l->setBuddy(imageApplyToBox);
715
716 QHBoxLayout* hl = new QHBoxLayout(canvasPage);
717 hl->addLayout(vl1);
718 hl->addLayout(vl2);
719
720 privateTabWidget->addTab(canvasPage, tr("Canvas"));
721
722 connect(canvasDefaultBtn, SIGNAL(clicked()), this, SLOT(setCanvasDefaultValues()));
723 connect(boxFrameColor, SIGNAL(colorChanged()), this, SLOT(applyCanvasFormat()));
724 connect(boxFramed, SIGNAL(toggled(bool)), this, SLOT(applyCanvasFormat()));
725 connect(boxFrameWidth, SIGNAL(valueChanged (int)), this, SLOT(applyCanvasFormat()));
726 connect(boxCanvasColor, SIGNAL(colorChanged()), this, SLOT(applyCanvasFormat()));
727 connect(boxCanvasTransparency, SIGNAL(valueChanged(int)), this, SLOT(updateCanvasTransparency(int)));
728 connect(colorBtn, SIGNAL(toggled(bool)), canvasColorBox, SLOT(setVisible(bool)));
729 connect(imageBtn, SIGNAL(toggled(bool)), canvasImageBox, SLOT(setVisible(bool)));
730 connect(canvasOpacitySlider, SIGNAL(valueChanged(int)), boxCanvasTransparency, SLOT(setValue(int)));
731 connect(boxCanvasTransparency, SIGNAL(valueChanged(int)), canvasOpacitySlider, SLOT(setValue(int)));
732 }
733
initLayerGeometryPage()734 void PlotDialog::initLayerGeometryPage()
735 {
736 layerGeometryPage = new QWidget();
737
738 ApplicationWindow *app = (ApplicationWindow *)parent();
739 QLocale locale = QLocale();
740 if (app)
741 locale = app->locale();
742
743 unitBox = new QComboBox();
744 unitBox->insertItem(tr("inch"));
745 unitBox->insertItem(tr("mm"));
746 unitBox->insertItem(tr("cm"));
747 unitBox->insertItem(tr("point"));
748 unitBox->insertItem(tr("pixel"));
749
750 QBoxLayout *bl1 = new QBoxLayout (QBoxLayout::LeftToRight);
751 bl1->addWidget(new QLabel(tr( "Unit" )));
752 bl1->addWidget(unitBox);
753
754 QGroupBox *gb1 = new QGroupBox(tr("Origin"));
755 boxX = new DoubleSpinBox();
756 boxX->setLocale(locale);
757 boxX->setDecimals(6);
758
759 boxY = new DoubleSpinBox();
760 boxY->setLocale(locale);
761 boxY->setDecimals(6);
762
763 QGridLayout *gl1 = new QGridLayout(gb1);
764 gl1->addWidget(new QLabel( tr("X= ")), 0, 0);
765 gl1->addWidget(boxX, 0, 1);
766 gl1->addWidget(new QLabel(tr("Y= ")), 1, 0);
767 gl1->addWidget(boxY, 1, 1);
768 gl1->setRowStretch(2, 1);
769
770 QGroupBox *gb2 = new QGroupBox(tr("Size"));
771 boxLayerWidth = new DoubleSpinBox();
772 boxLayerWidth->setMinimum(0);
773 boxLayerWidth->setLocale(locale);
774 boxLayerWidth->setDecimals(6);
775
776 boxLayerHeight = new DoubleSpinBox();
777 boxLayerHeight->setMinimum(0);
778 boxLayerHeight->setLocale(locale);
779 boxLayerHeight->setDecimals(6);
780
781 QGridLayout *gl2 = new QGridLayout(gb2);
782 gl2->addWidget(new QLabel( tr("width= ")), 0, 0);
783 gl2->addWidget(boxLayerWidth, 0, 1);
784
785 gl2->addWidget(new QLabel(tr("height= ")), 1, 0);
786 gl2->addWidget(boxLayerHeight, 1, 1);
787
788 keepRatioBox = new QCheckBox(tr("Keep aspect ratio"));
789 keepRatioBox->setChecked(app->d_keep_aspect_ration);
790 gl2->addWidget(keepRatioBox, 2, 1);
791
792 QLabel *l = new QLabel(tr("Apply &to..."));
793 gl2->addWidget(l, 3, 0);
794
795 sizeApplyToBox = new QComboBox();
796 sizeApplyToBox->insertItem(tr("Layer"));
797 sizeApplyToBox->insertItem(tr("Window"));
798 sizeApplyToBox->insertItem(tr("All Windows"));
799 gl2->addWidget(sizeApplyToBox, 3, 1);
800
801 l->setBuddy(sizeApplyToBox);
802
803 gl2->setRowStretch(4, 1);
804
805 QBoxLayout *bl2 = new QBoxLayout (QBoxLayout::LeftToRight);
806 bl2->addWidget(gb1);
807 bl2->addWidget(gb2);
808
809 QVBoxLayout * vl = new QVBoxLayout( layerGeometryPage );
810 vl->addLayout(bl1);
811 vl->addLayout(bl2);
812
813 privateTabWidget->addTab(layerGeometryPage, tr("Geometry"));
814
815 connect(boxLayerWidth, SIGNAL(valueChanged (double)), this, SLOT(adjustLayerHeight(double)));
816 connect(boxLayerHeight, SIGNAL(valueChanged (double)), this, SLOT(adjustLayerWidth(double)));
817 connect(unitBox, SIGNAL(activated(int)), this, SLOT(displayCoordinates(int)));
818 unitBox->setCurrentIndex(app->d_layer_geometry_unit);
819 }
820
initLayerDisplayPage()821 void PlotDialog::initLayerDisplayPage()
822 {
823 layerDisplayPage = new QWidget();
824
825 QGroupBox *gb1 = new QGroupBox(tr("Data Drawing Options"));
826
827 boxMissingData = new QCheckBox(tr("Co&nnect line across missing data"));
828 boxGridPosition = new QCheckBox(tr("&Grid on top of data"));
829
830 QVBoxLayout *vl1 = new QVBoxLayout(gb1);
831 vl1->addWidget(boxMissingData);
832 vl1->addWidget(boxGridPosition);
833 vl1->addStretch();
834
835 QGroupBox *gb2 = new QGroupBox(tr("Axes"));
836
837 boxLeftAxis = new QCheckBox(tr("&Left"));
838 boxLeftAxis->setIcon(QPixmap(":/left_axis.png"));
839 boxLeftAxis->setIconSize(QSize(33, 32));
840
841 boxRightAxis = new QCheckBox(tr("&Right"));
842 boxRightAxis->setIcon(QPixmap(":right_axis.png"));
843 boxRightAxis->setIconSize(QSize(33, 32));
844
845 boxBottomAxis = new QCheckBox(tr("&Bottom"));
846 boxBottomAxis->setIcon(QPixmap(":bottom_axis.png"));
847 boxBottomAxis->setIconSize(QSize(35, 32));
848
849 boxTopAxis = new QCheckBox(tr("&Top"));
850 boxTopAxis->setIcon(QPixmap(":top_axis.png"));
851 boxTopAxis->setIconSize(QSize(34, 34));
852
853 QGridLayout *vl2 = new QGridLayout(gb2);
854 vl2->addWidget(boxLeftAxis, 0, 0);
855 vl2->addWidget(boxRightAxis, 0, 1);
856 vl2->addWidget(boxBottomAxis, 1, 0);
857 vl2->addWidget(boxTopAxis, 1, 1);
858 vl2->setRowStretch(2, 1);
859
860 QVBoxLayout * vl = new QVBoxLayout( layerDisplayPage );
861 vl->addWidget(gb1);
862 vl->addWidget(gb2);
863
864 privateTabWidget->addTab(layerDisplayPage, tr("Display"));
865 connect(boxMissingData, SIGNAL(toggled(bool)), this, SLOT(acceptParams()));
866 connect(boxGridPosition, SIGNAL(toggled(bool)), this, SLOT(acceptParams()));
867
868 connect(boxLeftAxis, SIGNAL(toggled(bool)), this, SLOT(acceptParams()));
869 connect(boxRightAxis, SIGNAL(toggled(bool)), this, SLOT(acceptParams()));
870 connect(boxBottomAxis, SIGNAL(toggled(bool)), this, SLOT(acceptParams()));
871 connect(boxTopAxis, SIGNAL(toggled(bool)), this, SLOT(acceptParams()));
872 }
873
initLayerSpeedPage()874 void PlotDialog::initLayerSpeedPage()
875 {
876 speedPage = new QWidget();
877
878 speedModeBox = new QGroupBox(tr("&Speed Mode, Skip Points if needed"));
879 speedModeBox->setCheckable(true);
880 speedModeBox->setChecked(false);
881
882 boxMaxPoints = new QSpinBox();
883 boxMaxPoints->setMaximum(INT_MAX);
884 boxMaxPoints->setSuffix(" " + tr("data points"));
885 boxMaxPoints->setValue(3000);
886
887 QGridLayout *gl1 = new QGridLayout(speedModeBox);
888 gl1->addWidget(new QLabel(tr("Apply to curves with more than:")), 0, 0);
889 gl1->addWidget(boxMaxPoints, 0, 1);
890
891 ApplicationWindow *app = (ApplicationWindow *)parent();
892 QLocale locale = QLocale();
893 if (app)
894 locale = app->locale();
895
896 boxDouglasPeukerTolerance = new DoubleSpinBox();
897 boxDouglasPeukerTolerance->setLocale(locale);
898 boxDouglasPeukerTolerance->setMinimum(0.0);
899 boxDouglasPeukerTolerance->setSpecialValueText(tr("0 (all data points)"));
900
901 gl1->addWidget(new QLabel(tr("Tolerance (Douglas-Peucker algorithm)")), 1, 0);
902 gl1->addWidget(boxDouglasPeukerTolerance, 1, 1);
903 gl1->setRowStretch(2, 1);
904
905 QVBoxLayout * vl = new QVBoxLayout( speedPage );
906 vl->addWidget(speedModeBox);
907
908 privateTabWidget->addTab(speedPage, tr("Speed"));
909 connect(speedModeBox, SIGNAL(toggled(bool)), this, SLOT(acceptParams()));
910 connect(boxDouglasPeukerTolerance, SIGNAL(valueChanged(double)), this, SLOT(acceptParams()));
911 }
912
initPiePage()913 void PlotDialog::initPiePage()
914 {
915 piePage = new QWidget();
916
917 QGridLayout *gl1 = new QGridLayout();
918
919 boxPieLineColor = new ColorButton();
920 gl1->addWidget(boxPieLineColor, 0, 1);
921
922 QLabel *l1 = new QLabel("&" + tr("Color"));
923 l1->setBuddy(boxPieLineColor);
924 gl1->addWidget(l1, 0, 0);
925
926 boxPieLineStyle = new PenStyleBox();
927 gl1->addWidget(boxPieLineStyle, 1, 1);
928
929 QLabel *l2 = new QLabel("&" + tr("Style"));
930 l2->setBuddy(boxPieLineStyle);
931 gl1->addWidget(l2, 1, 0);
932
933 boxPieLineWidth = new DoubleSpinBox('f');
934 boxPieLineWidth->setSingleStep(0.1);
935 boxPieLineWidth->setMinimum(0.0);
936 boxPieLineWidth->setLocale(((ApplicationWindow *)this->parent())->locale());
937 gl1->addWidget(boxPieLineWidth, 2, 1);
938
939 QLabel *l3 = new QLabel("&" + tr("Width"));
940 l3->setBuddy(boxPieLineWidth);
941 gl1->addWidget(l3, 2, 0);
942
943 gl1->setRowStretch(3,1);
944
945 QGroupBox *gb1 = new QGroupBox(tr( "Border" ));
946 gb1->setLayout(gl1);
947
948 QGridLayout *gl2 = new QGridLayout();
949
950 boxFirstColor = new ColorBox();
951 gl2->addWidget(boxFirstColor, 0, 1);
952
953 QLabel *l4 = new QLabel("&" + tr("First color"));
954 l4->setBuddy(boxFirstColor);
955 gl2->addWidget(l4, 0, 0);
956
957 boxPiePattern = new PatternBox(false);
958 gl2->addWidget(boxPiePattern, 1, 1);
959 gl2->setRowStretch(2, 1);
960
961 QLabel *l5 = new QLabel("&" + tr("Pattern"));
962 l5->setBuddy(boxPiePattern);
963 gl2->addWidget(l5, 1, 0);
964
965 QGroupBox *gb2 = new QGroupBox(tr( "Fill" ));
966 gb2->setLayout(gl2);
967
968 QHBoxLayout* hl = new QHBoxLayout();
969 hl->addWidget(gb1);
970 hl->addWidget(gb2);
971 piePage->setLayout(hl);
972
973 privateTabWidget->addTab(piePage, tr( "Pattern" ) );
974 }
975
initPieGeometryPage()976 void PlotDialog::initPieGeometryPage()
977 {
978 pieGeometryPage = new QWidget();
979
980 QLocale locale = ((ApplicationWindow *)this->parent())->locale();
981
982 QGroupBox *gb3 = new QGroupBox(tr( "3D View" ));
983 QGridLayout *gl3 = new QGridLayout(gb3);
984
985 boxPieViewAngle = new DoubleSpinBox('f');
986 boxPieViewAngle->setWrapping(true);
987 boxPieViewAngle->setRange(0.0, 90.0);
988 boxPieViewAngle->setLocale(locale);
989 gl3->addWidget(boxPieViewAngle, 0, 1);
990
991 QLabel *l1 = new QLabel("&" + tr("View Angle (deg)"));
992 l1->setBuddy(boxPieViewAngle);
993 gl3->addWidget(l1, 0, 0);
994
995 boxPieThickness = new DoubleSpinBox('f');
996 boxPieThickness->setLocale(locale);
997 boxPieThickness->setRange(0.0, 300.0);
998 gl3->addWidget(boxPieThickness, 1, 1);
999
1000 QLabel *l2 = new QLabel("&" + tr("Thickness (% of radius)"));
1001 l2->setBuddy(boxPieThickness);
1002 gl3->addWidget(l2, 1, 0);
1003
1004 gl3->setRowStretch(2, 1);
1005
1006 QGroupBox *gb1 = new QGroupBox(tr( "Rotation" ));
1007 QGridLayout *gl1 = new QGridLayout(gb1);
1008
1009 boxPieStartAzimuth = new DoubleSpinBox('f');
1010 boxPieStartAzimuth->setRange(0.0, 360.0);
1011 boxPieStartAzimuth->setWrapping(true);
1012 boxPieStartAzimuth->setSingleStep(10.0);
1013 boxPieStartAzimuth->setLocale(locale);
1014 gl1->addWidget(boxPieStartAzimuth, 0, 1);
1015
1016 QLabel *l3 = new QLabel("&" + tr("Starting Azimuth (deg)"));
1017 l3->setBuddy(boxPieStartAzimuth);
1018 gl1->addWidget(l3, 0, 0);
1019
1020 boxPieConterClockwise = new QCheckBox(tr("Counter cloc&kwise"));
1021 gl1->addWidget(boxPieConterClockwise, 1, 0);
1022 gl1->setRowStretch(2, 1);
1023
1024 QGroupBox *gb2 = new QGroupBox(tr( "Radius/Center" ));
1025 QGridLayout *gl2 = new QGridLayout(gb2);
1026
1027 boxRadius = new QSpinBox();
1028 boxRadius->setRange(0, 300);
1029 boxRadius->setSingleStep(5);
1030 gl2->addWidget(boxRadius, 0, 1);
1031
1032 QLabel *l4 = new QLabel("&" + tr("Radius (% of frame)"));
1033 l4->setBuddy(boxRadius);
1034 gl2->addWidget(l4, 0, 0);
1035
1036 boxPieOffset = new QSpinBox();
1037 boxPieOffset->setRange(-100, 100);
1038 gl2->addWidget(boxPieOffset, 1, 1);
1039
1040 QLabel *l5 = new QLabel("&" + tr("Horizontal Offset (% of frame)"));
1041 l5->setBuddy(boxPieOffset);
1042 gl2->addWidget(l5, 1, 0);
1043
1044 gl2->setRowStretch(2, 1);
1045
1046 QVBoxLayout* vl = new QVBoxLayout(pieGeometryPage);
1047 vl->addWidget(gb3);
1048 vl->addWidget(gb1);
1049 vl->addWidget(gb2);
1050
1051 privateTabWidget->addTab(pieGeometryPage, tr( "Pie Geometry" ) );
1052
1053 connect(boxPieConterClockwise, SIGNAL(toggled(bool)), this, SLOT(acceptParams()));
1054 connect(boxPieViewAngle, SIGNAL(valueChanged(double)), this, SLOT(acceptParams()));
1055 connect(boxPieThickness, SIGNAL(valueChanged(double)), this, SLOT(acceptParams()));
1056 connect(boxPieStartAzimuth, SIGNAL(valueChanged(double)), this, SLOT(acceptParams()));
1057 connect(boxRadius, SIGNAL(valueChanged(int)), this, SLOT(acceptParams()));
1058 connect(boxPieOffset, SIGNAL(valueChanged(int)), this, SLOT(acceptParams()));
1059 }
1060
initPieLabelsPage()1061 void PlotDialog::initPieLabelsPage()
1062 {
1063 pieLabelsPage = new QWidget();
1064
1065 pieAutoLabelsBox = new QGroupBox(tr("Automatic &Format"));
1066 pieAutoLabelsBox->setCheckable(true);
1067
1068 QGridLayout *gl1 = new QGridLayout(pieAutoLabelsBox);
1069 boxPieValues = new QCheckBox(tr("&Values"));
1070 gl1->addWidget(boxPieValues, 0, 0);
1071
1072 boxPiePercentages = new QCheckBox(tr("&Percentages"));
1073 gl1->addWidget(boxPiePercentages, 1, 0);
1074
1075 boxPieCategories = new QCheckBox(tr("Categories/&Rows"));
1076 gl1->addWidget(boxPieCategories, 2, 0);
1077
1078 gl1->setRowStretch(3, 1);
1079
1080 boxPieWedge = new QGroupBox(tr( "Associate Position with &Wedge" ));
1081 boxPieWedge->setCheckable(true);
1082
1083 QGridLayout *gl2 = new QGridLayout(boxPieWedge);
1084
1085 boxPieEdgeDist = new DoubleSpinBox('f');
1086 boxPieEdgeDist->setRange(-100, 100);
1087 boxPieEdgeDist->setLocale(((ApplicationWindow *)this->parent())->locale());
1088 gl2->addWidget(boxPieEdgeDist, 0, 1);
1089
1090 QLabel *l1 = new QLabel("&" + tr("Dist. from Pie Edge"));
1091 l1->setBuddy(boxPieEdgeDist);
1092 gl2->addWidget(l1, 0, 0);
1093
1094 gl2->setRowStretch(1, 1);
1095
1096 QVBoxLayout* vl = new QVBoxLayout(pieLabelsPage);
1097 vl->addWidget(pieAutoLabelsBox);
1098 vl->addWidget(boxPieWedge);
1099
1100 privateTabWidget->addTab(pieLabelsPage, tr( "Labels" ) );
1101
1102 connect(boxPieEdgeDist, SIGNAL(valueChanged(double)), this, SLOT(acceptParams()));
1103 }
1104
initPrintPage()1105 void PlotDialog::initPrintPage()
1106 {
1107 QGroupBox *gb = new QGroupBox();
1108 QVBoxLayout *vl = new QVBoxLayout(gb);
1109 boxScaleLayers = new QCheckBox(tr("&Scale layers to paper size"));
1110 vl->addWidget(boxScaleLayers);
1111 boxPrintCrops = new QCheckBox(tr("Print Crop&marks"));
1112 vl->addWidget(boxPrintCrops);
1113 vl->addStretch();
1114
1115 printPage = new QWidget();
1116 QHBoxLayout* hlayout = new QHBoxLayout(printPage);
1117 hlayout->addWidget(gb);
1118 privateTabWidget->addTab(printPage, tr( "Print" ) );
1119 }
1120
initFunctionPage()1121 void PlotDialog::initFunctionPage()
1122 {
1123 ApplicationWindow *app = (ApplicationWindow *)this->parent();
1124 if (!app)
1125 return;
1126
1127 functionEdit = new FunctionDialog(app, false);//in order to have correct locale settings, parent must be app window
1128
1129 functionPage = new QWidget();
1130 QVBoxLayout* vl = new QVBoxLayout(functionPage);
1131 vl->addWidget(functionEdit);
1132 vl->addStretch();
1133 }
1134
initLabelsPage()1135 void PlotDialog::initLabelsPage()
1136 {
1137 labelsGroupBox = new QGroupBox(tr("&Show"));
1138 labelsGroupBox->setCheckable (true);
1139
1140 QGridLayout *gl = new QGridLayout(labelsGroupBox);
1141 labelsColumnLbl = new QLabel(tr( "Column" ));
1142 gl->addWidget(labelsColumnLbl, 0, 0);
1143 boxLabelsColumn = new QComboBox();
1144 gl->addWidget(boxLabelsColumn, 0, 1);
1145
1146 gl->addWidget(new QLabel(tr( "Color" )), 1, 0);
1147 boxLabelsColor = new ColorButton();
1148 gl->addWidget(boxLabelsColor, 1, 1);
1149 boxLabelsWhiteOut = new QCheckBox(tr("White O&ut"));
1150 gl->addWidget(boxLabelsWhiteOut, 1, 2);
1151
1152 justifyLabelsLbl = new QLabel(tr( "Justify" ));
1153 gl->addWidget(justifyLabelsLbl, 2, 0);
1154 boxLabelsAlign = new QComboBox();
1155 boxLabelsAlign->addItem( tr( "Center" ) );
1156 boxLabelsAlign->addItem( tr( "Left" ) );
1157 boxLabelsAlign->addItem( tr( "Right" ) );
1158 gl->addWidget(boxLabelsAlign, 2, 1);
1159
1160 gl->addWidget(new QLabel(tr( "Rotate (deg)" )), 3, 0);
1161 boxLabelsAngle = new DoubleSpinBox('f');
1162 boxLabelsAngle->setDecimals(1);
1163 boxLabelsAngle->setLocale(((ApplicationWindow *)parent())->locale());
1164 boxLabelsAngle->setRange(0, 180);
1165 gl->addWidget(boxLabelsAngle, 3, 1);
1166 btnLabelsFont = new QPushButton(tr("&Font"));
1167 btnLabelsFont->setIcon(QIcon(":/font.png"));
1168 gl->addWidget(btnLabelsFont, 2, 2);
1169
1170 gl->addWidget(new QLabel(tr("X Offset (font height %)")), 4, 0);
1171 boxLabelsXOffset = new QSpinBox();
1172 boxLabelsXOffset->setRange(-INT_MAX, INT_MAX);
1173 boxLabelsXOffset->setSingleStep(10);
1174 gl->addWidget(boxLabelsXOffset, 4, 1);
1175
1176 gl->addWidget(new QLabel(tr("Y Offset (font height %)")), 5, 0);
1177 boxLabelsYOffset = new QSpinBox();
1178 boxLabelsYOffset->setRange(-INT_MAX, INT_MAX);
1179 boxLabelsYOffset->setSingleStep(10);
1180 gl->addWidget(boxLabelsYOffset, 5, 1);
1181
1182 QLabel *l = new QLabel(tr("Apply Format &to"));
1183 gl->addWidget(l, 6, 0);
1184
1185 boxLabelsFormatApplyToBox = new QComboBox();
1186 boxLabelsFormatApplyToBox->insertItem(tr("Selected Curve"));
1187 boxLabelsFormatApplyToBox->insertItem(tr("Layer"));
1188 boxLabelsFormatApplyToBox->insertItem(tr("Window"));
1189 boxLabelsFormatApplyToBox->insertItem(tr("All Windows"));
1190 l->setBuddy(boxLabelsFormatApplyToBox);
1191 gl->addWidget(boxLabelsFormatApplyToBox, 6, 1);
1192
1193 gl->setRowStretch (7, 1);
1194 gl->setColumnStretch (3, 1);
1195
1196 labelsPage = new QWidget();
1197 QHBoxLayout* hlayout = new QHBoxLayout(labelsPage);
1198 hlayout->addWidget(labelsGroupBox);
1199 privateTabWidget->addTab(labelsPage, tr("Labels"));
1200
1201 connect(labelsGroupBox, SIGNAL(toggled(bool)), this, SLOT(acceptParams()));
1202 connect(boxLabelsColumn, SIGNAL(activated(int)), this, SLOT(acceptParams()));
1203 connect(boxLabelsAlign, SIGNAL(activated(int)), this, SLOT(acceptParams()));
1204 connect(boxLabelsWhiteOut, SIGNAL(toggled(bool)), this, SLOT(acceptParams()));
1205 connect(boxLabelsColor, SIGNAL(colorChanged()), this, SLOT(acceptParams()));
1206 connect(boxLabelsXOffset, SIGNAL(valueChanged(int)), this, SLOT(acceptParams()));
1207 connect(boxLabelsYOffset, SIGNAL(valueChanged(int)), this, SLOT(acceptParams()));
1208 connect(boxLabelsAngle, SIGNAL(valueChanged(double)), this, SLOT(acceptParams()));
1209 connect(btnLabelsFont, SIGNAL(clicked()), this, SLOT(chooseLabelsFont()));
1210 }
1211
initAxesPage()1212 void PlotDialog::initAxesPage()
1213 {
1214 QGroupBox *gb = new QGroupBox(tr( "Attach curve to: "));
1215 QGridLayout *gl = new QGridLayout(gb);
1216 gl->addWidget(new QLabel( tr( "x Axis" )), 0, 0);
1217 boxXAxis = new QComboBox();
1218 boxXAxis->setEditable(false);
1219 boxXAxis->addItem(tr("Bottom"));
1220 boxXAxis->addItem(tr("Top"));
1221 gl->addWidget(boxXAxis, 0, 1);
1222
1223 gl->addWidget(new QLabel( tr( "y Axis" )), 1, 0);
1224 boxYAxis = new QComboBox();
1225 boxYAxis->setEditable(false);
1226 boxYAxis->addItem(tr("Left"));
1227 boxYAxis->addItem(tr("Right"));
1228 gl->addWidget(boxYAxis, 1, 1);
1229 gl->setRowStretch (2, 1);
1230
1231 axesPage = new QWidget();
1232 QHBoxLayout* hlayout = new QHBoxLayout(axesPage);
1233 hlayout->addWidget(gb);
1234 privateTabWidget->addTab(axesPage, tr( "Axes" ) );
1235 }
1236
initLinePage()1237 void PlotDialog::initLinePage()
1238 {
1239 QGroupBox *gb = new QGroupBox();
1240 QGridLayout *gl1 = new QGridLayout(gb);
1241 gl1->addWidget(new QLabel( tr( "Connect" )), 0, 0);
1242
1243 boxConnect = new QComboBox();
1244 boxConnect->setEditable(false);
1245 boxConnect->addItem(tr("No line"));
1246 boxConnect->addItem(tr("Lines"));
1247 boxConnect->addItem(tr("Sticks"));
1248 boxConnect->addItem(tr("Horizontal Steps"));
1249 boxConnect->addItem(tr("Dots"));
1250 boxConnect->addItem(tr("Spline"));
1251 boxConnect->addItem(tr("Vertical Steps"));
1252 gl1->addWidget(boxConnect, 0, 1);
1253
1254 boxLineStyle = new PenStyleBox();
1255 gl1->addWidget(boxLineStyle, 1, 1);
1256
1257 QLabel *l1 = new QLabel("&" + tr( "Style" ));
1258 l1->setBuddy(boxLineStyle);
1259 gl1->addWidget(l1, 1, 0);
1260
1261 boxLineWidth = new DoubleSpinBox('f');
1262 boxLineWidth->setLocale(((ApplicationWindow *)this->parent())->locale());
1263 boxLineWidth->setSingleStep(0.1);
1264 boxLineWidth->setMinimum(0.1);
1265 boxLineWidth->setValue( 1 );
1266 gl1->addWidget(boxLineWidth, 2, 1);
1267
1268 QLabel *l2 = new QLabel("&" + tr( "Width" ));
1269 gl1->addWidget(l2, 2, 0);
1270 l2->setBuddy(boxLineWidth);
1271
1272 boxLineColor = new ColorButton();
1273 gl1->addWidget(boxLineColor, 3, 1);
1274
1275 QLabel *l3 = new QLabel("&" + tr( "Color" ));
1276 gl1->addWidget(l3, 3, 0);
1277 l3->setBuddy(boxLineColor);
1278
1279 boxLineTransparency = new QSpinBox();
1280 boxLineTransparency->setRange(0, 100);
1281 boxLineTransparency->setSuffix(" %");
1282 boxLineTransparency->setWrapping(true);
1283
1284 lineTransparencySlider = new QSlider();
1285 lineTransparencySlider->setOrientation(Qt::Horizontal);
1286 lineTransparencySlider->setRange(0, 100);
1287
1288 QLabel *l4 = new QLabel("&" + tr("Opacity"));
1289 l4->setBuddy(lineTransparencySlider);
1290 gl1->addWidget(l4, 4, 0);
1291
1292 QHBoxLayout* hb1 = new QHBoxLayout();
1293 hb1->addWidget(lineTransparencySlider);
1294 hb1->addWidget(boxLineTransparency);
1295 gl1->addLayout(hb1, 4, 1);
1296
1297 lineFormatApplyToBox = new QComboBox();
1298 lineFormatApplyToBox->insertItem(tr("Selected Curve"));
1299 lineFormatApplyToBox->insertItem(tr("Layer"));
1300 lineFormatApplyToBox->insertItem(tr("Window"));
1301 lineFormatApplyToBox->insertItem(tr("All Windows"));
1302 gl1->addWidget(lineFormatApplyToBox, 5, 1);
1303
1304 QLabel *l5 = new QLabel(tr("Apply &to..."));
1305 gl1->addWidget(l5, 5, 0);
1306 l5->setBuddy(lineFormatApplyToBox);
1307
1308 boxApplyColorTo = new QCheckBox(tr("Apply Co&lor"));
1309 boxApplyColorTo->setDisabled(true);
1310 gl1->addWidget(boxApplyColorTo, 6, 1);
1311
1312 gl1->setRowStretch(7, 1);
1313 gl1->setColumnStretch(2, 1);
1314
1315 fillGroupBox = new QGroupBox("&" + tr("Fill area under curve"));
1316 fillGroupBox->setCheckable(true);
1317 QGridLayout *gl2 = new QGridLayout(fillGroupBox);
1318 gl2->addWidget(new QLabel(tr( "Fill color" )), 0, 0);
1319 boxAreaColor = new ColorButton();
1320 gl2->addWidget(boxAreaColor, 0, 1);
1321
1322 boxCurveOpacity = new QSpinBox();
1323 boxCurveOpacity->setRange(0, 100);
1324 boxCurveOpacity->setWrapping(true);
1325 boxCurveOpacity->setSuffix(" %");
1326
1327 curveOpacitySlider = new QSlider();
1328 curveOpacitySlider->setOrientation(Qt::Horizontal);
1329 curveOpacitySlider->setRange(0, 100);
1330
1331 QLabel *l7 = new QLabel("&" + tr("Opacity"));
1332 l7->setBuddy(curveOpacitySlider);
1333 gl2->addWidget(l7, 1, 0);
1334
1335 QHBoxLayout* hb = new QHBoxLayout();
1336 hb->addWidget(curveOpacitySlider);
1337 hb->addWidget(boxCurveOpacity);
1338 gl2->addLayout(hb, 1, 1);
1339
1340 boxPattern = new PatternBox(false);
1341 gl2->addWidget(boxPattern, 2, 1);
1342
1343 QLabel *l6 = new QLabel("&" + tr("Pattern"));
1344 l6->setBuddy(boxPattern);
1345 gl2->addWidget(l6, 2, 0);
1346 gl2->setColumnStretch(2, 1);
1347 gl2->setRowStretch(3, 1);
1348
1349 linePage = new QWidget();
1350 QHBoxLayout* hlayout = new QHBoxLayout(linePage);
1351 hlayout->addWidget(gb);
1352 hlayout->addWidget(fillGroupBox);
1353 privateTabWidget->addTab(linePage, tr("Line"));
1354
1355 connect(lineFormatApplyToBox, SIGNAL(activated(int)), this, SLOT(enableBoxApplyColor(int)));
1356 connect(boxLineWidth, SIGNAL(valueChanged(double)), this, SLOT(acceptParams()));
1357 connect(boxLineColor, SIGNAL(colorChanged()), this, SLOT(acceptParams()));
1358 connect(boxConnect, SIGNAL(activated(int)), this, SLOT(acceptParams()));
1359 connect(boxLineStyle, SIGNAL(activated(int)), this, SLOT(acceptParams()));
1360 connect(boxAreaColor, SIGNAL(colorChanged()), this, SLOT(acceptParams()));
1361 connect(boxPattern, SIGNAL(activated(int)), this, SLOT(acceptParams()));
1362 connect(fillGroupBox, SIGNAL(toggled(bool)), this, SLOT(showAreaColor(bool)));
1363 connect(fillGroupBox, SIGNAL(clicked()), this, SLOT(acceptParams()));
1364 connect(boxCurveOpacity, SIGNAL(valueChanged(int)), this, SLOT(acceptParams()));
1365 connect(curveOpacitySlider, SIGNAL(valueChanged(int)), boxCurveOpacity, SLOT(setValue(int)));
1366 connect(boxCurveOpacity, SIGNAL(valueChanged(int)), curveOpacitySlider, SLOT(setValue(int)));
1367 connect(lineTransparencySlider, SIGNAL(valueChanged(int)), boxLineTransparency, SLOT(setValue(int)));
1368 connect(boxLineTransparency, SIGNAL(valueChanged(int)), lineTransparencySlider, SLOT(setValue(int)));
1369 connect(boxLineTransparency, SIGNAL(valueChanged(int)), this, SLOT(acceptParams()));
1370 }
1371
initSymbolsPage()1372 void PlotDialog::initSymbolsPage()
1373 {
1374 QHBoxLayout* hl0 = new QHBoxLayout();
1375
1376 standardSymbolBtn = new QRadioButton(tr("&Standard Symbol"));
1377 standardSymbolBtn->setChecked(true);
1378 hl0->addWidget(standardSymbolBtn);
1379
1380 imageSymbolBtn = new QRadioButton(tr("&Image"));
1381 hl0->addWidget(imageSymbolBtn);
1382
1383 standardSymbolFormatBox = new QGroupBox();
1384 QGridLayout *gl = new QGridLayout(standardSymbolFormatBox);
1385 gl->addWidget(new QLabel(tr( "Style" )), 0, 0);
1386 boxSymbolStyle = new SymbolBox();
1387 gl->addWidget(boxSymbolStyle, 0, 1);
1388 gl->addWidget(new QLabel(tr( "Size" )), 1, 0);
1389 boxSymbolSize = new QSpinBox();
1390 boxSymbolSize->setRange(1, 100);
1391 boxSymbolSize->setValue(5);
1392 gl->addWidget(boxSymbolSize, 1, 1);
1393
1394 gl->addWidget(new QLabel(tr( "Edge Color" )), 2, 0);
1395 boxSymbolColor = new ColorButton();
1396 gl->addWidget(boxSymbolColor, 2, 1);
1397 gl->addWidget(new QLabel(tr( "Edge Width" )), 3, 0);
1398 boxPenWidth = new DoubleSpinBox('f');
1399 boxPenWidth->setLocale(((ApplicationWindow *)this->parent())->locale());
1400 boxPenWidth->setSingleStep(0.1);
1401 boxPenWidth->setRange(0.1, 100);
1402 gl->addWidget(boxPenWidth, 3, 1);
1403
1404 boxFillSymbol = new QCheckBox("&" + tr("Fill Color"));
1405 gl->addWidget(boxFillSymbol, 4, 0);
1406
1407 boxFillColor = new ColorButton();
1408 gl->addWidget(boxFillColor, 4, 1);
1409
1410 boxSymbolTransparency = new QSpinBox();
1411 boxSymbolTransparency->setRange(0, 100);
1412 boxSymbolTransparency->setSuffix(" %");
1413 boxSymbolTransparency->setWrapping(true);
1414
1415 symbTransparencySlider = new QSlider();
1416 symbTransparencySlider->setOrientation(Qt::Horizontal);
1417 symbTransparencySlider->setRange(0, 100);
1418
1419 connect(symbTransparencySlider, SIGNAL(valueChanged(int)), boxSymbolTransparency, SLOT(setValue(int)));
1420 connect(boxSymbolTransparency, SIGNAL(valueChanged(int)), symbTransparencySlider, SLOT(setValue(int)));
1421
1422 QLabel *l1 = new QLabel("&" + tr("Opacity"));
1423 l1->setBuddy(symbTransparencySlider);
1424 gl->addWidget(l1, 5, 0);
1425
1426 QHBoxLayout* hb = new QHBoxLayout();
1427 hb->addWidget(symbTransparencySlider);
1428 hb->addWidget(boxSymbolTransparency);
1429 gl->addLayout(hb, 5, 1);
1430
1431 gl->setRowStretch(6, 1);
1432 gl->setColumnStretch(2, 1);
1433
1434 imageSymBolFormatBox = new QGroupBox();
1435 imageSymBolFormatBox->hide();
1436
1437 QGridLayout *gl1 = new QGridLayout(imageSymBolFormatBox);
1438 gl1->addWidget(new QLabel( tr("File")), 0, 0);
1439
1440 imageSymbolPathBox = new QLineEdit();
1441 imageSymbolPathBox->setCompleter(completer);
1442 gl1->addWidget(imageSymbolPathBox, 0, 1);
1443
1444 QPushButton *browseBtn = new QPushButton();
1445 connect(browseBtn, SIGNAL(clicked()), this, SLOT(chooseSymbolImageFile()));
1446 browseBtn->setIcon(QIcon(":/folder_open.png"));
1447 gl1->addWidget(browseBtn, 0, 2);
1448
1449 gl1->addWidget(new QLabel(tr("Preview")), 1, 0);
1450 symbolImageLabel = new QLabel();
1451 gl1->addWidget(symbolImageLabel, 1, 1);
1452 gl1->setRowStretch(2, 1);
1453
1454 QHBoxLayout* hl = new QHBoxLayout();
1455 hl->addWidget(standardSymbolFormatBox);
1456 hl->addWidget(imageSymBolFormatBox);
1457
1458 QGridLayout *gl2 = new QGridLayout();
1459 gl2->addWidget(new QLabel(tr( "Skip Points" )), 0, 0);
1460 boxSkipSymbols = new QSpinBox();
1461 boxSkipSymbols->setMinimum(1);
1462 boxSkipSymbols->setWrapping(true);
1463 boxSkipSymbols->setSpecialValueText(tr("None"));
1464 gl2->addWidget(boxSkipSymbols, 0, 1);
1465
1466 QLabel *l = new QLabel(tr("Apply Format &to"));
1467 gl2->addWidget(l, 1, 0);
1468
1469 symbolsFormatApplyToBox = new QComboBox();
1470 symbolsFormatApplyToBox->insertItem(tr("Selected Curve"));
1471 symbolsFormatApplyToBox->insertItem(tr("Layer"));
1472 symbolsFormatApplyToBox->insertItem(tr("Window"));
1473 symbolsFormatApplyToBox->insertItem(tr("All Windows"));
1474 gl2->addWidget(symbolsFormatApplyToBox, 1, 1);
1475 l->setBuddy(symbolsFormatApplyToBox);
1476
1477 gl2->setColumnStretch(2, 1);
1478
1479 symbolPage = new QWidget();
1480 QVBoxLayout* vl = new QVBoxLayout(symbolPage);
1481 vl->addLayout(hl0);
1482 vl->addLayout(hl);
1483 vl->addLayout(gl2);
1484
1485 privateTabWidget->insertTab(symbolPage, tr( "Symbol" ));
1486
1487 connect(standardSymbolBtn, SIGNAL(toggled(bool)), standardSymbolFormatBox, SLOT(setVisible(bool)));
1488 connect(imageSymbolBtn, SIGNAL(toggled(bool)), imageSymBolFormatBox, SLOT(setVisible(bool)));
1489
1490 connect(boxSymbolSize, SIGNAL(valueChanged(int)), this, SLOT(acceptParams()));
1491 connect(boxPenWidth, SIGNAL(valueChanged(double)), this, SLOT(acceptParams()));
1492 connect(boxSymbolColor, SIGNAL(colorChanged()), this, SLOT(acceptParams()));
1493 connect(boxSymbolStyle, SIGNAL(activated(int)), this, SLOT(acceptParams()));
1494 connect(boxFillColor, SIGNAL(colorChanged()), this, SLOT(acceptParams()));
1495 connect(boxFillSymbol, SIGNAL(clicked()), this, SLOT(fillSymbols()));
1496 connect(boxSkipSymbols, SIGNAL(valueChanged(int)), this, SLOT(acceptParams()));
1497 connect(boxSymbolTransparency, SIGNAL(valueChanged(int)), this, SLOT(acceptParams()));
1498 }
1499
initBoxPage()1500 void PlotDialog::initBoxPage()
1501 {
1502 QGroupBox *gb1 = new QGroupBox(tr( "Box" ));
1503 QGridLayout *gl1 = new QGridLayout(gb1);
1504 gl1->addWidget(new QLabel(tr( "Type" )), 0, 0);
1505
1506 boxType = new QComboBox();
1507 boxType->setEditable(false);
1508 boxType->addItem(tr("No Box"));
1509 boxType->addItem(tr("Rectangle"));
1510 boxType->addItem(tr("Diamond"));
1511 boxType->addItem(tr("Perc 10, 25, 75, 90"));
1512 boxType->addItem(tr("Notch"));
1513 gl1->addWidget(boxType, 0, 1);
1514
1515 boxRangeLabel = new QLabel(tr( "Range" ));
1516 gl1->addWidget(boxRangeLabel, 1, 0);
1517 boxRange = new QComboBox();
1518 boxRange->setEditable(false);
1519 boxRange->addItem(tr("Standard Deviation"));
1520 boxRange->addItem(tr("Standard Error"));
1521 boxRange->addItem(tr("Perc 25, 75"));
1522 boxRange->addItem(tr("Perc 10, 90"));
1523 boxRange->addItem(tr("Perc 5, 95"));
1524 boxRange->addItem(tr("Perc 1, 99"));
1525 boxRange->addItem(tr("Max-Min"));
1526 boxRange->addItem(tr("Constant"));
1527 gl1->addWidget(boxRange, 1, 1);
1528
1529 boxCoeffLabel = new QLabel(tr( "Percentile (%)" ));
1530 gl1->addWidget(boxCoeffLabel, 2, 0);
1531 boxCoef = new QSpinBox();
1532 boxCoef->setRange(50, 100);
1533 boxCoef->setSingleStep(5);
1534 gl1->addWidget(boxCoef, 2, 1);
1535
1536 boxCntLabel = new QLabel(tr( "Coefficient" ));
1537 gl1->addWidget(boxCntLabel, 3, 0);
1538 boxCnt = new QDoubleSpinBox();
1539 boxCnt->setRange(0.0, 100.0);
1540 boxCnt->setSingleStep(0.01);
1541 boxCnt->setValue(1.0);
1542 gl1->addWidget(boxCnt, 3, 1);
1543
1544 gl1->addWidget(new QLabel(tr( "Box Width" )), 4, 0);
1545 boxWidth = new QSpinBox();
1546 boxWidth->setRange(0, 100);
1547 boxWidth->setSingleStep(5);
1548 gl1->addWidget(boxWidth, 4, 1);
1549
1550 boxBoxLabels = new QCheckBox(tr("Box &Labels"));
1551 gl1->addWidget(boxBoxLabels, 5, 1);
1552 gl1->setRowStretch(6, 1);
1553
1554 QGroupBox *gb2 = new QGroupBox(tr( "Whiskers" ));
1555 QGridLayout *gl2 = new QGridLayout(gb2);
1556 whiskerRangeLabel = new QLabel(tr( "Range" ));
1557 gl2->addWidget(whiskerRangeLabel, 0, 0);
1558
1559 boxWhiskersRange = new QComboBox();
1560 boxWhiskersRange->setEditable(false);
1561 boxWhiskersRange->addItem(tr("No Whiskers"));
1562 boxWhiskersRange->addItem(tr("Standard Deviation"));
1563 boxWhiskersRange->addItem(tr("Standard Error"));
1564 boxWhiskersRange->addItem(tr("75-25"));
1565 boxWhiskersRange->addItem(tr("90-10"));
1566 boxWhiskersRange->addItem(tr("95-5"));
1567 boxWhiskersRange->addItem(tr("99-1"));
1568 boxWhiskersRange->addItem(tr("Max-Min"));
1569 boxWhiskersRange->addItem(tr("Constant"));
1570 gl2->addWidget(boxWhiskersRange, 0, 1);
1571
1572 whiskerCoeffLabel = new QLabel(tr( "Percentile (%)" ));
1573 gl2->addWidget(whiskerCoeffLabel, 1, 0);
1574 boxWhiskersCoef = new QSpinBox();
1575 boxWhiskersCoef->setRange(50, 100);
1576 boxWhiskersCoef->setSingleStep(5);
1577 gl2->addWidget(boxWhiskersCoef, 1, 1);
1578
1579 whiskerCntLabel = new QLabel(tr( "Coef" ));
1580 gl2->addWidget(whiskerCntLabel, 2, 0);
1581 whiskerCnt = new QDoubleSpinBox();
1582 whiskerCnt->setRange(0.0, 100.0);
1583 whiskerCnt->setSingleStep(0.01);
1584 whiskerCnt->setValue(1.0);
1585 gl2->addWidget(whiskerCnt, 2, 1);
1586
1587 boxWhiskerLabels = new QCheckBox(tr("Whis&ker Labels"));
1588 gl2->addWidget(boxWhiskerLabels, 3, 1);
1589 gl2->setRowStretch(4, 1);
1590
1591 QHBoxLayout* hl1 = new QHBoxLayout();
1592 QLabel *l = new QLabel(tr("Apply Format &to"));
1593 hl1->addWidget(l);
1594
1595 boxWhiskersFormatApplyToBox = new QComboBox();
1596 boxWhiskersFormatApplyToBox->insertItem(tr("Selected Curve"));
1597 boxWhiskersFormatApplyToBox->insertItem(tr("Layer"));
1598 boxWhiskersFormatApplyToBox->insertItem(tr("Window"));
1599 boxWhiskersFormatApplyToBox->insertItem(tr("All Windows"));
1600 hl1->addWidget(boxWhiskersFormatApplyToBox);
1601 l->setBuddy(boxWhiskersFormatApplyToBox);
1602
1603 buttonBoxStatistics = new QPushButton(tr( "&Show statistics" ));
1604 buttonBoxStatistics->setIcon(QIcon(":/log.png"));
1605 hl1->addStretch();
1606 hl1->addWidget(buttonBoxStatistics);
1607
1608 QHBoxLayout* hl = new QHBoxLayout();
1609 hl->addWidget(gb1);
1610 hl->addWidget(gb2);
1611
1612 boxPage = new QWidget();
1613 QVBoxLayout* vl = new QVBoxLayout(boxPage);
1614 vl->addLayout(hl);
1615 vl->addLayout(hl1);
1616 privateTabWidget->insertTab(boxPage, tr( "Box/Whiskers" ) );
1617
1618 connect(boxBoxLabels, SIGNAL(toggled(bool)), this, SLOT(enableLabelsPage()));
1619 connect(boxWhiskerLabels, SIGNAL(toggled(bool)), this, SLOT(enableLabelsPage()));
1620 connect(boxWidth, SIGNAL(valueChanged(int)), this, SLOT(acceptParams()));
1621 connect(boxType, SIGNAL(activated(int)), this, SLOT(setBoxType(int)));
1622 connect(boxType, SIGNAL(activated(int)), this, SLOT(acceptParams()));
1623 connect(boxRange, SIGNAL(activated(int)), this, SLOT(setBoxRangeType(int)));
1624 connect(boxWhiskersRange, SIGNAL(activated(int)), this, SLOT(setWhiskersRange(int)));
1625 connect(buttonBoxStatistics, SIGNAL(clicked()), this, SLOT(showBoxStatistics()));
1626 }
1627
initPercentilePage()1628 void PlotDialog::initPercentilePage()
1629 {
1630 QGroupBox *gb1 = new QGroupBox(tr( "Type" ) );
1631 QGridLayout *gl1 = new QGridLayout(gb1);
1632 gl1->addWidget(new QLabel(tr( "Max" )), 0, 0);
1633
1634 boxMaxStyle = new SymbolBox();
1635 gl1->addWidget(boxMaxStyle, 0, 1);
1636
1637 gl1->addWidget(new QLabel(tr( "99%" )), 1, 0);
1638 box99Style = new SymbolBox();
1639 gl1->addWidget(box99Style, 1, 1);
1640
1641 gl1->addWidget(new QLabel(tr( "Mean" )), 2, 0);
1642 boxMeanStyle = new SymbolBox();
1643 gl1->addWidget(boxMeanStyle, 2, 1);
1644
1645 gl1->addWidget(new QLabel(tr( "1%" )), 3, 0);
1646 box1Style = new SymbolBox();
1647 gl1->addWidget(box1Style, 3, 1);
1648
1649 gl1->addWidget(new QLabel(tr( "Min" )), 4, 0);
1650 boxMinStyle = new SymbolBox();
1651 gl1->addWidget(boxMinStyle, 4, 1);
1652 gl1->setRowStretch(5, 1);
1653
1654 QGroupBox *gb2 = new QGroupBox(tr( "Symbol" ));
1655 QGridLayout *gl2 = new QGridLayout(gb2);
1656
1657 boxPercSize = new QSpinBox();
1658 boxPercSize->setMinValue( 1 );
1659 gl2->addWidget(boxPercSize, 0, 1);
1660
1661 QLabel *l1 = new QLabel("&" + tr( "Size" ));
1662 l1->setBuddy(boxPercSize);
1663 gl2->addWidget(l1, 0, 0);
1664
1665 gl2->addWidget(new QLabel(tr( "Edge Color" )), 1, 0);
1666 boxEdgeColor = new ColorButton();
1667 gl2->addWidget(boxEdgeColor, 1, 1);
1668
1669 boxEdgeWidth = new DoubleSpinBox('f');
1670 boxEdgeWidth->setLocale(((ApplicationWindow *)parent())->locale());
1671 boxEdgeWidth->setSingleStep(0.1);
1672 boxEdgeWidth->setRange(0, 100);
1673 gl2->addWidget(boxEdgeWidth, 2, 1);
1674
1675 QLabel *l2 = new QLabel("&" + tr("Edge Width"));
1676 l2->setBuddy(boxEdgeWidth);
1677 gl2->addWidget(l2, 2, 0);
1678
1679 boxFillSymbols = new QCheckBox("&" + tr("Fill Color"));
1680 gl2->addWidget(boxFillSymbols, 3, 0);
1681 boxPercFillColor = new ColorButton();
1682 gl2->addWidget(boxPercFillColor, 3, 1);
1683
1684 boxPercentileTransparency = new QSpinBox();
1685 boxPercentileTransparency->setRange(0, 100);
1686 boxPercentileTransparency->setSuffix(" %");
1687 boxPercentileTransparency->setWrapping(true);
1688
1689 percentileTransparencySlider = new QSlider();
1690 percentileTransparencySlider->setOrientation(Qt::Horizontal);
1691 percentileTransparencySlider->setRange(0, 100);
1692
1693 QLabel *l3 = new QLabel("&" + tr("Opacity"));
1694 l3->setBuddy(percentileTransparencySlider);
1695 gl2->addWidget(l3, 4, 0);
1696
1697 QHBoxLayout* hb1 = new QHBoxLayout();
1698 hb1->addWidget(percentileTransparencySlider);
1699 hb1->addWidget(boxPercentileTransparency);
1700 gl2->addLayout(hb1, 4, 1);
1701
1702 gl2->setRowStretch(5, 1);
1703 gl2->setColumnStretch(2, 1);
1704
1705 QHBoxLayout* hl1 = new QHBoxLayout();
1706 QLabel *l = new QLabel(tr("Apply Format &to"));
1707 hl1->addWidget(l);
1708
1709 percentileFormatApplyToBox = new QComboBox();
1710 percentileFormatApplyToBox->insertItem(tr("Selected Curve"));
1711 percentileFormatApplyToBox->insertItem(tr("Layer"));
1712 percentileFormatApplyToBox->insertItem(tr("Window"));
1713 percentileFormatApplyToBox->insertItem(tr("All Windows"));
1714 hl1->addWidget(percentileFormatApplyToBox);
1715 hl1->addStretch();
1716 l->setBuddy(percentileFormatApplyToBox);
1717
1718 percentilePage = new QWidget();
1719 QHBoxLayout* hl = new QHBoxLayout();
1720 hl->addWidget(gb1);
1721 hl->addWidget(gb2);
1722
1723 QVBoxLayout* vl = new QVBoxLayout(percentilePage);
1724 vl->addLayout(hl);
1725 vl->addLayout(hl1);
1726
1727 privateTabWidget->insertTab(percentilePage, tr( "Percentile" ) );
1728
1729 connect(boxPercSize, SIGNAL(valueChanged(int)), this, SLOT(acceptParams()));
1730 connect(boxEdgeWidth, SIGNAL(valueChanged(double)), this, SLOT(acceptParams()));
1731 connect(boxMeanStyle, SIGNAL(activated(int)), this, SLOT(acceptParams()));
1732 connect(boxMinStyle, SIGNAL(activated(int)), this, SLOT(acceptParams()));
1733 connect(boxMaxStyle, SIGNAL(activated(int)), this, SLOT(acceptParams()));
1734 connect(box99Style, SIGNAL(activated(int)), this, SLOT(acceptParams()));
1735 connect(box1Style, SIGNAL(activated(int)), this, SLOT(acceptParams()));
1736 connect(box1Style, SIGNAL(activated(int)), this, SLOT(acceptParams()));
1737 connect(boxEdgeColor, SIGNAL(colorChanged()), this, SLOT(acceptParams()));
1738 connect(boxPercFillColor, SIGNAL(colorChanged()), this, SLOT(acceptParams()));
1739 connect(boxFillSymbols, SIGNAL(clicked()), this, SLOT(fillBoxSymbols()));
1740 connect(percentileTransparencySlider, SIGNAL(valueChanged(int)), boxPercentileTransparency, SLOT(setValue(int)));
1741 connect(boxPercentileTransparency, SIGNAL(valueChanged(int)), percentileTransparencySlider, SLOT(setValue(int)));
1742 connect(boxPercentileTransparency, SIGNAL(valueChanged(int)), this, SLOT(acceptParams()));
1743 }
1744
initSpectrogramValuesPage()1745 void PlotDialog::initSpectrogramValuesPage()
1746 {
1747 ApplicationWindow *app = (ApplicationWindow *)this->parent();
1748 if (!app)
1749 return;
1750
1751 QGroupBox *gb = new QGroupBox();
1752 QGridLayout *gl = new QGridLayout(gb);
1753 gl->addWidget(new QLabel( tr( "Matrix" )), 0, 0);
1754 boxSpectroMatrix = new QComboBox();
1755 boxSpectroMatrix->setEditable(false);
1756 boxSpectroMatrix->addItems(app->matrixNames());
1757
1758 gl->addWidget(boxSpectroMatrix, 0, 1);
1759
1760 boxUseMatrixFormula = new QCheckBox(tr("Use matrix formula to calculate values"));
1761 gl->addWidget(boxUseMatrixFormula, 1, 1);
1762
1763 gl->setRowStretch (2, 1);
1764
1765 spectroValuesPage = new QWidget();
1766 QHBoxLayout* hlayout = new QHBoxLayout(spectroValuesPage);
1767 hlayout->addWidget(gb);
1768 privateTabWidget->insertTab(spectroValuesPage, tr( "Values"));
1769 }
1770
initSpectrogramPage()1771 void PlotDialog::initSpectrogramPage()
1772 {
1773 spectrogramPage = new QWidget();
1774
1775 imageGroupBox = new QGroupBox(tr( "Image" ));
1776 imageGroupBox->setCheckable (true);
1777
1778 QVBoxLayout *vl = new QVBoxLayout();
1779 grayScaleBox = new QRadioButton(tr("&Gray Scale"));
1780 connect(grayScaleBox, SIGNAL(toggled(bool)), this, SLOT(showColorMapEditor(bool)));
1781 vl->addWidget(grayScaleBox);
1782 defaultScaleBox = new QRadioButton(tr("&Default Color Map"));
1783 connect(defaultScaleBox, SIGNAL(toggled(bool)), this, SLOT(showColorMapEditor(bool)));
1784 vl->addWidget(defaultScaleBox);
1785 customScaleBox = new QRadioButton(tr("&Custom Color Map"));
1786 connect(customScaleBox, SIGNAL(toggled(bool)), this, SLOT(showColorMapEditor(bool)));
1787 vl->addWidget(customScaleBox);
1788
1789 QHBoxLayout *hl = new QHBoxLayout(imageGroupBox);
1790 ApplicationWindow *app = (ApplicationWindow*)parent();
1791 colorMapEditor = new ColorMapEditor(app->locale(), app->d_decimal_digits);
1792 hl->addLayout(vl);
1793 hl->addWidget(colorMapEditor);
1794
1795 axisScaleBox = new QGroupBox(tr( "Color Bar Scale" ));
1796 axisScaleBox->setCheckable (true);
1797
1798 QGridLayout *gl2 = new QGridLayout(axisScaleBox);
1799 gl2->addWidget(new QLabel(tr( "Axis" )), 0, 0);
1800
1801 colorScaleBox = new QComboBox();
1802 colorScaleBox->addItem(tr("Left"));
1803 colorScaleBox->addItem(tr("Right"));
1804 colorScaleBox->addItem(tr("Bottom"));
1805 colorScaleBox->addItem(tr("Top"));
1806 gl2->addWidget(colorScaleBox, 0, 1);
1807
1808 gl2->addWidget(new QLabel(tr( "Width" )), 1, 0);
1809 colorScaleWidthBox = new QSpinBox();
1810 colorScaleWidthBox->setRange(2, 10000);
1811 gl2->addWidget(colorScaleWidthBox, 1, 1);
1812
1813 QVBoxLayout* vl2 = new QVBoxLayout(spectrogramPage);
1814 vl2->addWidget(imageGroupBox);
1815 vl2->addWidget(axisScaleBox);
1816 vl2->addStretch();
1817
1818 privateTabWidget->insertTab(spectrogramPage, tr("Colors"));
1819 }
1820
initContourLinesPage()1821 void PlotDialog::initContourLinesPage()
1822 {
1823 ApplicationWindow *app = (ApplicationWindow *)parent();
1824 QLocale locale = QLocale();
1825 if (app)
1826 locale = app->locale();
1827
1828 contourLinesPage = new QWidget();
1829
1830 levelsGroupBox = new QGroupBox(tr("&Show Contour Lines"));
1831 levelsGroupBox->setCheckable(true);
1832 QHBoxLayout *hl0 = new QHBoxLayout();
1833
1834 QGroupBox *gb1 = new QGroupBox(tr("Set Equidistant Levels"));
1835 QGridLayout *hl1 = new QGridLayout(gb1);
1836
1837 hl1->addWidget(new QLabel(tr("Levels")), 0, 0);
1838 levelsBox = new QSpinBox();
1839 levelsBox->setRange(0, 1000);
1840 hl1->addWidget(levelsBox, 0, 1);
1841
1842 hl1->addWidget(new QLabel(tr("Start")), 1, 0);
1843 firstContourLineBox = new DoubleSpinBox();
1844 firstContourLineBox->setLocale(locale);
1845 firstContourLineBox->setDecimals(6);
1846 hl1->addWidget(firstContourLineBox, 1, 1);
1847
1848 hl1->addWidget(new QLabel(tr("Step")), 2, 0);
1849 contourLinesDistanceBox = new DoubleSpinBox();
1850 contourLinesDistanceBox->setLocale(locale);
1851 contourLinesDistanceBox->setDecimals(6);
1852 hl1->addWidget(contourLinesDistanceBox, 2, 1);
1853
1854 btnSetEquidistantLevels = new QPushButton(tr("Set &Levels"));
1855 connect(btnSetEquidistantLevels, SIGNAL(clicked()), this, SLOT(setEquidistantLevels()));
1856 hl1->addWidget(btnSetEquidistantLevels, 3, 1);
1857
1858 hl1->setColumnStretch(1, 10);
1859 hl1->setRowStretch(4, 1);
1860
1861 contourLinesEditor = new ContourLinesEditor(app->locale());
1862 hl0->addWidget(contourLinesEditor);
1863 hl0->addWidget(gb1);
1864
1865 QGroupBox *penGroupBox = new QGroupBox(tr("Pen"));
1866 QHBoxLayout *hl2 = new QHBoxLayout(penGroupBox);
1867
1868 QVBoxLayout *vl1 = new QVBoxLayout;
1869 autoContourBox = new QRadioButton(tr("Use &Color Map"));
1870 connect(autoContourBox, SIGNAL(toggled(bool)), this, SLOT(showDefaultContourLinesBox(bool)));
1871 vl1->addWidget(autoContourBox);
1872
1873 defaultContourBox = new QRadioButton(tr("Use Default &Pen"));
1874 connect(defaultContourBox, SIGNAL(toggled(bool)), this, SLOT(showDefaultContourLinesBox(bool)));
1875 vl1->addWidget(defaultContourBox);
1876
1877 customPenBtn = new QRadioButton(tr("Use &Table Custom Pen"));
1878 connect(customPenBtn, SIGNAL(toggled(bool)), this, SLOT(showCustomPenColumn(bool)));
1879 vl1->addWidget(customPenBtn);
1880
1881 hl2->addLayout(vl1);
1882
1883 defaultPenBox = new QGroupBox();
1884 QGridLayout *gl1 = new QGridLayout(defaultPenBox);
1885 gl1->addWidget(new QLabel(tr( "Color" )), 0, 0);
1886
1887 levelsColorBox = new ColorButton(defaultPenBox);
1888 gl1->addWidget(levelsColorBox, 0, 1);
1889
1890 gl1->addWidget(new QLabel(tr( "Width" )), 1, 0);
1891 contourWidthBox = new DoubleSpinBox('f');
1892 contourWidthBox->setLocale(locale);
1893 contourWidthBox->setSingleStep(0.1);
1894 contourWidthBox->setRange(0, 100);
1895 gl1->addWidget(contourWidthBox, 1, 1);
1896
1897 gl1->addWidget(new QLabel(tr( "Style" )), 2, 0);
1898 boxContourStyle = new PenStyleBox();
1899 gl1->addWidget(boxContourStyle, 2, 1);
1900 hl2->addWidget(defaultPenBox);
1901
1902 QVBoxLayout *vl0 = new QVBoxLayout(levelsGroupBox);
1903 vl0->addLayout(hl0);
1904 vl0->addWidget(penGroupBox);
1905 vl0->addStretch();
1906
1907 QVBoxLayout* vl2 = new QVBoxLayout(contourLinesPage);
1908 vl2->addWidget(levelsGroupBox);
1909
1910 privateTabWidget->insertTab(contourLinesPage, tr("Contour Lines"));
1911 }
1912
fillBoxSymbols()1913 void PlotDialog::fillBoxSymbols()
1914 {
1915 bool filled = boxFillSymbols->isChecked();
1916 boxPercFillColor->setEnabled(filled);
1917 percentileTransparencySlider->setEnabled(filled);
1918 boxPercentileTransparency->setEnabled(filled);
1919 acceptParams();
1920 }
1921
fillSymbols()1922 void PlotDialog::fillSymbols()
1923 {
1924 bool filled = boxFillSymbol->isChecked();
1925 boxFillColor->setEnabled(filled);
1926 boxSymbolTransparency->setEnabled(filled);
1927 symbTransparencySlider->setEnabled(filled);
1928 acceptParams();
1929 }
1930
initErrorsPage()1931 void PlotDialog::initErrorsPage()
1932 {
1933 QGroupBox *gb1 = new QGroupBox(tr( "Direction" ));
1934
1935 QVBoxLayout* vl = new QVBoxLayout(gb1);
1936 plusBox = new QCheckBox(tr( "Plus" ));
1937 vl->addWidget(plusBox);
1938 minusBox = new QCheckBox(tr( "Minus" ));
1939 vl->addWidget(minusBox);
1940 xBox = new QCheckBox(tr( "&X Error Bar" ));
1941 vl->addWidget(xBox);
1942 vl->addWidget(xBox);
1943 vl->addStretch();
1944
1945 QGroupBox *gb2 = new QGroupBox(tr( "Style" ));
1946 QGridLayout *gl = new QGridLayout(gb2);
1947 gl->addWidget(new QLabel(tr( "Color" )), 0, 0);
1948
1949 colorBox = new ColorButton();
1950 gl->addWidget(colorBox, 0, 1);
1951
1952 gl->addWidget(new QLabel(tr( "Line Width" )), 1, 0);
1953 widthBox = new DoubleSpinBox('f');
1954 widthBox->setLocale(((ApplicationWindow *)parent())->locale());
1955 widthBox->setSingleStep(0.1);
1956 widthBox->setRange(0, 100);
1957 gl->addWidget(widthBox, 1, 1);
1958
1959 gl->addWidget(new QLabel(tr( "Cap Width" )), 2, 0);
1960 capBox = new QComboBox();
1961 capBox->addItem( tr( "8" ) );
1962 capBox->addItem( tr( "10" ) );
1963 capBox->addItem( tr( "12" ) );
1964 capBox->addItem( tr( "16" ) );
1965 capBox->addItem( tr( "20" ) );
1966 capBox->setEditable (true);
1967 gl->addWidget(capBox, 2, 1);
1968
1969 throughBox = new QCheckBox(tr( "Through Symbol" ));
1970 gl->addWidget(throughBox, 3, 0);
1971 gl->setRowStretch (4, 1);
1972
1973
1974 QGroupBox *gb3 = new QGroupBox();
1975 QGridLayout *gl3 = new QGridLayout(gb3);
1976
1977 gl3->addWidget(new QLabel(tr( "Skip Points" )), 0, 0);
1978 boxSkipErrorBars = new QSpinBox;
1979 boxSkipErrorBars->setMinimum(1);
1980 boxSkipErrorBars->setWrapping(true);
1981 boxSkipErrorBars->setSpecialValueText(tr("None"));
1982 gl3->addWidget(boxSkipErrorBars, 0, 1);
1983
1984 errorBarsFormatApplyToBox = new QComboBox;
1985
1986 QLabel *l = new QLabel(tr("Apply Format &to"));
1987 gl3->addWidget(l, 2, 0);
1988
1989 errorBarsFormatApplyToBox->insertItem(tr("Selected Curve"));
1990 errorBarsFormatApplyToBox->insertItem(tr("Layer"));
1991 errorBarsFormatApplyToBox->insertItem(tr("Window"));
1992 errorBarsFormatApplyToBox->insertItem(tr("All Windows"));
1993 gl3->addWidget(errorBarsFormatApplyToBox, 2, 1);
1994 l->setBuddy(errorBarsFormatApplyToBox);
1995
1996 errorsPage = new QWidget();
1997 QHBoxLayout* hl = new QHBoxLayout();
1998 hl->addWidget(gb1);
1999 hl->addWidget(gb2);
2000
2001 QVBoxLayout* vl0 = new QVBoxLayout(errorsPage);
2002 vl0->addLayout(hl);
2003 vl0->addWidget(gb3);
2004
2005 privateTabWidget->insertTab( errorsPage, tr( "Error Bars" ) );
2006
2007 connect(boxSkipErrorBars, SIGNAL(valueChanged(int)), this, SLOT(acceptParams()));
2008 connect(capBox, SIGNAL(activated(int)), this, SLOT(acceptParams()));
2009 connect(widthBox, SIGNAL(valueChanged(double)), this, SLOT(acceptParams()));
2010 connect(colorBox, SIGNAL(colorChanged()), this, SLOT(pickErrorBarsColor()));
2011 connect(xBox, SIGNAL(clicked()), this, SLOT(acceptParams()));
2012 connect(plusBox, SIGNAL(clicked()), this, SLOT(acceptParams()));
2013 connect(minusBox, SIGNAL(clicked()), this, SLOT(acceptParams()));
2014 connect(throughBox, SIGNAL(clicked()), this, SLOT(acceptParams()));
2015 }
2016
initHistogramPage()2017 void PlotDialog::initHistogramPage()
2018 {
2019 QHBoxLayout* hl = new QHBoxLayout();
2020 automaticBox = new QCheckBox(tr( "Automatic Binning" ));
2021 hl->addWidget(automaticBox);
2022 hl->addStretch();
2023 buttonStatistics = new QPushButton(tr( "&Show statistics" ));
2024 hl->addWidget(buttonStatistics);
2025
2026 QLocale locale = ((ApplicationWindow *)parent())->locale();
2027 GroupBoxH = new QGroupBox();
2028 QGridLayout *gl = new QGridLayout(GroupBoxH);
2029 gl->addWidget(new QLabel(tr( "Bin Size" )), 0, 0);
2030 binSizeBox = new DoubleSpinBox();
2031 binSizeBox->setMinimum(0.0);
2032 binSizeBox->setLocale(locale);
2033
2034 gl->addWidget(binSizeBox, 0, 1);
2035 gl->addWidget(new QLabel(tr( "Begin" )), 1, 0);
2036 histogramBeginBox = new DoubleSpinBox();
2037 histogramBeginBox->setLocale(locale);
2038 gl->addWidget(histogramBeginBox, 1, 1);
2039 gl->addWidget(new QLabel(tr( "End" )), 2, 0);
2040 histogramEndBox = new DoubleSpinBox();
2041 histogramEndBox->setLocale(locale);
2042 gl->addWidget(histogramEndBox, 2, 1);
2043
2044 histogramPage = new QWidget();
2045 QVBoxLayout* vl = new QVBoxLayout(histogramPage);
2046 vl->addLayout(hl);
2047 vl->addWidget(GroupBoxH);
2048 vl->addStretch();
2049
2050 privateTabWidget->insertTab( histogramPage, tr( "Histogram Data" ) );
2051
2052 connect(binSizeBox, SIGNAL(valueChanged(double)), this, SLOT(acceptParams()));
2053 connect(histogramBeginBox, SIGNAL(valueChanged(double)), this, SLOT(acceptParams()));
2054 connect(histogramEndBox, SIGNAL(valueChanged(double)), this, SLOT(acceptParams()));
2055
2056 connect(automaticBox, SIGNAL(clicked(bool)), this, SLOT(setAutomaticBinning(bool)));
2057 connect(buttonStatistics, SIGNAL(clicked()), this, SLOT(showStatistics()));
2058 }
2059
initSpacingPage()2060 void PlotDialog::initSpacingPage()
2061 {
2062 spacingPage = new QWidget();
2063
2064 QGridLayout *gl = new QGridLayout(spacingPage);
2065 gl->addWidget(new QLabel(tr( "Gap Between Bars (in %)" )), 0, 0);
2066 gapBox = new QSpinBox();
2067 gapBox->setRange(0, 100);
2068 gapBox->setSingleStep(10);
2069 gl->addWidget(gapBox, 0, 1);
2070 connect(gapBox, SIGNAL(valueChanged(int)), this, SLOT(acceptParams()));
2071
2072 QLabel *l = new QLabel(tr("Apply &to..."));
2073 gl->addWidget(l, 0, 2);
2074
2075 gapApplyToBox = new QComboBox();
2076 gapApplyToBox->insertItem(tr("Selected Curve"));
2077 gapApplyToBox->insertItem(tr("Layer"));
2078 gapApplyToBox->insertItem(tr("Window"));
2079 gapApplyToBox->insertItem(tr("All Windows"));
2080 gl->addWidget(gapApplyToBox, 0, 3);
2081
2082 l->setBuddy(gapApplyToBox);
2083
2084 barsOffsetLabel = new QLabel(tr( "Offset (in %)" ));
2085 gl->addWidget(barsOffsetLabel, 1, 0);
2086 offsetBox = new QSpinBox();
2087 offsetBox->setRange(-1000, 1000);
2088 offsetBox->setSingleStep(50);
2089 gl->addWidget(offsetBox, 1, 1);
2090 connect(offsetBox, SIGNAL(valueChanged(int)), this, SLOT(acceptParams()));
2091 gl->setRowStretch (2, 1);
2092
2093 privateTabWidget->insertTab( spacingPage, tr( "Spacing" ));
2094 }
2095
initVectPage()2096 void PlotDialog::initVectPage()
2097 {
2098 QGroupBox *gb1 = new QGroupBox();
2099 QGridLayout *gl1 = new QGridLayout(gb1);
2100 gl1->addWidget(new QLabel(tr( "Color" )), 0, 0);
2101 vectColorBox = new ColorButton();
2102 gl1->addWidget(vectColorBox, 0, 1);
2103 gl1->addWidget(new QLabel(tr( "Line Width" )), 1, 0);
2104 vectWidthBox = new DoubleSpinBox('f');
2105 vectWidthBox->setLocale(((ApplicationWindow *)parent())->locale());
2106 vectWidthBox->setSingleStep(0.1);
2107 vectWidthBox->setRange(0, 100);
2108 gl1->addWidget(vectWidthBox, 1, 1);
2109
2110 QGroupBox *gb2 = new QGroupBox(tr( "Arrowheads" ));
2111 QGridLayout *gl2 = new QGridLayout(gb2);
2112 gl2->addWidget(new QLabel(tr( "Length" )), 0, 0);
2113 headLengthBox = new QSpinBox();
2114 headLengthBox->setRange(0, 100);
2115 gl2->addWidget(headLengthBox, 0, 1);
2116 gl2->addWidget(new QLabel(tr( "Angle" )), 1, 0);
2117 headAngleBox = new QSpinBox();
2118 headAngleBox->setRange(0, 85);
2119 headAngleBox->setSingleStep(5);
2120 gl2->addWidget(headAngleBox, 1, 1);
2121 filledHeadBox = new QCheckBox(tr( "&Filled" ));
2122 gl2->addWidget(filledHeadBox, 2, 0);
2123 gl2->setRowStretch(3, 1);
2124
2125 GroupBoxVectEnd = new QGroupBox(tr( "End Point" ));
2126 QGridLayout *gl3 = new QGridLayout(GroupBoxVectEnd);
2127 labelXEnd = new QLabel(tr( "X End" ));
2128 gl3->addWidget(labelXEnd, 0, 0);
2129 xEndBox = new QComboBox(false);
2130 gl3->addWidget(xEndBox, 0, 1);
2131
2132 labelYEnd = new QLabel(tr( "Y End" ));
2133 gl3->addWidget(labelYEnd, 1, 0);
2134 yEndBox = new QComboBox( false);
2135 gl3->addWidget(yEndBox, 1, 1);
2136
2137 labelPosition = new QLabel(tr( "Position" ));
2138 gl3->addWidget(labelPosition, 2, 0);
2139 vectPosBox = new QComboBox( false);
2140 vectPosBox->addItem(tr("Tail"));
2141 vectPosBox->addItem(tr("Middle"));
2142 vectPosBox->addItem(tr("Head"));
2143 gl3->addWidget(vectPosBox, 2, 1);
2144 gl3->setRowStretch(3, 1);
2145
2146 vectPage = new QWidget();
2147
2148 QVBoxLayout *vl1 = new QVBoxLayout();
2149 vl1->addWidget(gb1);
2150 vl1->addWidget(gb2);
2151
2152 QHBoxLayout *hl = new QHBoxLayout(vectPage);
2153 hl->addLayout(vl1);
2154 hl->addWidget(GroupBoxVectEnd);
2155
2156 privateTabWidget->insertTab( vectPage, tr( "Vector" ) );
2157 }
2158
setMultiLayer(MultiLayer * ml)2159 void PlotDialog::setMultiLayer(MultiLayer *ml)
2160 {
2161 if (!ml)
2162 return;
2163
2164 d_ml = ml;
2165 displayPlotCoordinates(ml->applicationWindow()->d_layer_geometry_unit);
2166 boxResizeLayers->setChecked(!ml->scaleLayersOnResize());
2167
2168 boxLinkXAxes->setChecked(d_ml->hasLinkedXLayerAxes());
2169
2170 boxScaleLayers->setChecked(d_ml->scaleLayersOnPrint());
2171 boxPrintCrops->setChecked(d_ml->printCropmarksEnabled());
2172
2173 QTreeWidgetItem *item = new QTreeWidgetItem(listBox, QStringList(ml->name()));
2174 item->setIcon(0, QIcon(":/folder_open.png"));
2175 listBox->addTopLevelItem(item);
2176 listBox->setCurrentItem(item);
2177
2178 listBox->blockSignals(true);
2179 QList<Graph *> layers = ml->layersList();
2180 int i = 0;
2181 foreach(Graph *g, layers){
2182 LayerItem *layer = new LayerItem(g, item, tr("Layer") + QString::number(++i));
2183 item->addChild(layer);
2184
2185 if (g == ml->activeLayer()){
2186 layer->setExpanded(true);
2187 listBox->blockSignals(false);
2188 layer->setActive(true);
2189 listBox->setCurrentItem(layer);
2190 listBox->blockSignals(true);
2191 }
2192 }
2193 listBox->blockSignals(false);
2194 }
2195
selectMultiLayerItem()2196 void PlotDialog::selectMultiLayerItem()
2197 {
2198 listBox->setCurrentItem(listBox->topLevelItem(0));
2199 }
2200
selectCurve(int index)2201 void PlotDialog::selectCurve(int index)
2202 {
2203 LayerItem *layerItem = (LayerItem *)listBox->currentItem();
2204 if (!layerItem)
2205 return;
2206 if (layerItem->type() != LayerItem::LayerTreeItem)
2207 return;
2208 QTreeWidgetItem *item = layerItem->child(index);
2209 if (item){
2210 listBox->scrollToItem(item);
2211 ((CurveTreeItem *)item)->setActive(true);
2212 listBox->setCurrentItem(item);
2213 }
2214 }
2215
showBoxStatistics()2216 void PlotDialog::showBoxStatistics()
2217 {
2218 ApplicationWindow *app = (ApplicationWindow *)this->parent();
2219 if (!app)
2220 return;
2221
2222 QTreeWidgetItem *it = listBox->currentItem();
2223 if (!it)
2224 return;
2225 if (it->type() != CurveTreeItem::PlotCurveTreeItem)
2226 return;
2227
2228 QwtPlotItem *plotItem = (QwtPlotItem *)((CurveTreeItem *)it)->plotItem();
2229 if (!plotItem)
2230 return;
2231
2232 BoxCurve *b = (BoxCurve *)plotItem;
2233 if (!b || b->type() != Graph::Box)
2234 return;
2235
2236 QDateTime dt = QDateTime::currentDateTime();
2237 QString info = dt.toString(Qt::LocalDate)+"\t"+tr("Statistics for") + " " + b->title().text() + " :\n";
2238 info += b->statistics();
2239 info += "-------------------------------------------------------------\n";
2240
2241 app->current_folder->appendLogInfo(info);
2242 app->showResults(true);
2243 }
2244
showStatistics()2245 void PlotDialog::showStatistics()
2246 {
2247 ApplicationWindow *app = (ApplicationWindow *)this->parent();
2248 if (!app)
2249 return;
2250
2251 QTreeWidgetItem *it = listBox->currentItem();
2252 if (!it)
2253 return;
2254 if (it->type() != CurveTreeItem::PlotCurveTreeItem)
2255 return;
2256
2257 QwtPlotItem *plotItem = (QwtPlotItem *)((CurveTreeItem *)it)->plotItem();
2258 if (!plotItem)
2259 return;
2260
2261 QwtHistogram *h = (QwtHistogram *)plotItem;
2262 if (!h)
2263 return;
2264
2265 QString tableName = app->generateUniqueName(tr("Bins"));
2266 Table *t = app->newTable(h->dataSize(), 4, tableName, tr("Histogram and Probabilities for") + " " + h->title().text());
2267 if (t)
2268 {
2269 double h_sum = 0.0;
2270 for (int i = 0; i < h->dataSize(); i++ )
2271 h_sum += h->y(i);
2272
2273 double sum = 0.0;
2274 for (int i = 0; i < h->dataSize(); i++ )
2275 {
2276 sum += h->y(i);
2277 t->setCell(i, 0, h->x(i));
2278 t->setCell(i, 1, h->y(i));
2279 t->setCell(i, 2, sum);
2280 t->setCell(i, 3, sum/h_sum*100);
2281 }
2282 t->setHeader(QStringList() << tr("Bins") << tr("Quantity") << tr("Sum") << tr("Percent"));
2283 t->showMaximized();
2284 }
2285
2286 QDateTime dt = QDateTime::currentDateTime();
2287 QString info = dt.toString(Qt::LocalDate)+"\t"+tr("Histogram and Probabilities for") + " " + h->title().text()+"\n";
2288 info += tr("Mean")+" = "+QString::number(h->mean())+"\t";
2289 info += tr("Standard Deviation")+" = "+QString::number(h->standardDeviation())+"\n";
2290 info += tr("Minimum")+" = "+QString::number(h->minimum())+"\t";
2291 info += tr("Maximum")+" = "+QString::number(h->maximum())+"\t";
2292 info += tr("Bins")+" = "+QString::number(h->dataSize())+"\n";
2293 info += "-------------------------------------------------------------\n";
2294 if (!info.isEmpty()){
2295 app->current_folder->appendLogInfo(info);
2296 app->showResults(true);
2297 }
2298
2299 close();
2300 }
2301
contextMenuEvent(QContextMenuEvent * e)2302 void PlotDialog::contextMenuEvent(QContextMenuEvent *e)
2303 {
2304 QTreeWidgetItem *item = listBox->currentItem();
2305 if (!item || !item->parent())
2306 return;
2307
2308 QPoint pos = listBox->viewport()->mapFromGlobal(QCursor::pos());
2309 QRect rect = listBox->visualItemRect(listBox->currentItem());
2310 if (rect.contains(pos)){
2311 QMenu contextMenu(this);
2312 if (item->type() == CurveTreeItem::PlotCurveTreeItem){
2313 QwtPlotItem *it = (QwtPlotItem *)((CurveTreeItem *)item)->plotItem();
2314 if (it){
2315 int index = ((CurveTreeItem *)item)->plotItemIndex();
2316 if (index)
2317 contextMenu.insertItem(QPixmap(":/arrow_up.png"), tr("Move &upward"), this, SLOT(raiseCurve()));
2318
2319 Graph *graph = ((CurveTreeItem *)item)->graph();
2320 if (graph && index < graph->curveCount() - 1)
2321 contextMenu.insertItem(QPixmap(":/arrow_down.png"), tr("Move do&wnward"), this, SLOT(shiftCurveBy()));
2322 contextMenu.insertSeparator();
2323 }
2324
2325 if (it && it->rtti() == QwtPlotItem::Rtti_PlotCurve && ((PlotCurve *)it)->type() != Graph::Function){
2326 contextMenu.insertItem(tr("&Plot Associations..."), this, SLOT(editCurve()));
2327 contextMenu.insertItem(tr("Edit &Range..."), this, SLOT(editCurveRange()));
2328 contextMenu.insertSeparator();
2329 }
2330 contextMenu.insertItem(it->isVisible() ? tr("&Hide") : tr("&Show"), this, SLOT(updateVisibility()));
2331 } else if (item->type() == FrameWidgetTreeItem::FrameWidgetItem){
2332 FrameWidget *fw = ((FrameWidgetTreeItem *)item)->frameWidget();
2333 contextMenu.insertItem(fw->isVisible() ? tr("&Hide") : tr("&Show"), this, SLOT(updateVisibility()));
2334 }
2335 contextMenu.insertItem(QPixmap(":/delete.png"), tr("&Delete"), this, SLOT(removeSelectedObject()));
2336 contextMenu.exec(QCursor::pos());
2337 }
2338 e->accept();
2339 }
2340
removeSelectedObject()2341 void PlotDialog::removeSelectedObject()
2342 {
2343 QTreeWidgetItem *item = listBox->currentItem();
2344 if (!item)
2345 return;
2346
2347 Graph *graph = NULL;
2348 switch (item->type()){
2349 case FrameWidgetTreeItem::FrameWidgetItem:
2350 enrichmentDialog->close();
2351 enrichmentDialog = NULL;
2352 graph = ((FrameWidgetTreeItem *)item)->graph();
2353 if (graph)
2354 graph->remove(((FrameWidgetTreeItem *)item)->frameWidget());
2355 break;
2356 case CurveTreeItem::PlotCurveTreeItem:
2357 graph = ((CurveTreeItem *)item)->graph();
2358 if (graph)
2359 graph->removeCurve(((CurveTreeItem *)item)->plotItemIndex());
2360 break;
2361 case LayerItem::LayerTreeItem:{
2362 d_ml->removeLayer(((LayerItem *)item)->graph());
2363 listBox->clear();
2364 setMultiLayer(d_ml);
2365 }
2366 break;
2367 default:
2368 return;
2369 }
2370
2371 if (!graph)
2372 return;
2373
2374 graph->updatePlot();
2375
2376 listBox->blockSignals(true);
2377
2378 LayerItem *layerItem = (LayerItem *)item->parent();
2379 QTreeWidgetItem *rootItem = layerItem->parent();
2380
2381 int index = rootItem->indexOfChild (layerItem);
2382 rootItem->takeChild(index);
2383 delete layerItem;
2384
2385 layerItem = new LayerItem(graph, rootItem, tr("Layer") + QString::number(d_ml->layerIndex(graph) + 1));
2386 rootItem->addChild(layerItem);
2387
2388 listBox->blockSignals(false);
2389
2390 if (graph->curveCount() > 0){
2391 layerItem->setExpanded(true);
2392 CurveTreeItem *it = (CurveTreeItem *)layerItem->child(0);
2393 if (it){
2394 listBox->setCurrentItem(it);
2395 setActiveCurve(it);
2396 }
2397 } else if (!graph->enrichmentsList().isEmpty()){
2398 layerItem->setExpanded(true);
2399 FrameWidgetTreeItem *it = (FrameWidgetTreeItem *)layerItem->child(0);
2400 if (it)
2401 listBox->setCurrentItem(it);
2402 } else {
2403 listBox->setCurrentItem(layerItem);
2404
2405 clearTabWidget();
2406 privateTabWidget->addTab (layerPage, tr("Layer"));
2407 privateTabWidget->addTab (canvasPage, tr("Canvas"));
2408 privateTabWidget->addTab (layerGeometryPage, tr("Geometry"));
2409 privateTabWidget->addTab (speedPage, tr("Speed"));
2410 privateTabWidget->addTab (layerDisplayPage, tr("Display"));
2411 privateTabWidget->showPage(layerPage);
2412
2413 setActiveLayer(layerItem);
2414 }
2415 }
2416
chooseBackgroundImageFile(const QString & fn)2417 void PlotDialog::chooseBackgroundImageFile(const QString& fn)
2418 {
2419 ApplicationWindow *app = (ApplicationWindow *)this->parent();
2420 if (!app)
2421 return;
2422
2423 LayerItem *item = (LayerItem *)listBox->currentItem();
2424 if (!item)
2425 return;
2426
2427 Graph *g = item->graph();
2428 if (!g)
2429 return;
2430
2431 QString path = fn;
2432 if (path.isEmpty())
2433 path = ApplicationWindow::getFileName(this, tr("QtiPlot - Import image from file"), g->canvasBackgroundFileName(),
2434 ApplicationWindow::imageFilter(), 0, false);
2435
2436 if (!path.isEmpty()){
2437 imagePathBox->setText(path);
2438 applyCanvasFormat();
2439 QFileInfo fi(path);
2440 app->imagesDirPath = fi.dirPath(true);
2441 app->modifiedProject();
2442 }
2443 }
2444
chooseSymbolImageFile()2445 void PlotDialog::chooseSymbolImageFile()
2446 {
2447 QTreeWidgetItem *it = listBox->currentItem();
2448 if (!it)
2449 return;
2450
2451 CurveTreeItem *item = (CurveTreeItem *)it;
2452 QwtPlotCurve *c = (QwtPlotCurve *)item->plotItem();
2453 if (!c || c->rtti() != QwtPlotItem::Rtti_PlotCurve)
2454 return;
2455
2456 ApplicationWindow *app = (ApplicationWindow *)this->parent();
2457 if (!app)
2458 return;
2459
2460 QString path = ApplicationWindow::getFileName(this, tr("QtiPlot - Import image from file"), imageSymbolPathBox->text(),
2461 ApplicationWindow::imageFilter(), 0, false);
2462 if (!path.isEmpty()){
2463 imageSymbolPathBox->setText(path);
2464 acceptParams();
2465
2466 QFileInfo fi(path);
2467 app->imagesDirPath = fi.dirPath(true);
2468 app->modifiedProject();
2469 }
2470 }
2471
pickErrorBarsColor()2472 void PlotDialog::pickErrorBarsColor()
2473 {
2474 CurveTreeItem *item = (CurveTreeItem *)listBox->currentItem();
2475 if (!item)
2476 return;
2477 if (item->type() != CurveTreeItem::PlotCurveTreeItem)
2478 return;
2479
2480 Graph *graph = item->graph();
2481 if (!graph)
2482 return;
2483
2484 graph->updateErrorBars((ErrorBarsCurve *)item->plotItem(), xBox->isChecked(), widthBox->value(),
2485 capBox->currentText().toInt(), colorBox->color(), plusBox->isChecked(), minusBox->isChecked(),
2486 throughBox->isChecked());
2487 }
2488
showAreaColor(bool show)2489 void PlotDialog::showAreaColor(bool show)
2490 {
2491 boxAreaColor->setEnabled(show);
2492 boxPattern->setEnabled(show);
2493 }
2494
updateTabWindow(QTreeWidgetItem * currentItem,QTreeWidgetItem * previousItem)2495 void PlotDialog::updateTabWindow(QTreeWidgetItem *currentItem, QTreeWidgetItem *previousItem)
2496 {
2497 if (!currentItem)
2498 return;
2499
2500 bool forceClearTabs = false;
2501 if (!previousItem){
2502 previousItem = currentItem;
2503 forceClearTabs = true;
2504 }
2505
2506 if (previousItem->type() == CurveTreeItem::PlotCurveTreeItem)
2507 ((CurveTreeItem *)previousItem)->setActive(false);
2508 else if (previousItem->type() == LayerItem::LayerTreeItem)
2509 ((LayerItem *)previousItem)->setActive(false);
2510 else if (previousItem->type() == FrameWidgetTreeItem::FrameWidgetItem)
2511 ((FrameWidgetTreeItem *)previousItem)->setActive(false);
2512
2513 boxPlotType->blockSignals(true);
2514
2515 if (currentItem->type() == CurveTreeItem::PlotCurveTreeItem){
2516 CurveTreeItem *curveItem = (CurveTreeItem *)currentItem;
2517 if (previousItem->type() != CurveTreeItem::PlotCurveTreeItem ||
2518 ((CurveTreeItem *)previousItem)->plotItemStyle() != curveItem->plotItemStyle() ||
2519 ((CurveTreeItem *)previousItem)->plotItemType() != curveItem->plotItemType() ||
2520 forceClearTabs){
2521 clearTabWidget();
2522 int plot_type = setPlotType(curveItem);
2523 if (plot_type >= 0)
2524 insertTabs(plot_type);
2525 if (!curvePlotTypeBox->isVisible())
2526 curvePlotTypeBox->show();
2527 }
2528 setActiveCurve(curveItem);
2529 } else if (currentItem->type() == LayerItem::LayerTreeItem){
2530 if (previousItem->type() != LayerItem::LayerTreeItem){
2531 clearTabWidget();
2532 privateTabWidget->addTab (layerPage, tr("Layer"));
2533 privateTabWidget->addTab (canvasPage, tr("Canvas"));
2534 privateTabWidget->addTab (layerGeometryPage, tr("Geometry"));
2535 privateTabWidget->addTab (speedPage, tr("Speed"));
2536 privateTabWidget->addTab (layerDisplayPage, tr("Display"));
2537 privateTabWidget->showPage(layerPage);
2538 }
2539 setActiveLayer((LayerItem *)currentItem);
2540 } else if (currentItem->type() == FrameWidgetTreeItem::FrameWidgetItem){
2541 clearTabWidget();
2542
2543 FrameWidgetTreeItem *it = (FrameWidgetTreeItem *)currentItem;
2544 it->setActive(true);
2545 FrameWidget *w = it->frameWidget();
2546
2547 EnrichmentDialog::WidgetType wt = EnrichmentDialog::Text;
2548 if (qobject_cast<RectangleWidget *>(w))
2549 wt = EnrichmentDialog::Frame;
2550 else if (qobject_cast<EllipseWidget *>(w))
2551 wt = EnrichmentDialog::Ellipse;
2552 else if (qobject_cast<ImageWidget *>(w))
2553 wt = EnrichmentDialog::Image;
2554 else if (qobject_cast<TexWidget *>(w))
2555 wt = EnrichmentDialog::Tex;
2556
2557 if (!enrichmentDialog)
2558 enrichmentDialog = new EnrichmentDialog(wt, it->graph(), (ApplicationWindow *)this->parent(), privateTabWidget);
2559 enrichmentDialog->setWidget(w);
2560
2561 privateTabWidget->hide();
2562 ((QGridLayout*)this->layout())->addWidget(enrichmentDialog, 0, 1);
2563
2564 curvePlotTypeBox->hide();
2565 btnWorksheet->hide();
2566 btnEditCurve->hide();
2567 btnEditCurveRange->hide();
2568 } else {
2569 clearTabWidget();
2570 privateTabWidget->addTab(plotGeometryPage, tr("Dimensions"));
2571 privateTabWidget->addTab(printPage, tr("Print"));
2572 privateTabWidget->addTab(fontsPage, tr("Fonts"));
2573 privateTabWidget->addTab(miscPage, tr("Miscellaneous"));
2574 privateTabWidget->showPage(plotGeometryPage);
2575
2576 curvePlotTypeBox->hide();
2577 btnWorksheet->hide();
2578 btnEditCurve->hide();
2579 btnEditCurveRange->hide();
2580 }
2581 boxPlotType->blockSignals(false);
2582 }
2583
insertTabs(int plot_type)2584 void PlotDialog::insertTabs(int plot_type)
2585 {
2586 if (plot_type == Graph::Pie){
2587 privateTabWidget->addTab (piePage, tr("Pattern"));
2588 privateTabWidget->addTab (pieGeometryPage, tr("Pie Geometry"));
2589 privateTabWidget->addTab (pieLabelsPage, tr("Labels"));
2590 privateTabWidget->showPage(piePage);
2591 return;
2592 }
2593
2594 privateTabWidget->addTab (axesPage, tr("Axes"));
2595 if (plot_type == Graph::Line){
2596 boxConnect->setEnabled(true);
2597 privateTabWidget->addTab (linePage, tr("Line"));
2598 privateTabWidget->showPage(linePage);
2599 } else if (plot_type == Graph::Scatter){
2600 boxConnect->setEnabled(true);
2601 privateTabWidget->addTab (symbolPage, tr("Symbol"));
2602 privateTabWidget->showPage(symbolPage);
2603 } else if (plot_type == Graph::LineSymbols){
2604 boxConnect->setEnabled(true);
2605 privateTabWidget->addTab (linePage, tr("Line"));
2606 privateTabWidget->addTab (symbolPage, tr("Symbol"));
2607 privateTabWidget->showPage(symbolPage);
2608 } else if (plot_type == Graph::VerticalBars ||
2609 plot_type == Graph::HorizontalBars ||
2610 plot_type == Graph::Histogram){
2611 boxConnect->setEnabled(false);
2612 privateTabWidget->addTab (linePage, tr("Pattern"));
2613 privateTabWidget->addTab (spacingPage, tr("Spacing"));
2614
2615 if (plot_type == Graph::Histogram){
2616 privateTabWidget->addTab (histogramPage, tr("Histogram Data"));
2617 privateTabWidget->showPage(histogramPage);
2618 } else
2619 privateTabWidget->showPage(linePage);
2620 } else if (plot_type == Graph::VectXYXY || plot_type == Graph::VectXYAM){
2621 boxConnect->setEnabled(true);
2622 //privateTabWidget->addTab (linePage, tr("Line")); //TODO: Restore this in 0.9.8 together with saving/restoring of vector curves
2623 privateTabWidget->addTab (vectPage, tr("Vector"));
2624 customVectorsPage(plot_type == Graph::VectXYAM);
2625 privateTabWidget->showPage(vectPage);
2626 } else if (plot_type == Graph::ErrorBars){
2627 privateTabWidget->addTab (errorsPage, tr("Error Bars"));
2628 privateTabWidget->showPage(errorsPage);
2629 } else if (plot_type == Graph::Box) {
2630 boxConnect->setEnabled(false);
2631 privateTabWidget->addTab (linePage, tr("Pattern"));
2632 privateTabWidget->addTab (boxPage, tr("Box/Whiskers"));
2633 privateTabWidget->addTab (percentilePage, tr("Percentile"));
2634 privateTabWidget->showPage(linePage);
2635 } else if (plot_type == Graph::ColorMap || plot_type == Graph::GrayScale || plot_type == Graph::Contour){
2636 privateTabWidget->addTab(spectroValuesPage, tr("Values"));
2637 privateTabWidget->addTab(spectrogramPage, tr("Colors"));
2638 privateTabWidget->addTab(contourLinesPage, tr("Contour Lines"));
2639 privateTabWidget->addTab(labelsPage, tr("Labels"));
2640 privateTabWidget->showPage(spectrogramPage);
2641 return;
2642 }
2643
2644 QTreeWidgetItem *item = listBox->currentItem();
2645 if (!item || item->type() != CurveTreeItem::PlotCurveTreeItem)
2646 return;
2647
2648 PlotCurve *fc = (PlotCurve *)((CurveTreeItem *)item)->plotItem();
2649 if (fc->type() == Graph::Function){
2650 privateTabWidget->addTab(functionPage, tr("&Function"));
2651 Graph *g = qobject_cast<Graph*>(fc->plot());
2652 if (g){
2653 functionEdit->setCurveToModify(g, g->curveIndex(fc));
2654 privateTabWidget->showPage(functionPage);
2655 }
2656 } else {
2657 DataCurve *c = (DataCurve *)((CurveTreeItem *)item)->plotItem();
2658 if (c && c->type() != Graph::Function && c->type() != Graph::ErrorBars){
2659 privateTabWidget->addTab (labelsPage, tr("Labels"));
2660 if (c->hasSelectedLabels()){
2661 privateTabWidget->showPage(labelsPage);
2662 c->setLabelsSelected(false);
2663 }
2664 }
2665 }
2666 }
2667
clearTabWidget()2668 void PlotDialog::clearTabWidget()
2669 {
2670 privateTabWidget->removeTab(privateTabWidget->indexOf(labelsPage));
2671 privateTabWidget->removeTab(privateTabWidget->indexOf(axesPage));
2672 privateTabWidget->removeTab(privateTabWidget->indexOf(linePage));
2673 privateTabWidget->removeTab(privateTabWidget->indexOf(symbolPage));
2674 privateTabWidget->removeTab(privateTabWidget->indexOf(errorsPage));
2675 privateTabWidget->removeTab(privateTabWidget->indexOf(histogramPage));
2676 privateTabWidget->removeTab(privateTabWidget->indexOf(spacingPage));
2677 privateTabWidget->removeTab(privateTabWidget->indexOf(vectPage));
2678 privateTabWidget->removeTab(privateTabWidget->indexOf(boxPage));
2679 privateTabWidget->removeTab(privateTabWidget->indexOf(percentilePage));
2680 privateTabWidget->removeTab(privateTabWidget->indexOf(spectroValuesPage));
2681 privateTabWidget->removeTab(privateTabWidget->indexOf(spectrogramPage));
2682 privateTabWidget->removeTab(privateTabWidget->indexOf(contourLinesPage));
2683 privateTabWidget->removeTab(privateTabWidget->indexOf(piePage));
2684 privateTabWidget->removeTab(privateTabWidget->indexOf(pieGeometryPage));
2685 privateTabWidget->removeTab(privateTabWidget->indexOf(pieLabelsPage));
2686 privateTabWidget->removeTab(privateTabWidget->indexOf(layerPage));
2687 privateTabWidget->removeTab(privateTabWidget->indexOf(layerGeometryPage));
2688 privateTabWidget->removeTab(privateTabWidget->indexOf(canvasPage));
2689 privateTabWidget->removeTab(privateTabWidget->indexOf(speedPage));
2690 privateTabWidget->removeTab(privateTabWidget->indexOf(layerDisplayPage));
2691 privateTabWidget->removeTab(privateTabWidget->indexOf(fontsPage));
2692 privateTabWidget->removeTab(privateTabWidget->indexOf(printPage));
2693 privateTabWidget->removeTab(privateTabWidget->indexOf(miscPage));
2694 privateTabWidget->removeTab(privateTabWidget->indexOf(functionPage));
2695 privateTabWidget->removeTab(privateTabWidget->indexOf(plotGeometryPage));
2696
2697 if (enrichmentDialog){
2698 enrichmentDialog->close();
2699 enrichmentDialog = NULL;
2700 }
2701
2702 privateTabWidget->show();
2703 }
2704
quit()2705 void PlotDialog::quit()
2706 {
2707 if (acceptParams())
2708 close();
2709 }
2710
showWorksheet()2711 void PlotDialog::showWorksheet()
2712 {
2713 ApplicationWindow *app = (ApplicationWindow *)this->parent();
2714 if (!app)
2715 return;
2716
2717 CurveTreeItem *item = (CurveTreeItem *)listBox->currentItem();
2718 if (!item)
2719 return;
2720 if (item->type() != CurveTreeItem::PlotCurveTreeItem)
2721 return;
2722
2723 app->showCurveWorksheet(item->graph(), item->plotItemIndex());
2724 close();
2725 }
2726
setPlotType(CurveTreeItem * item)2727 int PlotDialog::setPlotType(CurveTreeItem *item)
2728 {
2729 int curveType = item->plotItemStyle();
2730 if (curveType >= 0){
2731 boxPlotType->clear();
2732
2733 if (curveType == Graph::ErrorBars)
2734 boxPlotType->addItem( tr( "Error Bars" ) );
2735 else if (curveType == Graph::Pie)
2736 boxPlotType->addItem( tr( "Pie" ) );
2737 else if (curveType == Graph::VerticalBars)
2738 boxPlotType->addItem( tr( "Vertical Bars" ) );
2739 else if (curveType == Graph::HorizontalBars)
2740 boxPlotType->addItem( tr( "Horizontal Bars" ) );
2741 else if (curveType == Graph::Histogram)
2742 boxPlotType->addItem( tr( "Histogram" ) );
2743 else if (curveType == Graph::VectXYXY || curveType == Graph::VectXYAM){
2744 boxPlotType->addItem( tr( "Vector XYXY" ) );
2745 boxPlotType->addItem( tr( "Vector XYAM" ) );
2746 if (curveType == Graph::VectXYAM)
2747 boxPlotType->setCurrentIndex(1);
2748 } else if (curveType == Graph::Box)
2749 boxPlotType->addItem( tr( "Box" ) );
2750 else if (curveType == Graph::ColorMap || curveType == Graph::GrayScale || curveType == Graph::Contour)
2751 boxPlotType->insertItem(tr("Contour") + " / " + tr("Image"));
2752 else {
2753 boxPlotType->addItem( tr( "Line" ) );
2754 boxPlotType->addItem( tr( "Scatter" ) );
2755 boxPlotType->addItem( tr( "Line + Symbol" ) );
2756
2757 QwtPlotCurve *c = (QwtPlotCurve*)item->plotItem();
2758 if (!c)
2759 return -1;
2760
2761 QwtSymbol s = c->symbol();
2762 if (s.style() == QwtSymbol::NoSymbol){
2763 boxPlotType->setCurrentIndex(0);
2764 return Graph::Line;
2765 } else if (c->style() == QwtPlotCurve::NoCurve) {
2766 boxPlotType->setCurrentIndex(1);
2767 return Graph::Scatter;
2768 } else {
2769 boxPlotType->setCurrentIndex(2);
2770 return Graph::LineSymbols;
2771 }
2772 }
2773 }
2774 return curveType;
2775 }
2776
setActiveLayer(LayerItem * item)2777 void PlotDialog::setActiveLayer(LayerItem *item)
2778 {
2779 if (!item)
2780 return;
2781 item->setActive(true);
2782
2783 Graph *g = item->graph();
2784 if (!g)
2785 return;
2786
2787 curvePlotTypeBox->hide();
2788 btnWorksheet->hide();
2789 btnEditCurve->hide();
2790 btnEditCurveRange->hide();
2791
2792 boxBorderColor->blockSignals(true);
2793 boxBackgroundColor->blockSignals(true);
2794 boxCanvasColor->blockSignals(true);
2795 boxAntialiasing->blockSignals(true);
2796 boxAutoscaling->blockSignals(true);
2797 boxMargin->blockSignals(true);
2798 boxBackgroundTransparency->blockSignals(true);
2799 bkgOpacitySlider->blockSignals(true);
2800 boxCanvasTransparency->blockSignals(true);
2801 canvasOpacitySlider->blockSignals(true);
2802 boxBorderWidth->blockSignals(true);
2803
2804 boxMargin->setValue(g->margin());
2805 boxBorderWidth->setValue(g->lineWidth());
2806 boxBorderColor->setColor(g->frameColor());
2807
2808 QColor c = g->paletteBackgroundColor();
2809 boxBackgroundTransparency->setValue(100*c.alphaF());
2810 bkgOpacitySlider->setValue(boxBackgroundTransparency->value());
2811 boxBackgroundColor->setEnabled(c.alpha());
2812 c.setAlpha(255);
2813 boxBackgroundColor->setColor(c);
2814
2815 c = g->canvasBackground();
2816 int val = qRound(100*c.alphaF());
2817 boxCanvasTransparency->setValue(val);
2818 canvasOpacitySlider->setValue(val);
2819 boxCanvasColor->setEnabled(c.alpha());
2820 c.setAlpha(255);
2821 boxCanvasColor->setColor(c);
2822
2823 boxAntialiasing->setChecked(g->antialiasing());
2824 boxAutoscaling->setChecked(g->isAutoscalingEnabled());
2825 layerScaleFonts->setChecked(g->autoscaleFonts());
2826
2827 boxLayerWidth->blockSignals(true);
2828 boxLayerHeight->blockSignals(true);
2829
2830 displayCoordinates(unitBox->currentIndex(), g);
2831
2832 boxLayerWidth->blockSignals(false);
2833 boxLayerHeight->blockSignals(false);
2834
2835 aspect_ratio = (double)g->canvas()->width()/(double)g->canvas()->height();
2836
2837 boxBackgroundTransparency->blockSignals(false);
2838 bkgOpacitySlider->blockSignals(false);
2839 boxCanvasTransparency->blockSignals(false);
2840 canvasOpacitySlider->blockSignals(false);
2841 boxBorderWidth->blockSignals(false);
2842 boxBorderColor->blockSignals(false);
2843 boxBackgroundColor->blockSignals(false);
2844 boxCanvasColor->blockSignals(false);
2845 boxAntialiasing->blockSignals(false);
2846 boxAutoscaling->blockSignals(false);
2847 boxMargin->blockSignals(false);
2848
2849 speedModeBox->blockSignals(true);
2850 speedModeBox->setChecked(g->getDouglasPeukerTolerance() > 0.0);
2851 speedModeBox->blockSignals(false);
2852
2853 boxDouglasPeukerTolerance->blockSignals(true);
2854 boxDouglasPeukerTolerance->setValue(g->getDouglasPeukerTolerance());
2855 boxDouglasPeukerTolerance->blockSignals(false);
2856
2857 boxMaxPoints->blockSignals(true);
2858 boxMaxPoints->setValue(g->speedModeMaxPoints());
2859 boxMaxPoints->blockSignals(false);
2860
2861 boxMissingData->blockSignals(true);
2862 boxMissingData->setChecked(!g->isMissingDataGapEnabled());
2863 boxMissingData->blockSignals(false);
2864
2865 boxGridPosition->blockSignals(true);
2866 boxGridPosition->setChecked(g->hasGridOnTop());
2867 boxGridPosition->blockSignals(false);
2868
2869 boxLeftAxis->blockSignals(true);
2870 boxLeftAxis->setChecked(g->axisEnabled(QwtPlot::yLeft));
2871 boxLeftAxis->blockSignals(false);
2872
2873 boxRightAxis->blockSignals(true);
2874 boxRightAxis->setChecked(g->axisEnabled(QwtPlot::yRight));
2875 boxRightAxis->blockSignals(false);
2876
2877 boxBottomAxis->blockSignals(true);
2878 boxBottomAxis->setChecked(g->axisEnabled(QwtPlot::xBottom));
2879 boxBottomAxis->blockSignals(false);
2880
2881 boxTopAxis->blockSignals(true);
2882 boxTopAxis->setChecked(g->axisEnabled(QwtPlot::xTop));
2883 boxTopAxis->blockSignals(false);
2884
2885 imagePathBox->blockSignals(true);
2886 imagePathBox->setText(g->canvasBackgroundFileName());
2887 imagePathBox->blockSignals(false);
2888
2889 imageBtn->setChecked(!g->backgroundPixmap().isNull());
2890
2891 boxFramed->blockSignals(true);
2892 boxFramed->setChecked(g->canvasFrameWidth()>0);
2893 boxFramed->blockSignals(false);
2894
2895 boxFrameColor->blockSignals(true);
2896 boxFrameColor->setColor(g->canvasFrameColor());
2897 boxFrameColor->blockSignals(false);
2898
2899 boxFrameWidth->blockSignals(true);
2900 boxFrameWidth->setValue(g->canvasFrameWidth());
2901 boxFrameWidth->blockSignals(false);
2902 }
2903
updateContourLevelsDisplay(Spectrogram * sp)2904 void PlotDialog::updateContourLevelsDisplay(Spectrogram *sp)
2905 {
2906 QwtValueList levels = sp->contourLevels();
2907 levelsBox->setValue(levels.size());
2908 if (levels.size() >= 1)
2909 firstContourLineBox->setValue(levels[0]);
2910 if (levels.size() >= 2)
2911 contourLinesDistanceBox->setValue(fabs(levels[1] - levels[0]));
2912 }
2913
setActiveCurve(CurveTreeItem * item)2914 void PlotDialog::setActiveCurve(CurveTreeItem *item)
2915 {
2916 if (!item)
2917 return;
2918
2919 const QwtPlotItem *i = item->plotItem();
2920 if (!i)
2921 return;
2922
2923 Graph *g = item->graph();
2924 if (g){
2925 int index = item->plotItemIndex();
2926 btnUp->setEnabled(index > 0);
2927 btnDown->setEnabled(index < g->curveCount() - 1);
2928 }
2929
2930 item->setActive(true);
2931 listBox->scrollToItem(item);
2932 btnWorksheet->show();
2933 btnEditCurve->show();
2934 btnEditCurveRange->show();
2935
2936 //axes page
2937 boxXAxis->setCurrentIndex(i->xAxis()-2);
2938 boxYAxis->setCurrentIndex(i->yAxis());
2939
2940 if (i->rtti() == QwtPlotItem::Rtti_PlotSpectrogram){
2941 btnEditCurve->hide();
2942 btnEditCurveRange->hide();
2943 Spectrogram *sp = (Spectrogram *)i;
2944
2945 boxSpectroMatrix->setCurrentIndex(boxSpectroMatrix->findText (sp->matrix()->objectName()));
2946 boxUseMatrixFormula->setChecked(sp->useMatrixFormula());
2947 boxUseMatrixFormula->setEnabled(!sp->matrix()->formula().isEmpty());
2948
2949 imageGroupBox->setChecked(sp->testDisplayMode(QwtPlotSpectrogram::ImageMode));
2950 grayScaleBox->setChecked(sp->colorMapPolicy() == Spectrogram::GrayScale);
2951 defaultScaleBox->setChecked(sp->colorMapPolicy() == Spectrogram::Default);
2952 customScaleBox->setChecked(sp->colorMapPolicy() == Spectrogram::Custom);
2953
2954 colorMapEditor->setRange(sp->range().minValue(), sp->range().maxValue());
2955 colorMapEditor->setColorMap(sp->colorMap());
2956
2957 levelsGroupBox->setChecked(sp->testDisplayMode(QwtPlotSpectrogram::ContourMode));
2958
2959 contourLinesEditor->setSpectrogram(sp);
2960 updateContourLevelsDisplay(sp);
2961
2962 autoContourBox->setChecked(sp->useColorMapPen());
2963 defaultContourBox->setChecked(sp->defaultContourPen().style() != Qt::NoPen);
2964 customPenBtn->setChecked(sp->defaultContourPen().style() == Qt::NoPen && !sp->useColorMapPen());
2965
2966 levelsColorBox->setColor(sp->defaultContourPen().color());
2967 contourWidthBox->setValue(sp->defaultContourPen().widthF());
2968 if (sp->defaultContourPen().style() != Qt::NoPen)
2969 boxContourStyle->setCurrentIndex(sp->defaultContourPen().style() - 1);
2970 else
2971 boxContourStyle->setCurrentIndex(0);
2972
2973 axisScaleBox->setChecked(sp->hasColorScale());
2974 colorScaleBox->setCurrentItem((int)sp->colorScaleAxis());
2975 colorScaleWidthBox->setValue(sp->colorBarWidth());
2976
2977 //labels page
2978
2979 showAllLabelControls(false);
2980
2981 labelsGroupBox->blockSignals(true);
2982 labelsGroupBox->setEnabled(sp->testDisplayMode(QwtPlotSpectrogram::ContourMode));
2983 labelsGroupBox->setChecked(sp->hasLabels() && sp->testDisplayMode(QwtPlotSpectrogram::ContourMode));
2984 boxLabelsColor->setColor(sp->labelsColor());
2985 boxLabelsAngle->setValue(sp->labelsRotation());
2986
2987 boxLabelsXOffset->blockSignals(true);
2988 boxLabelsXOffset->setValue(qRound(sp->labelsXOffset()));
2989 boxLabelsXOffset->blockSignals(false);
2990
2991 boxLabelsYOffset->blockSignals(true);
2992 boxLabelsYOffset->setValue(qRound(sp->labelsYOffset()));
2993 boxLabelsYOffset->blockSignals(false);
2994 boxLabelsWhiteOut->setChecked(sp->labelsWhiteOut());
2995 labelsGroupBox->blockSignals(false);
2996
2997 if (sp->hasSelectedLabels())
2998 privateTabWidget->showPage(labelsPage);
2999 return;
3000 }
3001
3002 PlotCurve *c = (PlotCurve*)i;
3003 btnEditCurve->setVisible(c->type() != Graph::Function);
3004 btnEditCurveRange->setVisible(c->type() != Graph::Function);
3005
3006 int curveType = item->plotItemStyle();
3007 if (curveType == Graph::Pie){
3008 PieCurve *pie = (PieCurve*)i;
3009 boxPiePattern->setPattern(pie->pattern());
3010 boxPieLineWidth->setValue(pie->pen().widthF());
3011 boxPieLineColor->setColor(pie->pen().color());
3012 boxPieLineStyle->setStyle(pie->pen().style());
3013 boxFirstColor->setCurrentIndex(pie->firstColor());
3014
3015 boxPieViewAngle->blockSignals(true);
3016 boxPieViewAngle->setValue(pie->viewAngle());
3017 boxPieViewAngle->blockSignals(false);
3018 boxPieThickness->blockSignals(true);
3019 boxPieThickness->setValue(pie->thickness());
3020 boxPieThickness->blockSignals(false);
3021 boxPieStartAzimuth->blockSignals(true);
3022 boxPieStartAzimuth->setValue(pie->startAzimuth());
3023 boxPieStartAzimuth->blockSignals(false);
3024 boxPieConterClockwise->blockSignals(true);
3025 boxPieConterClockwise->setChecked(pie->counterClockwise());
3026 boxPieConterClockwise->blockSignals(false);
3027 boxRadius->blockSignals(true);
3028 boxRadius->setValue(pie->radius());
3029 boxRadius->blockSignals(false);
3030 boxPieOffset->blockSignals(true);
3031 boxPieOffset->setValue((int)pie->horizontalOffset());
3032 boxPieOffset->blockSignals(false);
3033
3034 pieAutoLabelsBox->setChecked(pie->labelsAutoFormat());
3035 boxPieValues->setChecked(pie->labelsValuesFormat());
3036 boxPiePercentages->setChecked(pie->labelsPercentagesFormat());
3037 boxPieCategories->setChecked(pie->labelCategories());
3038 boxPieEdgeDist->blockSignals(true);
3039 boxPieEdgeDist->setValue(pie->labelsEdgeDistance());
3040 boxPieEdgeDist->blockSignals(false);
3041 boxPieWedge->setChecked(pie->fixedLabelsPosition());
3042 return;
3043 }
3044
3045 //line page
3046 int style = c->style();
3047 if (curveType == Graph::Spline)
3048 style = 5;
3049 else if (curveType == Graph::VerticalSteps)
3050 style = 6;
3051 boxConnect->setCurrentIndex(style);
3052
3053 boxLineStyle->setStyle(c->pen().style());
3054 QColor lc = c->pen().color();
3055 boxLineTransparency->blockSignals(true);
3056 boxLineTransparency->setValue(qRound(100.0*lc.alphaF()));
3057 boxLineTransparency->blockSignals(false);
3058
3059 lineTransparencySlider->blockSignals(true);
3060 lineTransparencySlider->setValue(boxLineTransparency->value());
3061 lineTransparencySlider->blockSignals(false);
3062
3063 lc.setAlpha(255);
3064 boxLineColor->blockSignals(true);
3065 boxLineColor->setColor(lc);
3066 boxLineColor->blockSignals(false);
3067 boxLineWidth->blockSignals(true);
3068 boxLineWidth->setValue(c->pen().widthF());
3069 boxLineWidth->blockSignals(false);
3070 fillGroupBox->blockSignals(true);
3071 fillGroupBox->setChecked(c->brush().style() != Qt::NoBrush );
3072 fillGroupBox->blockSignals(false);
3073
3074 QColor ac = c->brush().color();
3075 int val = qRound(100*ac.alphaF());
3076 boxCurveOpacity->blockSignals(true);
3077 boxCurveOpacity->setValue(val);
3078 curveOpacitySlider->setValue(val);
3079 boxCurveOpacity->blockSignals(false);
3080
3081 ac.setAlpha(255);
3082
3083 boxAreaColor->blockSignals(true);
3084 boxAreaColor->setColor(ac);
3085 boxAreaColor->blockSignals(false);
3086
3087 boxPattern->setPattern(c->brush().style());
3088
3089 //symbol page
3090 const QwtSymbol s = c->symbol();
3091 if (s.pen().style() != Qt::NoPen){
3092 standardSymbolBtn->setChecked(true);
3093
3094 boxSymbolSize->blockSignals(true);
3095 boxSymbolSize->setValue(s.size().width()/2);
3096 boxSymbolSize->blockSignals(false);
3097
3098 boxSymbolStyle->setStyle(s.style());
3099 boxSymbolColor->blockSignals(true);
3100 boxSymbolColor->setColor(s.pen().color());
3101 boxSymbolColor->blockSignals(false);
3102
3103 boxPenWidth->blockSignals(true);
3104 boxPenWidth->setValue(s.pen().widthF());
3105 boxPenWidth->blockSignals(false);
3106
3107 bool filled = s.brush() != Qt::NoBrush;
3108 QColor fc = s.brush().color();
3109 boxSymbolTransparency->blockSignals(true);
3110 boxSymbolTransparency->setEnabled(filled);
3111 boxSymbolTransparency->setValue(qRound(100.0*fc.alphaF()));
3112 boxSymbolTransparency->blockSignals(false);
3113
3114 symbTransparencySlider->blockSignals(true);
3115 symbTransparencySlider->setEnabled(filled);
3116 symbTransparencySlider->setValue(boxSymbolTransparency->value());
3117 symbTransparencySlider->blockSignals(false);
3118
3119 boxFillSymbol->setChecked(filled);
3120 boxFillColor->setEnabled(filled);
3121 boxFillColor->blockSignals(true);
3122 fc.setAlpha(255);
3123 boxFillColor->setColor(fc);
3124 boxFillColor->blockSignals(false);
3125 } else {
3126 imageSymbolBtn->setChecked(true);
3127
3128 ImageSymbol *is = (ImageSymbol *)(&c->symbol());
3129 imageSymbolPathBox->setText(is->imagePath());
3130 symbolImageLabel->setPixmap(is->pixmap());
3131 }
3132
3133 boxSkipSymbols->blockSignals(true);
3134 boxSkipSymbols->setValue(c->skipSymbolsCount());
3135 boxSkipSymbols->setMaximum(c->dataSize());
3136 boxSkipSymbols->blockSignals(false);
3137
3138 if (c->type() == Graph::Function){
3139 functionEdit->setCurveToModify((FunctionCurve *)c);
3140 return;
3141 }
3142
3143 if (curveType == Graph::VerticalBars || curveType == Graph::HorizontalBars || curveType == Graph::Histogram){//spacing page
3144 QwtBarCurve *b = (QwtBarCurve*)i;
3145 if (b){
3146 gapBox->blockSignals(true);
3147 gapBox->setValue(b->gap());
3148 gapBox->blockSignals(false);
3149
3150 offsetBox->blockSignals(true);
3151 offsetBox->setValue(b->offset());
3152 offsetBox->blockSignals(false);
3153
3154 bool stack = b->isStacked();
3155 barsOffsetLabel->setHidden(stack);
3156 offsetBox->setHidden(stack);
3157 if (stack)
3158 gapApplyToBox->setCurrentIndex(1);
3159 }
3160 }
3161
3162 if (curveType == Graph::Histogram){//Histogram page
3163 QwtHistogram *h = (QwtHistogram*)i;
3164 if (h){
3165 automaticBox->setChecked(h->autoBinning());
3166 setAutomaticBinning();
3167 }
3168 }
3169
3170 if (curveType == Graph::VectXYXY || curveType == Graph::VectXYAM){//Vector page
3171 VectorCurve *v = (VectorCurve*)i;
3172 if (v){
3173 vectColorBox->setColor(v->color());
3174 vectWidthBox->setValue(v->width());
3175 headLengthBox->setValue(v->headLength());
3176 headAngleBox->setValue(v->headAngle());
3177 filledHeadBox->setChecked(v->filledArrowHead());
3178 vectPosBox->setCurrentIndex(v->position());
3179 updateEndPointColumns(item->text(0));
3180 }
3181 }
3182
3183 if (curveType == Graph::ErrorBars){
3184 ErrorBarsCurve *err = (ErrorBarsCurve*)i;
3185 if (err){
3186 widthBox->blockSignals(true);
3187 widthBox->setValue(err->width());
3188 widthBox->blockSignals(false);
3189 capBox->setEditText(QString::number(err->capLength()));
3190
3191 colorBox->blockSignals(true);
3192 colorBox->setColor(err->color());
3193 colorBox->blockSignals(false);
3194
3195 throughBox->blockSignals(true);
3196 throughBox->setChecked(err->throughSymbol());
3197 throughBox->blockSignals(false);
3198 plusBox->blockSignals(true);
3199 plusBox->setChecked(err->plusSide());
3200 plusBox->blockSignals(false);
3201 minusBox->blockSignals(true);
3202 minusBox->setChecked(err->minusSide());
3203 minusBox->blockSignals(false);
3204 xBox->blockSignals(true);
3205 xBox->setChecked(err->xErrors());
3206 xBox->blockSignals(false);
3207
3208 boxSkipErrorBars->blockSignals(true);
3209 boxSkipErrorBars->setMaximum(err->dataSize());
3210 boxSkipErrorBars->setValue(err->skipSymbolsCount());
3211 boxSkipErrorBars->blockSignals(false);
3212 }
3213 return;
3214 }
3215
3216 if (curveType == Graph::Box){
3217 BoxCurve *b = (BoxCurve*)i;
3218 if (b){
3219 boxMaxStyle->blockSignals(true);
3220 boxMaxStyle->setStyle(b->maxStyle());
3221 boxMaxStyle->blockSignals(false);
3222
3223 boxMinStyle->blockSignals(true);
3224 boxMinStyle->setStyle(b->minStyle());
3225 boxMinStyle->blockSignals(false);
3226
3227 boxMeanStyle->blockSignals(true);
3228 boxMeanStyle->setStyle(b->meanStyle());
3229 boxMeanStyle->blockSignals(false);
3230
3231 box99Style->blockSignals(true);
3232 box99Style->setStyle(b->p99Style());
3233 box99Style->blockSignals(false);
3234
3235 box1Style->blockSignals(true);
3236 box1Style->setStyle(b->p1Style());
3237 box1Style->blockSignals(false);
3238
3239 boxPercSize->blockSignals(true);
3240 boxPercSize->setValue(s.size().width()/2);
3241 boxPercSize->blockSignals(false);
3242
3243 QColor sc = s.brush().color();
3244 bool filled = (s.brush() != Qt::NoBrush);
3245 boxFillSymbols->blockSignals(true);
3246 boxFillSymbols->setChecked(filled);
3247 boxFillSymbols->blockSignals(false);
3248
3249 boxPercentileTransparency->setEnabled(filled);
3250 boxPercentileTransparency->blockSignals(true);
3251 boxPercentileTransparency->setValue(100.0*sc.alphaF());
3252 boxPercentileTransparency->blockSignals(false);
3253
3254 percentileTransparencySlider->setEnabled(filled);
3255 percentileTransparencySlider->blockSignals(true);
3256 percentileTransparencySlider->setValue(boxPercentileTransparency->value());
3257 percentileTransparencySlider->blockSignals(false);
3258
3259 boxPercFillColor->setEnabled(filled);
3260 boxPercFillColor->blockSignals(true);
3261 sc.setAlpha(255);
3262 boxPercFillColor->setColor(sc);
3263 boxPercFillColor->blockSignals(false);
3264
3265 boxEdgeColor->blockSignals(true);
3266 boxEdgeColor->setColor(s.pen().color());
3267 boxEdgeColor->blockSignals(false);
3268
3269 boxEdgeWidth->blockSignals(true);
3270 boxEdgeWidth->setValue(s.pen().widthF());
3271 boxEdgeWidth->blockSignals(false);
3272
3273 boxRange->setCurrentIndex (b->boxRangeType()-1);
3274
3275 boxType->blockSignals(true);
3276 boxType->setCurrentIndex (b->boxStyle());
3277 boxType->blockSignals(false);
3278
3279 boxWidth->blockSignals(true);
3280 boxWidth->setValue(b->boxWidth());
3281 boxWidth->blockSignals(false);
3282
3283 setBoxRangeType(boxRange->currentIndex());
3284 setBoxType(boxType->currentIndex());
3285 if (b->boxRangeType() == BoxCurve::SD || b->boxRangeType() == BoxCurve::SE)
3286 boxCnt->setValue(b->boxRange());
3287 else
3288 boxCoef->setValue((int)b->boxRange());
3289
3290 boxWhiskersRange->setCurrentIndex (b->whiskersRangeType());
3291 setWhiskersRange(boxWhiskersRange->currentIndex());
3292 if (b->whiskersRangeType() == BoxCurve::SD || b->whiskersRangeType() == BoxCurve::SE)
3293 whiskerCnt->setValue(b->whiskersRange());
3294 else
3295 boxWhiskersCoef->setValue((int)b->whiskersRange());
3296
3297 bool visibleLabels = b->hasVisibleLabels();
3298 boxBoxLabels->blockSignals(true);
3299 boxBoxLabels->setChecked(b->hasBoxLabels() && visibleLabels);
3300 boxBoxLabels->blockSignals(false);
3301
3302 boxWhiskerLabels->blockSignals(true);
3303 boxWhiskerLabels->setChecked(b->hasWhiskerLabels() && visibleLabels);
3304 boxWhiskerLabels->blockSignals(false);
3305
3306 privateTabWidget->setTabEnabled(privateTabWidget->indexOf(labelsPage), (b->hasBoxLabels() || b->hasWhiskerLabels()) && visibleLabels);
3307 }
3308 }
3309
3310 DataCurve *dc = (DataCurve *)i;
3311 if (!dc->table()){
3312 privateTabWidget->removeTab(privateTabWidget->indexOf(labelsPage));
3313 return;
3314 }
3315 labelsGroupBox->blockSignals(true);
3316 showAllLabelControls(true, curveType);
3317
3318 labelsGroupBox->setChecked(dc->hasVisibleLabels());
3319
3320 boxLabelsColumn->blockSignals(true);
3321 if (curveType != Graph::Box){
3322 QStringList cols = dc->table()->columnsList();
3323 boxLabelsColumn->clear();
3324 boxLabelsColumn->addItems(cols);
3325 int labelsColIndex = cols.indexOf(dc->labelsColumnName());
3326 if (labelsColIndex >= 0)
3327 boxLabelsColumn->setCurrentIndex(labelsColIndex);
3328 } else
3329 boxLabelsColumn->setCurrentIndex(((BoxCurve*)i)->labelsDisplayPolicy());
3330 boxLabelsColumn->blockSignals(false);
3331
3332 boxLabelsAngle->blockSignals(true);
3333 boxLabelsAngle->setValue(dc->labelsRotation());
3334 boxLabelsAngle->blockSignals(false);
3335
3336 boxLabelsColor->blockSignals(true);
3337 boxLabelsColor->setColor(dc->labelsColor());
3338 boxLabelsColor->blockSignals(false);
3339
3340 boxLabelsXOffset->blockSignals(true);
3341 boxLabelsXOffset->setValue(dc->labelsXOffset());
3342 boxLabelsXOffset->blockSignals(false);
3343
3344 boxLabelsYOffset->blockSignals(true);
3345 boxLabelsYOffset->setValue(dc->labelsYOffset());
3346 boxLabelsYOffset->blockSignals(false);
3347
3348 boxLabelsWhiteOut->blockSignals(true);
3349 boxLabelsWhiteOut->setChecked(dc->labelsWhiteOut());
3350 boxLabelsWhiteOut->blockSignals(false);
3351
3352 boxLabelsAlign->blockSignals(true);
3353 switch(dc->labelsAlignment()){
3354 case Qt::AlignHCenter:
3355 boxLabelsAlign->setCurrentIndex(0);
3356 break;
3357 case Qt::AlignLeft:
3358 boxLabelsAlign->setCurrentIndex(1);
3359 break;
3360 case Qt::AlignRight:
3361 boxLabelsAlign->setCurrentIndex(2);
3362 break;
3363 }
3364 boxLabelsAlign->blockSignals(false);
3365
3366 labelsGroupBox->blockSignals(false);
3367 }
3368
updateEndPointColumns(const QString & text)3369 void PlotDialog::updateEndPointColumns(const QString& text)
3370 {
3371 QStringList cols = text.split(", ", QString::SkipEmptyParts);
3372 QStringList aux = cols[0].split(": ", QString::SkipEmptyParts);
3373 QString table = aux[0];
3374 QStringList list;
3375 foreach(QString s, columnNames){
3376 if (s.contains(table))
3377 list << s;
3378 }
3379
3380 xEndBox->clear();
3381 xEndBox->insertStringList(list);
3382 xEndBox->setCurrentText(table + "_" + cols[2].remove("(X)").remove("(A)"));
3383
3384 yEndBox->clear();
3385 yEndBox->insertStringList(list);
3386 yEndBox->setCurrentText(table + "_" + cols[3].remove("(Y)").remove("(M)"));
3387 }
3388
applyCanvasSize()3389 void PlotDialog::applyCanvasSize()
3390 {
3391 if (privateTabWidget->currentWidget() != layerGeometryPage)
3392 return;
3393
3394 ApplicationWindow *app = (ApplicationWindow *)this->parent();
3395 switch(sizeApplyToBox->currentIndex()){
3396 case 1://this window
3397 {
3398 QSize size = QSize();
3399 QList<Graph *> layersLst = d_ml->layersList();
3400 foreach(Graph *g, layersLst){
3401 size = layerCanvasRect(g, boxX->value(), boxY->value(), boxLayerWidth->value(),
3402 boxLayerHeight->value(), (FrameWidget::Unit)unitBox->currentIndex()).size();
3403 g->setCanvasSize(size);
3404 }
3405 if (size.isValid())
3406 d_ml->setLayerCanvasSize(size.width(), size.height());
3407 }
3408 break;
3409
3410 case 2://all windows
3411 {
3412 QList<MdiSubWindow *> windows = app->windowsList();
3413 foreach(MdiSubWindow *w, windows){
3414 MultiLayer *ml = qobject_cast<MultiLayer *>(w);
3415 if (!ml)
3416 continue;
3417
3418 QSize size = QSize();
3419 QList<Graph *> layersLst = ml->layersList();
3420 foreach(Graph *g, layersLst){
3421 size = layerCanvasRect(g, boxX->value(), boxY->value(), boxLayerWidth->value(),
3422 boxLayerHeight->value(), (FrameWidget::Unit)unitBox->currentIndex()).size();
3423 g->setCanvasSize(size);
3424 }
3425 if (size.isValid())
3426 ml->setLayerCanvasSize(size.width(), size.height());
3427 }
3428 }
3429 break;
3430
3431 default:
3432 break;
3433 }
3434 }
3435
resizeLayerToFitImage(Graph * g)3436 void PlotDialog::resizeLayerToFitImage(Graph *g)
3437 {
3438 if (!g)
3439 return;
3440
3441 QPixmap pix = g->backgroundPixmap();
3442 if (!pix.isNull())
3443 g->setCanvasSize(pix.size());
3444 }
3445
resizeCanvasToFitImage()3446 void PlotDialog::resizeCanvasToFitImage()
3447 {
3448 if (privateTabWidget->currentWidget() != canvasPage)
3449 return;
3450
3451 ApplicationWindow *app = (ApplicationWindow *)this->parent();
3452 switch(imageApplyToBox->currentIndex()){
3453 case 0://this layer
3454 {
3455 LayerItem *item = (LayerItem *)listBox->currentItem();
3456 if (!item)
3457 return;
3458 resizeLayerToFitImage(item->graph());
3459 }
3460 break;
3461 case 1://this window
3462 {
3463 QList<Graph *> layersLst = d_ml->layersList();
3464 foreach(Graph *g, layersLst)
3465 resizeLayerToFitImage(g);
3466 }
3467 break;
3468 case 2://all windows
3469 {
3470 QList<MdiSubWindow *> windows = app->windowsList();
3471 foreach(MdiSubWindow *w, windows){
3472 MultiLayer *ml = qobject_cast<MultiLayer *>(w);
3473 if (!ml)
3474 continue;
3475
3476 QList<Graph *> layersLst = ml->layersList();
3477 foreach(Graph *g, layersLst)
3478 resizeLayerToFitImage(g);
3479 }
3480 }
3481 break;
3482 default:
3483 break;
3484 }
3485 app->modifiedProject();
3486 }
3487
applyCanvasFormatToLayer(Graph * g)3488 void PlotDialog::applyCanvasFormatToLayer(Graph *g)
3489 {
3490 if (!g)
3491 return;
3492
3493 if (colorBtn->isChecked()){
3494 g->setCanvasBackgroundImage("");
3495 QColor c = boxCanvasColor->color();
3496 c.setAlphaF(0.01*boxCanvasTransparency->value());
3497 g->setCanvasBackground(c);
3498 } else if (imageBtn->isChecked()){
3499 QColor c = Qt::white;
3500 c.setAlpha(0);
3501 g->setCanvasBackground(c);
3502 g->setCanvasBackgroundImage(imagePathBox->text());
3503 }
3504
3505 if (boxFramed->isChecked())
3506 g->setCanvasFrame(boxFrameWidth->value(), boxFrameColor->color());
3507 else
3508 g->setCanvasFrame(0);
3509 }
3510
applyCanvasFormat()3511 void PlotDialog::applyCanvasFormat()
3512 {
3513 if (privateTabWidget->currentWidget() != canvasPage)
3514 return;
3515
3516 ApplicationWindow *app = (ApplicationWindow *)this->parent();
3517 switch(imageApplyToBox->currentIndex()){
3518 case 0://this layer
3519 {
3520 LayerItem *item = (LayerItem *)listBox->currentItem();
3521 if (!item)
3522 return;
3523 applyCanvasFormatToLayer(item->graph());
3524 }
3525 break;
3526
3527 case 1://this window
3528 {
3529 QList<Graph *> layersLst = d_ml->layersList();
3530 foreach(Graph *g, layersLst)
3531 applyCanvasFormatToLayer(g);
3532 }
3533 break;
3534
3535 case 2://all windows
3536 {
3537 QList<MdiSubWindow *> windows = app->windowsList();
3538 foreach(MdiSubWindow *w, windows){
3539 MultiLayer *ml = qobject_cast<MultiLayer *>(w);
3540 if (!ml)
3541 continue;
3542
3543 QList<Graph *> layersLst = ml->layersList();
3544 foreach(Graph *g, layersLst)
3545 applyCanvasFormatToLayer(g);
3546 }
3547 }
3548 break;
3549
3550 default:
3551 break;
3552 }
3553 app->modifiedProject();
3554 }
3555
applyLayerFormat()3556 void PlotDialog::applyLayerFormat()
3557 {
3558 if (privateTabWidget->currentWidget() != layerPage)
3559 return;
3560
3561 ApplicationWindow *app = (ApplicationWindow *)this->parent();
3562 switch(backgroundApplyToBox->currentIndex()){
3563 case 0://this layer
3564 {
3565 LayerItem *item = (LayerItem *)listBox->currentItem();
3566 if (!item)
3567 return;
3568 applyFormatToLayer(item->graph());
3569 }
3570 break;
3571
3572 case 1://this window
3573 {
3574 QList<Graph *> layersLst = d_ml->layersList();
3575 foreach(Graph *g, layersLst)
3576 applyFormatToLayer(g);
3577 }
3578 break;
3579
3580 case 2://all windows
3581 {
3582 QList<MdiSubWindow *> windows = app->windowsList();
3583 foreach(MdiSubWindow *w, windows){
3584 MultiLayer *ml = qobject_cast<MultiLayer *>(w);
3585 if (!ml)
3586 continue;
3587
3588 QList<Graph *> layersLst = ml->layersList();
3589 foreach(Graph *g, layersLst)
3590 applyFormatToLayer(g);
3591 }
3592 }
3593 break;
3594
3595 default:
3596 break;
3597 }
3598 app->modifiedProject();
3599 }
3600
applyFormatToLayer(Graph * g)3601 void PlotDialog::applyFormatToLayer(Graph *g)
3602 {
3603 if (!g)
3604 return;
3605
3606 g->setFrame(boxBorderWidth->value(), boxBorderColor->color());
3607 g->setMargin(boxMargin->value());
3608
3609 QColor c = boxBackgroundColor->color();
3610 c.setAlphaF(0.01*boxBackgroundTransparency->value());
3611 g->setBackgroundColor(c);
3612
3613 g->setAntialiasing(boxAntialiasing->isChecked());
3614 g->enableAutoscaling(boxAutoscaling->isChecked());
3615 g->updateScale();
3616 g->setAutoscaleFonts(layerScaleFonts->isChecked());
3617 }
3618
acceptParams()3619 bool PlotDialog::acceptParams()
3620 {
3621 if (enrichmentDialog && privateTabWidget->isHidden()){
3622 enrichmentDialog->accept();
3623 return true;
3624 }
3625
3626 if (privateTabWidget->currentWidget() == plotGeometryPage){
3627 FrameWidget::setRect(d_ml, boxPlotX->value(), boxPlotY->value(), boxPlotWidth->value(),
3628 boxPlotHeight->value(), (FrameWidget::Unit)plotUnitBox->currentIndex());
3629 d_ml->setScaleLayersOnResize(!boxResizeLayers->isChecked());
3630 d_ml->notifyChanges();
3631 return true;
3632 } else if (privateTabWidget->currentWidget() == fontsPage){
3633 d_ml->setFonts(titleFont, axesFont, numbersFont, legendFont);
3634 d_ml->notifyChanges();
3635 return true;
3636 } else if (privateTabWidget->currentWidget() == printPage){
3637 d_ml->setScaleLayersOnPrint(boxScaleLayers->isChecked());
3638 d_ml->printCropmarks(boxPrintCrops->isChecked());
3639 d_ml->notifyChanges();
3640 return true;
3641 } else if (privateTabWidget->currentWidget() == miscPage){
3642 d_ml->linkXLayerAxes(boxLinkXAxes->isChecked());
3643 if (boxLinkAllXAxes->currentIndex() == 1){
3644 ApplicationWindow *app = (ApplicationWindow *)this->parent();
3645 if (app){
3646 QList<MdiSubWindow *> windows = app->windowsList();
3647 foreach(MdiSubWindow *w, windows){
3648 MultiLayer *ml = qobject_cast<MultiLayer *>(w);
3649 if (ml)
3650 ml->linkXLayerAxes(boxLinkXAxes->isChecked());
3651 }
3652 }
3653 }
3654 d_ml->notifyChanges();
3655 return true;
3656 } else if (privateTabWidget->currentWidget() == layerPage){
3657 applyLayerFormat();
3658 return true;
3659 } else if (privateTabWidget->currentWidget() == layerGeometryPage){
3660 LayerItem *item = (LayerItem *)listBox->currentItem();
3661 if (!item)
3662 return false;
3663 Graph *g = item->graph();
3664 if (!g)
3665 return false;
3666
3667 g->setCanvasGeometry(layerCanvasRect(g, boxX->value(), boxY->value(), boxLayerWidth->value(),
3668 boxLayerHeight->value(), (FrameWidget::Unit)unitBox->currentIndex()));
3669 g->notifyChanges();
3670
3671 applyCanvasSize();
3672
3673 ApplicationWindow *app = (ApplicationWindow *)this->parent();
3674 if (app)
3675 app->d_layer_geometry_unit = unitBox->currentIndex();
3676
3677 return true;
3678 } else if (privateTabWidget->currentWidget() == canvasPage){
3679 applyCanvasFormat();
3680 return true;
3681 } else if (privateTabWidget->currentWidget() == speedPage){
3682 LayerItem *item = (LayerItem *)listBox->currentItem();
3683 if (!item)
3684 return false;
3685 Graph *g = item->graph();
3686 if (!g)
3687 return false;
3688
3689 double tolerance = boxDouglasPeukerTolerance->value();
3690 if (!speedModeBox->isChecked())
3691 tolerance = 0;
3692
3693 g->enableDouglasPeukerSpeedMode(tolerance, boxMaxPoints->value());
3694 g->notifyChanges();
3695 return true;
3696 } else if (privateTabWidget->currentWidget() == layerDisplayPage){
3697 LayerItem *item = (LayerItem *)listBox->currentItem();
3698 if (!item)
3699 return false;
3700 Graph *g = item->graph();
3701 if (!g)
3702 return false;
3703
3704 g->showMissingDataGap(!boxMissingData->isChecked());
3705 g->setGridOnTop(boxGridPosition->isChecked());
3706
3707 bool notifyChanges = false;
3708 if (g->axisEnabled(QwtPlot::yLeft) != boxLeftAxis->isChecked()){
3709 g->enableAxis(QwtPlot::yLeft, boxLeftAxis->isChecked());
3710 notifyChanges = true;
3711 }
3712
3713 if (g->axisEnabled(QwtPlot::yRight) != boxRightAxis->isChecked()){
3714 g->enableAxis(QwtPlot::yRight, boxRightAxis->isChecked());
3715 notifyChanges = true;
3716 }
3717
3718 if (g->axisEnabled(QwtPlot::xBottom) != boxBottomAxis->isChecked()){
3719 g->enableAxis(QwtPlot::xBottom, boxBottomAxis->isChecked());
3720 notifyChanges = true;
3721 }
3722
3723 if (g->axisEnabled(QwtPlot::xTop) != boxTopAxis->isChecked()){
3724 g->enableAxis(QwtPlot::xTop, boxTopAxis->isChecked());
3725 notifyChanges = true;
3726 }
3727
3728 if (notifyChanges)
3729 g->notifyChanges();
3730
3731 return true;
3732 }
3733
3734 QTreeWidgetItem *it = listBox->currentItem();
3735 if (!it)
3736 return false;
3737
3738 CurveTreeItem *item = (CurveTreeItem *)it;
3739 QwtPlotItem *plotItem = (QwtPlotItem *)item->plotItem();
3740 if (!plotItem)
3741 return false;
3742
3743 Graph *graph = item->graph();
3744 if (!graph)
3745 return false;
3746
3747 if (privateTabWidget->currentPage() == axesPage){
3748 plotItem->setAxis(boxXAxis->currentIndex() + 2, boxYAxis->currentIndex());
3749 if (graph->isAutoscalingEnabled())
3750 graph->setAutoScale();
3751 graph->updateAxesTitles();
3752 return true;
3753 } else if (privateTabWidget->currentPage() == spectroValuesPage){
3754 Spectrogram *sp = (Spectrogram *)plotItem;
3755 if (!sp || sp->rtti() != QwtPlotItem::Rtti_PlotSpectrogram)
3756 return false;
3757
3758 ApplicationWindow *app = (ApplicationWindow *)this->parent();
3759 Matrix *m = app->matrix(boxSpectroMatrix->currentText());
3760 if (!m)
3761 return false;
3762 if (!sp->setMatrix(m, boxUseMatrixFormula->isChecked()))
3763 boxUseMatrixFormula->setChecked(false);
3764 updateContourLevelsDisplay(sp);
3765 } else if (privateTabWidget->currentPage() == spectrogramPage){
3766 Spectrogram *sp = (Spectrogram *)plotItem;
3767 if (!sp || sp->rtti() != QwtPlotItem::Rtti_PlotSpectrogram)
3768 return false;
3769
3770 sp->setDisplayMode(QwtPlotSpectrogram::ImageMode, imageGroupBox->isChecked());
3771
3772 if (grayScaleBox->isChecked()){
3773 sp->setGrayScale();
3774 colorMapEditor->setColorMap(LinearColorMap(Qt::black, Qt::white));
3775 } else if (defaultScaleBox->isChecked()){
3776 sp->setDefaultColorMap();
3777 colorMapEditor->setColorMap(sp->colorMap());
3778 } else
3779 sp->setCustomColorMap(colorMapEditor->colorMap());
3780
3781 sp->showColorScale((QwtPlot::Axis)colorScaleBox->currentItem(), axisScaleBox->isChecked());
3782 sp->setColorBarWidth(colorScaleWidthBox->value());
3783
3784 //Update axes page
3785 boxXAxis->setCurrentIndex(sp->xAxis() - 2);
3786 boxYAxis->setCurrentIndex(sp->yAxis());
3787 } else if (privateTabWidget->currentPage() == contourLinesPage){
3788 Spectrogram *sp = (Spectrogram *)plotItem;
3789 if (!sp || sp->rtti() != QwtPlotItem::Rtti_PlotSpectrogram)
3790 return false;
3791
3792 if (defaultContourBox->isChecked()){
3793 QPen pen = QPen(levelsColorBox->color(), contourWidthBox->value(), boxContourStyle->style());
3794 sp->setDefaultContourPen(pen);
3795 } else if (customPenBtn->isChecked())
3796 contourLinesEditor->updateContourPens();
3797 else
3798 sp->setColorMapPen();
3799
3800 contourLinesEditor->updateContourLevels();
3801
3802 sp->setDisplayMode(QwtPlotSpectrogram::ContourMode, levelsGroupBox->isChecked());
3803
3804 labelsGroupBox->setEnabled(levelsGroupBox->isChecked());
3805
3806 if (!levelsGroupBox->isChecked()){
3807 labelsGroupBox->setChecked(false);
3808 sp->showContourLineLabels(false);
3809 }
3810 } else if (privateTabWidget->currentPage() == linePage){
3811 graph->setCurveStyle(item->plotItemIndex(), boxConnect->currentIndex());
3812
3813 QColor col = boxAreaColor->color();
3814 col.setAlphaF(0.01*boxCurveOpacity->value());
3815 QBrush br = QBrush(col, boxPattern->getSelectedPattern());
3816 if (!fillGroupBox->isChecked())
3817 br = QBrush();
3818
3819 QColor lc = boxLineColor->color();
3820 lc.setAlphaF(0.01*boxLineTransparency->value());
3821 QPen pen = QPen(lc, boxLineWidth->value(), boxLineStyle->style(), Qt::SquareCap, Qt::MiterJoin);
3822 pen.setCosmetic(true);
3823 QwtPlotCurve *curve = (QwtPlotCurve *)plotItem;
3824 curve->setPen(pen);
3825 curve->setBrush(br);
3826
3827 applyLineFormat((QwtPlotCurve *)plotItem);
3828 } else if (privateTabWidget->currentPage() == symbolPage)
3829 applySymbolsFormat((QwtPlotCurve *)plotItem);
3830 else if (privateTabWidget->currentPage() == histogramPage){
3831 QwtHistogram *h = (QwtHistogram *)plotItem;
3832 if (!h)
3833 return false;
3834
3835 if (h->autoBinning() == automaticBox->isChecked() &&
3836 h->binSize() == binSizeBox->value() &&
3837 h->begin() == histogramBeginBox->value() &&
3838 h->end() == histogramEndBox->value()) return true;
3839
3840 if (binSizeBox->value() <= 0){
3841 QMessageBox::critical(this, tr("QtiPlot - Bin size input error"), tr("Please enter a positive bin size value!"));
3842 binSizeBox->blockSignals(true);
3843 binSizeBox->setValue(h->binSize());
3844 binSizeBox->blockSignals(false);
3845 binSizeBox->setFocus();
3846 return false;
3847 }
3848
3849 h->setBinning(automaticBox->isChecked(), binSizeBox->value(), histogramBeginBox->value(), histogramEndBox->value());
3850 h->loadData();
3851 graph->updateScale();
3852 graph->notifyChanges();
3853
3854 setAutomaticBinning(automaticBox->isChecked());
3855 return true;
3856 } else if (privateTabWidget->currentPage() == spacingPage){
3857 graph->setBarsGap(item->plotItemIndex(), gapBox->value(), offsetBox->value());
3858 if (gapApplyToBox->currentIndex())
3859 applyGap(graph);
3860 } else if (privateTabWidget->currentPage() == vectPage){
3861 ApplicationWindow *app = (ApplicationWindow *)this->parent();
3862 if (!app)
3863 return false;
3864
3865 QString xEndCol = xEndBox->currentText();
3866 QString yEndCol = yEndBox->currentText();
3867 Table* w = app->table(xEndCol);
3868 if (!w)
3869 return false;
3870
3871 graph->updateVectorsLayout(item->plotItemIndex(), vectColorBox->color(),
3872 vectWidthBox->value(), headLengthBox->value(), headAngleBox->value(),
3873 filledHeadBox->isChecked(), vectPosBox->currentIndex(), xEndCol, yEndCol);
3874
3875 VectorCurve *v = (VectorCurve*)item->plotItem();
3876 QString tableName = v->table()->name();
3877 item->setText(0, tableName + ": " + v->plotAssociation().replaceInStrings(tableName + "_", "").join(", "));
3878 return true;
3879 } else if (privateTabWidget->currentPage() == errorsPage){
3880 ErrorBarsCurve *err = (ErrorBarsCurve *)item->plotItem();
3881 if (!err)
3882 return false;
3883
3884 applyErrorBarFormat(err);
3885 } else if (privateTabWidget->currentPage() == piePage){
3886 PieCurve *pie = (PieCurve*)plotItem;
3887 pie->setPen(QPen(boxPieLineColor->color(), boxPieLineWidth->value(), boxPieLineStyle->style()));
3888 pie->setBrushStyle(boxPiePattern->getSelectedPattern());
3889 pie->setFirstColor(boxFirstColor->currentIndex());
3890 } else if (privateTabWidget->currentPage() == pieGeometryPage){
3891 PieCurve *pie = (PieCurve*)plotItem;
3892 pie->setViewAngle(boxPieViewAngle->value());
3893 pie->setThickness(boxPieThickness->value());
3894 pie->setRadius(boxRadius->value());
3895 pie->setHorizontalOffset(boxPieOffset->value());
3896 pie->setStartAzimuth(boxPieStartAzimuth->value());
3897 pie->setCounterClockwise(boxPieConterClockwise->isChecked());
3898 } else if (privateTabWidget->currentPage() == pieLabelsPage){
3899 PieCurve *pie = (PieCurve*)plotItem;
3900 pie->setLabelsAutoFormat(pieAutoLabelsBox->isChecked());
3901 pie->setLabelValuesFormat(boxPieValues->isChecked());
3902 pie->setLabelPercentagesFormat(boxPiePercentages->isChecked());
3903 pie->setLabelCategories(boxPieCategories->isChecked());
3904 pie->setFixedLabelsPosition(boxPieWedge->isChecked());
3905 pie->setLabelsEdgeDistance(boxPieEdgeDist->value());
3906 graph->replot();
3907 } else if (privateTabWidget->currentPage() == percentilePage){
3908 applyPercentileFormat((BoxCurve*)plotItem);
3909 } else if (privateTabWidget->currentPage() == boxPage){
3910 applyBoxWhiskersFormat((BoxCurve*)plotItem);
3911 } else if (privateTabWidget->currentPage() == labelsPage){
3912 if (plotItem->rtti() == QwtPlotItem::Rtti_PlotCurve){
3913 DataCurve *c = (DataCurve *)plotItem;
3914
3915 QString text = item->text(0);
3916 QStringList t = text.split(": ", QString::SkipEmptyParts);
3917 QString table = t[0];
3918 QStringList cols = t[1].split(",", QString::SkipEmptyParts);
3919
3920 if (c->type() != Graph::Box){
3921 bool specialCurve = (c->type() == Graph::Histogram);
3922 if (labelsGroupBox->isChecked() && !specialCurve){
3923 c->setLabelsColumnName(boxLabelsColumn->currentText());
3924
3925 if (cols.count() == 3)
3926 cols[2] = boxLabelsColumn->currentText().remove(table + "_") + "(L)";
3927 else if (cols.count() == 5)//vector curves
3928 cols[4] = boxLabelsColumn->currentText().remove(table + "_") + "(L)";
3929 else
3930 cols << boxLabelsColumn->currentText().remove(table + "_") + "(L)";
3931 item->setText(0, table + ": " + cols.join(","));
3932 } else {
3933 if (specialCurve){
3934 if (!labelsGroupBox->isChecked())
3935 c->clearLabels();
3936 else
3937 c->setLabelsColumnName(QString());
3938 } else if (cols.size() > 1){
3939 c->setLabelsColumnName(QString());
3940 cols.pop_back();
3941 item->setText(0, table + ": " + cols.join(","));
3942 }
3943 }
3944 }
3945 }
3946 applyLabelsFormat(plotItem);
3947 } else if (privateTabWidget->currentPage() == functionPage){
3948 functionEdit->apply();
3949 }
3950
3951 graph->replot();
3952 graph->notifyChanges();
3953 return true;
3954 }
3955
setAutomaticBinning(bool on)3956 void PlotDialog::setAutomaticBinning(bool on)
3957 {
3958 GroupBoxH->setEnabled(!on);
3959 if (on){
3960 QTreeWidgetItem *it = listBox->currentItem();
3961 if (!it)
3962 return;
3963
3964 CurveTreeItem *item = (CurveTreeItem *)it;
3965 QwtPlotItem *plotItem = (QwtPlotItem *)item->plotItem();
3966 if (!plotItem)
3967 return;
3968
3969 QwtHistogram *h = (QwtHistogram *)plotItem;
3970 if (!h || h->type() != Graph::Histogram)
3971 return;
3972
3973 binSizeBox->blockSignals(true);
3974 binSizeBox->setValue(h->binSize());
3975 binSizeBox->blockSignals(false);
3976
3977 histogramBeginBox->blockSignals(true);
3978 histogramBeginBox->setValue(h->begin());
3979 histogramBeginBox->blockSignals(false);
3980
3981 histogramEndBox->blockSignals(true);
3982 histogramEndBox->setValue(h->end());
3983 histogramEndBox->blockSignals(false);
3984 }
3985 }
3986
setBoxType(int index)3987 void PlotDialog::setBoxType(int index)
3988 {
3989 boxCoeffLabel->hide();
3990 boxRangeLabel->hide();
3991 boxRange->hide();
3992 boxCoef->hide();
3993 boxCntLabel->hide();
3994 boxCnt->hide();
3995
3996 if (index != BoxCurve::NoBox && index != BoxCurve::WindBox)
3997 {
3998 boxRange->show();
3999 boxRangeLabel->show();
4000 int id = boxRange->currentIndex() + 1;
4001 if (id == BoxCurve::UserDef)
4002 {
4003 boxCoef->show();
4004 boxCoeffLabel->show();
4005 }
4006 else if (id == BoxCurve::SD || id == BoxCurve::SE)
4007 {
4008 boxCntLabel->show();
4009 boxCnt->show();
4010 }
4011 }
4012 }
4013
setBoxRangeType(int index)4014 void PlotDialog::setBoxRangeType(int index)
4015 {
4016 boxCoeffLabel->hide();
4017 boxCoef->hide();
4018 boxCntLabel->hide();
4019 boxCnt->hide();
4020
4021 index++;
4022 if (index == BoxCurve::UserDef)
4023 {
4024 boxCoeffLabel->show();
4025 boxCoef->show();
4026 }
4027 else if (index == BoxCurve::SD || index == BoxCurve::SE)
4028 {
4029 boxCntLabel->show();
4030 boxCnt->show();
4031 }
4032 }
4033
setWhiskersRange(int index)4034 void PlotDialog::setWhiskersRange(int index)
4035 {
4036 whiskerCoeffLabel->hide();
4037 boxWhiskersCoef->hide();
4038 whiskerCntLabel->hide();
4039 whiskerCnt->hide();
4040
4041 if (index == BoxCurve::UserDef)
4042 {
4043 whiskerCoeffLabel->show();
4044 boxWhiskersCoef->show();
4045 }
4046 else if (index == BoxCurve::SD || index == BoxCurve::SE)
4047 {
4048 whiskerCntLabel->show();
4049 whiskerCnt->show();
4050 }
4051 }
4052
customVectorsPage(bool angleMag)4053 void PlotDialog::customVectorsPage(bool angleMag)
4054 {
4055 if (angleMag)
4056 {
4057 GroupBoxVectEnd->setTitle(tr("Vector Data"));
4058 labelXEnd->setText(tr("Angle"));
4059 labelYEnd->setText(tr("Magnitude"));
4060 labelPosition->show();
4061 vectPosBox->show();
4062 }
4063 else
4064 {
4065 GroupBoxVectEnd->setTitle(tr("End Point"));
4066 labelXEnd->setText(tr("X End"));
4067 labelYEnd->setText(tr("Y End"));
4068 labelPosition->hide();
4069 vectPosBox->hide();
4070 }
4071 }
4072
showColorMapEditor(bool)4073 void PlotDialog::showColorMapEditor(bool)
4074 {
4075 if (grayScaleBox->isChecked() || defaultScaleBox->isChecked())
4076 colorMapEditor->hide();
4077 else {
4078 colorMapEditor->show();
4079 colorMapEditor->setFocus();
4080 }
4081 }
4082
showDefaultContourLinesBox(bool)4083 void PlotDialog::showDefaultContourLinesBox(bool)
4084 {
4085 if (autoContourBox->isChecked())
4086 defaultPenBox->hide();
4087 else
4088 defaultPenBox->show();
4089 }
4090
showCustomPenColumn(bool on)4091 void PlotDialog::showCustomPenColumn(bool on)
4092 {
4093 contourLinesEditor->showPenColumn(on);
4094 if (on)
4095 defaultPenBox->hide();
4096 }
4097
updateTreeWidgetItem(QTreeWidgetItem * item)4098 void PlotDialog::updateTreeWidgetItem(QTreeWidgetItem *item)
4099 {
4100 if (item->type() != QTreeWidgetItem::Type)
4101 return;
4102
4103 if (item->isExpanded())
4104 item->setIcon(0, QIcon(":/folder_open.png"));
4105 else
4106 item->setIcon(0, QIcon(":/folder_closed.png"));
4107 }
4108
updateVisibility()4109 void PlotDialog::updateVisibility()
4110 {
4111 QTreeWidgetItem *item = listBox->currentItem();
4112 if (!item)
4113 return;
4114
4115 item->setCheckState(0, item->checkState(0) == Qt::Unchecked ? Qt::Checked : Qt::Unchecked);
4116 updateVisibility(item, 0);
4117 }
4118
updateVisibility(QTreeWidgetItem * item,int column)4119 void PlotDialog::updateVisibility(QTreeWidgetItem *item, int column)
4120 {
4121 if (!item || column)
4122 return;
4123
4124 bool checked = (item->checkState(0) == Qt::Checked);
4125 if (item->type() == CurveTreeItem::PlotCurveTreeItem){
4126 PlotCurve *curve = (PlotCurve *)((CurveTreeItem *)item)->plotItem();
4127 if (curve->isVisible() != checked)
4128 ((CurveTreeItem *)item)->graph()->notifyChanges();
4129 curve->setVisible(checked);
4130 curve->plot()->replot();
4131 } else if (item->type() == FrameWidgetTreeItem::FrameWidgetItem){
4132 FrameWidget *fw = ((FrameWidgetTreeItem *)item)->frameWidget();
4133 if (fw->isVisible() != checked)
4134 ((FrameWidgetTreeItem *)item)->graph()->notifyChanges();
4135 fw->setVisible(checked);
4136 }
4137 }
4138
updateBackgroundTransparency(int alpha)4139 void PlotDialog::updateBackgroundTransparency(int alpha)
4140 {
4141 boxBackgroundColor->setEnabled(alpha);
4142 applyLayerFormat();
4143 }
4144
updateCanvasTransparency(int alpha)4145 void PlotDialog::updateCanvasTransparency(int alpha)
4146 {
4147 boxCanvasColor->setEnabled(alpha);
4148 applyCanvasFormat();
4149 }
4150
setTitlesFont()4151 void PlotDialog::setTitlesFont()
4152 {
4153 bool ok;
4154 QFont font = QFontDialog::getFont(&ok,titleFont,this);
4155 if ( ok )
4156 titleFont = font;
4157 }
4158
setAxesLabelsFont()4159 void PlotDialog::setAxesLabelsFont()
4160 {
4161 bool ok;
4162 QFont font = QFontDialog::getFont(&ok,axesFont,this);
4163 if ( ok )
4164 axesFont = font;
4165 }
4166
setAxesNumbersFont()4167 void PlotDialog::setAxesNumbersFont()
4168 {
4169 bool ok;
4170 QFont font = QFontDialog::getFont(&ok,numbersFont,this);
4171 if ( ok )
4172 numbersFont = font;
4173 }
4174
setLegendsFont()4175 void PlotDialog::setLegendsFont()
4176 {
4177 bool ok;
4178 QFont font = QFontDialog::getFont(&ok, legendFont,this);
4179 if ( ok )
4180 legendFont = font;
4181 }
4182
initFonts(const QFont & titlefont,const QFont & axesfont,const QFont & numbersfont,const QFont & legendfont)4183 void PlotDialog::initFonts(const QFont& titlefont, const QFont& axesfont, const QFont& numbersfont, const QFont& legendfont)
4184 {
4185 axesFont = axesfont;
4186 titleFont = titlefont;
4187 numbersFont = numbersfont;
4188 legendFont = legendfont;
4189 }
4190
adjustLayerHeight(double width)4191 void PlotDialog::adjustLayerHeight(double width)
4192 {
4193 if (keepRatioBox->isChecked()){
4194 boxLayerHeight->blockSignals(true);
4195 boxLayerHeight->setValue(width/aspect_ratio);
4196 boxLayerHeight->blockSignals(false);
4197 } else
4198 aspect_ratio = width/boxLayerHeight->value();
4199 }
4200
adjustLayerWidth(double height)4201 void PlotDialog::adjustLayerWidth(double height)
4202 {
4203 if (keepRatioBox->isChecked()){
4204 boxLayerWidth->blockSignals(true);
4205 boxLayerWidth->setValue(height*aspect_ratio);
4206 boxLayerWidth->blockSignals(false);
4207 } else
4208 aspect_ratio = boxLayerWidth->value()/height;
4209 }
4210
adjustPlotHeight(double width)4211 void PlotDialog::adjustPlotHeight(double width)
4212 {
4213 if (keepPlotRatioBox->isChecked()){
4214 boxPlotHeight->blockSignals(true);
4215 boxPlotHeight->setValue(width/plot_aspect_ratio);
4216 boxPlotHeight->blockSignals(false);
4217 } else
4218 plot_aspect_ratio = width/boxPlotHeight->value();
4219 }
4220
adjustPlotWidth(double height)4221 void PlotDialog::adjustPlotWidth(double height)
4222 {
4223 if (keepPlotRatioBox->isChecked()){
4224 boxPlotWidth->blockSignals(true);
4225 boxPlotWidth->setValue(height*plot_aspect_ratio);
4226 boxPlotWidth->blockSignals(false);
4227 } else
4228 plot_aspect_ratio = boxPlotWidth->value()/height;
4229 }
4230
closeEvent(QCloseEvent * e)4231 void PlotDialog::closeEvent(QCloseEvent* e)
4232 {
4233 ApplicationWindow *app = qobject_cast<ApplicationWindow *>(this->parent());
4234 if (app){
4235 app->d_extended_plot_dialog = btnMore->isChecked ();
4236 app->d_keep_aspect_ration = keepRatioBox->isChecked() || keepPlotRatioBox->isChecked();
4237 }
4238
4239 e->accept();
4240 }
4241
chooseLabelsFont()4242 void PlotDialog::chooseLabelsFont()
4243 {
4244 QTreeWidgetItem *item = listBox->currentItem();
4245 if (!item || item->type() != CurveTreeItem::PlotCurveTreeItem)
4246 return;
4247
4248 const QwtPlotItem *i = ((CurveTreeItem *)item)->plotItem();
4249 Graph *graph = ((CurveTreeItem *)item)->graph();
4250 if (!i || !graph)
4251 return;
4252
4253 QFont font = QFont();
4254 bool spectrogram = false;
4255 if (i->rtti() == QwtPlotItem::Rtti_PlotSpectrogram){
4256 spectrogram = true;
4257 font = ((Spectrogram *)i)->labelsFont();
4258 } else
4259 font = ((DataCurve *)i)->labelsFont();
4260
4261 bool okF;
4262 QFont fnt = QFontDialog::getFont(&okF, font, this);
4263 if (okF && fnt != font)
4264 setLabelsFont(fnt, graph, i);
4265 }
4266
setLabelsFontToPlotItem(const QFont & font,const QwtPlotItem * i)4267 void PlotDialog::setLabelsFontToPlotItem(const QFont& font, const QwtPlotItem *i)
4268 {
4269 if (!i)
4270 return;
4271
4272 if (i->rtti() == QwtPlotItem::Rtti_PlotSpectrogram)
4273 ((Spectrogram *)i)->setLabelsFont(font);
4274 else
4275 ((DataCurve *)i)->setLabelsFont(font);
4276 }
4277
setLabelsFontToLayer(const QFont & font,Graph * g)4278 void PlotDialog::setLabelsFontToLayer(const QFont& font, Graph *g)
4279 {
4280 if (!g)
4281 return;
4282
4283 QList<QwtPlotItem *> lst = g->curvesList();
4284 foreach (QwtPlotItem *it, lst)
4285 setLabelsFontToPlotItem(font, it);
4286
4287 g->replot();
4288 }
4289
setLabelsFont(const QFont & font,Graph * plot,const QwtPlotItem * i)4290 void PlotDialog::setLabelsFont(const QFont& font, Graph *plot, const QwtPlotItem *i)
4291 {
4292 ApplicationWindow *app = (ApplicationWindow *)this->parent();
4293 switch(boxLabelsFormatApplyToBox->currentIndex()){
4294 case 0://selected curve
4295 setLabelsFontToPlotItem(font, i);
4296 plot->replot();
4297 break;
4298 case 1://this layer
4299 setLabelsFontToLayer(font, plot);
4300 break;
4301 case 2://this window
4302 {
4303 QList<Graph *> layersLst = plot->multiLayer()->layersList();
4304 foreach(Graph *g, layersLst)
4305 setLabelsFontToLayer(font, g);
4306 }
4307 break;
4308 case 3://all windows
4309 {
4310 QList<MdiSubWindow *> windows = app->windowsList();
4311 foreach(MdiSubWindow *w, windows){
4312 MultiLayer *ml = qobject_cast<MultiLayer *>(w);
4313 if (!ml)
4314 continue;
4315
4316 QList<Graph *> layersLst = ml->layersList();
4317 foreach(Graph *g, layersLst)
4318 setLabelsFontToLayer(font, g);
4319 }
4320 }
4321 break;
4322 default:
4323 break;
4324 }
4325 app->modifiedProject();
4326 }
4327
labelsAlignment()4328 int PlotDialog::labelsAlignment()
4329 {
4330 int align = -1;
4331 switch (boxLabelsAlign->currentIndex())
4332 {
4333 case 0:
4334 align = Qt::AlignHCenter;
4335 break;
4336
4337 case 1:
4338 align = Qt::AlignLeft;
4339 break;
4340
4341 case 2:
4342 align = Qt::AlignRight;
4343 break;
4344 }
4345 return align;
4346 }
4347
displayPlotCoordinates(int unit)4348 void PlotDialog::displayPlotCoordinates(int unit)
4349 {
4350 if (unit == FrameWidget::Pixel || unit == FrameWidget::Point){
4351 boxPlotX->setFormat('f', 0);
4352 boxPlotY->setFormat('f', 0);
4353 boxPlotWidth->setFormat('f', 0);
4354 boxPlotHeight->setFormat('f', 0);
4355
4356 boxPlotX->setSingleStep(1.0);
4357 boxPlotY->setSingleStep(1.0);
4358 boxPlotWidth->setSingleStep(1.0);
4359 boxPlotHeight->setSingleStep(1.0);
4360 } else {
4361 boxPlotX->setFormat('g', 6);
4362 boxPlotY->setFormat('g', 6);
4363 boxPlotWidth->setFormat('g', 6);
4364 boxPlotHeight->setFormat('g', 6);
4365
4366 boxPlotX->setSingleStep(0.1);
4367 boxPlotY->setSingleStep(0.1);
4368 boxPlotWidth->setSingleStep(0.1);
4369 boxPlotHeight->setSingleStep(0.1);
4370 }
4371
4372 plot_aspect_ratio = (double)d_ml->width()/(double)d_ml->height();
4373
4374 boxPlotX->setValue(FrameWidget::xIn(d_ml, (FrameWidget::Unit)unit));
4375 boxPlotY->setValue(FrameWidget::yIn(d_ml, (FrameWidget::Unit)unit));
4376 boxPlotWidth->setValue(FrameWidget::widthIn(d_ml, (FrameWidget::Unit)unit));
4377 boxPlotHeight->setValue(FrameWidget::heightIn(d_ml, (FrameWidget::Unit)unit));
4378 }
4379
displayCoordinates(int unit,Graph * g)4380 void PlotDialog::displayCoordinates(int unit, Graph *g)
4381 {
4382 if (!g){
4383 QTreeWidgetItem *item = listBox->currentItem();
4384 if (item){
4385 g = ((LayerItem *)item)->graph();
4386 if (!g)
4387 return;
4388 }
4389 }
4390
4391 if (unit == FrameWidget::Pixel || unit == FrameWidget::Point){
4392 boxX->setFormat('f', 0);
4393 boxY->setFormat('f', 0);
4394 boxLayerWidth->setFormat('f', 0);
4395 boxLayerHeight->setFormat('f', 0);
4396
4397 boxX->setSingleStep(1.0);
4398 boxY->setSingleStep(1.0);
4399 boxLayerWidth->setSingleStep(1.0);
4400 boxLayerHeight->setSingleStep(1.0);
4401 } else {
4402 boxX->setFormat('g', 6);
4403 boxY->setFormat('g', 6);
4404 boxLayerWidth->setFormat('g', 6);
4405 boxLayerHeight->setFormat('g', 6);
4406
4407 boxX->setSingleStep(0.1);
4408 boxY->setSingleStep(0.1);
4409 boxLayerWidth->setSingleStep(0.1);
4410 boxLayerHeight->setSingleStep(0.1);
4411 }
4412
4413 QwtPlotCanvas *canvas = g->canvas();
4414 aspect_ratio = (double)canvas->width()/(double)canvas->height();
4415
4416 boxX->setValue(FrameWidget::xIn(canvas, (FrameWidget::Unit)unit) + FrameWidget::xIn(g, (FrameWidget::Unit)unit));
4417 boxY->setValue(FrameWidget::yIn(canvas, (FrameWidget::Unit)unit) + FrameWidget::yIn(g, (FrameWidget::Unit)unit));
4418 boxLayerWidth->setValue(FrameWidget::widthIn(canvas, (FrameWidget::Unit)unit));
4419 boxLayerHeight->setValue(FrameWidget::heightIn(canvas, (FrameWidget::Unit)unit));
4420 }
4421
setLayerDefaultValues()4422 void PlotDialog::setLayerDefaultValues()
4423 {
4424 ApplicationWindow *app = (ApplicationWindow *)this->parent();
4425 if (!app)
4426 return;
4427
4428 app->d_graph_background_color = boxBackgroundColor->color();
4429 app->d_graph_background_opacity = boxBackgroundTransparency->value();
4430 app->d_graph_border_color = boxBorderColor->color();
4431 app->d_graph_border_width = boxBorderWidth->value();
4432 app->defaultPlotMargin = boxMargin->value();
4433 app->antialiasing2DPlots = boxAntialiasing->isChecked();
4434
4435 app->saveSettings();
4436 }
4437
setCanvasDefaultValues()4438 void PlotDialog::setCanvasDefaultValues()
4439 {
4440 ApplicationWindow *app = (ApplicationWindow *)this->parent();
4441 if (!app)
4442 return;
4443
4444 app->d_graph_canvas_color = boxCanvasColor->color();
4445 app->d_graph_canvas_opacity = boxCanvasTransparency->value();
4446
4447 if (boxFramed->isChecked())
4448 app->canvasFrameWidth = boxFrameWidth->value();
4449 else
4450 app->canvasFrameWidth = 0;
4451
4452 app->d_canvas_frame_color = boxFrameColor->color();
4453
4454 app->saveSettings();
4455 }
4456
showAllLabelControls(bool show,int curveType)4457 void PlotDialog::showAllLabelControls(bool show, int curveType)
4458 {
4459 bool on = (curveType != Graph::Histogram);
4460 boxLabelsColumn->setVisible(show && on);
4461 labelsColumnLbl->setVisible(show && on);
4462
4463 if (curveType == Graph::Box){
4464 labelsColumnLbl->setText(tr("Display"));
4465 boxLabelsColumn->clear();
4466 boxLabelsColumn->addItem(tr("Percentage"));
4467 boxLabelsColumn->addItem(tr("Value"));
4468 boxLabelsColumn->addItem(tr("Percentage (Value)"));
4469 boxLabelsColumn->addItem(tr("Value (Percentage)"));
4470 labelsGroupBox->setCheckable(false);
4471 labelsGroupBox->setTitle("");
4472 } else {
4473 labelsColumnLbl->setText(tr("Column"));
4474 labelsGroupBox->setTitle(tr("&Show"));
4475 labelsGroupBox->setCheckable(true);
4476 }
4477
4478 boxLabelsAlign->setVisible(show);
4479 justifyLabelsLbl->setVisible(show);
4480 }
4481
setEquidistantLevels()4482 void PlotDialog::setEquidistantLevels()
4483 {
4484 QTreeWidgetItem *it = listBox->currentItem();
4485 if (!it)
4486 return;
4487
4488 CurveTreeItem *item = (CurveTreeItem *)it;
4489 QwtPlotItem *plotItem = (QwtPlotItem *)item->plotItem();
4490 if (!plotItem)
4491 return;
4492
4493 Spectrogram *sp = (Spectrogram *)plotItem;
4494 if (!sp || sp->rtti() != QwtPlotItem::Rtti_PlotSpectrogram)
4495 return;
4496
4497 QwtValueList levels;
4498 double firstVal = firstContourLineBox->value();
4499 for (int i = 0; i < levelsBox->value(); i++)
4500 levels << firstVal + i*contourLinesDistanceBox->value();
4501 sp->setContourLevels(levels);
4502 sp->plot()->replot();
4503 contourLinesEditor->updateContents();
4504 }
4505
applyLineFormatToLayer(Graph * g)4506 void PlotDialog::applyLineFormatToLayer(Graph *g)
4507 {
4508 if (!g)
4509 return;
4510
4511 QList<QwtPlotItem *> lst = g->curvesList();
4512 int i = -1;
4513 foreach (QwtPlotItem *it, lst){
4514 i++;
4515 if (it->rtti() == QwtPlotItem::Rtti_PlotSpectrogram)
4516 continue;
4517
4518 PlotCurve *c = (PlotCurve *)it;
4519 if (c->type() == Graph::ErrorBars)
4520 continue;
4521
4522 QColor lc = c->pen().color();
4523 if (boxApplyColorTo->isChecked())
4524 lc = boxLineColor->color();
4525 lc.setAlphaF(0.01*boxLineTransparency->value());
4526
4527 QPen pen = QPen(lc, boxLineWidth->value(), boxLineStyle->style(), Qt::SquareCap, Qt::MiterJoin);
4528 pen.setCosmetic(true);
4529 c->setPen(pen);
4530
4531 g->setCurveStyle(i, boxConnect->currentIndex());
4532 }
4533 g->replot();
4534 }
4535
applyLineFormat(QwtPlotCurve * c)4536 void PlotDialog::applyLineFormat(QwtPlotCurve *c)
4537 {
4538 if (!c || privateTabWidget->currentPage() != linePage)
4539 return;
4540
4541 Graph *layer = (Graph *)c->plot();
4542 ApplicationWindow *app = (ApplicationWindow *)this->parent();
4543 switch(lineFormatApplyToBox->currentIndex()){
4544 case 0://selected curve
4545 break;
4546 case 1://this layer
4547 applyLineFormatToLayer(layer);
4548 break;
4549 case 2://this window
4550 {
4551 QList<Graph *> layersLst = layer->multiLayer()->layersList();
4552 foreach(Graph *g, layersLst)
4553 applyLineFormatToLayer(g);
4554 }
4555 break;
4556 case 3://all windows
4557 {
4558 QList<MdiSubWindow *> windows = app->windowsList();
4559 foreach(MdiSubWindow *w, windows){
4560 MultiLayer *ml = qobject_cast<MultiLayer *>(w);
4561 if (!ml)
4562 continue;
4563
4564 QList<Graph *> layersLst = ml->layersList();
4565 foreach(Graph *g, layersLst)
4566 applyLineFormatToLayer(g);
4567 }
4568 }
4569 break;
4570 default:
4571 break;
4572 }
4573 app->modifiedProject();
4574 }
4575
applySymbolsFormatToCurve(QwtPlotCurve * c,bool fillColor,bool penColor)4576 void PlotDialog::applySymbolsFormatToCurve(QwtPlotCurve *c, bool fillColor, bool penColor)
4577 {
4578 if (!c)
4579 return;
4580
4581 if (standardSymbolBtn->isChecked()){
4582 QwtSymbol symbol = c->symbol();
4583 if (symbol.style() == QwtSymbol::NoSymbol)
4584 return;
4585
4586 int size = 2*boxSymbolSize->value() + 1;
4587
4588 QBrush br = symbol.brush();
4589 QColor fc = br.color();
4590 if (fillColor)
4591 fc = boxFillColor->color();
4592 fc.setAlphaF(0.01*boxSymbolTransparency->value());
4593 br = QBrush(fc, Qt::SolidPattern);
4594
4595 if (!boxFillSymbol->isChecked())
4596 br = QBrush();
4597
4598 QPen pen = QPen(symbol.pen().color(), boxPenWidth->value(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
4599 if (penColor)
4600 pen.setColor(boxSymbolColor->color());
4601 pen.setCosmetic(true);
4602
4603 QwtSymbol s = QwtSymbol(boxSymbolStyle->selectedSymbol(), br, pen, QSize(size, size));
4604 c->setSymbol(s);
4605 } else if (imageSymbolBtn->isChecked()){
4606 QString path = imageSymbolPathBox->text();
4607 QFileInfo fi(path);
4608 if (fi.exists() && fi.isReadable() && fi.isFile()){
4609 ImageSymbol symbol = ImageSymbol(path);
4610 c->setSymbol(symbol);
4611 symbolImageLabel->setPixmap(symbol.pixmap());
4612 } else
4613 c->setSymbol(ImageSymbol(*symbolImageLabel->pixmap(), path));
4614 }
4615
4616 ((PlotCurve *)c)->setSkipSymbolsCount(boxSkipSymbols->value());
4617 }
4618
applySymbolsFormatToLayer(Graph * g)4619 void PlotDialog::applySymbolsFormatToLayer(Graph *g)
4620 {
4621 if (!g)
4622 return;
4623
4624 QList<QwtPlotItem *> lst = g->curvesList();
4625 foreach (QwtPlotItem *it, lst){
4626 if (it->rtti() == QwtPlotItem::Rtti_PlotSpectrogram)
4627 continue;
4628
4629 QwtPlotCurve *c = (QwtPlotCurve *)it;
4630 if (c->symbol().style() != QwtSymbol::NoSymbol)
4631 applySymbolsFormatToCurve(c, false, false);
4632 }
4633 g->replot();
4634 }
4635
applySymbolsFormat(QwtPlotCurve * c)4636 void PlotDialog::applySymbolsFormat(QwtPlotCurve *c)
4637 {
4638 if (!c || privateTabWidget->currentPage() != symbolPage)
4639 return;
4640
4641 Graph *layer = (Graph *)c->plot();
4642 ApplicationWindow *app = (ApplicationWindow *)this->parent();
4643 switch(symbolsFormatApplyToBox->currentIndex()){
4644 case 0://selected curve
4645 applySymbolsFormatToCurve(c);
4646 break;
4647 case 1://this layer
4648 applySymbolsFormatToLayer(layer);
4649 break;
4650 case 2://this window
4651 {
4652 QList<Graph *> layersLst = layer->multiLayer()->layersList();
4653 foreach(Graph *g, layersLst)
4654 applySymbolsFormatToLayer(g);
4655 }
4656 break;
4657 case 3://all windows
4658 {
4659 QList<MdiSubWindow *> windows = app->windowsList();
4660 foreach(MdiSubWindow *w, windows){
4661 MultiLayer *ml = qobject_cast<MultiLayer *>(w);
4662 if (!ml)
4663 continue;
4664
4665 QList<Graph *> layersLst = ml->layersList();
4666 foreach(Graph *g, layersLst)
4667 applySymbolsFormatToLayer(g);
4668 }
4669 }
4670 break;
4671 default:
4672 break;
4673 }
4674 app->modifiedProject();
4675 }
4676
applyErrorBarFormatToCurve(ErrorBarsCurve * err,bool color)4677 void PlotDialog::applyErrorBarFormatToCurve(ErrorBarsCurve *err, bool color)
4678 {
4679 if (!err)
4680 return;
4681
4682 Graph *g = (Graph *)err->plot();
4683 if (!g)
4684 return;
4685
4686 QColor col = err->color();
4687 if (color)
4688 col = colorBox->color();
4689
4690 g->updateErrorBars(err, xBox->isChecked(), widthBox->value(),
4691 capBox->currentText().toInt(), col, plusBox->isChecked(), minusBox->isChecked(),
4692 throughBox->isChecked());
4693 err->setSkipSymbolsCount(boxSkipErrorBars->value());
4694 }
4695
applyErrorBarFormatToLayer(Graph * g)4696 void PlotDialog::applyErrorBarFormatToLayer(Graph *g)
4697 {
4698 if (!g)
4699 return;
4700
4701 QList<QwtPlotItem *> lst = g->curvesList();
4702 int i = -1;
4703 foreach (QwtPlotItem *it, lst){
4704 i++;
4705 if (it->rtti() == QwtPlotItem::Rtti_PlotSpectrogram)
4706 continue;
4707
4708 PlotCurve *c = (ErrorBarsCurve *)it;
4709 if (c->type() == Graph::ErrorBars)
4710 applyErrorBarFormatToCurve((ErrorBarsCurve *)it, false);
4711 }
4712 g->replot();
4713 }
4714
applyErrorBarFormat(ErrorBarsCurve * c)4715 void PlotDialog::applyErrorBarFormat(ErrorBarsCurve *c)
4716 {
4717 if (!c || privateTabWidget->currentPage() != errorsPage)
4718 return;
4719
4720 Graph *layer = (Graph *)c->plot();
4721 if (!layer)
4722 return;
4723
4724 ApplicationWindow *app = (ApplicationWindow *)this->parent();
4725 switch(errorBarsFormatApplyToBox->currentIndex()){
4726 case 0://selected curve
4727 applyErrorBarFormatToCurve(c);
4728 break;
4729 case 1://this layer
4730 applyErrorBarFormatToLayer(layer);
4731 break;
4732 case 2://this window
4733 {
4734 QList<Graph *> layersLst = layer->multiLayer()->layersList();
4735 foreach(Graph *g, layersLst)
4736 applyErrorBarFormatToLayer(g);
4737 }
4738 break;
4739 case 3://all windows
4740 {
4741 QList<MdiSubWindow *> windows = app->windowsList();
4742 foreach(MdiSubWindow *w, windows){
4743 MultiLayer *ml = qobject_cast<MultiLayer *>(w);
4744 if (!ml)
4745 continue;
4746
4747 QList<Graph *> layersLst = ml->layersList();
4748 foreach(Graph *g, layersLst)
4749 applyErrorBarFormatToLayer(g);
4750 }
4751 }
4752 break;
4753 default:
4754 break;
4755 }
4756 app->modifiedProject();
4757 }
4758
applyBoxWhiskersFormatToCurve(BoxCurve * b)4759 void PlotDialog::applyBoxWhiskersFormatToCurve(BoxCurve *b)
4760 {
4761 if (!b)
4762 return;
4763
4764 b->setBoxWidth(boxWidth->value());
4765 b->setBoxStyle(boxType->currentIndex());
4766 if (boxCnt->isVisible())
4767 b->setBoxRange(boxRange->currentIndex() + 1, boxCnt->value());
4768 else
4769 b->setBoxRange(boxRange->currentIndex() + 1, (double)boxCoef->value());
4770
4771 if (whiskerCnt->isVisible())
4772 b->setWhiskersRange(boxWhiskersRange->currentIndex(), whiskerCnt->value());
4773 else
4774 b->setWhiskersRange(boxWhiskersRange->currentIndex(), (double)boxWhiskersCoef->value());
4775
4776 b->showBoxLabels(boxBoxLabels->isChecked());
4777 b->showWhiskerLabels(boxWhiskerLabels->isChecked());
4778 }
4779
applyBoxWhiskersFormatToLayer(Graph * g)4780 void PlotDialog::applyBoxWhiskersFormatToLayer(Graph *g)
4781 {
4782 if (!g)
4783 return;
4784
4785 for (int i = 0; i < g->curveCount(); i++){
4786 DataCurve *c = g->dataCurve(i);
4787 if (!c || c->type() != Graph::Box)
4788 continue;
4789
4790 applyBoxWhiskersFormatToCurve((BoxCurve *)c);
4791 }
4792 g->replot();
4793 }
4794
applyBoxWhiskersFormat(BoxCurve * c)4795 void PlotDialog::applyBoxWhiskersFormat(BoxCurve *c)
4796 {
4797 if (!c || privateTabWidget->currentPage() != boxPage)
4798 return;
4799
4800 Graph *layer = (Graph *)c->plot();
4801 if (!layer)
4802 return;
4803
4804 ApplicationWindow *app = (ApplicationWindow *)this->parent();
4805 switch(boxWhiskersFormatApplyToBox->currentIndex()){
4806 case 0://selected curve
4807 applyBoxWhiskersFormatToCurve(c);
4808 break;
4809 case 1://this layer
4810 applyBoxWhiskersFormatToLayer(layer);
4811 break;
4812 case 2://this window
4813 {
4814 QList<Graph *> layersLst = layer->multiLayer()->layersList();
4815 foreach(Graph *g, layersLst)
4816 applyBoxWhiskersFormatToLayer(g);
4817 }
4818 break;
4819 case 3://all windows
4820 {
4821 QList<MdiSubWindow *> windows = app->windowsList();
4822 foreach(MdiSubWindow *w, windows){
4823 MultiLayer *ml = qobject_cast<MultiLayer *>(w);
4824 if (!ml)
4825 continue;
4826
4827 QList<Graph *> layersLst = ml->layersList();
4828 foreach(Graph *g, layersLst)
4829 applyBoxWhiskersFormatToLayer(g);
4830 }
4831 }
4832 break;
4833 default:
4834 break;
4835 }
4836 app->modifiedProject();
4837 }
4838
applyPercentileFormatToCurve(BoxCurve * b)4839 void PlotDialog::applyPercentileFormatToCurve(BoxCurve *b)
4840 {
4841 if (!b)
4842 return;
4843
4844 b->setMaxStyle(boxMaxStyle->selectedSymbol());
4845 b->setP99Style(box99Style->selectedSymbol());
4846 b->setMeanStyle(boxMeanStyle->selectedSymbol());
4847 b->setP1Style(box1Style->selectedSymbol());
4848 b->setMinStyle(boxMinStyle->selectedSymbol());
4849
4850 int size = 2*boxPercSize->value() + 1;
4851 QBrush br = QBrush();
4852 if (boxFillSymbols->isChecked()){
4853 QColor c = boxPercFillColor->color();
4854 c.setAlphaF(0.01*boxPercentileTransparency->value());
4855 br = QBrush(c, Qt::SolidPattern);
4856 }
4857
4858 QPen pen = QPen(boxEdgeColor->color(), boxEdgeWidth->value(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
4859 pen.setCosmetic(true);
4860 b->setSymbol(QwtSymbol(QwtSymbol::NoSymbol, br, pen, QSize(size, size)));
4861 }
4862
applyPercentileFormatToLayer(Graph * g)4863 void PlotDialog::applyPercentileFormatToLayer(Graph *g)
4864 {
4865 if (!g)
4866 return;
4867
4868 for (int i = 0; i < g->curveCount(); i++){
4869 DataCurve *c = g->dataCurve(i);
4870 if (!c || c->type() != Graph::Box)
4871 continue;
4872
4873 applyPercentileFormatToCurve((BoxCurve *)c);
4874 }
4875 g->replot();
4876 }
4877
applyPercentileFormat(BoxCurve * c)4878 void PlotDialog::applyPercentileFormat(BoxCurve *c)
4879 {
4880 if (!c || privateTabWidget->currentPage() != percentilePage)
4881 return;
4882
4883 Graph *layer = (Graph *)c->plot();
4884 if (!layer)
4885 return;
4886
4887 ApplicationWindow *app = (ApplicationWindow *)this->parent();
4888 switch(percentileFormatApplyToBox->currentIndex()){
4889 case 0://selected curve
4890 applyPercentileFormatToCurve(c);
4891 break;
4892 case 1://this layer
4893 applyPercentileFormatToLayer(layer);
4894 break;
4895 case 2://this window
4896 {
4897 QList<Graph *> layersLst = layer->multiLayer()->layersList();
4898 foreach(Graph *g, layersLst)
4899 applyPercentileFormatToLayer(g);
4900 }
4901 break;
4902 case 3://all windows
4903 {
4904 QList<MdiSubWindow *> windows = app->windowsList();
4905 foreach(MdiSubWindow *w, windows){
4906 MultiLayer *ml = qobject_cast<MultiLayer *>(w);
4907 if (!ml)
4908 continue;
4909
4910 QList<Graph *> layersLst = ml->layersList();
4911 foreach(Graph *g, layersLst)
4912 applyPercentileFormatToLayer(g);
4913 }
4914 }
4915 break;
4916 default:
4917 break;
4918 }
4919 app->modifiedProject();
4920 }
4921
applyLabelsFormatToItem(QwtPlotItem * it)4922 void PlotDialog::applyLabelsFormatToItem(QwtPlotItem *it)
4923 {
4924 if (!it)
4925 return;
4926
4927 Spectrogram *sp = (Spectrogram *)it;
4928 if (sp && sp->rtti() == QwtPlotItem::Rtti_PlotSpectrogram){
4929 sp->setLabelsRotation(boxLabelsAngle->value());
4930 sp->showContourLineLabels(labelsGroupBox->isChecked());
4931 sp->setLabelsWhiteOut(boxLabelsWhiteOut->isChecked());
4932 sp->setLabelsOffset((double)boxLabelsXOffset->value(), (double)boxLabelsYOffset->value());
4933 sp->setLabelsColor(boxLabelsColor->color());
4934 } else if (it->rtti() == QwtPlotItem::Rtti_PlotCurve){
4935 DataCurve *c = (DataCurve *)it;
4936 c->setLabelsRotation(boxLabelsAngle->value());
4937 c->setLabelsWhiteOut(boxLabelsWhiteOut->isChecked());
4938 c->setLabelsOffset(boxLabelsXOffset->value(), boxLabelsYOffset->value());
4939 c->setLabelsColor(boxLabelsColor->color());
4940 c->setLabelsAlignment(labelsAlignment());
4941
4942 if (c->type() == Graph::Box)
4943 ((BoxCurve *)c)->setLabelsDisplayPolicy((BoxCurve::LabelsDisplayPolicy)boxLabelsColumn->currentIndex());
4944 }
4945 }
4946
applyLabelsFormatToLayer(Graph * g)4947 void PlotDialog::applyLabelsFormatToLayer(Graph *g)
4948 {
4949 if (!g)
4950 return;
4951
4952 QList<QwtPlotItem *> lst = g->curvesList();
4953 foreach (QwtPlotItem *it, lst)
4954 applyLabelsFormatToItem(it);
4955
4956 g->replot();
4957 }
4958
applyLabelsFormat(QwtPlotItem * c)4959 void PlotDialog::applyLabelsFormat(QwtPlotItem *c)
4960 {
4961 if (!c || privateTabWidget->currentPage() != labelsPage)
4962 return;
4963
4964 Graph *layer = (Graph *)c->plot();
4965 if (!layer)
4966 return;
4967
4968 ApplicationWindow *app = (ApplicationWindow *)this->parent();
4969 switch(boxLabelsFormatApplyToBox->currentIndex()){
4970 case 0://selected curve
4971 applyLabelsFormatToItem(c);
4972 break;
4973 case 1://this layer
4974 applyLabelsFormatToLayer(layer);
4975 break;
4976 case 2://this window
4977 {
4978 QList<Graph *> layersLst = layer->multiLayer()->layersList();
4979 foreach(Graph *g, layersLst)
4980 applyLabelsFormatToLayer(g);
4981 }
4982 break;
4983 case 3://all windows
4984 {
4985 QList<MdiSubWindow *> windows = app->windowsList();
4986 foreach(MdiSubWindow *w, windows){
4987 MultiLayer *ml = qobject_cast<MultiLayer *>(w);
4988 if (!ml)
4989 continue;
4990
4991 QList<Graph *> layersLst = ml->layersList();
4992 foreach(Graph *g, layersLst)
4993 applyLabelsFormatToLayer(g);
4994 }
4995 }
4996 break;
4997 default:
4998 break;
4999 }
5000 app->modifiedProject();
5001 }
5002
layerCanvasRect(QWidget * widget,double x,double y,double w,double h,FrameWidget::Unit unit)5003 QRect PlotDialog::layerCanvasRect(QWidget *widget, double x, double y, double w, double h, FrameWidget::Unit unit)
5004 {
5005 if (!widget)
5006 return QRect(qRound(x), qRound(y), qRound(w), qRound(h));
5007
5008 int dpiX = widget->logicalDpiX();
5009 int dpiY = widget->logicalDpiY();
5010
5011 switch(unit){
5012 case FrameWidget::Pixel:
5013 default:
5014 return QRect(qRound(x), qRound(y), qRound(w), qRound(h));
5015 break;
5016 case FrameWidget::Inch:
5017 return QRect(qRound(x*dpiX), qRound(y*dpiY), qRound(w*dpiX), qRound(h*dpiY));
5018 break;
5019 case FrameWidget::Millimeter:
5020 return QRect(qRound(x*dpiX/25.4), qRound(y*dpiY/25.4), qRound(w*dpiX/25.4), qRound(h*dpiY/25.4));
5021 break;
5022 case FrameWidget::Centimeter:
5023 return QRect(qRound(x*dpiX/2.54), qRound(y*dpiY/2.54), qRound(w*dpiX/2.54), qRound(h*dpiY/2.54));
5024 break;
5025 case FrameWidget::Point:
5026 return QRect(qRound(x*dpiX/72.0), qRound(y*dpiY/72.0), qRound(w*dpiX/72.0), qRound(h*dpiY/72.0));
5027 break;
5028 }
5029 return QRect(qRound(x), qRound(y), qRound(w), qRound(h));
5030 }
5031
raiseCurve()5032 void PlotDialog::raiseCurve()
5033 {
5034 shiftCurveBy(-1);
5035 }
5036
shiftCurveBy(int offset)5037 void PlotDialog::shiftCurveBy(int offset)
5038 {
5039 QTreeWidgetItem *item = listBox->currentItem();
5040 if (!item || item->type() != CurveTreeItem::PlotCurveTreeItem)
5041 return;
5042
5043 Graph *graph = ((CurveTreeItem *)item)->graph();
5044 if (!graph)
5045 return;
5046
5047 int index = ((CurveTreeItem *)item)->plotItemIndex();
5048 int newIndex = index + offset;
5049 graph->changeCurveIndex(index, newIndex);
5050
5051 LayerItem *layerItem = (LayerItem *)item->parent();
5052 QTreeWidgetItem *rootItem = layerItem->parent();
5053
5054 listBox->blockSignals(true);
5055
5056 rootItem->takeChild(rootItem->indexOfChild (layerItem));
5057 delete layerItem;
5058
5059 layerItem = new LayerItem(graph, rootItem, tr("Layer") + QString::number(d_ml->layerIndex(graph) + 1));
5060 rootItem->addChild(layerItem);
5061
5062 layerItem->setExpanded(true);
5063
5064 listBox->blockSignals(false);
5065
5066 CurveTreeItem *it = (CurveTreeItem *)layerItem->child(newIndex);
5067 if (it){
5068 listBox->setCurrentItem(it);
5069 setActiveCurve(it);
5070 }
5071
5072 btnUp->setEnabled(newIndex > 0);
5073 btnDown->setEnabled(newIndex < graph->curveCount() - 1);
5074 }
5075
applyGapToLayer(Graph * g)5076 void PlotDialog::applyGapToLayer(Graph *g)
5077 {
5078 if (!g)
5079 return;
5080
5081 int gap = gapBox->value();
5082 for (int i = 0; i < g->curveCount(); i++){
5083 QwtBarCurve *bars = (QwtBarCurve *)g->dataCurve(i);
5084 if (!bars)
5085 continue;
5086
5087 int type = bars->type();
5088 if (type == Graph::VerticalBars || type == Graph::HorizontalBars || type == Graph::Histogram)
5089 bars->setGap(gap);
5090 }
5091 }
5092
applyGap(Graph * g)5093 void PlotDialog::applyGap(Graph *g)
5094 {
5095 if (!g || privateTabWidget->currentWidget() != spacingPage)
5096 return;
5097
5098 ApplicationWindow *app = (ApplicationWindow *)this->parent();
5099 switch(gapApplyToBox->currentIndex()){
5100 case 1://this layer
5101 applyGapToLayer(g);
5102 break;
5103
5104 case 2://this window
5105 {
5106 QList<Graph *> layersLst = d_ml->layersList();
5107 foreach(Graph *g, layersLst){
5108 applyGapToLayer(g);
5109 g->replot();
5110 }
5111 }
5112 break;
5113
5114 case 3://all windows
5115 {
5116 QList<MdiSubWindow *> windows = app->windowsList();
5117 foreach(MdiSubWindow *w, windows){
5118 MultiLayer *ml = qobject_cast<MultiLayer *>(w);
5119 if (!ml)
5120 continue;
5121
5122 QList<Graph *> layersLst = ml->layersList();
5123 foreach(Graph *g, layersLst){
5124 applyGapToLayer(g);
5125 g->replot();
5126 }
5127 }
5128 }
5129 break;
5130
5131 default:
5132 break;
5133 }
5134 app->modifiedProject();
5135 }
5136
enableBoxApplyColor(int index)5137 void PlotDialog::enableBoxApplyColor(int index)
5138 {
5139 boxApplyColorTo->setEnabled(index);
5140 }
5141
enableLabelsPage()5142 void PlotDialog::enableLabelsPage()
5143 {
5144 int index = privateTabWidget->indexOf(labelsPage);
5145 privateTabWidget->setTabEnabled(index, boxBoxLabels->isChecked() || boxWhiskerLabels->isChecked());
5146 acceptParams();
5147 }
5148 /*****************************************************************************
5149 *
5150 * Class LayerItem
5151 *
5152 *****************************************************************************/
5153
LayerItem(Graph * g,QTreeWidgetItem * parent,const QString & s)5154 LayerItem::LayerItem(Graph *g, QTreeWidgetItem *parent, const QString& s)
5155 : QTreeWidgetItem( parent, QStringList(s), LayerTreeItem ),
5156 d_graph(g)
5157 {
5158 setIcon(0, QPixmap(":/layer_disabled.png"));
5159 if (g){
5160 insertCurvesList();
5161 insertEnrichmentsList();
5162 }
5163 }
5164
setActive(bool on)5165 void LayerItem::setActive(bool on)
5166 {
5167 if (on)
5168 setIcon(0, QPixmap(":/layer_enabled.png"));
5169 else
5170 setIcon(0, QPixmap(":/layer_disabled.png"));
5171 }
5172
insertCurvesList()5173 void LayerItem::insertCurvesList()
5174 {
5175 for (int i=0; i<d_graph->curveCount(); i++){
5176 QString plotAssociation = QString();
5177 QwtPlotItem *it = (QwtPlotItem *)d_graph->plotItem(i);
5178 if (!it)
5179 continue;
5180
5181 if (it->rtti() == QwtPlotItem::Rtti_PlotCurve){
5182 PlotCurve *c = (PlotCurve *)it;
5183 if (c->type() != Graph::Function && ((DataCurve *)it)->table()){
5184 QStringList lst = ((DataCurve *)it)->plotAssociation();
5185 QString tableName = ((DataCurve *)it)->table()->name();
5186 plotAssociation = tableName + ": " + lst.replaceInStrings(tableName + "_", "").join(", ");
5187 } else
5188 plotAssociation = it->title().text();
5189 } else
5190 plotAssociation = it->title().text();
5191
5192 addChild(new CurveTreeItem(it, this, plotAssociation));
5193 }
5194 }
5195
insertEnrichmentsList()5196 void LayerItem::insertEnrichmentsList()
5197 {
5198 QList <FrameWidget *> lst = d_graph->enrichmentsList();
5199 foreach (FrameWidget *w, lst){
5200 addChild(new FrameWidgetTreeItem(w, this, w->objectName()));
5201 }
5202 }
5203
5204 /*****************************************************************************
5205 *
5206 * Class CurveTreeItem
5207 *
5208 *****************************************************************************/
5209
CurveTreeItem(QwtPlotItem * curve,LayerItem * parent,const QString & s)5210 CurveTreeItem::CurveTreeItem(QwtPlotItem *curve, LayerItem *parent, const QString& s)
5211 : QTreeWidgetItem( parent, QStringList(s), PlotCurveTreeItem ),
5212 d_curve(curve)
5213 {
5214 setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
5215 setIcon(0, QPixmap(":/graph_disabled.png"));
5216 setCheckState(0, curve->isVisible() ? Qt::Checked : Qt::Unchecked);
5217 }
5218
setActive(bool on)5219 void CurveTreeItem::setActive(bool on)
5220 {
5221 if (on)
5222 setIcon(0, QPixmap(":/graph_enabled.png"));
5223 else
5224 setIcon(0, QPixmap(":/graph_disabled.png"));
5225 }
5226
plotItemIndex()5227 int CurveTreeItem::plotItemIndex()
5228 {
5229 Graph *g = graph();
5230 if (!g)
5231 return -1;
5232
5233 QList<QwtPlotItem *> itemsList = g->curvesList();
5234 return itemsList.indexOf(d_curve);
5235 }
5236
plotItemStyle()5237 int CurveTreeItem::plotItemStyle()
5238 {
5239 if (d_curve->rtti() != QwtPlotItem::Rtti_PlotSpectrogram)
5240 return ((PlotCurve *)d_curve)->plotStyle();
5241 else
5242 return Graph::ColorMap;
5243
5244 return -1;
5245 }
5246
plotItemType()5247 int CurveTreeItem::plotItemType()
5248 {
5249 if (d_curve->rtti() != QwtPlotItem::Rtti_PlotSpectrogram)
5250 return ((PlotCurve *)d_curve)->type();
5251 else
5252 return Graph::ColorMap;
5253
5254 return -1;
5255 }
5256
5257 /*****************************************************************************
5258 *
5259 * Class FrameWidgetTreeItem
5260 *
5261 *****************************************************************************/
FrameWidgetTreeItem(FrameWidget * w,LayerItem * parent,const QString & s)5262 FrameWidgetTreeItem::FrameWidgetTreeItem(FrameWidget *w, LayerItem *parent, const QString& s)
5263 : QTreeWidgetItem(parent, QStringList(s), FrameWidgetItem),
5264 d_widget(w)
5265 {
5266 setActive(false);
5267 setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
5268 setCheckState(0, d_widget->isVisible() ? Qt::Checked : Qt::Unchecked);
5269 }
5270
setActive(bool on)5271 void FrameWidgetTreeItem::setActive(bool on)
5272 {
5273 QPixmap pix = frameWidgetPixmap();
5274 if (on)
5275 setIcon(0, pix);
5276 else
5277 setIcon(0, QIcon(pix).pixmap(pix.size(), QIcon::Disabled));
5278 }
5279
frameWidgetPixmap()5280 QPixmap FrameWidgetTreeItem::frameWidgetPixmap()
5281 {
5282 if (!d_widget)
5283 return QPixmap();
5284
5285 if (qobject_cast<LegendWidget *>(d_widget))
5286 return QPixmap(":/legend.png");
5287 else if (qobject_cast<RectangleWidget *>(d_widget)){
5288 QPixmap pix = QPixmap(16, 16);
5289 pix.fill(Qt::transparent);
5290 QPainter p;
5291 p.begin(&pix);
5292 p.setPen(QPen(Qt::blue));
5293 p.setBrush(Qt::lightGray);
5294 p.drawRect(QRect(1, 2, 12, 10));
5295 return pix;
5296 } else if (qobject_cast<EllipseWidget *>(d_widget)){
5297 QPixmap pix = QPixmap(16, 16);
5298 pix.fill(Qt::transparent);
5299 QPainter p;
5300 p.begin(&pix);
5301 p.setPen(QPen(Qt::blue));
5302 p.setBrush(Qt::lightGray);
5303 p.drawEllipse(QRect(0, 2, 15, 12));
5304 return pix;
5305 } else if (qobject_cast<ImageWidget *>(d_widget))
5306 return QPixmap(":/monalisa.png");
5307 else if (qobject_cast<TexWidget *>(d_widget))
5308 return QPixmap(":/formula.png");
5309
5310 return QPixmap();
5311 }
5312