PlotDialog.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : PlotDialog.h
00003     Project              : QtiPlot
00004     --------------------------------------------------------------------
00005     Copyright            : (C) 2006 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 QLabel;
00039 class QLineEdit;
00040 class QListWidget;
00041 class QPushButton;
00042 class QSpinBox;
00043 class QTabWidget;
00044 class QWidget;
00045 class QStringList;
00046 class QGroupBox;
00047 class QDoubleSpinBox;
00048 class QRadioButton;
00049 class QTreeWidget;
00050 class QSlider;
00051 
00052 class LayerItem;
00053 class CurveTreeItem;
00054 class ColorBox;
00055 class PatternBox;
00056 class ColorButton;
00057 class MultiLayer;
00058 class SymbolBox;
00059 class ColorMapEditor;
00060 class QwtPlotItem;
00061 class DoubleSpinBox;
00062 class PenStyleBox;
00063 class Spectrogram;
00064 class QwtErrorPlotCurve;
00065 class ContourLinesEditor;
00066 class FunctionDialog;
00067 
00069 class PlotDialog : public QDialog
00070 {
00071     Q_OBJECT
00072 
00073 public:
00074     PlotDialog(bool showExtended, QWidget* parent = 0, Qt::WFlags fl = 0 );
00075     void initFonts(const QFont& titlefont, const QFont& axesfont, const QFont& numbersfont, const QFont& legendfont);
00076     void insertColumnsList(const QStringList& names){columnNames = names;};
00077     void setMultiLayer(MultiLayer *ml);
00078 
00079 public slots:
00080     void showAll(bool all);
00081     void selectCurve(int index);
00082 
00083 private slots:
00084     void showStatistics();
00085     void customVectorsPage(bool angleMag);
00086     void updateEndPointColumns(const QString& text);
00087 
00088     void fillBoxSymbols();
00089     void fillSymbols();
00090     bool acceptParams();
00091     void showWorksheet();
00092     void quit();
00093 
00094     int setPlotType(CurveTreeItem *item);
00095     void changePlotType(int plotType);
00096     void setActiveCurve(CurveTreeItem *item);
00097 
00098     void insertTabs(int plot_type);
00099     void updateTabWindow(QTreeWidgetItem *currentItem, QTreeWidgetItem *previousItem);
00100     void showAreaColor(bool show);
00101 
00102     void removeSelectedCurve();
00103 
00104     void pickErrorBarsColor();
00105 
00106     void setAutomaticBinning();
00107     bool validInput();
00108     void showPlotAssociations(QTreeWidgetItem *item, int);
00109 
00110     //box plots
00111     void setBoxType(int index);
00112     void setBoxRangeType(int index);
00113     void setWhiskersRange(int index);
00114 
00115     //spectrograms
00116     void showDefaultContourLinesBox(bool show);
00117     void showColorMapEditor(bool show);
00118 
00119     //layer geometry
00120     void adjustLayerHeight(double width);
00121     void adjustLayerWidth(double height);
00122     void displayCoordinates(int unit, Graph *g = 0);
00123     //plot window geometry
00124     void displayPlotCoordinates(int unit);
00125     void adjustPlotWidth(double height);
00126     void adjustPlotHeight(double width);
00127 
00128 protected slots:
00129     void setActiveLayer(LayerItem *item);
00130     void updateTreeWidgetItem(QTreeWidgetItem *item);
00131     void updateBackgroundTransparency(int alpha);
00132     void updateCanvasTransparency(int alpha);
00133     void setTitlesFont();
00134     void setAxesLabelsFont();
00135     void setAxesNumbersFont();
00136     void setLegendsFont();
00137     void editCurve();
00138     void chooseLabelsFont();
00139     void applyLayerFormat();
00140     void setLayerDefaultValues();
00141     void setEquidistantLevels();
00142     void showCustomPenColumn(bool on);
00143 
00144 private:
00145     void applyCanvasSize();
00146 
00147     void applyFormatToLayer(Graph *g);
00148     void applySymbolsFormatToCurve(QwtPlotCurve *c, bool fillColor = true, bool penColor = true);
00149     void applySymbolsFormatToLayer(Graph *g);
00150     void applySymbolsFormat(QwtPlotCurve *c);
00151 
00152     void applyLineFormatToLayer(Graph *g);
00153     void applyLineFormat(QwtPlotCurve *c);
00154 
00155     void applyErrorBarFormatToCurve(QwtErrorPlotCurve *err, bool color = true);
00156     void applyErrorBarFormatToLayer(Graph *g);
00157     void applyErrorBarFormat(QwtErrorPlotCurve *c);
00158 
00159     int labelsAlignment();
00160     void closeEvent(QCloseEvent* e);
00161 
00162     void clearTabWidget();
00163     void initAxesPage();
00164     void initLinePage();
00165     void initSymbolsPage();
00166     void initHistogramPage();
00167     void initErrorsPage();
00168     void initSpacingPage();
00169     void initVectPage();
00170     void initBoxPage();
00171     void initPercentilePage();
00172     void initSpectrogramPage();
00173     void initSpectrogramValuesPage();
00174     void initContourLinesPage();
00175     void initLayerPage();
00176     void initLayerGeometryPage();
00177     void initPlotGeometryPage();
00178     void initLayerSpeedPage();
00179     void initFontsPage();
00180     void initMiscPage();
00181     void initPiePage();
00182     void initPieGeometryPage();
00183     void initPieLabelsPage();
00184     void initPrintPage();
00185     void initLabelsPage();
00186     void initFunctionPage();
00187     void contextMenuEvent(QContextMenuEvent *e);
00188     void showAllLabelControls(bool show = true);
00189     void updateContourLevelsDisplay(Spectrogram *sp);
00190     QRect layerCanvasRect(QWidget *widget, double x, double y, double w, double h, FrameWidget::Unit unit);
00191 
00192     double aspect_ratio, plot_aspect_ratio;
00193 
00194     QFont titleFont, legendFont, axesFont, numbersFont;
00195 
00196     MultiLayer *d_ml;
00197     QStringList columnNames;
00198 
00199     DoubleSpinBox* boxX, *boxY, *boxLayerWidth, *boxLayerHeight;
00200     QCheckBox *keepRatioBox;
00201 
00202     QPushButton *btnTitle, *btnAxesLabels, *btnAxesNumbers, *btnLegend;
00203     ColorMapEditor *colorMapEditor;
00204     QWidget *curvePlotTypeBox, *layerPage, *layerGeometryPage, *piePage, *fontsPage, *printPage, *speedPage, *functionPage;
00205     QTreeWidget* listBox;
00206     QCheckBox *boxAntialiasing, *boxScaleLayers, *boxPrintCrops;
00207     ColorButton *boxBorderColor, *boxBackgroundColor, *boxCanvasColor;
00208     QSpinBox *boxBackgroundTransparency, *boxCanvasTransparency, *boxBorderWidth, *boxMargin;
00209     QSpinBox *boxRadius;
00210     DoubleSpinBox *boxPieLineWidth;
00211     ColorBox *boxFirstColor;
00212     ColorButton *boxPieLineColor;
00213     PatternBox *boxPiePattern;
00214     PenStyleBox* boxPieLineStyle;
00215 
00216     QPushButton* buttonApply, *btnWorksheet;
00217     QPushButton* buttonOk, *btnMore;
00218     QPushButton* buttonCancel;
00219     QComboBox* boxPlotType;
00220     QWidget* linePage;
00221     QComboBox* boxConnect;
00222     PenStyleBox* boxLineStyle;
00223     DoubleSpinBox *boxLineWidth, *boxPenWidth;
00224     ColorButton* boxLineColor, *boxAreaColor;
00225     QWidget* symbolPage;
00226     QSpinBox* boxSymbolSize;
00227     ColorButton *boxSymbolColor, *boxFillColor;
00228     SymbolBox* boxSymbolStyle;
00229     PatternBox *boxPattern;
00230     QTabWidget* privateTabWidget;
00231     QWidget *errorsPage, *spectrogramPage, *contourLinesPage;
00232     QGroupBox* fillGroupBox;
00233     QCheckBox* plusBox;
00234     QCheckBox* minusBox;
00235     QCheckBox* xBox;
00236     ColorButton *colorBox, *levelsColorBox, *vectColorBox;
00237     DoubleSpinBox* widthBox;
00238     QComboBox* capBox;
00239     QCheckBox* throughBox;
00240     QLabel *labelPosition, *labelXEnd, *labelYEnd;
00241     QGroupBox* GroupBoxH;
00242     QWidget *histogramPage, *spacingPage;
00243     QLineEdit *binSizeBox, *histogramBeginBox, *histogramEndBox;
00244     QCheckBox *automaticBox;
00245     QPushButton* buttonStatistics, *btnEditCurve;
00246     QSpinBox* gapBox, *offsetBox, *boxWidth;
00247     QWidget *vectPage, *boxPage, *percentilePage, *axesPage;
00248     QComboBox *xEndBox, *yEndBox, *boxType, *boxWhiskersType, *boxWhiskersRange, *boxRange;
00249     QSpinBox* headAngleBox, *headLengthBox, *boxPercSize;
00250     DoubleSpinBox *vectWidthBox, *boxEdgeWidth;
00251     QCheckBox *filledHeadBox;
00252     QSpinBox *boxCoef, *boxWhiskersCoef;
00253     QCheckBox *boxFillSymbols, *boxFillSymbol;
00254     ColorButton *boxPercFillColor, *boxEdgeColor;
00255     QLabel  *whiskerCoeffLabel, *whiskerRangeLabel, *boxCoeffLabel;
00256     QLabel *boxRangeLabel, *whiskerCntLabel, *boxCntLabel;
00257     QGroupBox *GroupBoxVectEnd;
00258     QComboBox *vectPosBox, *boxXAxis, *boxYAxis, *colorScaleBox;
00259     PenStyleBox *boxContourStyle;
00260     QSpinBox *levelsBox, *colorScaleWidthBox;
00261     DoubleSpinBox *contourWidthBox;
00262     QGroupBox *levelsGroupBox, *axisScaleBox, *imageGroupBox;
00263     QGroupBox *defaultPenBox;
00264     QRadioButton *defaultScaleBox, *grayScaleBox, *customScaleBox, *defaultContourBox, *autoContourBox;
00265 
00266     SymbolBox *boxMaxStyle, *boxMinStyle, *boxMeanStyle, *box99Style, *box1Style;
00267     QDoubleSpinBox *whiskerCnt, *boxCnt;
00269     QGroupBox *labelsGroupBox;
00270     DoubleSpinBox *boxLabelsAngle;
00271     QSpinBox *boxLabelsXOffset, *boxLabelsYOffset;
00272     QCheckBox *boxLabelsWhiteOut;
00273     QPushButton *btnLabelsFont;
00274     QComboBox *boxLabelsAlign, *boxLabelsColumn;
00275     ColorButton* boxLabelsColor;
00276     QWidget *labelsPage;
00277 
00278     QGroupBox *pieAutoLabelsBox, *boxPieWedge;
00279     DoubleSpinBox *boxPieStartAzimuth, *boxPieEdgeDist, *boxPieViewAngle, *boxPieThickness;
00280     QCheckBox *boxPieConterClockwise, *boxPieValues, *boxPiePercentages, *boxPieCategories;
00281     QWidget *pieLabelsPage;
00282     QSpinBox *boxPieOffset;
00283     QWidget *pieGeometryPage;
00284 
00285     QComboBox *unitBox;
00286     QComboBox *backgroundApplyToBox;
00287     QPushButton *layerDefaultBtn;
00288 
00289     DoubleSpinBox *firstContourLineBox, *contourLinesDistanceBox;
00290     QLabel *justifyLabelsLbl, *labelsColumnLbl;
00291 
00292     QWidget *spectroValuesPage;
00293     QComboBox *boxSpectroMatrix;
00294     QCheckBox *boxUseMatrixFormula;
00295     ContourLinesEditor *contourLinesEditor;
00296     QPushButton *btnSetEquidistantLevels;
00297     QRadioButton *customPenBtn;
00298 
00299     QSpinBox *boxSkipSymbols, *boxSkipErrorBars;
00300     QComboBox *symbolsFormatApplyToBox, *lineFormatApplyToBox, *errorBarsFormatApplyToBox, *sizeApplyToBox;
00301     QSpinBox *boxMaxPoints;
00302     DoubleSpinBox *boxDouglasPeukerTolerance;
00303     QGroupBox *speedModeBox;
00304 
00305     QWidget *miscPage, *plotGeometryPage;
00306     QCheckBox *boxLinkXAxes;
00307     QComboBox *boxLinkAllXAxes;
00308 
00309     FunctionDialog *functionEdit;
00310     QSpinBox *boxCurveOpacity;
00311     QSlider *curveOpacitySlider;
00312 
00313     DoubleSpinBox *boxPlotX, *boxPlotY, *boxPlotWidth, *boxPlotHeight;
00314     QComboBox *plotUnitBox;
00315     QCheckBox *boxResizeLayers, *keepPlotRatioBox, *layerScaleFonts;
00316 };
00317 
00318 /*****************************************************************************
00319  *
00320  * Class LayerItem
00321  *
00322  *****************************************************************************/
00324 class LayerItem : public QTreeWidgetItem
00325 {
00326 public:
00327     enum {LayerTreeItem = 1001};
00328     LayerItem(Graph *g, QTreeWidgetItem *parent, const QString& s);
00329 
00330     Graph *graph() { return d_graph; };
00331     void setActive(bool select);
00332 
00333 protected:
00334     void insertCurvesList();
00335     Graph *d_graph;
00336 };
00337 
00338 /*****************************************************************************
00339  *
00340  * Class CurveTreeItem
00341  *
00342  *****************************************************************************/
00344 class CurveTreeItem : public QTreeWidgetItem
00345 {
00346 public:
00347     enum {PlotCurveTreeItem = 1002};
00348     CurveTreeItem(QwtPlotItem *curve, LayerItem *parent, const QString& s);
00349 
00350     Graph* graph(){return ((LayerItem *)parent())->graph();};
00351     void setActive(bool on);
00352 
00353     const QwtPlotItem *plotItem() { return d_curve; };
00354     int plotItemType();
00355     int plotItemStyle();
00356     int plotItemIndex();
00357 
00358 protected:
00359     QwtPlotItem *d_curve;
00360 };
00361 
00362 #endif