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);
162 
163 private:
164  void resizeLayerToFitImage(Graph *g);
166  void applyCanvasSize();
167 
168  void applyFormatToLayer(Graph *g);
169  void applySymbolsFormatToCurve(QwtPlotCurve *c, bool fillColor = true, bool penColor = true);
171  void applySymbolsFormat(QwtPlotCurve *c);
172 
173  void applyLineFormatToLayer(Graph *g);
174  void applyLineFormat(QwtPlotCurve *c);
175 
176  void applyErrorBarFormatToCurve(ErrorBarsCurve *err, bool color = true);
179 
183 
187 
188  void applyLabelsFormatToItem(QwtPlotItem *);
190  void applyLabelsFormat(QwtPlotItem *);
191 
192  void applyGapToLayer(Graph *g);
193  void applyGap(Graph *g);
194 
195  void setLabelsFont(const QFont& font, Graph *, const QwtPlotItem *);
196  void setLabelsFontToPlotItem(const QFont& font, const QwtPlotItem *);
197  void setLabelsFontToLayer(const QFont& font, Graph *);
198 
199  int labelsAlignment();
200  void closeEvent(QCloseEvent* e);
201 
202  void clearTabWidget();
203  void initAxesPage();
204  void initLinePage();
205  void initSymbolsPage();
206  void initHistogramPage();
207  void initErrorsPage();
208  void initSpacingPage();
209  void initVectPage();
210  void initBoxPage();
211  void initPercentilePage();
212  void initSpectrogramPage();
214  void initContourLinesPage();
215  void initLayerPage();
216  void initCanvasPage();
217  void initLayerGeometryPage();
218  void initPlotGeometryPage();
219  void initLayerDisplayPage();
220  void initLayerSpeedPage();
221  void initFontsPage();
222  void initMiscPage();
223  void initPiePage();
224  void initPieGeometryPage();
225  void initPieLabelsPage();
226  void initPrintPage();
227  void initLabelsPage();
228  void initFunctionPage();
229  void contextMenuEvent(QContextMenuEvent *e);
230  void showAllLabelControls(bool show = true, int curveType = 0);
232  QRect layerCanvasRect(QWidget *widget, double x, double y, double w, double h, FrameWidget::Unit unit);
233 
235 
237 
239  QStringList columnNames;
240 
242  QCheckBox *keepRatioBox;
243 
248  QTreeWidget* listBox;
252  QSpinBox *boxRadius;
258  QLineEdit *imagePathBox;
259  QComboBox *imageApplyToBox;
260  QRadioButton *colorBtn, *imageBtn;
262 
263  QPushButton* buttonApply, *btnWorksheet;
264  QPushButton* buttonOk, *btnMore;
265  QPushButton* buttonCancel;
266  QComboBox* boxPlotType;
267  QWidget* linePage;
268  QComboBox* boxConnect;
272  QWidget* symbolPage;
273  QSpinBox* boxSymbolSize;
277  QTabWidget* privateTabWidget;
279  QGroupBox* fillGroupBox;
280  QCheckBox* plusBox;
281  QCheckBox* minusBox;
282  QCheckBox* xBox;
285  QComboBox* capBox;
286  QCheckBox* throughBox;
288  QGroupBox* GroupBoxH;
291  QCheckBox *automaticBox;
293  QSpinBox* gapBox, *offsetBox, *boxWidth;
298  QCheckBox *filledHeadBox;
304  QGroupBox *GroupBoxVectEnd;
310  QGroupBox *defaultPenBox;
312 
316  QDoubleSpinBox *whiskerCnt, *boxCnt;
318  QGroupBox *labelsGroupBox;
321  QCheckBox *boxLabelsWhiteOut;
322  QPushButton *btnLabelsFont;
325  QWidget *labelsPage;
326 
330  QWidget *pieLabelsPage;
331  QSpinBox *boxPieOffset;
332  QWidget *pieGeometryPage;
333 
334  QComboBox *unitBox;
336  QPushButton *layerDefaultBtn;
337 
340 
342  QComboBox *boxSpectroMatrix;
346  QRadioButton *customPenBtn;
347 
350  QSpinBox *boxMaxPoints;
352  QGroupBox *speedModeBox;
353  QCheckBox *boxApplyColorTo;
354 
356  QCheckBox *boxLinkXAxes;
357  QComboBox *boxLinkAllXAxes;
358 
362 
367  QPushButton *btnUp, *btnDown;
369 
372  QLineEdit *imageSymbolPathBox;
374 
375  QGroupBox *boxFramed;
377  QSpinBox *boxFrameWidth;
378  QPushButton *canvasDefaultBtn;
380 
382  QCompleter *completer;
383 };
384 
385 /*****************************************************************************
386  *
387  * Class LayerItem
388  *
389  *****************************************************************************/
391 class LayerItem : public QTreeWidgetItem
392 {
393 public:
394  enum {LayerTreeItem = 1001};
395  LayerItem(Graph *g, QTreeWidgetItem *parent, const QString& s);
396 
397  Graph *graph() { return d_graph; };
398  void setActive(bool select);
399 
400 protected:
401  void insertCurvesList();
402  void insertEnrichmentsList();
404 };
405 
406 /*****************************************************************************
407  *
408  * Class CurveTreeItem
409  *
410  *****************************************************************************/
412 class CurveTreeItem : public QTreeWidgetItem
413 {
414 public:
415  enum {PlotCurveTreeItem = 1002};
416  CurveTreeItem(QwtPlotItem *curve, LayerItem *parent, const QString& s);
417 
418  Graph* graph(){return ((LayerItem *)parent())->graph();};
419  void setActive(bool on);
420 
421  const QwtPlotItem *plotItem() { return d_curve; };
422  int plotItemType();
423  int plotItemStyle();
424  int plotItemIndex();
425 
426 protected:
427  QwtPlotItem *d_curve;
428 };
429 
430 /*****************************************************************************
431  *
432  * Class FrameWidgetTreeItem
433  *
434  *****************************************************************************/
436 class FrameWidgetTreeItem : public QTreeWidgetItem
437 {
438 public:
439  enum {FrameWidgetItem = 1003};
440  FrameWidgetTreeItem(FrameWidget *w, LayerItem *parent, const QString& s);
441 
442  Graph* graph(){return ((LayerItem *)parent())->graph();};
444 
445  void setActive(bool on);
446 
447 protected:
448  QPixmap frameWidgetPixmap();
449 
451 };
452 #endif