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