QtiPlot  0.9.8.2
PlotDialog.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : PlotDialog.h
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 #ifndef PLOTDIALOG_H
30 #define PLOTDIALOG_H
31 
32 #include <QDialog>
33 #include <QTreeWidgetItem>
34 #include <MultiLayer.h>
35 
36 class QCheckBox;
37 class QComboBox;
38 class QCompleter;
39 class QLabel;
40 class QLineEdit;
41 class QListWidget;
42 class QPushButton;
43 class QSpinBox;
44 class QTabWidget;
45 class QWidget;
46 class QStringList;
47 class QGroupBox;
48 class QDoubleSpinBox;
49 class QRadioButton;
50 class QTreeWidget;
51 class QSlider;
52 
53 class LayerItem;
54 class CurveTreeItem;
55 class ColorBox;
56 class PatternBox;
57 class ColorButton;
58 class MultiLayer;
59 class SymbolBox;
60 class ColorMapEditor;
61 class QwtPlotItem;
62 class DoubleSpinBox;
63 class PenStyleBox;
64 class Spectrogram;
65 class ErrorBarsCurve;
66 class BoxCurve;
67 class DataCurve;
68 class ContourLinesEditor;
69 class FunctionDialog;
70 class EnrichmentDialog;
71 
73 class PlotDialog : public QDialog
74 {
75  Q_OBJECT
76 
77 public:
78  PlotDialog(bool showExtended, QWidget* parent = 0, Qt::WFlags fl = 0 );
79  void initFonts(const QFont& titlefont, const QFont& axesfont, const QFont& numbersfont, const QFont& legendfont);
80  void insertColumnsList(const QStringList& names){columnNames = names;};
81  void setMultiLayer(MultiLayer *ml);
82  void selectMultiLayerItem();
83 
84 public slots:
85  void showAll(bool all);
86  void selectCurve(int index);
87 
88 private slots:
89  void showBoxStatistics();
90  void showStatistics();
91  void customVectorsPage(bool angleMag);
92  void updateEndPointColumns(const QString& text);
93 
94  void fillBoxSymbols();
95  void fillSymbols();
96  bool acceptParams();
97  void showWorksheet();
98  void quit();
99 
100  int setPlotType(CurveTreeItem *item);
101  void changePlotType(int plotType);
102  void setActiveCurve(CurveTreeItem *item);
103 
104  void raiseCurve();
105  void shiftCurveBy(int offset = 1);
106 
107  void insertTabs(int plot_type);
108  void updateTabWindow(QTreeWidgetItem *currentItem, QTreeWidgetItem *previousItem);
109  void showAreaColor(bool show);
110 
111  void removeSelectedObject();
112 
113  void chooseBackgroundImageFile(const QString& fn = QString());
114  void resizeCanvasToFitImage();
115 
116  void chooseSymbolImageFile();
117 
118  void pickErrorBarsColor();
119  void enableBoxApplyColor(int);
120 
121  void setAutomaticBinning(bool on = true);
122 
123  //box plots
124  void setBoxType(int index);
125  void setBoxRangeType(int index);
126  void setWhiskersRange(int index);
127  void enableLabelsPage();
128 
129  //spectrograms
130  void showDefaultContourLinesBox(bool show);
131  void showColorMapEditor(bool show);
132 
133  //layer geometry
134  void adjustLayerHeight(double width);
135  void adjustLayerWidth(double height);
136  void displayCoordinates(int unit, Graph *g = 0);
137  //plot window geometry
138  void displayPlotCoordinates(int unit);
139  void adjustPlotWidth(double height);
140  void adjustPlotHeight(double width);
141 
142  void setCanvasDefaultValues();
143 
144  void setActiveLayer(LayerItem *item);
145  void updateTreeWidgetItem(QTreeWidgetItem *item);
146  void updateVisibility();
147  void updateVisibility(QTreeWidgetItem *item, int column);
148  void updateBackgroundTransparency(int alpha);
149  void updateCanvasTransparency(int alpha);
150  void setTitlesFont();
151  void setAxesLabelsFont();
152  void setAxesNumbersFont();
153  void setLegendsFont();
154  void editCurve();
155  void editCurveRange();
156  void chooseLabelsFont();
157  void applyLayerFormat();
158  void applyCanvasFormat();
159  void setLayerDefaultValues();
160  void setEquidistantLevels();
161  void showCustomPenColumn(bool on);
163 
164 private:
165  void resizeLayerToFitImage(Graph *g);
167  void applyCanvasSize();
168 
169  void applyFormatToLayer(Graph *g);
170  void applySymbolsFormatToCurve(QwtPlotCurve *c, bool fillColor = true, bool penColor = true);
172  void applySymbolsFormat(QwtPlotCurve *c);
173 
174  void applyLineFormatToLayer(Graph *g);
175  void applyLineFormat(QwtPlotCurve *c);
176 
177  void applyErrorBarFormatToCurve(ErrorBarsCurve *err, bool color = true);
180 
184 
188 
189  void applyLabelsFormatToItem(QwtPlotItem *);
191  void applyLabelsFormat(QwtPlotItem *);
192 
193  void applyGapToLayer(Graph *g);
194  void applyGap(Graph *g);
195 
196  void setLabelsFont(const QFont& font, Graph *, const QwtPlotItem *);
197  void setLabelsFontToPlotItem(const QFont& font, const QwtPlotItem *);
198  void setLabelsFontToLayer(const QFont& font, Graph *);
199 
200  int labelsAlignment();
201  void closeEvent(QCloseEvent* e);
202 
203  void clearTabWidget();
204  void initAxesPage();
205  void initLinePage();
206  void initSymbolsPage();
207  void initHistogramPage();
208  void initErrorsPage();
209  void initSpacingPage();
210  void initVectPage();
211  void initBoxPage();
212  void initPercentilePage();
213  void initSpectrogramPage();
215  void initContourLinesPage();
216  void initLayerPage();
217  void initCanvasPage();
218  void initLayerGeometryPage();
219  void initPlotGeometryPage();
220  void initLayerDisplayPage();
221  void initLayerSpeedPage();
222  void initFontsPage();
223  void initMiscPage();
224  void initPiePage();
225  void initPieGeometryPage();
226  void initPieLabelsPage();
227  void initPrintPage();
228  void initLabelsPage();
229  void initFunctionPage();
230  void contextMenuEvent(QContextMenuEvent *e);
231  void showAllLabelControls(bool show = true, int curveType = 0);
233  QRect layerCanvasRect(QWidget *widget, double x, double y, double w, double h, FrameWidget::Unit unit);
234 
236 
238 
240  QStringList columnNames;
241 
243  QCheckBox *keepRatioBox;
244 
249  QTreeWidget* listBox;
253  QSpinBox *boxRadius;
259  QLineEdit *imagePathBox;
260  QComboBox *imageApplyToBox;
261  QRadioButton *colorBtn, *imageBtn;
263 
264  QPushButton* buttonApply, *btnWorksheet;
265  QPushButton* buttonOk, *btnMore;
266  QPushButton* buttonCancel;
267  QComboBox* boxPlotType;
268  QWidget* linePage;
269  QComboBox* boxConnect;
273  QWidget* symbolPage;
274  QSpinBox* boxSymbolSize;
278  QTabWidget* privateTabWidget;
280  QGroupBox* fillGroupBox;
281  QCheckBox* plusBox;
282  QCheckBox* minusBox;
283  QCheckBox* xBox;
286  QComboBox* capBox;
287  QCheckBox* throughBox;
289  QGroupBox* GroupBoxH;
292  QCheckBox *automaticBox;
294  QSpinBox* gapBox, *offsetBox, *boxWidth;
299  QCheckBox *filledHeadBox;
305  QGroupBox *GroupBoxVectEnd;
311  QGroupBox *defaultPenBox;
313 
317  QDoubleSpinBox *whiskerCnt, *boxCnt;
319  QGroupBox *labelsGroupBox;
322  QCheckBox *boxLabelsWhiteOut;
323  QPushButton *btnLabelsFont;
326  QWidget *labelsPage;
327 
331  QWidget *pieLabelsPage;
332  QSpinBox *boxPieOffset;
333  QWidget *pieGeometryPage;
334 
335  QComboBox *unitBox;
337  QPushButton *layerDefaultBtn;
338 
341 
343  QComboBox *boxSpectroMatrix;
347  QRadioButton *customPenBtn;
348 
351  QSpinBox *boxMaxPoints;
353  QGroupBox *speedModeBox;
354  QCheckBox *boxApplyColorTo;
355 
357  QCheckBox *boxLinkXAxes;
358  QComboBox *boxLinkAllXAxes;
359 
363 
368  QPushButton *btnUp, *btnDown;
370 
373  QLineEdit *imageSymbolPathBox;
375 
376  QGroupBox *boxFramed;
378  QSpinBox *boxFrameWidth;
379  QPushButton *canvasDefaultBtn;
381 
383  QCompleter *completer;
384 };
385 
386 /*****************************************************************************
387  *
388  * Class LayerItem
389  *
390  *****************************************************************************/
392 class LayerItem : public QTreeWidgetItem
393 {
394 public:
395  enum {LayerTreeItem = 1001};
396  LayerItem(Graph *g, QTreeWidgetItem *parent, const QString& s);
397 
398  Graph *graph() { return d_graph; };
399  void setActive(bool select);
400 
401 protected:
402  void insertCurvesList();
403  void insertEnrichmentsList();
405 };
406 
407 /*****************************************************************************
408  *
409  * Class CurveTreeItem
410  *
411  *****************************************************************************/
413 class CurveTreeItem : public QTreeWidgetItem
414 {
415 public:
416  enum {PlotCurveTreeItem = 1002};
417  CurveTreeItem(QwtPlotItem *curve, LayerItem *parent, const QString& s);
418 
419  Graph* graph(){return ((LayerItem *)parent())->graph();};
420  void setActive(bool on);
421 
422  const QwtPlotItem *plotItem() { return d_curve; };
423  int plotItemType();
424  int plotItemStyle();
425  int plotItemIndex();
426 
427 protected:
428  QwtPlotItem *d_curve;
429 };
430 
431 /*****************************************************************************
432  *
433  * Class FrameWidgetTreeItem
434  *
435  *****************************************************************************/
437 class FrameWidgetTreeItem : public QTreeWidgetItem
438 {
439 public:
440  enum {FrameWidgetItem = 1003};
441  FrameWidgetTreeItem(FrameWidget *w, LayerItem *parent, const QString& s);
442 
443  Graph* graph(){return ((LayerItem *)parent())->graph();};
445 
446  void setActive(bool on);
447 
448 protected:
449  QPixmap frameWidgetPixmap();
450 
452 };
453 #endif