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 72 //! Custom plot/curves dialog 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); insertColumnsList(const QStringList & names)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 void plotAssociationsDialogClosed(); 163 164 private: 165 void resizeLayerToFitImage(Graph *g); 166 void applyCanvasFormatToLayer(Graph *g); 167 void applyCanvasSize(); 168 169 void applyFormatToLayer(Graph *g); 170 void applySymbolsFormatToCurve(QwtPlotCurve *c, bool fillColor = true, bool penColor = true); 171 void applySymbolsFormatToLayer(Graph *g); 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); 178 void applyErrorBarFormatToLayer(Graph *g); 179 void applyErrorBarFormat(ErrorBarsCurve *c); 180 181 void applyBoxWhiskersFormatToCurve(BoxCurve *b); 182 void applyBoxWhiskersFormatToLayer(Graph *g); 183 void applyBoxWhiskersFormat(BoxCurve *c); 184 185 void applyPercentileFormatToCurve(BoxCurve *b); 186 void applyPercentileFormatToLayer(Graph *g); 187 void applyPercentileFormat(BoxCurve *c); 188 189 void applyLabelsFormatToItem(QwtPlotItem *); 190 void applyLabelsFormatToLayer(Graph *); 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(); 214 void initSpectrogramValuesPage(); 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); 232 void updateContourLevelsDisplay(Spectrogram *sp); 233 QRect layerCanvasRect(QWidget *widget, double x, double y, double w, double h, FrameWidget::Unit unit); 234 235 double aspect_ratio, plot_aspect_ratio; 236 237 QFont titleFont, legendFont, axesFont, numbersFont; 238 239 MultiLayer *d_ml; 240 QStringList columnNames; 241 242 DoubleSpinBox* boxX, *boxY, *boxLayerWidth, *boxLayerHeight; 243 QCheckBox *keepRatioBox; 244 245 QPushButton *btnTitle, *btnAxesLabels, *btnAxesNumbers, *btnLegend; 246 ColorMapEditor *colorMapEditor; 247 QWidget *curvePlotTypeBox, *layerPage, *layerGeometryPage, *piePage, *fontsPage, *printPage; 248 QWidget *layerDisplayPage, *speedPage, *functionPage, *canvasPage; 249 QTreeWidget* listBox; 250 QCheckBox *boxAntialiasing, *boxScaleLayers, *boxPrintCrops, *boxAutoscaling, *boxGridPosition, *boxMissingData; 251 ColorButton *boxBorderColor, *boxBackgroundColor, *boxCanvasColor; 252 QSpinBox *boxBackgroundTransparency, *boxCanvasTransparency, *boxBorderWidth, *boxMargin; 253 QSpinBox *boxRadius; 254 DoubleSpinBox *boxPieLineWidth; 255 ColorBox *boxFirstColor; 256 ColorButton *boxPieLineColor; 257 PatternBox *boxPiePattern; 258 PenStyleBox* boxPieLineStyle; 259 QLineEdit *imagePathBox; 260 QComboBox *imageApplyToBox; 261 QRadioButton *colorBtn, *imageBtn; 262 QGroupBox *canvasColorBox, *canvasImageBox; 263 264 QPushButton* buttonApply, *btnWorksheet; 265 QPushButton* buttonOk, *btnMore; 266 QPushButton* buttonCancel; 267 QComboBox* boxPlotType; 268 QWidget* linePage; 269 QComboBox* boxConnect; 270 PenStyleBox* boxLineStyle; 271 DoubleSpinBox *boxLineWidth, *boxPenWidth; 272 ColorButton* boxLineColor, *boxAreaColor; 273 QWidget* symbolPage; 274 QSpinBox* boxSymbolSize; 275 ColorButton *boxSymbolColor, *boxFillColor; 276 SymbolBox* boxSymbolStyle; 277 PatternBox *boxPattern; 278 QTabWidget* privateTabWidget; 279 QWidget *errorsPage, *spectrogramPage, *contourLinesPage; 280 QGroupBox* fillGroupBox; 281 QCheckBox* plusBox; 282 QCheckBox* minusBox; 283 QCheckBox* xBox; 284 ColorButton *colorBox, *levelsColorBox, *vectColorBox; 285 DoubleSpinBox* widthBox; 286 QComboBox* capBox; 287 QCheckBox* throughBox; 288 QLabel *labelPosition, *labelXEnd, *labelYEnd; 289 QGroupBox* GroupBoxH; 290 QWidget *histogramPage, *spacingPage; 291 DoubleSpinBox *binSizeBox, *histogramBeginBox, *histogramEndBox; 292 QCheckBox *automaticBox; 293 QPushButton* buttonStatistics, *btnEditCurve, *buttonBoxStatistics, *btnEditCurveRange; 294 QSpinBox* gapBox, *offsetBox, *boxWidth; 295 QWidget *vectPage, *boxPage, *percentilePage, *axesPage; 296 QComboBox *xEndBox, *yEndBox, *boxType, *boxWhiskersType, *boxWhiskersRange, *boxRange; 297 QSpinBox* headAngleBox, *headLengthBox, *boxPercSize; 298 DoubleSpinBox *vectWidthBox, *boxEdgeWidth; 299 QCheckBox *filledHeadBox; 300 QSpinBox *boxCoef, *boxWhiskersCoef; 301 QCheckBox *boxFillSymbols, *boxFillSymbol; 302 ColorButton *boxPercFillColor, *boxEdgeColor; 303 QLabel *whiskerCoeffLabel, *whiskerRangeLabel, *boxCoeffLabel; 304 QLabel *boxRangeLabel, *whiskerCntLabel, *boxCntLabel; 305 QGroupBox *GroupBoxVectEnd; 306 QComboBox *vectPosBox, *boxXAxis, *boxYAxis, *colorScaleBox; 307 PenStyleBox *boxContourStyle; 308 QSpinBox *levelsBox, *colorScaleWidthBox; 309 DoubleSpinBox *contourWidthBox; 310 QGroupBox *levelsGroupBox, *axisScaleBox, *imageGroupBox; 311 QGroupBox *defaultPenBox; 312 QRadioButton *defaultScaleBox, *grayScaleBox, *customScaleBox, *defaultContourBox, *autoContourBox; 313 314 QCheckBox *boxWhiskerLabels, *boxBoxLabels; 315 QComboBox *boxWhiskersFormatApplyToBox, *boxLabelsFormatApplyToBox, *percentileFormatApplyToBox; 316 SymbolBox *boxMaxStyle, *boxMinStyle, *boxMeanStyle, *box99Style, *box1Style; 317 QDoubleSpinBox *whiskerCnt, *boxCnt; 318 //!Labels page 319 QGroupBox *labelsGroupBox; 320 DoubleSpinBox *boxLabelsAngle; 321 QSpinBox *boxLabelsXOffset, *boxLabelsYOffset; 322 QCheckBox *boxLabelsWhiteOut; 323 QPushButton *btnLabelsFont; 324 QComboBox *boxLabelsAlign, *boxLabelsColumn; 325 ColorButton* boxLabelsColor; 326 QWidget *labelsPage; 327 328 QGroupBox *pieAutoLabelsBox, *boxPieWedge; 329 DoubleSpinBox *boxPieStartAzimuth, *boxPieEdgeDist, *boxPieViewAngle, *boxPieThickness; 330 QCheckBox *boxPieConterClockwise, *boxPieValues, *boxPiePercentages, *boxPieCategories; 331 QWidget *pieLabelsPage; 332 QSpinBox *boxPieOffset; 333 QWidget *pieGeometryPage; 334 335 QComboBox *unitBox; 336 QComboBox *backgroundApplyToBox; 337 QPushButton *layerDefaultBtn; 338 339 DoubleSpinBox *firstContourLineBox, *contourLinesDistanceBox; 340 QLabel *justifyLabelsLbl, *labelsColumnLbl; 341 342 QWidget *spectroValuesPage; 343 QComboBox *boxSpectroMatrix; 344 QCheckBox *boxUseMatrixFormula; 345 ContourLinesEditor *contourLinesEditor; 346 QPushButton *btnSetEquidistantLevels; 347 QRadioButton *customPenBtn; 348 349 QSpinBox *boxSkipSymbols, *boxSkipErrorBars; 350 QComboBox *symbolsFormatApplyToBox, *lineFormatApplyToBox, *errorBarsFormatApplyToBox, *sizeApplyToBox; 351 QSpinBox *boxMaxPoints; 352 DoubleSpinBox *boxDouglasPeukerTolerance; 353 QGroupBox *speedModeBox; 354 QCheckBox *boxApplyColorTo; 355 356 QWidget *miscPage, *plotGeometryPage; 357 QCheckBox *boxLinkXAxes; 358 QComboBox *boxLinkAllXAxes; 359 360 FunctionDialog *functionEdit; 361 QSpinBox *boxCurveOpacity, *boxSymbolTransparency, *boxLineTransparency, *boxPercentileTransparency; 362 QSlider *curveOpacitySlider, *symbTransparencySlider, *lineTransparencySlider, *percentileTransparencySlider; 363 364 DoubleSpinBox *boxPlotX, *boxPlotY, *boxPlotWidth, *boxPlotHeight; 365 QComboBox *plotUnitBox, *gapApplyToBox; 366 QCheckBox *boxResizeLayers, *keepPlotRatioBox, *layerScaleFonts; 367 EnrichmentDialog *enrichmentDialog; 368 QPushButton *btnUp, *btnDown; 369 QLabel *barsOffsetLabel; 370 371 QRadioButton *standardSymbolBtn, *imageSymbolBtn; 372 QGroupBox *standardSymbolFormatBox, *imageSymBolFormatBox; 373 QLineEdit *imageSymbolPathBox; 374 QLabel *symbolImageLabel; 375 376 QGroupBox *boxFramed; 377 ColorButton *boxFrameColor; 378 QSpinBox *boxFrameWidth; 379 QPushButton *canvasDefaultBtn; 380 QSlider *canvasOpacitySlider, *bkgOpacitySlider; 381 382 QCheckBox *boxLeftAxis, *boxRightAxis, *boxBottomAxis, *boxTopAxis; 383 QCompleter *completer; 384 }; 385 386 /***************************************************************************** 387 * 388 * Class LayerItem 389 * 390 *****************************************************************************/ 391 //! LayerItem tree widget item class 392 class LayerItem : public QTreeWidgetItem 393 { 394 public: 395 enum {LayerTreeItem = 1001}; 396 LayerItem(Graph *g, QTreeWidgetItem *parent, const QString& s); 397 graph()398 Graph *graph() { return d_graph; }; 399 void setActive(bool select); 400 401 protected: 402 void insertCurvesList(); 403 void insertEnrichmentsList(); 404 Graph *d_graph; 405 }; 406 407 /***************************************************************************** 408 * 409 * Class CurveTreeItem 410 * 411 *****************************************************************************/ 412 //! CurveTreeItem tree widget item class 413 class CurveTreeItem : public QTreeWidgetItem 414 { 415 public: 416 enum {PlotCurveTreeItem = 1002}; 417 CurveTreeItem(QwtPlotItem *curve, LayerItem *parent, const QString& s); 418 graph()419 Graph* graph(){return ((LayerItem *)parent())->graph();}; 420 void setActive(bool on); 421 plotItem()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 *****************************************************************************/ 436 //! FrameWidgetTreeItem tree widget item class 437 class FrameWidgetTreeItem : public QTreeWidgetItem 438 { 439 public: 440 enum {FrameWidgetItem = 1003}; 441 FrameWidgetTreeItem(FrameWidget *w, LayerItem *parent, const QString& s); 442 graph()443 Graph* graph(){return ((LayerItem *)parent())->graph();}; frameWidget()444 FrameWidget *frameWidget(){return d_widget;}; 445 446 void setActive(bool on); 447 448 protected: 449 QPixmap frameWidgetPixmap(); 450 451 FrameWidget *d_widget; 452 }; 453 #endif 454