00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef QPSHAPE_H_
00028 #define QPSHAPE_H_
00029
00030 #ifdef AIPS_HAS_QWT
00031
00032 #include <graphics/GenericPlotter/PlotShape.h>
00033 #include <casaqt/QwtPlotter/QPOptions.h>
00034 #include <casaqt/QwtPlotter/QPPlotItem.qo.h>
00035
00036 #include <qwt_plot_item.h>
00037 #include <qwt_plot_marker.h>
00038
00039 namespace casa {
00040
00041
00042
00043 class QPShape : public QPPlotItem, public virtual PlotShape {
00044 public:
00045
00046
00047
00048
00049 static QPShape* clone(const PlotShape& copy);
00050
00051
00052
00053
00054
00055 QPShape();
00056
00057
00058
00059 QPShape(const PlotShape& copy);
00060
00061
00062 virtual ~QPShape();
00063
00064
00065
00066 using PlotShape::setLine;
00067 using PlotShape::setAreaFill;
00068
00069
00070
00071
00072 #if QWT_VERSION < 0x060000
00073
00074 virtual QWidget* legendItem() const;
00075 #endif
00076
00077
00078
00079
00080 bool lineShown() const;
00081
00082
00083 void setLineShown(bool line = true);
00084
00085
00086 PlotLinePtr line() const;
00087
00088
00089 void setLine(const PlotLine& line);
00090
00091
00092 bool areaFilled() const;
00093
00094
00095 void setAreaFilled(bool area = true);
00096
00097
00098 PlotAreaFillPtr areaFill() const;
00099
00100
00101 void setAreaFill(const PlotAreaFill& fill);
00102
00103 protected:
00104 QPLine m_line;
00105 QPAreaFill m_area;
00106
00107
00108
00109 virtual QwtSymbol::Style legendStyle() const = 0;
00110 };
00111
00112
00113
00114 class QPRectangle : public QPShape, public PlotShapeRectangle {
00115 public:
00116
00117
00118
00119 static const String CLASS_NAME;
00120
00121
00122
00123
00124
00125 QPRectangle(const PlotCoordinate& upperLeft,
00126 const PlotCoordinate& lowerRight);
00127
00128
00129 QPRectangle(const QwtDoubleRect& r);
00130
00131
00132 QPRectangle(const PlotShapeRectangle& copy);
00133
00134
00135 ~QPRectangle();
00136
00137
00138
00139
00140
00141 bool isValid() const;
00142
00143
00144 QwtDoubleRect boundingRect() const;
00145
00146
00147
00148
00149
00150 vector<PlotCoordinate> coordinates() const;
00151
00152
00153 void setCoordinates(const vector<PlotCoordinate>& coords);
00154
00155
00156 void setRectCoordinates(const PlotCoordinate& upperLeft,
00157 const PlotCoordinate& lowerRight);
00158
00159 protected:
00160
00161 const String& className() const { return CLASS_NAME; }
00162
00163
00164 #if QWT_VERSION >= 0x060000
00165 void draw_(QPainter* painter, const QwtScaleMap& xMap,
00166 const QwtScaleMap& yMap, const QRectF& canvasRect,
00167 unsigned int drawIndex, unsigned int drawCount) const;
00168 #else
00169 void draw_(QPainter* painter, const QwtScaleMap& xMap,
00170 const QwtScaleMap& yMap, const QRect& canvasRect,
00171 unsigned int drawIndex, unsigned int drawCount) const;
00172 #endif
00173
00174
00175 QwtSymbol::Style legendStyle() const { return QwtSymbol::Rect; }
00176
00177
00178 private:
00179 PlotCoordinate m_upperLeft;
00180 PlotCoordinate m_lowerRight;
00181 };
00182
00183
00184
00185 class QPEllipse : public QPShape, public PlotShapeEllipse {
00186 public:
00187
00188
00189
00190 static const String CLASS_NAME;
00191
00192
00193
00194
00195
00196 QPEllipse(const PlotCoordinate& center, const PlotCoordinate& radii);
00197
00198
00199 QPEllipse(const QwtDoubleRect& r);
00200
00201
00202 QPEllipse(const PlotShapeEllipse& copy);
00203
00204
00205 ~QPEllipse();
00206
00207
00208
00209
00210
00211 bool isValid() const;
00212
00213
00214 QwtDoubleRect boundingRect() const;
00215
00216
00217
00218
00219
00220 vector<PlotCoordinate> coordinates() const;
00221
00222
00223 void setCoordinates(const vector<PlotCoordinate>& coords);
00224
00225
00226 void setEllipseCoordinates(const PlotCoordinate& center,
00227 const PlotCoordinate& radii);
00228
00229
00230 PlotCoordinate radii() const;
00231
00232
00233 void setRadii(const PlotCoordinate& radii);
00234
00235
00236 PlotCoordinate center() const;
00237
00238
00239 void setCenter(const PlotCoordinate& center);
00240
00241 protected:
00242
00243 const String& className() const { return CLASS_NAME; }
00244
00245
00246 #if QWT_VERSION >= 0x060000
00247 void draw_(QPainter* painter, const QwtScaleMap& xMap,
00248 const QwtScaleMap& yMap, const QRectF& canvasRect,
00249 unsigned int drawIndex, unsigned int drawCount) const;
00250 #else
00251 void draw_(QPainter* painter, const QwtScaleMap& xMap,
00252 const QwtScaleMap& yMap, const QRect& canvasRect,
00253 unsigned int drawIndex, unsigned int drawCount) const;
00254 #endif
00255
00256
00257 QwtSymbol::Style legendStyle() const { return QwtSymbol::Ellipse; }
00258
00259 private:
00260 PlotCoordinate m_center;
00261 PlotCoordinate m_radii;
00262 };
00263
00264
00265
00266 class QPPolygon : public QPShape, public PlotShapePolygon {
00267 public:
00268
00269
00270
00271 static const String CLASS_NAME;
00272
00273
00274
00275
00276
00277 QPPolygon(const vector<PlotCoordinate>& coords);
00278
00279
00280 QPPolygon(const PlotShapePolygon& copy);
00281
00282
00283 ~QPPolygon();
00284
00285
00286
00287
00288
00289 bool isValid() const;
00290
00291
00292 QwtDoubleRect boundingRect() const;
00293
00294
00295
00296
00297
00298 vector<PlotCoordinate> coordinates() const;
00299
00300
00301 void setCoordinates(const vector<PlotCoordinate>& coords);
00302
00303 protected:
00304
00305 const String& className() const { return CLASS_NAME; }
00306
00307
00308 #if QWT_VERSION >= 0x060000
00309 void draw_(QPainter* painter, const QwtScaleMap& xMap,
00310 const QwtScaleMap& yMap, const QRectF& canvasRect,
00311 unsigned int drawIndex, unsigned int drawCount) const;
00312 #else
00313 void draw_(QPainter* painter, const QwtScaleMap& xMap,
00314 const QwtScaleMap& yMap, const QRect& canvasRect,
00315 unsigned int drawIndex, unsigned int drawCount) const;
00316 #endif
00317
00318
00319 QwtSymbol::Style legendStyle() const { return QwtSymbol::Hexagon; }
00320
00321 private:
00322 vector<PlotCoordinate> m_coords;
00323 };
00324
00325
00326
00327 class QPLineShape : public QPShape, public PlotShapeLine {
00328 public:
00329
00330
00331
00332 static const String CLASS_NAME;
00333
00334
00335
00336
00337
00338 QPLineShape(double location, PlotAxis axis);
00339
00340
00341 QPLineShape(const PlotShapeLine& copy);
00342
00343
00344 ~QPLineShape();
00345
00346
00347
00348
00349
00350 bool isValid() const;
00351
00352
00353 QwtDoubleRect boundingRect() const;
00354
00355
00356
00357
00358
00359 vector<PlotCoordinate> coordinates() const;
00360
00361
00362 void setCoordinates(const vector<PlotCoordinate>& coords);
00363
00364
00365 void setLineCoordinates(double location, PlotAxis axis);
00366
00367
00368 double location() const;
00369
00370
00371 PlotAxis axis() const;
00372
00373 protected:
00374
00375 const String& className() const { return CLASS_NAME; }
00376
00377
00378 #if QWT_VERSION >= 0x060000
00379 void draw_(QPainter* painter, const QwtScaleMap& xMap,
00380 const QwtScaleMap& yMap, const QRectF& canvasRect,
00381 unsigned int drawIndex, unsigned int drawCount) const;
00382 #else
00383 void draw_(QPainter* painter, const QwtScaleMap& xMap,
00384 const QwtScaleMap& yMap, const QRect& canvasRect,
00385 unsigned int drawIndex, unsigned int drawCount) const;
00386 #endif
00387
00388
00389 QwtSymbol::Style legendStyle() const { return QwtSymbol::HLine; }
00390
00391 private:
00392 QwtPlotMarker m_marker;
00393 PlotAxis m_axis;
00394 };
00395
00396
00397
00398 class QPArrow : public QPShape, public PlotShapeArrow {
00399 public:
00400
00401
00402
00403 static const String CLASS_NAME;
00404
00405
00406
00407
00408
00409
00410 static std::pair<QPointF, QPointF> arrowPoints(QPointF from, QPointF to,
00411 double length);
00412 static void arrowPoints(double x1, double y1, double x2, double y2,
00413 double length, double& resX1, double& resY1,
00414 double& resX2, double& resY2);
00415
00416
00417
00418
00419
00420
00421 QPArrow(const PlotCoordinate& from, const PlotCoordinate& to);
00422
00423
00424 QPArrow(const PlotShapeArrow& copy);
00425
00426
00427 ~QPArrow();
00428
00429
00430
00431
00432
00433 bool isValid() const;
00434
00435
00436 QwtDoubleRect boundingRect() const;
00437
00438
00439
00440
00441
00442 vector<PlotCoordinate> coordinates() const;
00443
00444
00445 void setCoordinates(const vector<PlotCoordinate>& coords);
00446
00447
00448 void setArrowCoordinates(const PlotCoordinate& from,
00449 const PlotCoordinate& to);
00450
00451
00452 Style arrowStyleFrom() const;
00453
00454
00455 Style arrowStyleTo() const;
00456
00457
00458 void setArrowStyleFrom(Style style) { setArrowStyles(style, m_toStyle); }
00459
00460
00461 void setArrowStyleTo(Style style) { setArrowStyles(m_fromStyle, style); }
00462
00463
00464 void setArrowStyles(Style from, Style to);
00465
00466
00467 double arrowSize() const;
00468
00469
00470 void setArrowSize(double size);
00471
00472 protected:
00473
00474 const String& className() const { return CLASS_NAME; }
00475
00476
00477 #if QWT_VERSION >= 0x060000
00478 void draw_(QPainter* painter, const QwtScaleMap& xMap,
00479 const QwtScaleMap& yMap, const QRectF& canvasRect,
00480 unsigned int drawIndex, unsigned int drawCount) const;
00481 #else
00482 void draw_(QPainter* painter, const QwtScaleMap& xMap,
00483 const QwtScaleMap& yMap, const QRect& canvasRect,
00484 unsigned int drawIndex, unsigned int drawCount) const;
00485 #endif
00486
00487
00488 QwtSymbol::Style legendStyle() const { return QwtSymbol::HLine; }
00489
00490 private:
00491 PlotCoordinate m_from;
00492 PlotCoordinate m_to;
00493 Style m_fromStyle, m_toStyle;
00494 double m_size;
00495
00496
00497
00498
00499
00500
00501
00502 static std::pair<QPointF, QPointF> arrowPointsHelper(QPointF p1, QPointF p2,
00503 double length);
00504 };
00505
00506
00507
00508 class QPPath : public QPShape, public PlotShapePath {
00509 public:
00510
00511
00512
00513 static const String CLASS_NAME;
00514
00515
00516
00517
00518
00519 QPPath(const vector<PlotCoordinate>& points);
00520
00521
00522 QPPath(const PlotShapePath& copy);
00523
00524
00525 ~QPPath();
00526
00527
00528
00529
00530
00531 bool isValid() const;
00532
00533
00534 QwtDoubleRect boundingRect() const;
00535
00536
00537
00538
00539
00540 vector<PlotCoordinate> coordinates() const;
00541
00542
00543 void setCoordinates(const vector<PlotCoordinate>& coords);
00544
00545 protected:
00546
00547 const String& className() const { return CLASS_NAME; }
00548
00549
00550 #if QWT_VERSION >= 0x060000
00551 void draw_(QPainter* painter, const QwtScaleMap& xMap,
00552 const QwtScaleMap& yMap, const QRectF& canvasRect,
00553 unsigned int drawIndex, unsigned int drawCount) const;
00554 #else
00555 void draw_(QPainter* painter, const QwtScaleMap& xMap,
00556 const QwtScaleMap& yMap, const QRect& canvasRect,
00557 unsigned int drawIndex, unsigned int drawCount) const;
00558 #endif
00559
00560
00561 QwtSymbol::Style legendStyle() const { return QwtSymbol::HLine; }
00562
00563 private:
00564 vector<PlotCoordinate> m_coords;
00565 };
00566
00567
00568
00569 class QPArc : public QPShape, public PlotShapeArc {
00570 public:
00571
00572
00573
00574 static const String CLASS_NAME;
00575
00576
00577
00578
00579
00580
00581 QPArc(const PlotCoordinate& start, const PlotCoordinate& widthHeight,
00582 int startAngle, int spanAngle);
00583
00584
00585 QPArc(const PlotShapeArc& copy);
00586
00587
00588 ~QPArc();
00589
00590
00591
00592 using PlotShapeArc::setWidthHeight;
00593
00594
00595
00596
00597
00598 bool isValid() const;
00599
00600
00601 QwtDoubleRect boundingRect() const;
00602
00603
00604
00605
00606
00607 vector<PlotCoordinate> coordinates() const;
00608
00609
00610 void setCoordinates(const vector<PlotCoordinate>& coords);
00611
00612
00613 PlotCoordinate startCoordinate() const;
00614
00615
00616 void setStartCoordinate(const PlotCoordinate& coord);
00617
00618
00619 PlotCoordinate widthHeight() const;
00620
00621
00622 void setWidthHeight(const PlotCoordinate& widthHeight);
00623
00624
00625 int startAngle() const;
00626
00627
00628 void setStartAngle(int startAngle);
00629
00630
00631 int spanAngle() const;
00632
00633
00634 void setSpanAngle(int spanAngle);
00635
00636
00637 int orientation() const;
00638
00639
00640 void setOrientation(int o);
00641
00642 protected:
00643
00644 const String& className() const { return CLASS_NAME; }
00645
00646
00647 #if QWT_VERSION >= 0x060000
00648 void draw_(QPainter* painter, const QwtScaleMap& xMap,
00649 const QwtScaleMap& yMap, const QRectF& canvasRect,
00650 unsigned int drawIndex, unsigned int drawCount) const;
00651 #else
00652 void draw_(QPainter* painter, const QwtScaleMap& xMap,
00653 const QwtScaleMap& yMap, const QRect& canvasRect,
00654 unsigned int drawIndex, unsigned int drawCount) const;
00655 #endif
00656
00657
00658 QwtSymbol::Style legendStyle() const { return QwtSymbol::HLine; }
00659
00660 private:
00661 PlotCoordinate m_start;
00662 PlotCoordinate m_size;
00663 int m_startAngle;
00664 int m_spanAngle;
00665 int m_orient;
00666 };
00667
00668
00669
00670 class QPPoint : public QPPlotItem, public PlotPoint {
00671 public:
00672
00673
00674
00675 static const String CLASS_NAME;
00676
00677
00678
00679
00680
00681
00682 QPPoint(const PlotCoordinate& coordinate, const PlotSymbol& symbol);
00683 QPPoint(const PlotCoordinate& coordinate, const PlotSymbolPtr symbol);
00684 QPPoint(const PlotCoordinate& coordinate,
00685 PlotSymbol::Symbol symbol = PlotSymbol::DIAMOND);
00686
00687
00688
00689 QPPoint(const PlotPoint& copy);
00690
00691
00692 ~QPPoint();
00693
00694
00695
00696 using PlotPoint::setSymbol;
00697
00698
00699
00700
00701
00702 bool isValid() const { return true; }
00703
00704
00705 QwtDoubleRect boundingRect() const;
00706
00707 #if QWT_VERSION < 0x060000
00708
00709 QWidget* legendItem() const;
00710 #endif
00711
00712
00713
00714
00715 PlotCoordinate coordinate() const;
00716
00717
00718 void setCoordinate(const PlotCoordinate& coordinate);
00719
00720
00721 PlotSymbolPtr symbol() const;
00722
00723
00724 void setSymbol(const PlotSymbol& symbol);
00725
00726 protected:
00727
00728 const String& className() const { return CLASS_NAME; }
00729
00730
00731 #if QWT_VERSION >= 0x060000
00732 void draw_(QPainter* painter, const QwtScaleMap& xMap,
00733 const QwtScaleMap& yMap, const QRectF& canvasRect,
00734 unsigned int drawIndex, unsigned int drawCount) const;
00735 #else
00736 void draw_(QPainter* painter, const QwtScaleMap& xMap,
00737 const QwtScaleMap& yMap, const QRect& canvasRect,
00738 unsigned int drawIndex, unsigned int drawCount) const;
00739 #endif
00740
00741 private:
00742 QPSymbol m_symbol;
00743 PlotCoordinate m_coord;
00744 };
00745
00746 }
00747
00748 #else
00749
00750 #include <QPointF>
00751 #include <utility>
00752
00753 using namespace std;
00754
00755 namespace casa {
00756
00757
00758
00759 class QPArrow {
00760 public:
00761 static std::pair<QPointF, QPointF> arrowPoints(QPointF from, QPointF to,
00762 double length);
00763
00764 static void arrowPoints(double x1, double y1, double x2, double y2,
00765 double length, double& resX1, double& resY1,
00766 double& resX2, double& resY2);
00767
00768 private:
00769 static std::pair<QPointF, QPointF> arrowPointsHelper(QPointF p1, QPointF p2,
00770 double length);
00771 };
00772
00773 }
00774
00775 #endif
00776
00777 #endif