QtiPlot 0.9.8.2
PlotDialog.h
Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : PlotDialog.h
00003     Project              : QtiPlot
00004     --------------------------------------------------------------------
00005     Copyright            : (C) 2006 - 2011 by Ion Vasilief
00006     Email (use @ for *)  : ion_vasilief*yahoo.fr
00007     Description          : Custom curves dialog
00008 
00009  ***************************************************************************/
00010 
00011 /***************************************************************************
00012  *                                                                         *
00013  *  This program is free software; you can redistribute it and/or modify   *
00014  *  it under the terms of the GNU General Public License as published by   *
00015  *  the Free Software Foundation; either version 2 of the License, or      *
00016  *  (at your option) any later version.                                    *
00017  *                                                                         *
00018  *  This program is distributed in the hope that it will be useful,        *
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00021  *  GNU General Public License for more details.                           *
00022  *                                                                         *
00023  *   You should have received a copy of the GNU General Public License     *
00024  *   along with this program; if not, write to the Free Software           *
00025  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
00026  *   Boston, MA  02110-1301  USA                                           *
00027  *                                                                         *
00028  ***************************************************************************/
00029 #ifndef PLOTDIALOG_H
00030 #define PLOTDIALOG_H
00031 
00032 #include <QDialog>
00033 #include <QTreeWidgetItem>
00034 #include <MultiLayer.h>
00035 
00036 class QCheckBox;
00037 class QComboBox;
00038 class QCompleter;
00039 class QLabel;
00040 class QLineEdit;
00041 class QListWidget;
00042 class QPushButton;
00043 class QSpinBox;
00044 class QTabWidget;
00045 class QWidget;
00046 class QStringList;
00047 class QGroupBox;
00048 class QDoubleSpinBox;
00049 class QRadioButton;
00050 class QTreeWidget;
00051 class QSlider;
00052 
00053 class LayerItem;
00054 class CurveTreeItem;
00055 class ColorBox;
00056 class PatternBox;
00057 class ColorButton;
00058 class MultiLayer;
00059 class SymbolBox;
00060 class ColorMapEditor;
00061 class QwtPlotItem;
00062 class DoubleSpinBox;
00063 class PenStyleBox;
00064 class Spectrogram;
00065 class ErrorBarsCurve;
00066 class BoxCurve;
00067 class DataCurve;
00068 class ContourLinesEditor;
00069 class FunctionDialog;
00070 class EnrichmentDialog;
00071 
00073 class PlotDialog : public QDialog
00074 {
00075     Q_OBJECT
00076 
00077 public:
00078     PlotDialog(bool showExtended, QWidget* parent = 0, Qt::WFlags fl = 0 );
00079     void initFonts(const QFont& titlefont, const QFont& axesfont, const QFont& numbersfont, const QFont& legendfont);
00080     void insertColumnsList(const QStringList& names){columnNames = names;};
00081     void setMultiLayer(MultiLayer *ml);
00082     void selectMultiLayerItem();
00083 
00084 public slots:
00085     void showAll(bool all);
00086     void selectCurve(int index);
00087 
00088 private slots:
00089     void showBoxStatistics();
00090     void showStatistics();
00091     void customVectorsPage(bool angleMag);
00092     void updateEndPointColumns(const QString& text);
00093 
00094     void fillBoxSymbols();
00095     void fillSymbols();
00096     bool acceptParams();
00097     void showWorksheet();
00098     void quit();
00099 
00100     int setPlotType(CurveTreeItem *item);
00101     void changePlotType(int plotType);
00102     void setActiveCurve(CurveTreeItem *item);
00103 
00104     void raiseCurve();
00105     void shiftCurveBy(int offset = 1);
00106 
00107     void insertTabs(int plot_type);
00108     void updateTabWindow(QTreeWidgetItem *currentItem, QTreeWidgetItem *previousItem);
00109     void showAreaColor(bool show);
00110 
00111     void removeSelectedObject();
00112 
00113     void chooseBackgroundImageFile(const QString& fn = QString());
00114     void resizeCanvasToFitImage();
00115 
00116     void chooseSymbolImageFile();
00117 
00118     void pickErrorBarsColor();
00119     void enableBoxApplyColor(int);
00120 
00121     void setAutomaticBinning(bool on = true);
00122 
00123     //box plots
00124     void setBoxType(int index);
00125     void setBoxRangeType(int index);
00126     void setWhiskersRange(int index);
00127     void enableLabelsPage();
00128 
00129     //spectrograms
00130     void showDefaultContourLinesBox(bool show);
00131     void showColorMapEditor(bool show);
00132 
00133     //layer geometry
00134     void adjustLayerHeight(double width);
00135     void adjustLayerWidth(double height);
00136     void displayCoordinates(int unit, Graph *g = 0);
00137     //plot window geometry
00138     void displayPlotCoordinates(int unit);
00139     void adjustPlotWidth(double height);
00140     void adjustPlotHeight(double width);
00141 
00142     void setCanvasDefaultValues();
00143 
00144     void setActiveLayer(LayerItem *item);
00145     void updateTreeWidgetItem(QTreeWidgetItem *item);
00146     void updateVisibility();
00147     void updateVisibility(QTreeWidgetItem *item, int column);
00148     void updateBackgroundTransparency(int alpha);
00149     void updateCanvasTransparency(int alpha);
00150     void setTitlesFont();
00151     void setAxesLabelsFont();
00152     void setAxesNumbersFont();
00153     void setLegendsFont();
00154     void editCurve();
00155     void editCurveRange();
00156     void chooseLabelsFont();
00157     void applyLayerFormat();
00158     void applyCanvasFormat();
00159     void setLayerDefaultValues();
00160     void setEquidistantLevels();
00161     void showCustomPenColumn(bool on);
00162 
00163 private:
00164     void resizeLayerToFitImage(Graph *g);
00165     void applyCanvasFormatToLayer(Graph *g);
00166     void applyCanvasSize();
00167 
00168     void applyFormatToLayer(Graph *g);
00169     void applySymbolsFormatToCurve(QwtPlotCurve *c, bool fillColor = true, bool penColor = true);
00170     void applySymbolsFormatToLayer(Graph *g);
00171     void applySymbolsFormat(QwtPlotCurve *c);
00172 
00173     void applyLineFormatToLayer(Graph *g);
00174     void applyLineFormat(QwtPlotCurve *c);
00175 
00176     void applyErrorBarFormatToCurve(ErrorBarsCurve *err, bool color = true);
00177     void applyErrorBarFormatToLayer(Graph *g);
00178     void applyErrorBarFormat(ErrorBarsCurve *c);
00179 
00180     void applyBoxWhiskersFormatToCurve(BoxCurve *b);
00181     void applyBoxWhiskersFormatToLayer(Graph *g);
00182     void applyBoxWhiskersFormat(BoxCurve *c);
00183 
00184     void applyPercentileFormatToCurve(BoxCurve *b);
00185     void applyPercentileFormatToLayer(Graph *g);
00186     void applyPercentileFormat(BoxCurve *c);
00187 
00188     void applyLabelsFormatToItem(QwtPlotItem *);
00189     void applyLabelsFormatToLayer(Graph *);
00190     void applyLabelsFormat(QwtPlotItem *);
00191 
00192     void applyGapToLayer(Graph *g);
00193     void applyGap(Graph *g);
00194 
00195     void setLabelsFont(const QFont& font, Graph *, const QwtPlotItem *);
00196     void setLabelsFontToPlotItem(const QFont& font, const QwtPlotItem *);
00197     void setLabelsFontToLayer(const QFont& font, Graph *);
00198 
00199     int labelsAlignment();
00200     void closeEvent(QCloseEvent* e);
00201 
00202     void clearTabWidget();
00203     void initAxesPage();
00204     void initLinePage();
00205     void initSymbolsPage();
00206     void initHistogramPage();
00207     void initErrorsPage();
00208     void initSpacingPage();
00209     void initVectPage();
00210     void initBoxPage();
00211     void initPercentilePage();
00212     void initSpectrogramPage();
00213     void initSpectrogramValuesPage();
00214     void initContourLinesPage();
00215     void initLayerPage();
00216     void initCanvasPage();
00217     void initLayerGeometryPage();
00218     void initPlotGeometryPage();
00219     void initLayerDisplayPage();
00220     void initLayerSpeedPage();
00221     void initFontsPage();
00222     void initMiscPage();
00223     void initPiePage();
00224     void initPieGeometryPage();
00225     void initPieLabelsPage();
00226     void initPrintPage();
00227     void initLabelsPage();
00228     void initFunctionPage();
00229     void contextMenuEvent(QContextMenuEvent *e);
00230     void showAllLabelControls(bool show = true, int curveType = 0);
00231     void updateContourLevelsDisplay(Spectrogram *sp);
00232     QRect layerCanvasRect(QWidget *widget, double x, double y, double w, double h, FrameWidget::Unit unit);
00233 
00234     double aspect_ratio, plot_aspect_ratio;
00235 
00236     QFont titleFont, legendFont, axesFont, numbersFont;
00237 
00238     MultiLayer *d_ml;
00239     QStringList columnNames;
00240 
00241     DoubleSpinBox* boxX, *boxY, *boxLayerWidth, *boxLayerHeight;
00242     QCheckBox *keepRatioBox;
00243 
00244     QPushButton *btnTitle, *btnAxesLabels, *btnAxesNumbers, *btnLegend;
00245     ColorMapEditor *colorMapEditor;
00246     QWidget *curvePlotTypeBox, *layerPage, *layerGeometryPage, *piePage, *fontsPage, *printPage;
00247     QWidget *layerDisplayPage, *speedPage, *functionPage, *canvasPage;
00248     QTreeWidget* listBox;
00249     QCheckBox *boxAntialiasing, *boxScaleLayers, *boxPrintCrops, *boxAutoscaling, *boxGridPosition, *boxMissingData;
00250     ColorButton *boxBorderColor, *boxBackgroundColor, *boxCanvasColor;
00251     QSpinBox *boxBackgroundTransparency, *boxCanvasTransparency, *boxBorderWidth, *boxMargin;
00252     QSpinBox *boxRadius;
00253     DoubleSpinBox *boxPieLineWidth;
00254     ColorBox *boxFirstColor;
00255     ColorButton *boxPieLineColor;
00256     PatternBox *boxPiePattern;
00257     PenStyleBox* boxPieLineStyle;
00258     QLineEdit *imagePathBox;
00259     QComboBox *imageApplyToBox;
00260     QRadioButton *colorBtn, *imageBtn;
00261     QGroupBox *canvasColorBox, *canvasImageBox;
00262 
00263     QPushButton* buttonApply, *btnWorksheet;
00264     QPushButton* buttonOk, *btnMore;
00265     QPushButton* buttonCancel;
00266     QComboBox* boxPlotType;
00267     QWidget* linePage;
00268     QComboBox* boxConnect;
00269     PenStyleBox* boxLineStyle;
00270     DoubleSpinBox *boxLineWidth, *boxPenWidth;
00271     ColorButton* boxLineColor, *boxAreaColor;
00272     QWidget* symbolPage;
00273     QSpinBox* boxSymbolSize;
00274     ColorButton *boxSymbolColor, *boxFillColor;
00275     SymbolBox* boxSymbolStyle;
00276     PatternBox *boxPattern;
00277     QTabWidget* privateTabWidget;
00278     QWidget *errorsPage, *spectrogramPage, *contourLinesPage;
00279     QGroupBox* fillGroupBox;
00280     QCheckBox* plusBox;
00281     QCheckBox* minusBox;
00282     QCheckBox* xBox;
00283     ColorButton *colorBox, *levelsColorBox, *vectColorBox;
00284     DoubleSpinBox* widthBox;
00285     QComboBox* capBox;
00286     QCheckBox* throughBox;
00287     QLabel *labelPosition, *labelXEnd, *labelYEnd;
00288     QGroupBox* GroupBoxH;
00289     QWidget *histogramPage, *spacingPage;
00290     DoubleSpinBox *binSizeBox, *histogramBeginBox, *histogramEndBox;
00291     QCheckBox *automaticBox;
00292     QPushButton* buttonStatistics, *btnEditCurve, *buttonBoxStatistics, *btnEditCurveRange;
00293     QSpinBox* gapBox, *offsetBox, *boxWidth;
00294     QWidget *vectPage, *boxPage, *percentilePage, *axesPage;
00295     QComboBox *xEndBox, *yEndBox, *boxType, *boxWhiskersType, *boxWhiskersRange, *boxRange;
00296     QSpinBox* headAngleBox, *headLengthBox, *boxPercSize;
00297     DoubleSpinBox *vectWidthBox, *boxEdgeWidth;
00298     QCheckBox *filledHeadBox;
00299     QSpinBox *boxCoef, *boxWhiskersCoef;
00300     QCheckBox *boxFillSymbols, *boxFillSymbol;
00301     ColorButton *boxPercFillColor, *boxEdgeColor;
00302     QLabel  *whiskerCoeffLabel, *whiskerRangeLabel, *boxCoeffLabel;
00303     QLabel *boxRangeLabel, *whiskerCntLabel, *boxCntLabel;
00304     QGroupBox *GroupBoxVectEnd;
00305     QComboBox *vectPosBox, *boxXAxis, *boxYAxis, *colorScaleBox;
00306     PenStyleBox *boxContourStyle;
00307     QSpinBox *levelsBox, *colorScaleWidthBox;
00308     DoubleSpinBox *contourWidthBox;
00309     QGroupBox *levelsGroupBox, *axisScaleBox, *imageGroupBox;
00310     QGroupBox *defaultPenBox;
00311     QRadioButton *defaultScaleBox, *grayScaleBox, *customScaleBox, *defaultContourBox, *autoContourBox;
00312 
00313     QCheckBox *boxWhiskerLabels, *boxBoxLabels;
00314     QComboBox *boxWhiskersFormatApplyToBox, *boxLabelsFormatApplyToBox, *percentileFormatApplyToBox;
00315     SymbolBox *boxMaxStyle, *boxMinStyle, *boxMeanStyle, *box99Style, *box1Style;
00316     QDoubleSpinBox *whiskerCnt, *boxCnt;
00318     QGroupBox *labelsGroupBox;
00319     DoubleSpinBox *boxLabelsAngle;
00320     QSpinBox *boxLabelsXOffset, *boxLabelsYOffset;
00321     QCheckBox *boxLabelsWhiteOut;
00322     QPushButton *btnLabelsFont;
00323     QComboBox *boxLabelsAlign, *boxLabelsColumn;
00324     ColorButton* boxLabelsColor;
00325     QWidget *labelsPage;
00326 
00327     QGroupBox *pieAutoLabelsBox, *boxPieWedge;
00328     DoubleSpinBox *boxPieStartAzimuth, *boxPieEdgeDist, *boxPieViewAngle, *boxPieThickness;
00329     QCheckBox *boxPieConterClockwise, *boxPieValues, *boxPiePercentages, *boxPieCategories;
00330     QWidget *pieLabelsPage;
00331     QSpinBox *boxPieOffset;
00332     QWidget *pieGeometryPage;
00333 
00334     QComboBox *unitBox;
00335     QComboBox *backgroundApplyToBox;
00336     QPushButton *layerDefaultBtn;
00337 
00338     DoubleSpinBox *firstContourLineBox, *contourLinesDistanceBox;
00339     QLabel *justifyLabelsLbl, *labelsColumnLbl;
00340 
00341     QWidget *spectroValuesPage;
00342     QComboBox *boxSpectroMatrix;
00343     QCheckBox *boxUseMatrixFormula;
00344     ContourLinesEditor *contourLinesEditor;
00345     QPushButton *btnSetEquidistantLevels;
00346     QRadioButton *customPenBtn;
00347 
00348     QSpinBox *boxSkipSymbols, *boxSkipErrorBars;
00349     QComboBox *symbolsFormatApplyToBox, *lineFormatApplyToBox, *errorBarsFormatApplyToBox, *sizeApplyToBox;
00350     QSpinBox *boxMaxPoints;
00351     DoubleSpinBox *boxDouglasPeukerTolerance;
00352     QGroupBox *speedModeBox;
00353     QCheckBox *boxApplyColorTo;
00354 
00355     QWidget *miscPage, *plotGeometryPage;
00356     QCheckBox *boxLinkXAxes;
00357     QComboBox *boxLinkAllXAxes;
00358 
00359     FunctionDialog *functionEdit;
00360     QSpinBox *boxCurveOpacity, *boxSymbolTransparency, *boxLineTransparency, *boxPercentileTransparency;
00361     QSlider *curveOpacitySlider, *symbTransparencySlider, *lineTransparencySlider, *percentileTransparencySlider;
00362 
00363     DoubleSpinBox *boxPlotX, *boxPlotY, *boxPlotWidth, *boxPlotHeight;
00364     QComboBox *plotUnitBox, *gapApplyToBox;
00365     QCheckBox *boxResizeLayers, *keepPlotRatioBox, *layerScaleFonts;
00366     EnrichmentDialog *enrichmentDialog;
00367     QPushButton *btnUp, *btnDown;
00368     QLabel *barsOffsetLabel;
00369 
00370     QRadioButton *standardSymbolBtn, *imageSymbolBtn;
00371     QGroupBox *standardSymbolFormatBox, *imageSymBolFormatBox;
00372     QLineEdit *imageSymbolPathBox;
00373     QLabel *symbolImageLabel;
00374 
00375     QGroupBox *boxFramed;
00376     ColorButton *boxFrameColor;
00377     QSpinBox *boxFrameWidth;
00378     QPushButton *canvasDefaultBtn;
00379     QSlider *canvasOpacitySlider, *bkgOpacitySlider;
00380 
00381     QCheckBox *boxLeftAxis, *boxRightAxis, *boxBottomAxis, *boxTopAxis;
00382     QCompleter *completer;
00383 };
00384 
00385 /*****************************************************************************
00386  *
00387  * Class LayerItem
00388  *
00389  *****************************************************************************/
00391 class LayerItem : public QTreeWidgetItem
00392 {
00393 public:
00394     enum {LayerTreeItem = 1001};
00395     LayerItem(Graph *g, QTreeWidgetItem *parent, const QString& s);
00396 
00397     Graph *graph() { return d_graph; };
00398     void setActive(bool select);
00399 
00400 protected:
00401     void insertCurvesList();
00402     void insertEnrichmentsList();
00403     Graph *d_graph;
00404 };
00405 
00406 /*****************************************************************************
00407  *
00408  * Class CurveTreeItem
00409  *
00410  *****************************************************************************/
00412 class CurveTreeItem : public QTreeWidgetItem
00413 {
00414 public:
00415     enum {PlotCurveTreeItem = 1002};
00416     CurveTreeItem(QwtPlotItem *curve, LayerItem *parent, const QString& s);
00417 
00418     Graph* graph(){return ((LayerItem *)parent())->graph();};
00419     void setActive(bool on);
00420 
00421     const QwtPlotItem *plotItem() { return d_curve; };
00422     int plotItemType();
00423     int plotItemStyle();
00424     int plotItemIndex();
00425 
00426 protected:
00427     QwtPlotItem *d_curve;
00428 };
00429 
00430 /*****************************************************************************
00431  *
00432  * Class FrameWidgetTreeItem
00433  *
00434  *****************************************************************************/
00436 class FrameWidgetTreeItem : public QTreeWidgetItem
00437 {
00438 public:
00439     enum {FrameWidgetItem = 1003};
00440     FrameWidgetTreeItem(FrameWidget *w, LayerItem *parent, const QString& s);
00441 
00442     Graph* graph(){return ((LayerItem *)parent())->graph();};
00443     FrameWidget *frameWidget(){return d_widget;};
00444 
00445      void setActive(bool on);
00446 
00447 protected:
00448     QPixmap frameWidgetPixmap();
00449 
00450     FrameWidget *d_widget;
00451 };
00452 #endif