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 PLOTSHAPE_H_
00028 #define PLOTSHAPE_H_
00029
00030 #include <graphics/GenericPlotter/PlotItem.h>
00031
00032 #include <vector>
00033
00034 namespace casa {
00035
00036
00037 class PlotShape : public virtual PlotItem {
00038 public:
00039
00040 PlotShape() { }
00041
00042
00043 virtual ~PlotShape() { }
00044
00045
00046
00047
00048 virtual unsigned int drawCount() const { return 1; }
00049
00050
00051
00052
00053
00054
00055 virtual std::vector<PlotCoordinate> coordinates() const = 0;
00056
00057
00058
00059
00060 virtual void setCoordinates(const std::vector<PlotCoordinate>& c) = 0;
00061
00062
00063 virtual bool lineShown() const = 0;
00064
00065
00066 virtual void setLineShown(bool line = true) = 0;
00067
00068
00069 virtual PlotLinePtr line() const = 0;
00070
00071
00072 virtual void setLine(const PlotLine& line) = 0;
00073
00074
00075 virtual bool areaFilled() const = 0;
00076
00077
00078 virtual void setAreaFilled(bool area = true) = 0;
00079
00080
00081 virtual PlotAreaFillPtr areaFill() const = 0;
00082
00083
00084 virtual void setAreaFill(const PlotAreaFill& fill) = 0;
00085
00086
00087
00088
00089
00090
00091 virtual void setLine(const PlotLinePtr l) {
00092 if(!l.null()) setLine(*l);
00093 else setLineShown(false);
00094 }
00095 virtual void setLine(const String& color,
00096 PlotLine::Style style = PlotLine::SOLID, double width = 1.0) {
00097 PlotLinePtr l = line();
00098 l->setColor(color);
00099 l->setStyle(style);
00100 l->setWidth(width);
00101 setLine(*l);
00102 }
00103
00104
00105
00106
00107 virtual void setAreaFill(const PlotAreaFillPtr f) {
00108 if(!f.null()) setAreaFill(*f);
00109 else setAreaFilled(false);
00110 }
00111 virtual void setAreaFill(const String& color,
00112 PlotAreaFill::Pattern pattern = PlotAreaFill::FILL) {
00113 PlotAreaFillPtr f = areaFill();
00114 f->setColor(color);
00115 f->setPattern(pattern);
00116 setAreaFill(*f);
00117 }
00118
00119 };
00120
00121
00122
00123
00124 class PlotShapeRectangle : public virtual PlotShape {
00125 public:
00126
00127 PlotShapeRectangle() { }
00128
00129
00130 virtual ~PlotShapeRectangle() { }
00131
00132
00133 virtual void setRectCoordinates(const PlotCoordinate& upperLeft,
00134 const PlotCoordinate& lowerRight) = 0;
00135 };
00136
00137
00138
00139
00140 class PlotShapeEllipse : public virtual PlotShape {
00141 public:
00142
00143 PlotShapeEllipse() { }
00144
00145
00146 virtual ~PlotShapeEllipse() { }
00147
00148
00149
00150 virtual void setEllipseCoordinates(const PlotCoordinate& center,
00151 const PlotCoordinate& radii) = 0;
00152
00153
00154 virtual PlotCoordinate radii() const = 0;
00155
00156
00157 virtual void setRadii(const PlotCoordinate& radii) = 0;
00158
00159
00160 virtual PlotCoordinate center() const = 0;
00161
00162
00163 virtual void setCenter(const PlotCoordinate& center) = 0;
00164 };
00165
00166
00167
00168 class PlotShapePolygon : public virtual PlotShape {
00169 public:
00170
00171 PlotShapePolygon() { }
00172
00173
00174 virtual ~PlotShapePolygon() { }
00175
00176
00177
00178 virtual unsigned int drawCount() const { return coordinates().size(); }
00179 };
00180
00181
00182
00183
00184
00185
00186
00187 class PlotShapeLine : public virtual PlotShape {
00188 public:
00189
00190 PlotShapeLine() { }
00191
00192
00193 virtual ~PlotShapeLine() { }
00194
00195
00196 virtual void setLineCoordinates(double location, PlotAxis axis) = 0;
00197
00198
00199 virtual double location() const = 0;
00200
00201
00202 virtual PlotAxis axis() const = 0;
00203 };
00204
00205
00206
00207
00208
00209
00210
00211 class PlotShapeArrow : public virtual PlotShape {
00212 public:
00213
00214 enum Style {
00215 TRIANGLE,
00216 V_ARROW,
00217 NOARROW
00218 };
00219
00220
00221
00222 PlotShapeArrow() { }
00223
00224
00225 virtual ~PlotShapeArrow() { }
00226
00227
00228 virtual void setArrowCoordinates(const PlotCoordinate& from,
00229 const PlotCoordinate& to) = 0;
00230
00231
00232
00233 virtual Style arrowStyleFrom() const = 0;
00234 virtual Style arrowStyleTo() const = 0;
00235
00236
00237
00238
00239 virtual void setArrowStyleFrom(Style style) = 0;
00240 virtual void setArrowStyleTo(Style style) = 0;
00241 virtual void setArrowStyles(Style from, Style to) {
00242 setArrowStyleFrom(from);
00243 setArrowStyleTo(to);
00244 }
00245
00246
00247
00248 virtual double arrowSize() const = 0;
00249
00250
00251 virtual void setArrowSize(double size) = 0;
00252 };
00253
00254
00255
00256
00257
00258 class PlotShapePath : public virtual PlotShape {
00259 public:
00260
00261 PlotShapePath() { }
00262
00263
00264 virtual ~PlotShapePath() { }
00265
00266
00267
00268 virtual unsigned int drawCount() const { return coordinates().size(); }
00269 };
00270
00271
00272
00273
00274
00275
00276 class PlotShapeArc : public virtual PlotShape {
00277 public:
00278
00279 PlotShapeArc() { }
00280
00281
00282 virtual ~PlotShapeArc() { }
00283
00284
00285
00286 virtual PlotCoordinate startCoordinate() const = 0;
00287
00288
00289 virtual void setStartCoordinate(const PlotCoordinate& coord) = 0;
00290
00291
00292 virtual PlotCoordinate widthHeight() const = 0;
00293
00294
00295 virtual void setWidthHeight(double width, double height) {
00296 setWidthHeight(PlotCoordinate(width, height, PlotCoordinate::WORLD)); }
00297
00298
00299 virtual void setWidthHeight(const PlotCoordinate& widthHeight) = 0;
00300
00301
00302 virtual int startAngle() const = 0;
00303
00304
00305 virtual void setStartAngle(int startAngle) = 0;
00306
00307
00308 virtual int spanAngle() const = 0;
00309
00310
00311 virtual void setSpanAngle(int spanAngle) = 0;
00312
00313
00314 virtual int orientation() const = 0;
00315
00316
00317 virtual void setOrientation(int o) = 0;
00318 };
00319
00320
00321
00322
00323 class PlotPoint : public virtual PlotItem {
00324 public:
00325
00326 PlotPoint() { }
00327
00328
00329 virtual ~PlotPoint() { }
00330
00331
00332
00333
00334 virtual unsigned int drawCount() const { return 1; }
00335
00336
00337
00338
00339
00340 virtual PlotCoordinate coordinate() const = 0;
00341
00342
00343 virtual void setCoordinate(const PlotCoordinate& coordinate) = 0;
00344
00345
00346 virtual PlotSymbolPtr symbol() const = 0;
00347
00348
00349 virtual void setSymbol(const PlotSymbol& symbol) = 0;
00350
00351
00352
00353
00354
00355
00356 virtual void setSymbol(const PlotSymbolPtr symbol) {
00357 if(!symbol.null()) setSymbol(*symbol); }
00358 virtual void setSymbol(PlotSymbol::Symbol sym) {
00359 PlotSymbolPtr s = symbol();
00360 s->setSymbol(sym);
00361 setSymbol(*s);
00362 }
00363
00364 };
00365
00366
00368
00370
00371 INHERITANCE_POINTER2(PlotShape, PlotShapePtr, PlotItem, PlotItemPtr)
00372 INHERITANCE_POINTER(PlotShapeRectangle, PlotShapeRectanglePtr, PlotShape,
00373 PlotShapePtr, PlotItem, PlotItemPtr)
00374 INHERITANCE_POINTER(PlotShapeEllipse, PlotShapeEllipsePtr, PlotShape,
00375 PlotShapePtr, PlotItem, PlotItemPtr)
00376 INHERITANCE_POINTER(PlotShapePolygon, PlotShapePolygonPtr, PlotShape,
00377 PlotShapePtr, PlotItem, PlotItemPtr)
00378 INHERITANCE_POINTER(PlotShapeLine, PlotShapeLinePtr, PlotShape, PlotShapePtr,
00379 PlotItem, PlotItemPtr)
00380 INHERITANCE_POINTER(PlotShapeArrow, PlotShapeArrowPtr, PlotShape,
00381 PlotShapePtr, PlotItem, PlotItemPtr)
00382 INHERITANCE_POINTER(PlotShapePath, PlotShapePathPtr, PlotShape, PlotShapePtr,
00383 PlotItem, PlotItemPtr)
00384 INHERITANCE_POINTER(PlotShapeArc, PlotShapeArcPtr, PlotShape, PlotShapePtr,
00385 PlotItem, PlotItemPtr)
00386 INHERITANCE_POINTER2(PlotPoint, PlotPointPtr, PlotItem, PlotItemPtr)
00387
00388 }
00389
00390 #endif