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 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     void showPlotAssociations(QTreeWidgetItem *item, int);
00123 
00124     //box plots
00125     void setBoxType(int index);
00126     void setBoxRangeType(int index);
00127     void setWhiskersRange(int index);
00128     void enableLabelsPage();
00129 
00130     //spectrograms
00131     void showDefaultContourLinesBox(bool show);
00132     void showColorMapEditor(bool show);
00133 
00134     //layer geometry
00135     void adjustLayerHeight(double width);
00136     void adjustLayerWidth(double height);
00137     void displayCoordinates(int unit, Graph *g = 0);
00138     //plot window geometry
00139     void displayPlotCoordinates(int unit);
00140     void adjustPlotWidth(double height);
00141     void adjustPlotHeight(double width);
00142 
00143     void setCanvasDefaultValues();
00144 
00145     void setActiveLayer(LayerItem *item);
00146     void updateTreeWidgetItem(QTreeWidgetItem *item);
00147     void updateBackgroundTransparency(int alpha);
00148     void updateCanvasTransparency(int alpha);
00149     void setTitlesFont();
00150     void setAxesLabelsFont();
00151     void setAxesNumbersFont();
00152     void setLegendsFont();
00153     void editCurve();
00154     void chooseLabelsFont();
00155     void applyLayerFormat();
00156     void applyCanvasFormat();
00157     void setLayerDefaultValues();
00158     void setEquidistantLevels();
00159     void showCustomPenColumn(bool on);
00160 
00161 private:
00162     void resizeLayerToFitImage(Graph *g);
00163     void applyCanvasFormatToLayer(Graph *g);
00164     void applyCanvasSize();
00165 
00166     void applyFormatToLayer(Graph *g);
00167     void applySymbolsFormatToCurve(QwtPlotCurve *c, bool fillColor = true, bool penColor = true);
00168     void applySymbolsFormatToLayer(Graph *g);
00169     void applySymbolsFormat(QwtPlotCurve *c);
00170 
00171     void applyLineFormatToLayer(Graph *g);
00172     void applyLineFormat(QwtPlotCurve *c);
00173 
00174     void applyErrorBarFormatToCurve(ErrorBarsCurve *err, bool color = true);
00175     void applyErrorBarFormatToLayer(Graph *g);
00176     void applyErrorBarFormat(ErrorBarsCurve *c);
00177 
00178     void applyBoxWhiskersFormatToCurve(BoxCurve *b);
00179     void applyBoxWhiskersFormatToLayer(Graph *g);
00180     void applyBoxWhiskersFormat(BoxCurve *c);
00181 
00182     void applyPercentileFormatToCurve(BoxCurve *b);
00183     void applyPercentileFormatToLayer(Graph *g);
00184     void applyPercentileFormat(BoxCurve *c);
00185 
00186     void applyLabelsFormatToItem(QwtPlotItem *);
00187     void applyLabelsFormatToLayer(Graph *);
00188     void applyLabelsFormat(QwtPlotItem *);
00189 
00190     void applyGapToLayer(Graph *g);
00191     void applyGap(Graph *g);
00192 
00193     void setLabelsFont(const QFont& font, Graph *, const QwtPlotItem *);
00194     void setLabelsFontToPlotItem(const QFont& font, const QwtPlotItem *);
00195     void setLabelsFontToLayer(const QFont& font, Graph *);
00196 
00197     int labelsAlignment();
00198     void closeEvent(QCloseEvent* e);
00199 
00200     void clearTabWidget();
00201     void initAxesPage();
00202     void initLinePage();
00203     void initSymbolsPage();
00204     void initHistogramPage();
00205     void initErrorsPage();
00206     void initSpacingPage();
00207     void initVectPage();
00208     void initBoxPage();
00209     void initPercentilePage();
00210     void initSpectrogramPage();
00211     void initSpectrogramValuesPage();
00212     void initContourLinesPage();
00213     void initLayerPage();
00214     void initCanvasPage();
00215     void initLayerGeometryPage();
00216     void initPlotGeometryPage();
00217     void initLayerSpeedPage();
00218     void initFontsPage();
00219     void initMiscPage();
00220     void initPiePage();
00221     void initPieGeometryPage();
00222     void initPieLabelsPage();
00223     void initPrintPage();
00224     void initLabelsPage();
00225     void initFunctionPage();
00226     void contextMenuEvent(QContextMenuEvent *e);
00227     void showAllLabelControls(bool show = true, int curveType = 0);
00228     void updateContourLevelsDisplay(Spectrogram *sp);
00229     QRect layerCanvasRect(QWidget *widget, double x, double y, double w, double h, FrameWidget::Unit unit);
00230 
00231     double aspect_ratio, plot_aspect_ratio;
00232 
00233     QFont titleFont, legendFont, axesFont, numbersFont;
00234 
00235     MultiLayer *d_ml;
00236     QStringList columnNames;
00237 
00238     DoubleSpinBox* boxX, *boxY, *boxLayerWidth, *boxLayerHeight;
00239     QCheckBox *keepRatioBox;
00240 
00241     QPushButton *btnTitle, *btnAxesLabels, *btnAxesNumbers, *btnLegend;
00242     ColorMapEditor *colorMapEditor;
00243     QWidget *curvePlotTypeBox, *layerPage, *layerGeometryPage, *piePage, *fontsPage, *printPage, *speedPage, *functionPage, *canvasPage;
00244     QTreeWidget* listBox;
00245     QCheckBox *boxAntialiasing, *boxScaleLayers, *boxPrintCrops, *boxAutoscaling;
00246     ColorButton *boxBorderColor, *boxBackgroundColor, *boxCanvasColor;
00247     QSpinBox *boxBackgroundTransparency, *boxCanvasTransparency, *boxBorderWidth, *boxMargin;
00248     QSpinBox *boxRadius;
00249     DoubleSpinBox *boxPieLineWidth;
00250     ColorBox *boxFirstColor;
00251     ColorButton *boxPieLineColor;
00252     PatternBox *boxPiePattern;
00253     PenStyleBox* boxPieLineStyle;
00254     QLineEdit *imagePathBox;
00255     QComboBox *imageApplyToBox;
00256     QRadioButton *colorBtn, *imageBtn;
00257     QGroupBox *canvasColorBox, *canvasImageBox;
00258 
00259     QPushButton* buttonApply, *btnWorksheet;
00260     QPushButton* buttonOk, *btnMore;
00261     QPushButton* buttonCancel;
00262     QComboBox* boxPlotType;
00263     QWidget* linePage;
00264     QComboBox* boxConnect;
00265     PenStyleBox* boxLineStyle;
00266     DoubleSpinBox *boxLineWidth, *boxPenWidth;
00267     ColorButton* boxLineColor, *boxAreaColor;
00268     QWidget* symbolPage;
00269     QSpinBox* boxSymbolSize;
00270     ColorButton *boxSymbolColor, *boxFillColor;
00271     SymbolBox* boxSymbolStyle;
00272     PatternBox *boxPattern;
00273     QTabWidget* privateTabWidget;
00274     QWidget *errorsPage, *spectrogramPage, *contourLinesPage;
00275     QGroupBox* fillGroupBox;
00276     QCheckBox* plusBox;
00277     QCheckBox* minusBox;
00278     QCheckBox* xBox;
00279     ColorButton *colorBox, *levelsColorBox, *vectColorBox;
00280     DoubleSpinBox* widthBox;
00281     QComboBox* capBox;
00282     QCheckBox* throughBox;
00283     QLabel *labelPosition, *labelXEnd, *labelYEnd;
00284     QGroupBox* GroupBoxH;
00285     QWidget *histogramPage, *spacingPage;
00286     DoubleSpinBox *binSizeBox, *histogramBeginBox, *histogramEndBox;
00287     QCheckBox *automaticBox;
00288     QPushButton* buttonStatistics, *btnEditCurve, *buttonBoxStatistics;
00289     QSpinBox* gapBox, *offsetBox, *boxWidth;
00290     QWidget *vectPage, *boxPage, *percentilePage, *axesPage;
00291     QComboBox *xEndBox, *yEndBox, *boxType, *boxWhiskersType, *boxWhiskersRange, *boxRange;
00292     QSpinBox* headAngleBox, *headLengthBox, *boxPercSize;
00293     DoubleSpinBox *vectWidthBox, *boxEdgeWidth;
00294     QCheckBox *filledHeadBox;
00295     QSpinBox *boxCoef, *boxWhiskersCoef;
00296     QCheckBox *boxFillSymbols, *boxFillSymbol;
00297     ColorButton *boxPercFillColor, *boxEdgeColor;
00298     QLabel  *whiskerCoeffLabel, *whiskerRangeLabel, *boxCoeffLabel;
00299     QLabel *boxRangeLabel, *whiskerCntLabel, *boxCntLabel;
00300     QGroupBox *GroupBoxVectEnd;
00301     QComboBox *vectPosBox, *boxXAxis, *boxYAxis, *colorScaleBox;
00302     PenStyleBox *boxContourStyle;
00303     QSpinBox *levelsBox, *colorScaleWidthBox;
00304     DoubleSpinBox *contourWidthBox;
00305     QGroupBox *levelsGroupBox, *axisScaleBox, *imageGroupBox;
00306     QGroupBox *defaultPenBox;
00307     QRadioButton *defaultScaleBox, *grayScaleBox, *customScaleBox, *defaultContourBox, *autoContourBox;
00308 
00309     QCheckBox *boxWhiskerLabels, *boxBoxLabels;
00310     QComboBox *boxWhiskersFormatApplyToBox, *boxLabelsFormatApplyToBox, *percentileFormatApplyToBox;
00311     SymbolBox *boxMaxStyle, *boxMinStyle, *boxMeanStyle, *box99Style, *box1Style;
00312     QDoubleSpinBox *whiskerCnt, *boxCnt;
00314     QGroupBox *labelsGroupBox;
00315     DoubleSpinBox *boxLabelsAngle;
00316     QSpinBox *boxLabelsXOffset, *boxLabelsYOffset;
00317     QCheckBox *boxLabelsWhiteOut;
00318     QPushButton *btnLabelsFont;
00319     QComboBox *boxLabelsAlign, *boxLabelsColumn;
00320     ColorButton* boxLabelsColor;
00321     QWidget *labelsPage;
00322 
00323     QGroupBox *pieAutoLabelsBox, *boxPieWedge;
00324     DoubleSpinBox *boxPieStartAzimuth, *boxPieEdgeDist, *boxPieViewAngle, *boxPieThickness;
00325     QCheckBox *boxPieConterClockwise, *boxPieValues, *boxPiePercentages, *boxPieCategories;
00326     QWidget *pieLabelsPage;
00327     QSpinBox *boxPieOffset;
00328     QWidget *pieGeometryPage;
00329 
00330     QComboBox *unitBox;
00331     QComboBox *backgroundApplyToBox;
00332     QPushButton *layerDefaultBtn;
00333 
00334     DoubleSpinBox *firstContourLineBox, *contourLinesDistanceBox;
00335     QLabel *justifyLabelsLbl, *labelsColumnLbl;
00336 
00337     QWidget *spectroValuesPage;
00338     QComboBox *boxSpectroMatrix;
00339     QCheckBox *boxUseMatrixFormula;
00340     ContourLinesEditor *contourLinesEditor;
00341     QPushButton *btnSetEquidistantLevels;
00342     QRadioButton *customPenBtn;
00343 
00344     QSpinBox *boxSkipSymbols, *boxSkipErrorBars;
00345     QComboBox *symbolsFormatApplyToBox, *lineFormatApplyToBox, *errorBarsFormatApplyToBox, *sizeApplyToBox;
00346     QSpinBox *boxMaxPoints;
00347     DoubleSpinBox *boxDouglasPeukerTolerance;
00348     QGroupBox *speedModeBox;
00349     QCheckBox *boxApplyColorTo;
00350 
00351     QWidget *miscPage, *plotGeometryPage;
00352     QCheckBox *boxLinkXAxes;
00353     QComboBox *boxLinkAllXAxes;
00354 
00355     FunctionDialog *functionEdit;
00356     QSpinBox *boxCurveOpacity;
00357     QSlider *curveOpacitySlider;
00358 
00359     DoubleSpinBox *boxPlotX, *boxPlotY, *boxPlotWidth, *boxPlotHeight;
00360     QComboBox *plotUnitBox, *gapApplyToBox;
00361     QCheckBox *boxResizeLayers, *keepPlotRatioBox, *layerScaleFonts;
00362     EnrichmentDialog *enrichmentDialog;
00363     QPushButton *btnUp, *btnDown;
00364     QLabel *barsOffsetLabel;
00365 
00366     QRadioButton *standardSymbolBtn, *imageSymbolBtn;
00367     QGroupBox *standardSymbolFormatBox, *imageSymBolFormatBox;
00368     QLineEdit *imageSymbolPathBox;
00369     QLabel *symbolImageLabel;
00370 
00371     QGroupBox *boxFramed;
00372     ColorButton *boxFrameColor;
00373     QSpinBox *boxFrameWidth;
00374     QPushButton *canvasDefaultBtn;
00375     QSlider *canvasOpacitySlider;
00376 
00377     QCompleter *completer;
00378 };
00379 
00380 /*****************************************************************************
00381  *
00382  * Class LayerItem
00383  *
00384  *****************************************************************************/
00386 class LayerItem : public QTreeWidgetItem
00387 {
00388 public:
00389     enum {LayerTreeItem = 1001};
00390     LayerItem(Graph *g, QTreeWidgetItem *parent, const QString& s);
00391 
00392     Graph *graph() { return d_graph; };
00393     void setActive(bool select);
00394 
00395 protected:
00396     void insertCurvesList();
00397     void insertEnrichmentsList();
00398     Graph *d_graph;
00399 };
00400 
00401 /*****************************************************************************
00402  *
00403  * Class CurveTreeItem
00404  *
00405  *****************************************************************************/
00407 class CurveTreeItem : public QTreeWidgetItem
00408 {
00409 public:
00410     enum {PlotCurveTreeItem = 1002};
00411     CurveTreeItem(QwtPlotItem *curve, LayerItem *parent, const QString& s);
00412 
00413     Graph* graph(){return ((LayerItem *)parent())->graph();};
00414     void setActive(bool on);
00415 
00416     const QwtPlotItem *plotItem() { return d_curve; };
00417     int plotItemType();
00418     int plotItemStyle();
00419     int plotItemIndex();
00420 
00421 protected:
00422     QwtPlotItem *d_curve;
00423 };
00424 
00425 /*****************************************************************************
00426  *
00427  * Class FrameWidgetTreeItem
00428  *
00429  *****************************************************************************/
00431 class FrameWidgetTreeItem : public QTreeWidgetItem
00432 {
00433 public:
00434     enum {FrameWidgetItem = 1003};
00435     FrameWidgetTreeItem(FrameWidget *w, LayerItem *parent, const QString& s);
00436 
00437     Graph* graph(){return ((LayerItem *)parent())->graph();};
00438     FrameWidget *frameWidget(){return d_widget;};
00439 
00440      void setActive(bool on);
00441 
00442 protected:
00443     QPixmap frameWidgetPixmap();
00444 
00445     FrameWidget *d_widget;
00446 };
00447 #endif