casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RegionShapes.h
Go to the documentation of this file.
1 //# RegionShapes.h: Classes for displaying region shapes on the viewer.
2 //# Copyright (C) 2008
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 #ifndef REGIONSHAPES_H_
28 #define REGIONSHAPES_H_
29 
31 
32 #include <cctype>
33 
34 #include <casa/namespace.h>
35 
36 namespace casa {
37 
38 // Subclass of RegionShape used for drawing ellipses. An ellipse has the
39 // following properties in addition to those listed for RegionShape:
40 // <ul><li>x and y coordinate</li>
41 // <li>x-radius and y-radius</li>
42 // <li>angle of rotation</li></ul>
43  class RSEllipse : public RegionShape {
44  public:
45  // World Constructor. x, y, xRadius, yRadius, and angle must all be
46  // 1) using the same world system as defined by worldSystem, and 2) in
47  // unit RegionShape::UNIT. Angle is counterclockwise, and angle 0 is the
48  // east vector.
49  RSEllipse(double x, double y, double xRadius, double yRadius,
50  casacore::MDirection::Types worldSystem, double angle = 0);
51 
52  // Pixel Constructor. Angle in counterclockwise degrees.
53  RSEllipse(double x, double y, double xRadius, double yRadius,
54  double angle = 0);
55 
56  // casacore::Record Constructor.
57  RSEllipse(const casacore::RecordInterface& properties);
58 
59  // Destructor.
60  virtual ~RSEllipse();
61 
62  // Implements RegionShape::drawAndUpdateBoundingBox.
64  casacore::String* error = NULL);
65 
66  // Implements RegionShape::type.
67  virtual casacore::String type() const {
68  return "ellipse";
69  }
70 
71  // Gets ellipse-specific coordinates, to avoid dependence on
72  // coordParameterValues() when the shape type is known.
73  // If toSystem is empty, no conversion is done; otherwise see the
74  // constraints listed in RegionShape::coordParameterValues(casacore::String).
75  void getEllipseCoordinates(double& x, double& y, double& xRadius,
76  double& yRadius, double& angle,
77  casacore::String toSystem = "") const;
78 
79  // Implements RegionShape::coordParameterValues.
80  virtual std::vector<double> coordParameterValues() const;
81 
82  // Implements RegionShape::coordParameterValues.
83  virtual std::vector<double> coordParameterValues(casacore::String toSystem) const;
84 
85  // Implements RegionShape::coordParameterNames.
86  virtual std::vector<casacore::String> coordParameterNames() const;
87 
88  // Implements RegionShape::coordParameterPositions.
89  virtual std::vector<CoordinateParameterType> coordParameterTypes() const;
90 
91  // Implements RegionShape::setCoordParameters.
92  virtual void setCoordParameters(const std::vector<double>& vals);
93 
94  // Implements RegionShape::setCoordParameters.
95  virtual void setCoordParameters(const std::vector<double>& vals, casacore::String system);
96 
97  // Implements RegionShape::move.
98  virtual void move(double dx, double dy, casacore::String system = "");
99 
100  // Implements RegionShape::getHandle.
101  virtual RSHandle getHandle() const;
102 
103  // Implements RegionShape option methods. Note: ellipses do not have
104  // additonal options.
105  // <group>
106  virtual std::vector<casacore::String> optionNames() const {
107  return std::vector<casacore::String>();
108  }
109  virtual std::vector<OptionType> optionTypes() const {
110  return std::vector<OptionType>();
111  }
112  virtual std::vector<RSOption> optionValues() const {
113  return std::vector<RSOption>();
114  }
115  virtual void setOptionValues(const vector<RSOption>& /*options*/) { }
116  // </group>
117 
118  protected:
119  vector<double> m_spec; // order: [x, y, x-radius, y-radius, angle]
120  // either world or pixel coords
121  vector<double> m_screenSpec; // same order, screen coords
122 
123 
124  // Implements RegionShape::getShapeSpecificProperties.
125  virtual void getShapeSpecificProperties(casacore::Record& properties) const {
126  properties.define(PROPTYPE, PROPTYPE_ELLIPSE);
127  }
128 
129  // Implements RegionShape::setShapeSpecificProperties.
130  virtual void setShapeSpecificProperties(const casacore::RecordInterface& /*props*/) { }
131 
132  // Updates screen coords using world/pixel coords and the given WorldCanvas
134 
135  // Update m_xMin, m_xMax, m_yMin, and m_yMax.
136  virtual void updateMinMax();
137  };
138 
139 
140 // Subclass of RSEllipse used for drawing circles. Only one radius (x) is
141 // taken and no angle.
142  class RSCircle : public RSEllipse {
143  public:
144  // World constructor. x, y, and xRadius must be of the type defined by
145  // worldSys and in units of RegionShape::UNIT.
146  RSCircle(double x, double y, double xRadius, casacore::MDirection::Types worldSys);
147 
148  // Pixel constructor.
149  RSCircle(double x, double y, double xRadius);
150 
151  // casacore::Record Constructor.
152  RSCircle(const casacore::RecordInterface& properties);
153 
154  // Destructor.
155  ~RSCircle();
156 
157  // Overrides RSEllipse::type.
159  return "circle";
160  }
161 
162  // Gets circle-specific coordinates, to avoid dependence on
163  // coordParameterValues() when the shape type is known.
164  // If toSystem is empty, no conversion is done; otherwise see the
165  // constraints listed in RegionShape::coordParameterValues(casacore::String).
166  void getCircleCoordinates(double& x, double& y, double& xRadius,
167  casacore::String toSystem = "") const;
168 
169  // Overrides RSEllipse::coordParameterValues.
170  std::vector<double> coordParameterValues() const;
171 
172  // Overrides RSEllipse::coordParameterValues.
173  std::vector<double> coordParameterValues(casacore::String toSystem) const;
174 
175  // Overrides RSEllipse::coordParameterNames.
176  std::vector<casacore::String> coordParameterNames() const;
177 
178  // Overrides RSEllipse::coordParameterPositions.
179  std::vector<CoordinateParameterType> coordParameterTypes() const;
180 
181  // Overrides RSEllipse::setCoordParameters.
182  void setCoordParameters(const std::vector<double>& vals);
183 
184  // Overrides RSEllipse::setCoordParameters.
185  void setCoordParameters(const std::vector<double>& vals, casacore::String valSystem);
186 
187  protected:
188  // Overrides RSEllipse::getShapeSpecificProperties.
190  properties.define(PROPTYPE, PROPTYPE_CIRCLE);
191  }
192 
193  // Overrides RSEllipse::updateScreenCoordinates.
195  };
196 
197 
198 // Subclass of RegionShape used for drawing rectangles. A rectangle has the
199 // following properties in addition to those listed for RegionShape:
200 // <ul><li>x and y coordinate of center</li>
201 // <li>width and height</li></ul>
202  class RSRectangle : public RegionShape {
203  public:
204  // Static Members //
205 
206  // Gets the four rectangle points for the given center, radii, and angle
207  // and puts them in the given vectors. Returns whether or not the
208  // operation succeeded. Angle is in counterclockwise degrees. The point
209  // order is [top right, top left, bottom left, bottom right] in the
210  // coordinate system of the given points.
211  static bool getRectanglePoints(double centerX, double centerY,
212  double radiusX, double radiusY,
213  double angle, casacore::Vector<double>& xPoints,
214  casacore::Vector<double>& yPoints);
215 
216 
217  // Non-Static Members //
218 
219  // World Constructor. x, y, width, and height must all be 1) using the
220  // same world system as defined by worldSystem, and 2) in unit
221  // RegionShape::UNIT. (x, y) specifies the center of the rectangle.
222  // Angle is in counterclockwise degrees starting at the east vector.
223  RSRectangle(double x, double y, double width, double height,
224  casacore::MDirection::Types worldSystem, double angle = 0);
225 
226  // Pixel Constructor. (x, y) specifies the center of the rectangle.
227  RSRectangle(double x, double y, double width, double height,
228  double angle = 0);
229 
230  // casacore::Record Constructor.
231  RSRectangle(const casacore::RecordInterface& properties);
232 
233  // Destructor.
234  ~RSRectangle();
235 
236  // Implements RegionShape::drawAndUpdateBoundingBox.
238 
239  // Implements RegionShape::type.
241  return "rectangle";
242  }
243 
244  // Gets rectangle-specific coordinates, to avoid dependence on
245  // coordParameterValues() when the shape type is known.
246  // If toSystem is empty, no conversion is done; otherwise see the
247  // constraints listed in RegionShape::coordParameterValues(casacore::String).
248  void getRectangleCoordinates(double& x, double& y, double& width,
249  double& height, double& angle,
250  casacore::String toSystem = "") const;
251 
252  // Implements RegionShape::coordParameterValues.
253  std::vector<double> coordParameterValues() const;
254 
255  // Implements RegionShape::coordParameterValues.
256  std::vector<double> coordParameterValues(casacore::String toSystem) const;
257 
258  // Implements RegionShape::coordParameterNames.
259  std::vector<casacore::String> coordParameterNames() const;
260 
261  // Implements RegionShape::coordParameterPositions.
262  std::vector<CoordinateParameterType> coordParameterTypes() const;
263 
264  // Implements RegionShape::setCoordParameters.
265  void setCoordParameters(const std::vector<double>& vals);
266 
267  // Implements RegionShape::setCoordParameters.
268  void setCoordParameters(const std::vector<double>& vals, casacore::String valSystem);
269 
270  // Implements RegionShape::move.
271  void move(double dx, double dy, casacore::String system = "");
272 
273  // Implements RegionShape::getHandle.
274  RSHandle getHandle() const;
275 
276  // Implements RegionShape option methods. Note: rectangles do not have
277  // additonal options.
278  // <group>
279  std::vector<casacore::String> optionNames() const {
280  return std::vector<casacore::String>();
281  }
282  std::vector<OptionType> optionTypes() const {
283  return std::vector<OptionType>();
284  }
285  std::vector<RSOption> optionValues() const {
286  return std::vector<RSOption>();
287  }
288  void setOptionValues(const vector<RSOption>& /*options*/) { }
289  // </group>
290 
291  protected:
292  vector<double> m_spec; // order: [x, y, width, height, angle]
293  // either world or pixel coords
294  casacore::Vector<double> m_x, m_y; // pixel/world coords for four points
295  // in order: [upL, boL, boR, upR]
296  casacore::Vector<double> m_screenX, m_screenY; // screen coords for four points
297  // same order
298 
299  // Implements RegionShape::getShapeSpecificProperties.
301  properties.define(PROPTYPE, PROPTYPE_RECTANGLE);
302  }
303 
304  // Implements RegionShape::setShapeSpecificProperties.
306 
307  // Updates screen coords using world/pixel coords and the given WorldCanvas
309 
310  // Translates m_spec into m_x and m_y.
311  void updatePoints();
312 
313  // Update m_xMin, m_xMax, m_yMin, and m_yMax.
314  void updateMinMax();
315  };
316 
317 
318 // Subclass of RegionShape used for drawing polygons. A polygon has the
319 // following properties in addition to those listed for RegionShape:
320 // <ul><li>list of x and y coordinates</li>
321 // <li>optional custom name</li></ul>
322 // The following properties are also available:
323 // <ul><li><b>RSPolygon::PROPXCOORDINATES</b> (<i>casacore::Array&lt;double&gt;</i>):
324 // vertices x values. <b>NOT STRICTLY REQUIRED, BUT A VALID POLYGON
325 // HAS AT LEAST TWO VERTICES.</b></li>
326 // <li><b>RSPolygon::PROPYCOORDINATES</b> (<i>casacore::Array&lt;double&gt;</li>):
327 // vertices y values. <b>NOT STRICTLY REQUIRED, BUT A VALID POLYGON
328 // HAS AT LEAST TWO VERTICES.</b></li></ul>
329  class RSPolygon : public RegionShape {
330  public:
331  // Static Members //
332 
333  // Properties. (See class descriptions of RegionShape and RSPolygon.)
334  // <group>
337  // </group>
338 
339 
340  // Non-Static Members //
341 
342  // World Constructor. x and y must both be 1) using the same world system
343  // as defined by worldSystem, and 2) in unit RegionShape::UNIT. A custom
344  // name can be provided to be returned with RSPolygon::type().
347 
348  // Pixel Constructor.
350  casacore::String custName = "");
351 
352  // casacore::Record Constructor.
353  RSPolygon(const casacore::RecordInterface& properties);
354 
355  // Destructor.
356  ~RSPolygon();
357 
358  // Sets the polygon coordinates to the given.
360  const casacore::Vector<double>& y);
361 
362  // Implements RegionShape::drawAndUpdateBoundingBox.
364 
365  // Implements RegionShape::type.
367  if(!m_custName.empty()) return m_custName;
368  else return "polygon";
369  }
370 
371  // Overrides RegionShape::oneWordType.
373  return "polygon";
374  }
375 
376  // Gets polygon-specific coordinates, to avoid dependence on
377  // coordParameterValues() when the shape type is known.
378  // If toSystem is empty, no conversion is done; otherwise see the
379  // constraints listed in RegionShape::coordParameterValues(casacore::String).
380  void getPolygonCoordinates(double& centerX, double& centerY,
381  casacore::String toSystem = "") const;
382 
383  // Gets actual polygon coordinates.
384  // If toSystem is empty, no conversion is done; otherwise see the
385  // constraints listed in RegionShape::coordParameterValues(casacore::String).
386  void getPolygonCoordinates(std::vector<double>& x, std::vector<double>& y,
387  casacore::String toSystem = "") const;
388 
389  // Implements RegionShape::coordParameterValues.
390  std::vector<double> coordParameterValues() const;
391 
392  // Implements RegionShape::coordParameterValues.
393  std::vector<double> coordParameterValues(casacore::String toSystem) const;
394 
395  // Implements RegionShape::coordParameterNames.
396  std::vector<casacore::String> coordParameterNames() const;
397 
398  // Implements RegionShape::coordParameterPositions.
399  std::vector<CoordinateParameterType> coordParameterTypes() const;
400 
401  // Implements RegionShape::setCoordParameters.
402  void setCoordParameters(const std::vector<double>& vals);
403 
404  // Implements RegionShape::setCoordParameters.
405  void setCoordParameters(const std::vector<double>& vals, casacore::String valSystem);
406 
407  // Implements RegionShape::move.
408  void move(double dx, double dy, casacore::String system = "");
409 
410  // Implements RegionShape::getHandle.
411  RSHandle getHandle() const;
412 
413  // Implements RegionShape::optionNames.
414  std::vector<casacore::String> optionNames() const;
415 
416  // Implements RegionShape::optionTypes.
417  std::vector<OptionType> optionTypes() const;
418 
419  // Implements RegionShape::optionValues.
420  std::vector<RSOption> optionValues() const;
421 
422  // Implements RegionShape::setOptions.
423  void setOptionValues(const std::vector<RSOption>& options);
424 
425  protected:
426  casacore::Vector<casacore::Double> m_x, m_y; // coordinates, world or pixel
427  double m_centerX, m_centerY; // center of polygon, world or pixel
429  unsigned int m_n; // number of points
430  casacore::String m_custName; // optional custom name
431 
432  // Implements RegionShape::getShapeSpecificProperties.
433  void getShapeSpecificProperties(casacore::Record& properties) const;
434 
435  // Implements RegionShape::setShapeSpecificProperties.
437 
438  // Updates screen coords using world/pixel coords and the given WorldCanvas
440 
441  // Update m_xMin, m_xMax, m_yMin, and m_yMax.
442  void updateMinMax();
443  };
444 
445 
446 // Subclass of RegionShape used for drawing lines. A line has the
447 // following properties in addition to those listed for RegionShape:
448 // <ul><li>x1, y1 and x2, y2 coordinates</li>
449 // <li>whether to draw an arrow on either of the endpoints</li>
450 // <li>arrow length</li></ul>
451  class RSLine : public RegionShape {
452  public:
453  // Static Members //
454 
455  // Different ways to draw the arrow(s) at the end of the line.
456  enum ArrowType {
458  };
459 
460  // Returns all possible arrow types.
461  // <group>
462  static std::vector<ArrowType> allArrowTypes() {
463  static std::vector<ArrowType> v(4);
464  v[0] = FilledTriangle;
465  v[1] = Triangle;
466  v[2] = V;
467  v[3] = FilledDoubleV;
468  return v;
469  }
470 
471  static std::vector<casacore::String> allArrowTypesStrings() {
472  std::vector<ArrowType> types = allArrowTypes();
473  std::vector<casacore::String> v(types.size());
474  for(unsigned int i = 0; i < v.size(); i++) v[i] = arrowType(types[i]);
475  return v;
476  }
477  // </group>
478 
479  // Converts to/from the casacore::String representation of arrow types.
480  // <group>
482  switch(type) {
483  case FilledTriangle:
484  return "filled triangle";
485  case Triangle:
486  return "triangle";
487  case V:
488  return "v";
489  case FilledDoubleV:
490  return "filled double v";
491 
492  default:
493  return "";
494  }
495  }
496 
499  for(unsigned int i = 0; i < t.size(); i++) t[i] = tolower(t[i]);
500  if(t == "filled triangle") return FilledTriangle;
501  else if(t == "triangle") return Triangle;
502  else if(t == "v") return V;
503  else if(t == "filled double v") return FilledDoubleV;
504 
505  else return FilledTriangle;
506  }
507  // </group>
508 
509 
510  // Non-Static Members //
511 
512  // World Constructor. x1, y1, x2, and y2 must all be 1) using the
513  // same world system as defined by worldSystem, and 2) in unit
514  // RegionShape::UNIT. arrowLength is in screen pixels. arrow1 defines
515  // whether (x1, y1) has an arrow; arrow2 for (x2, y2).
516  RSLine(double x1, double y1, double x2, double y2,
517  casacore::MDirection::Types worldSystem, int arrowLength, bool arrow1 = false,
518  bool arrow2 = false, ArrowType type1 = FilledDoubleV,
519  ArrowType type2 = FilledDoubleV);
520 
521  // Pixel Constructor. arrowLength is in screen pixels. arrow1 defines
522  // whether (x1, y1) has an arrow; arrow2 for (x2, y2).
523  RSLine(double x1, double y1, double x2, double y2, int arrowLength,
524  bool arrow1 = false, bool arrow2 = false,
526 
527  // casacore::Record Constructor.
528  RSLine(const casacore::RecordInterface& properties);
529 
530  // Destructor.
531  virtual ~RSLine();
532 
533  // Returns whether the two endpoints have arrows or not.
534  // </group>
535  bool p1Arrow() const {
536  return m_arrow1;
537  }
538  bool p2Arrow() const {
539  return m_arrow2;
540  }
541  // </group>
542 
543  // Implements RegionShape::drawAndUpdateBoundingBox.
545  casacore::String* error = NULL);
546 
547  // Implements RegionShape::type.
548  virtual casacore::String type() const {
549  return "line";
550  }
551 
552  // Gets line-specific coordinates, to avoid dependence on
553  // coordParameterValues() when the shape type is known.
554  // If toSystem is empty, no conversion is done; otherwise see the
555  // constraints listed in RegionShape::coordParameterValues(casacore::String).
556  void getLineCoordinates(double& x1, double& y1, double& x2, double& y2,
557  int& arrowLength, casacore::String toSystem = "") const;
558 
559  // Implements RegionShape::coordParameterVales.
560  virtual std::vector<double> coordParameterValues() const;
561 
562  // Implements RegionShape::coordParameterValues.
563  std::vector<double> coordParameterValues(casacore::String toSystem) const;
564 
565  // Implements RegionShape::coordParameterNames.
566  virtual std::vector<casacore::String> coordParameterNames() const;
567 
568  // Implements RegionShape::coordParameterPositions.
569  virtual std::vector<CoordinateParameterType> coordParameterTypes() const;
570 
571  // Implements RegionShape::setCoordParameters.
572  virtual void setCoordParameters(const std::vector<double>& vals);
573 
574  // Implements RegionShape::setCoordParameters.
575  virtual void setCoordParameters(const std::vector<double>& vals, casacore::String System);
576 
577  // Implements RegionShape::move.
578  virtual void move(double dx, double dy, casacore::String system = "");
579 
580  // Implements RegionShape::getHandle.
581  virtual RSHandle getHandle() const;
582 
583  // Implements RegionShape::optionNames.
584  virtual std::vector<casacore::String> optionNames() const;
585 
586  // Implements RegionShape::optionTypes.
587  virtual std::vector<OptionType> optionTypes() const;
588 
589  // Implements RegionShape::optionChoices.
590  virtual std::vector<std::vector<casacore::String> > optionChoices() const;
591 
592  // Implements RegionShape::optionValues.
593  virtual std::vector<RSOption> optionValues() const;
594 
595  // Implements RegionShape::setOptions.
596  virtual void setOptionValues(const std::vector<RSOption>& options);
597 
598  protected:
599  vector<double> m_spec; // order: [x1 y1 x2 y2], either world or pixel
600  vector<double> m_screenSpec; // same order, screen coords
601  int m_arrowLength; // arrow length, screen coords
602  bool m_arrow1, m_arrow2; // whether to draw the arrows
603  ArrowType m_aType1, m_aType2; // arrow types
604 
605  // Implements RegionShape::getShapeSpecificProperties.
606  virtual void getShapeSpecificProperties(casacore::Record& properties) const {
607  properties.define(PROPTYPE, PROPTYPE_LINE);
608  }
609 
610  // Implements RegionShape::setShapeSpecificProperties.
611  virtual void setShapeSpecificProperties(const casacore::RecordInterface& /*props*/) { }
612 
613  // Updates screen coords using world/pixel coords and the given WorldCanvas
615 
616  // Update m_xMin, m_xMax, m_yMin, and m_yMax.
617  void updateMinMax();
618 
619  // Generates arrow points based on the given (x1, y1) (x2, y2) points.
620  // NOTE: Duplicated code from casaqt/QwtPlotter/QPShape (QPArrow class).
621  static bool arrowPoints(double x1, double y1, double x2, double y2,
622  double length, double& resX1, double& resY1,
623  double& resX2, double& resY2);
624 
625  // Helper for arrowPoints. NOTE: Duplicated code.
626  static bool arrowPointsHelper(double x1, double y1, double x2, double y2,
627  double length, double& resX1, double& resY1,
628  double& resX2, double& resY2);
629  };
630 
631 
632 // Subclass of RSLine that takes a length and angle instead of a second point.
633  class RSVector : public RSLine {
634  public:
635  // World Constructor. x, y, length, and angle must all be 1) using the
636  // same world system as defined by worldSystem, and 2) in unit
637  // RegionShape::UNIT. Angle is counterclockwise, and the base is the east
638  // vector. arrowLength is in screen pixels. arrow defines whether the
639  // second point has an arrow.
640  RSVector(double x, double y, double length, double angle,
641  casacore::MDirection::Types worldSystem, int arrowLength,
642  bool arrow = true, ArrowType arrowType = FilledDoubleV);
643 
644  // Pixel Constructor. Angle is counterclockwise. arrowLength is in screen
645  // pixels. arrow defines whether the second point has an arrow.
646  RSVector(double x, double y, double length, double angle, int arrowLength,
647  bool arrow = true, ArrowType arrowType = FilledDoubleV);
648 
649  // casacore::Record Constructor.
650  RSVector(const casacore::RecordInterface& properties);
651 
652  // Destructor.
653  ~RSVector();
654 
655  // Returns whether the vector has an arrow at the end or not.
656  bool arrow() const {
657  return p2Arrow();
658  }
659 
660  // Overrides RSLine::type.
662  return "vector";
663  }
664 
665  // Gets vector-specific coordinates, to avoid dependence on
666  // coordParameterValues() when the shape type is known.
667  // If toSystem is empty, no conversion is done; otherwise see the
668  // constraints listed in RegionShape::coordParameterValues(casacore::String).
669  void getVectorCoordinates(double& x, double& y, double& angle,
670  double& length, int& arrowLength,
671  casacore::String toSystem = "") const;
672 
673  // Overrides RSLine::coordParameterValues.
674  std::vector<double> coordParameterValues() const;
675 
676  // Implements RegionShape::coordParameterValues.
677  std::vector<double> coordParameterValues(casacore::String toSystem) const;
678 
679  // Overrides RSLine::coordParameterNames.
680  std::vector<casacore::String> coordParameterNames() const;
681 
682  // Overrides RSLine::coordParameterPositions.
683  std::vector<CoordinateParameterType> coordParameterTypes() const;
684 
685  // Overrides RSLine::setCoordParameters.
686  void setCoordParameters(const std::vector<double>& vals);
687 
688  // Overrides RSLine::setCoordParameters.
689  void setCoordParameters(const std::vector<double>& vals, casacore::String valSystem);
690 
691  // Overrides RSLine::optionNames.
692  std::vector<casacore::String> optionNames() const;
693 
694  // Overrides RSLine::optionTypes.
695  std::vector<OptionType> optionTypes() const;
696 
697  // Overrides RSLine::optionChoices.
698  std::vector<std::vector<casacore::String> > optionChoices() const;
699 
700  // Overrides RSLine::optionValues.
701  std::vector<RSOption> optionValues() const;
702 
703  // Overrides RSLine::setOptions.
704  void setOptionValues(const std::vector<RSOption>& options);
705 
706  protected:
707  double m_length; // length, world or pixel
708  double m_angle; // angle, world or pixel
709 
710  // Overrides RSLine::getShapeSpecificProperties.
712  properties.define(PROPTYPE, PROPTYPE_VECTOR);
713  }
714  };
715 
716 
717 // Subclass of RegionShape used for drawing markers. A marker has the
718 // following properties in addition to those listed for RegionShape:
719 // <ul><li>x and y coordinates</li>
720 // <li>marker type, or list of marker types</li>
721 // <li>pixel height</li></ul>
722  class RSMarker : public RegionShape {
723  public:
724  // World Constructor for a single marker type. x and y must all be
725  // 1) using the same world system as defined by worldSystem, and
726  // 2) in the unit RegionShape::UNIT. pixelHeight is in screen pixels.
727  RSMarker(double x, double y, Display::Marker marker, int pixelHeight,
728  casacore::MDirection::Types worldSystem);
729 
730  // World Constructor for a compound marker type. x and y must all be
731  // 1) using the same world system as defined by worldSystem, and
732  // 2) in the unit RegionShape::UNIT. pixelHeight is in screen pixels.
733  RSMarker(double x, double y, const std::vector<Display::Marker>& markers,
734  int pixelHeight, casacore::MDirection::Types worldSystem);
735 
736  // Pixel Constructor for a single marker type. pixelHeight is in screen
737  // pixels.
738  RSMarker(double x, double y, Display::Marker marker, int pixelHeight);
739 
740  // Pixel Constructor for a compound marker type. pixelHeight is in screen
741  // pixels.
742  RSMarker(double x, double y, const std::vector<Display::Marker>& markers,
743  int pixelHeight);
744 
745  // casacore::Record Constructor.
746  RSMarker(const casacore::RecordInterface& properties);
747 
748  // Destructor.
749  ~RSMarker();
750 
751  // Gets/sets the markers used for this shape.
752  // <group>
753  std::vector<Display::Marker> markers() const;
754  void setMarker(Display::Marker marker);
755  void setMarkers(const std::vector<Display::Marker>& markers);
756  // </group>
757 
758 
759  // Implements RegionShape::drawAndUpdateBoundingBox.
760  bool drawAndUpdateBoundingBox(WorldCanvasHolder& wch, casacore::String* err = NULL);
761 
762  // Implements RegionShape::type.
763  casacore::String type() const;
764 
765  // Overrides RegionShape::oneWordType.
767  return "marker";
768  }
769 
770  // Gets marker-specific coordinates, to avoid dependence on
771  // coordParameterValues() when the shape type is known.
772  // If toSystem is empty, no conversion is done; otherwise see the
773  // constraints listed in RegionShape::coordParameterValues(casacore::String).
774  void getMarkerCoordinates(double& x, double& y, int& pixelHeight,
775  casacore::String toSystem = "") const;
776 
777  // Implements RegionShape::coordParameterValues.
778  std::vector<double> coordParameterValues() const;
779 
780  // Implements RegionShape::coordParameterValues.
781  std::vector<double> coordParameterValues(casacore::String toSystem) const;
782 
783  // Implements RegionShape::coordParameterNames.
784  std::vector<casacore::String> coordParameterNames() const;
785 
786  // Implements RegionShape::coordParameterPositions.
787  std::vector<CoordinateParameterType> coordParameterTypes() const;
788 
789  // Implements RegionShape::setCoordParameters.
790  void setCoordParameters(const std::vector<double>& vals);
791 
792  // Implements RegionShape::setCoordParameters.
793  void setCoordParameters(const std::vector<double>& vals, casacore::String valSystem);
794 
795  // Implements RegionShape::move.
796  void move(double dx, double dy, casacore::String system = "");
797 
798  // Implements RegionShape::getHandle.
799  RSHandle getHandle() const;
800 
801  // Implements RegionShape::optionNames.
802  std::vector<casacore::String> optionNames() const;
803 
804  // Implements RegionShape::optionTypes.
805  std::vector<OptionType> optionTypes() const;
806 
807  // Overrides RegionShape::optionChoices.
808  std::vector<std::vector<casacore::String> > optionChoices() const;
809 
810  // Implements RegionShape::optionValues.
811  std::vector<RSOption> optionValues() const;
812 
813  // Implements RegionShape::setOptions.
814  void setOptionValues(const std::vector<RSOption>& options);
815 
816  protected:
817  double m_x, m_y; // location, world or pixel
818  double m_screenX, m_screenY; // location, screen
819  vector<Display::Marker> m_markers; // marker(s) to be drawn
820  int m_pixelHeight; // pixel height for marker(s)
821 
822  // Implements RegionShape::getShapeSpecificProperties.
824  properties.define(PROPTYPE, PROPTYPE_MARKER);
825  }
826 
827  // Implements RegionShape::setShapeSpecificProperties.
829 
830  // Updates screen coords using world/pixel coords and the given WorldCanvas
831  bool updateScreenCoordinates(WorldCanvasHolder& wch, casacore::String* err);
832 
833  // Update m_xMin, m_xMax, m_yMin, and m_yMax.
834  void updateMinMax();
835 
836 
838  switch(marker) {
839  case Display::Cross:
840  return "cross";
841  case Display::X:
842  return "x";
843  case Display::Diamond:
844  return "diamond";
845  case Display::Circle:
846  return "circle";
847  case Display::Square:
848  return "square";
849  case Display::Triangle:
850  return "triangle";
852  return "inverted triangle";
854  return "filled circle";
856  return "filled square";
858  return "filled diamond";
860  return "filled triangle";
862  return "filled inverted triangle";
864  return "circle and cross";
865  case Display::CircleAndX:
866  return "circle and x";
868  return "circle and dot";
869 
870  default:
871  return "";
872  }
873  }
874 
875  static bool stringToMarker(const casacore::String& str, Display::Marker& marker) {
876  casacore::String m = str;
877  for(unsigned int i = 0; i < m.size(); i++) m[i] = tolower(str[i]);
878 
879  if(m == "cross") marker = Display::Cross;
880  else if(m == "x") marker = Display::X;
881  else if(m == "diamond") marker = Display::Diamond;
882  else if(m == "circle") marker = Display::Circle;
883  else if(m == "square") marker = Display::Square;
884  else if(m == "triangle") marker = Display::Triangle;
885  else if(m == "inverted triangle") marker = Display::InvertedTriangle;
886  else if(m == "filled circle") marker = Display::FilledCircle;
887  else if(m == "filled square") marker = Display::FilledSquare ;
888  else if(m == "filled diamond") marker = Display::FilledDiamond;
889  else if(m == "filled triangle") marker = Display::FilledTriangle;
890  else if(m == "filled inverted triangle")
892  else if(m == "circle and cross") marker = Display::CircleAndCross;
893  else if(m == "circle and x") marker = Display::CircleAndX;
894  else if(m == "circle and dot") marker = Display::CircleAndDot;
895  else return false;
896  return true;
897  }
898 
899  static std::vector<Display::Marker> allMarkers() {
900  static std::vector<Display::Marker> v(15);
901  v[0] = Display::Cross;
902  v[1] = Display::X;
903  v[2] = Display::Diamond;
904  v[3] = Display::Circle;
905  v[4] = Display::Square;
906  v[5] = Display::Triangle;
908  v[7] = Display::FilledCircle;
909  v[8] = Display::FilledSquare;
910  v[9] = Display::FilledDiamond;
911  v[10] = Display::FilledTriangle;
913  v[12] = Display::CircleAndCross;
914  v[13] = Display::CircleAndX;
915  v[14] = Display::CircleAndDot;
916  return v;
917  }
918  };
919 
920 
921 // Subclass of RegionShape used for drawing text. Text uses RegionShape's
922 // label property.
923  class RSText : public RegionShape {
924  public:
925  // World Constructor. x, y, and angle must both be 1) using the same world
926  // system as defined by worldSystem, and 2) in unit RegionShape::UNIT.
927  // Angle is counterclockwise, and the base is the east vector.
928  RSText(double x, double y, const casacore::String& text, casacore::MDirection::Types worldSys,
929  double angle = 0);
930 
931  // Pixel Constructor. Angle is counterclockwise.
932  RSText(double x, double y, const casacore::String& text, double angle = 0);
933 
934  // casacore::Record Constructor.
935  RSText(const casacore::RecordInterface& properties);
936 
937  // Destructor.
938  ~RSText();
939 
940  // Implements RegionShape::drawAndUpdateBoundingBox.
941  bool drawAndUpdateBoundingBox(WorldCanvasHolder& wch, casacore::String* err = NULL);
942 
943  // Implements RegionShape::type.
945  return "text";
946  }
947 
948  // Gets text-specific coordinates, to avoid dependence on
949  // coordParameterValues() when the shape type is known.
950  // If toSystem is empty, no conversion is done; otherwise see the
951  // constraints listed in RegionShape::coordParameterValues(casacore::String).
952  void getTextCoordinates(double& x, double& y, double& angle,
953  casacore::String toSystem = "") const;
954 
955  // Implements RegionShape::coordParameterValues.
956  std::vector<double> coordParameterValues() const;
957 
958  // Implements RegionShape::coordParameterValues.
959  std::vector<double> coordParameterValues(casacore::String toSystem) const;
960 
961  // Implements RegionShape::coordParameterNames.
962  std::vector<casacore::String> coordParameterNames() const;
963 
964  // Implements RegionShape::coordParameterPositions.
965  std::vector<CoordinateParameterType> coordParameterTypes() const;
966 
967  // Implements RegionShape::setCoordParameters.
968  void setCoordParameters(const std::vector<double>& vals);
969 
970  // Implements RegionShape::setCoordParameters.
971  void setCoordParameters(const std::vector<double>& vals, casacore::String valSystem);
972 
973  // Implements RegionShape::move.
974  void move(double dx, double dy, casacore::String system = "");
975 
976  // Implements RegionShape::getHandle.
977  RSHandle getHandle() const;
978 
979  // Implements RegionShape option methods. Note: text do not have
980  // additonal options.
981  // <group>
982  std::vector<casacore::String> optionNames() const {
983  return std::vector<casacore::String>();
984  }
985  std::vector<OptionType> optionTypes() const {
986  return std::vector<OptionType>();
987  }
988  std::vector<RSOption> optionValues() const {
989  return std::vector<RSOption>();
990  }
991  void setOptionValues(const vector<RSOption>& /*options*/) { }
992  // </group>
993 
994  protected:
995  double m_x, m_y; // location, pixel or world
996  double m_angle; // angle, pixel or world
997  double m_wWidth; // width in pixel/world
998  // updated during updateScreenCoordinates
999  double m_screenX, m_screenY; // location, screen
1000 
1001  // Implements RegionShape::getShapeSpecificProperties.
1003  properties.define(PROPTYPE, PROPTYPE_TEXT);
1004  }
1005 
1006  // Implements RegionShape::setShapeSpecificProperties.
1008 
1009  // Updates screen coords using world/pixel coords and the given WorldCanvas
1010  bool updateScreenCoordinates(WorldCanvasHolder& wch, casacore::String* err);
1011 
1012  // Update m_xMin, m_xMax, m_yMin, and m_yMax. Note that this is only valid
1013  // the screen coordinates have been updated.
1014  void updateMinMax();
1015  };
1016 
1017 
1018 // Subclass of RegionShape used for drawing composite regions. A composite
1019 // region consists of zero or more children RegionShapes. A RSComposite can
1020 // either see its children as dependent, in which the parent controls the
1021 // properties for each shape, or independent in which each child's properties
1022 // must be set individually. An RSComposite can have a custom name/type.
1023 // NOTE: xMin, xMax, yMin, and yMax values are ONLY valid if all children
1024 // shapes have the same coordinate system as the parent composite.
1025 // The following properties are also available:
1026 // <ul><li><b>RSComposite::PROPDEPENDENTCHILDREN</b> (<i>bool</i>):
1027 // whether the composite's children are dependent (true) or independent
1028 // (false). <b>OPTIONAL</b>.</li>
1029 // <li><b>RSComposite::PROPCHILDREN</b> (<i>casacore::Record of Records</li>):
1030 // ordered list of children records. Each field must have a unique
1031 // name (the specifics are irrelevant because it's the order that
1032 // matters) and the value must be a record that can be used to create a
1033 // RegionShape child. <b>NOT STRICTLY REQUIRED, BUT A VALID COMPOSITE
1034 // HAS AT LEAST ONE CHILD.</b></li></ul>
1035  class RSComposite : public RegionShape {
1036  public:
1037  // Static Members //
1038 
1039  // Properties. (See class descriptions of RegionShape and RSComposite.)
1040  // <group>
1043  // </group>
1044 
1045 
1046  // Non-Static Members //
1047 
1048  // World constructor. Initially empty composite. The dependent flag
1049  // controls whether the children are dependent or independent. If
1050  // customName is set, it will be returned on type(). The given world
1051  // system is only used for displaying/setting the center of the composite
1052  // and does not affect the coordinate systems of the children.
1053  RSComposite(casacore::MDirection::Types worldSys, bool dependent = true,
1054  casacore::String customName = "");
1055 
1056  // Pixel constructor. Initially empty composite. The dependent flag
1057  // controls whether the children are dependent or independent. If
1058  // custonName is set, it will be returned on type().
1059  RSComposite(bool dependent = true, casacore::String customName = "");
1060 
1061  // casacore::Record Constructor.
1062  RSComposite(const casacore::RecordInterface& properties);
1063 
1064  // Destructor.
1065  ~RSComposite();
1066 
1067  // Adds the given shape(s) to this composite. Note that in the case of
1068  // depdendent children, line properties, linethrough properties, and label
1069  // properties of the individual shapes are discarded in favor of those of
1070  // the parent RSComposite.
1071  // <group>
1072  void addShape(RegionShape* shape);
1073  void addShapes(const std::vector<RegionShape*> shapes);
1074  // </group>
1075 
1076  // Returns true if the children are dependent, false otherwise.
1077  bool childrenAreDependent() const;
1078 
1079  // Sets whether children are dependent or not. NOTE: This should never be
1080  // called AFTER the composite has already been added to the
1081  // QtRegionShapeManager. Preferably it should be done before adding any
1082  // children either.
1083  void setChildrenAreDependent(bool dependent = true);
1084 
1085  // Returns the composite's children.
1086  // <group>
1087  std::vector<RegionShape*> children();
1088  std::vector<const RegionShape*> children() const;
1089  // </group>
1090 
1091 
1092  // Overrides RegionShape methods in the case of dependent children.
1093  // <group>
1094  void setLineColor(const casacore::String& newColor, bool alsoSetLabel = true);
1095  void setLineWidth(double width);
1096  void setLineStyle(LineStyle style);
1097  void setLabel(const RegionShapeLabel& label);
1098  // </group>
1099 
1100  // Implements RegionShape::drawAndUpdateBoundingBox.
1101  bool drawAndUpdateBoundingBox(WorldCanvasHolder& wch, casacore::String* err = NULL);
1102 
1103  // Implements RegionShape::type.
1104  casacore::String type() const;
1105 
1106  // Overrides RegionShape::oneWordType.
1108  return "composite";
1109  }
1110 
1111  // Returns 0 degrees pixel/screen in the given coordinate system (own
1112  // system if toSystem is empty, otherwise see the constraints listed in
1113  // RegionShape::coordParameterValues(casacore::String).
1114  double getAngle(casacore::String toSystem = "") const;
1115 
1116  // Gets composite-specific coordinates, to avoid dependence on
1117  // coordParameterValues() when the shape type is known.
1118  // If toSystem is empty, no conversion is done; otherwise see the
1119  // constraints listed in RegionShape::coordParameterValues(casacore::String).
1120  void getCompositeCoordinates(double& centerX, double& centerY,
1121  casacore::String toSystem = "") const;
1122 
1123  // Implements RegionShape::coordParameterValues.
1124  std::vector<double> coordParameterValues() const;
1125 
1126  // Implements RegionShape::coordParameterValues.
1127  std::vector<double> coordParameterValues(casacore::String toSystem) const;
1128 
1129  // Implements RegionShape::coordParameterNames.
1130  std::vector<casacore::String> coordParameterNames() const;
1131 
1132  // Implements RegionShape::coordParameterPositions.
1133  std::vector<CoordinateParameterType> coordParameterTypes() const;
1134 
1135  // Implements RegionShape::setCoordParameters.
1136  void setCoordParameters(const std::vector<double>& vals);
1137 
1138  // Implements RegionShape::setCoordParameters.
1139  void setCoordParameters(const std::vector<double>& vals, casacore::String valSystem);
1140 
1141  // Implements RegionShape::move.
1142  void move(double dx, double dy, casacore::String system = "");
1143 
1144  // Implements RegionShape::getHandle.
1145  RSHandle getHandle() const;
1146 
1147  // Implements RegionShape::optionNames.
1148  std::vector<casacore::String> optionNames() const;
1149 
1150  // Implements RegionShape::optionTypes.
1151  std::vector<OptionType> optionTypes() const;
1152 
1153  // Implements RegionShape::optionValues.
1154  std::vector<RSOption> optionValues() const;
1155 
1156  // Implements RegionShape::setOptions.
1157  void setOptionValues(const std::vector<RSOption>& options);
1158 
1159  protected:
1160  casacore::String m_custName; // optional custom name
1161  bool m_dependentChildren; // whether children are dependent
1162  vector<RegionShape*> m_shapes; // children
1163  double m_centerX, m_centerY; // center
1164  bool m_syncAngleDepChildren; // flag for whether all children:
1165  // 1) are dependent
1166  // 2) have angles (rectangle, ellipse,
1167  // vector, text)
1168  // 3) all have synched (same) angle
1169  double m_syncAngle; // Sync angle (if applicable).
1170  bool m_applyChangesToChildren; // Whether or not to apply options changes
1171  // to children or not.
1172 
1173  // Implements RegionShape::getShapeSpecificProperties.
1174  void getShapeSpecificProperties(casacore::Record& properties) const;
1175 
1176  // Implements RegionShape::setShapeSpecificProperties.
1177  void setShapeSpecificProperties(const casacore::RecordInterface& properties);
1178 
1179  // Update m_xMin, m_xMax, m_yMin, and m_yMax.
1180  void updateMinMax();
1181 
1182  private:
1183  // Adds the given child but does not perform upkeep. Returns true if the
1184  // shape was added, false otherwise.
1185  bool addShapeHelper(RegionShape* shape);
1186 
1187  // Does upkeep after adding shapes.
1188  void addShapeUpkeep();
1189 
1190  // Gets the min/max of the child at the given index, in the composite's
1191  // coordinate system.
1192  void convertMinMax(double& xmin, double& xmax, double& ymin, double& ymax,
1193  unsigned int index) const;
1194  };
1195 
1196 }
1197 
1198 #endif /*REGIONSHAPES_H_*/
virtual bool updateScreenCoordinates(WorldCanvasHolder &wch, casacore::String *err)
Updates screen coords using world/pixel coords and the given WorldCanvas.
void getCircleCoordinates(double &x, double &y, double &xRadius, casacore::String toSystem="") const
Gets circle-specific coordinates, to avoid dependence on coordParameterValues() when the shape type i...
virtual void setCoordParameters(const std::vector< double > &vals)=0
Sets the coordinate parameter values to the given, in the same order as coordParameterValues().
virtual void getShapeSpecificProperties(casacore::Record &properties) const =0
Pure Virtual Methods //.
std::vector< double > coordParameterValues() const
Overrides RSEllipse::coordParameterValues.
RSCircle(double x, double y, double xRadius, casacore::MDirection::Types worldSys)
World constructor.
void setShapeSpecificProperties(const casacore::RecordInterface &)
Implements RegionShape::setShapeSpecificProperties.
static std::vector< Display::Marker > allMarkers()
Definition: RegionShapes.h:899
FilledPentagon, FilledHexagon,.
Definition: DisplayEnums.h:335
virtual std::vector< RSOption > optionValues() const =0
Returns the current values for options.
double m_angle
Definition: RegionShapes.h:996
std::vector< CoordinateParameterType > coordParameterTypes() const
Overrides RSEllipse::coordParameterPositions.
static bool arrowPointsHelper(double x1, double y1, double x2, double y2, double length, double &resX1, double &resY1, double &resX2, double &resY2)
Helper for arrowPoints.
void updateMinMax()
Update m_xMin, m_xMax, m_yMin, and m_yMax.
double m_wWidth
Definition: RegionShapes.h:997
vector< double > m_spec
Definition: RegionShapes.h:599
virtual std::vector< RSOption > optionValues() const
Returns the current values for options.
Definition: RegionShapes.h:112
virtual void setShapeSpecificProperties(const casacore::RecordInterface &)
Implements RegionShape::setShapeSpecificProperties.
Definition: RegionShapes.h:130
A &quot;handle&quot; is a four-point structure (usually a rectangle) that describes the boundaries in screen pi...
Definition: RSUtils.qo.h:445
void getShapeSpecificProperties(casacore::Record &properties) const
Implements RegionShape::getShapeSpecificProperties.
Definition: RegionShapes.h:823
static const casacore::String PROPCHILDREN
virtual std::vector< casacore::String > optionNames() const =0
Returns the names for options.
ArrowType m_aType1
Definition: RegionShapes.h:603
virtual void move(double dx, double dy, casacore::String system="")
Implements RegionShape::move.
virtual void setShapeSpecificProperties(const casacore::RecordInterface &)
Implements RegionShape::setShapeSpecificProperties.
Definition: RegionShapes.h:611
Pentagon, Hexagon,.
Definition: DisplayEnums.h:326
RSLine(double x1, double y1, double x2, double y2, casacore::MDirection::Types worldSystem, int arrowLength, bool arrow1=false, bool arrow2=false, ArrowType type1=FilledDoubleV, ArrowType type2=FilledDoubleV)
Non-Static Members //.
~RSRectangle()
Destructor.
void updateMinMax()
Update m_xMin, m_xMax, m_yMin, and m_yMax.
virtual std::vector< casacore::String > coordParameterNames() const
Implements RegionShape::coordParameterNames.
bool p2Arrow() const
Definition: RegionShapes.h:538
virtual Type type()
Return the type enum.
casacore::String oneWordType() const
Overrides RegionShape::oneWordType.
Definition: RegionShapes.h:766
virtual bool drawAndUpdateBoundingBox(WorldCanvasHolder &wch, casacore::String *error=NULL)
Implements RegionShape::drawAndUpdateBoundingBox.
bool m_applyChangesToChildren
virtual std::vector< std::vector< casacore::String > > optionChoices() const
For options that are string choices, return the available choices.
Definition: RegionShape.h:555
virtual void setOptionValues(const std::vector< RSOption > &options)
Implements RegionShape::setOptions.
virtual void move(double dx, double dy, casacore::String system="")
Implements RegionShape::move.
bool arrow() const
Returns whether the vector has an arrow at the end or not.
Definition: RegionShapes.h:656
static const casacore::String PROPTYPE_CIRCLE
Definition: RegionShape.h:258
size_type size() const
Capacity, size.
Definition: String.h:342
void setCoordParameters(const std::vector< double > &vals)
Implements RegionShape::setCoordParameters.
std::vector< casacore::String > coordParameterNames() const
Implements RegionShape::coordParameterNames.
virtual casacore::MDirection::Types worldSystem() const
If this shape is in world coordinates, returns the system used.
Definition: RegionShape.h:426
Basic, Unfilled shapes;.
Definition: DisplayEnums.h:315
virtual ~RSEllipse()
Destructor.
casacore::String type() const
Implements RegionShape::type.
Definition: RegionShapes.h:366
RSPolygon(const casacore::Vector< double > &x, const casacore::Vector< double > &y, casacore::MDirection::Types worldSystem, casacore::String custName="")
Non-Static Members //.
std::vector< casacore::String > coordParameterNames() const
Overrides RSEllipse::coordParameterNames.
Subclass of RegionShape used for drawing lines.
Definition: RegionShapes.h:451
virtual std::vector< OptionType > optionTypes() const
Returns the types for options.
Definition: RegionShapes.h:109
casacore::String m_custName
virtual bool drawAndUpdateBoundingBox(WorldCanvasHolder &wch, casacore::String *error=NULL)=0
Pure Virtual Methods //.
virtual casacore::String type() const =0
Returns the name/type of this shape, for displaying to the user.
virtual bool drawAndUpdateBoundingBox(WorldCanvasHolder &wch, casacore::String *error=NULL)
Implements RegionShape::drawAndUpdateBoundingBox.
static const casacore::String PROPTYPE_ELLIPSE
Definition: RegionShape.h:257
std::vector< OptionType > optionTypes() const
Definition: RegionShapes.h:985
virtual std::vector< OptionType > optionTypes() const =0
Returns the types for options.
vector< Display::Marker > m_markers
Definition: RegionShapes.h:819
Subclass of RegionShape used for drawing composite regions.
void getShapeSpecificProperties(casacore::Record &properties) const
Overrides RSEllipse::getShapeSpecificProperties.
Definition: RegionShapes.h:189
std::vector< RSOption > optionValues() const
Returns the current values for options.
Definition: RegionShapes.h:285
virtual void move(double dx, double dy, casacore::String system="")=0
Moves this shape the given delta x and delta y in the given system (empty for shape&#39;s native system)...
std::vector< CoordinateParameterType > coordParameterTypes() const
Implements RegionShape::coordParameterPositions.
ArrowType m_aType2
Definition: RegionShapes.h:603
casacore::Vector< double > m_screenY
Definition: RegionShapes.h:296
virtual std::vector< OptionType > optionTypes() const
Implements RegionShape::optionTypes.
RSEllipse(double x, double y, double xRadius, double yRadius, casacore::MDirection::Types worldSystem, double angle=0)
World Constructor.
int m_pixelHeight
Definition: RegionShapes.h:820
Types
Types of known MDirections Warning: The order defines the order in the translation matrix FromTo in ...
Definition: MDirection.h:188
std::vector< RSOption > optionValues() const
Implements RegionShape::optionValues.
Options options
casacore::Vector< casacore::Double > m_x
Definition: RegionShapes.h:426
virtual std::vector< casacore::String > coordParameterNames() const
Implements RegionShape::coordParameterNames.
void setOptionValues(const std::vector< RSOption > &options)
Implements RegionShape::setOptions.
static bool arrowPoints(double x1, double y1, double x2, double y2, double length, double &resX1, double &resY1, double &resX2, double &resY2)
Generates arrow points based on the given (x1, y1) (x2, y2) points.
void setPolygonCoordinates(const casacore::Vector< double > &x, const casacore::Vector< double > &y)
Sets the polygon coordinates to the given.
std::vector< double > coordParameterValues() const
Implements RegionShape::coordParameterValues.
ArrowType
Static Members //.
Definition: RegionShapes.h:456
void updateMinMax()
Update m_xMin, m_xMax, m_yMin, and m_yMax.
virtual void setOptionValues(const std::vector< RSOption > &options)=0
Sets the options to the given.
virtual std::vector< casacore::String > optionNames() const
Implements RegionShape::optionNames.
Subclass of RegionShape used for drawing rectangles.
Definition: RegionShapes.h:202
void updatePoints()
Translates m_spec into m_x and m_y.
casacore::String m_custName
Definition: RegionShapes.h:430
void setOptionValues(const vector< RSOption > &)
Definition: RegionShapes.h:991
virtual RSHandle getHandle() const =0
Returns a RSHandle (four points in screen coords that are like a bounding box for the shape) for this...
virtual std::vector< casacore::String > optionNames() const
Implements RegionShape option methods.
Definition: RegionShapes.h:106
Subclass of RegionShape used for drawing ellipses.
Definition: RegionShapes.h:43
void getShapeSpecificProperties(casacore::Record &properties) const
Overrides RSLine::getShapeSpecificProperties.
Definition: RegionShapes.h:711
void setShapeSpecificProperties(const casacore::RecordInterface &)
Implements RegionShape::setShapeSpecificProperties.
Definition: RegionShapes.h:305
bool drawAndUpdateBoundingBox(WorldCanvasHolder &wch, casacore::String *err=NULL)
Implements RegionShape::drawAndUpdateBoundingBox.
virtual std::vector< CoordinateParameterType > coordParameterTypes() const
Implements RegionShape::coordParameterPositions.
void move(double dx, double dy, casacore::String system="")
Implements RegionShape::move.
bool m_syncAngleDepChildren
static const casacore::String PROPTYPE
Definition: RegionShape.h:256
std::vector< CoordinateParameterType > coordParameterTypes() const
Implements RegionShape::coordParameterPositions.
double m_centerY
LatticeExprNode length(const LatticeExprNode &expr, const LatticeExprNode &axis)
2-argument function to get the length of an axis.
void setCoordParameters(const std::vector< double > &vals)
Overrides RSEllipse::setCoordParameters.
static std::vector< casacore::String > allArrowTypesStrings()
Definition: RegionShapes.h:471
void move(double dx, double dy, casacore::String system="")
Implements RegionShape::move.
static const casacore::String PROPDEPENDENTCHILDREN
Static Members //.
virtual RSHandle getHandle() const
Implements RegionShape::getHandle.
bool drawAndUpdateBoundingBox(WorldCanvasHolder &wch, casacore::String *err=NULL)
Implements RegionShape::drawAndUpdateBoundingBox.
void setShapeSpecificProperties(const casacore::RecordInterface &properties)
Implements RegionShape::setShapeSpecificProperties.
double m_y
Definition: RegionShapes.h:817
double m_angle
Definition: RegionShapes.h:708
vector< double > m_screenSpec
either world or pixel coords
Definition: RegionShapes.h:121
void getShapeSpecificProperties(casacore::Record &properties) const
Implements RegionShape::getShapeSpecificProperties.
casacore::String type() const
Implements RegionShape::type.
Definition: RegionShapes.h:240
void getShapeSpecificProperties(casacore::Record &properties) const
Implements RegionShape::getShapeSpecificProperties.
static ArrowType arrowType(const casacore::String &type)
Definition: RegionShapes.h:497
Subclass of RegionShape used for drawing markers.
Definition: RegionShapes.h:722
friend class WorldCanvasHolder
Protected interface for WorldCanvasHolder, can be called by the friends of DisplayData, but are nobody else&#39;s business.
Definition: DisplayData.h:750
void getPolygonCoordinates(double &centerX, double &centerY, casacore::String toSystem="") const
Gets polygon-specific coordinates, to avoid dependence on coordParameterValues() when the shape type ...
std::vector< OptionType > optionTypes() const
Returns the types for options.
Definition: RegionShapes.h:282
double m_length
Definition: RegionShapes.h:707
casacore::Vector< casacore::Double > m_y
Definition: RegionShapes.h:426
vector< double > m_spec
Definition: RegionShapes.h:292
A hierarchical collection of named fields of various types.
Definition: Record.h:180
int m_arrowLength
Definition: RegionShapes.h:601
RSHandle getHandle() const
Implements RegionShape::getHandle.
virtual std::vector< casacore::String > coordParameterNames() const =0
Returns the name for the coordinate parameters, in the same order as coordParameterValues().
casacore::String type() const
Implements RegionShape::type.
Definition: RegionShapes.h:944
Parent class for all RegionShapes.
Definition: RegionShape.h:223
std::vector< casacore::String > optionNames() const
Implements RegionShape option methods.
Definition: RegionShapes.h:982
std::vector< double > coordParameterValues() const
Implements RegionShape::coordParameterValues.
std::vector< casacore::String > optionNames() const
Implements RegionShape option methods.
Definition: RegionShapes.h:279
bool updateScreenCoordinates(WorldCanvasHolder &wch, casacore::String *err)
Updates screen coords using world/pixel coords and the given WorldCanvas.
static bool getRectanglePoints(double centerX, double centerY, double radiusX, double radiusY, double angle, casacore::Vector< double > &xPoints, casacore::Vector< double > &yPoints)
Static Members //.
~RSPolygon()
Destructor.
casacore::Vector< casacore::Double > m_screenX
Definition: RegionShapes.h:428
bool m_arrow2
Definition: RegionShapes.h:602
virtual void setCoordParameters(const std::vector< double > &vals)
Implements RegionShape::setCoordParameters.
casacore::Vector< double > m_x
either world or pixel coords
Definition: RegionShapes.h:294
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
vector< double > m_spec
Definition: RegionShapes.h:119
bool m_arrow1
Definition: RegionShapes.h:602
virtual std::vector< RSOption > optionValues() const
Implements RegionShape::optionValues.
void getEllipseCoordinates(double &x, double &y, double &xRadius, double &yRadius, double &angle, casacore::String toSystem="") const
Gets ellipse-specific coordinates, to avoid dependence on coordParameterValues() when the shape type ...
std::vector< RSOption > optionValues() const
Definition: RegionShapes.h:988
double m_screenY
Definition: RegionShapes.h:818
double m_screenY
Definition: RegionShapes.h:999
LineStyle
LSDoubleDashed is only used to preserve state (it is a Display::LineStyle option) ...
Definition: RegionEnums.h:27
virtual bool updateScreenCoordinates(WorldCanvasHolder &wch, casacore::String *err)
Updates screen coords using world/pixel coords and the given WorldCanvas.
vector< RegionShape * > m_shapes
unsigned int m_n
Definition: RegionShapes.h:429
casacore::Vector< double > m_screenX
in order: [upL, boL, boR, upR]
Definition: RegionShapes.h:296
virtual void getShapeSpecificProperties(casacore::Record &properties) const
Implements RegionShape::getShapeSpecificProperties.
Definition: RegionShapes.h:606
casacore::String type() const
Overrides RSEllipse::type.
Definition: RegionShapes.h:158
casacore::Vector< double > m_y
Definition: RegionShapes.h:294
static std::vector< ArrowType > allArrowTypes()
Returns all possible arrow types.
Definition: RegionShapes.h:462
vector< double > m_screenSpec
Definition: RegionShapes.h:600
Subclass of RSLine that takes a length and angle instead of a second point.
Definition: RegionShapes.h:633
A holder to interface between DisplayDatas and a WorldCanvas.
virtual void setCoordParameters(const std::vector< double > &vals)
Implements RegionShape::setCoordParameters.
std::vector< OptionType > optionTypes() const
Implements RegionShape::optionTypes.
Subclass of RSEllipse used for drawing circles.
Definition: RegionShapes.h:142
void getLineCoordinates(double &x1, double &y1, double &x2, double &y2, int &arrowLength, casacore::String toSystem="") const
Gets line-specific coordinates, to avoid dependence on coordParameterValues() when the shape type is ...
virtual void updateMinMax()
Update m_xMin, m_xMax, m_yMin, and m_yMax.
~RSCircle()
Destructor.
virtual ~RSLine()
Destructor.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
static casacore::String markerToString(Display::Marker marker)
Definition: RegionShapes.h:837
std::vector< casacore::String > coordParameterNames() const
Implements RegionShape::coordParameterNames.
void getRectangleCoordinates(double &x, double &y, double &width, double &height, double &angle, casacore::String toSystem="") const
Gets rectangle-specific coordinates, to avoid dependence on coordParameterValues() when the shape typ...
virtual std::vector< double > coordParameterValues() const =0
Returns the current values for the coordinate parameters.
static bool stringToMarker(const casacore::String &str, Display::Marker &marker)
Definition: RegionShapes.h:875
virtual RSHandle getHandle() const
Implements RegionShape::getHandle.
virtual std::vector< CoordinateParameterType > coordParameterTypes() const =0
Returns a vector indicating the types of the coordinate parameters, in the same order as coordParamet...
Abstract base class for Record classes.
void setShapeSpecificProperties(const casacore::RecordInterface &)
Implements RegionShape::setShapeSpecificProperties.
Definition: RegionShapes.h:828
RSHandle getHandle() const
Implements RegionShape::getHandle.
void setOptionValues(const vector< RSOption > &)
Sets the options to the given.
Definition: RegionShapes.h:288
static const casacore::String PROPTYPE_LINE
Definition: RegionShape.h:261
virtual std::vector< double > coordParameterValues() const
Implements RegionShape::coordParameterVales.
virtual std::vector< double > coordParameterValues() const
Implements RegionShape::coordParameterValues.
virtual void getShapeSpecificProperties(casacore::Record &properties) const
Implements RegionShape::getShapeSpecificProperties.
Definition: RegionShapes.h:125
void define(const RecordFieldId &, Bool value)
Define a value for the given field.
Subclass of RegionShape used for drawing text.
Definition: RegionShapes.h:923
casacore::String type() const
Overrides RSLine::type.
Definition: RegionShapes.h:661
Subclass of RegionShape used for drawing polygons.
Definition: RegionShapes.h:329
virtual void setShapeSpecificProperties(const casacore::RecordInterface &props)=0
Sets shape-specific properties from the given record.
bool updateScreenCoordinates(WorldCanvasHolder &wch, casacore::String *err)
Overrides RSEllipse::updateScreenCoordinates.
void getShapeSpecificProperties(casacore::Record &properties) const
same order
Definition: RegionShapes.h:300
RSRectangle(double x, double y, double width, double height, casacore::MDirection::Types worldSystem, double angle=0)
Non-Static Members //.
casacore::String oneWordType() const
Overrides RegionShape::oneWordType.
Definition: RegionShapes.h:372
virtual std::vector< CoordinateParameterType > coordParameterTypes() const
Implements RegionShape::coordParameterPositions.
std::vector< casacore::String > optionNames() const
Implements RegionShape::optionNames.
bool m_dependentChildren
static const casacore::String PROPYCOORDINATES
Definition: RegionShapes.h:336
bool p1Arrow() const
Definition: RegionShapes.h:535
virtual std::vector< std::vector< casacore::String > > optionChoices() const
Implements RegionShape::optionChoices.
virtual void setOptionValues(const vector< RSOption > &)
Sets the options to the given.
Definition: RegionShapes.h:115
casacore::Vector< casacore::Double > m_screenY
Definition: RegionShapes.h:428
static const casacore::String PROPTYPE_RECTANGLE
Definition: RegionShape.h:259
static casacore::String arrowType(ArrowType type)
Converts to/from the casacore::String representation of arrow types.
Definition: RegionShapes.h:481
void setCoordParameters(const std::vector< double > &vals)
Implements RegionShape::setCoordParameters.
static const casacore::String PROPXCOORDINATES
Static Members //.
Definition: RegionShapes.h:335
virtual casacore::String type() const
Implements RegionShape::type.
Definition: RegionShapes.h:67
double m_y
Definition: RegionShapes.h:995
Bool empty() const
Test for empty.
Definition: String.h:375
double m_syncAngle
1) are dependent 2) have angles (rectangle, ellipse, vector, text) 3) all have synched (same) angle ...
casacore::String oneWordType() const
Overrides RegionShape::oneWordType.
bool updateScreenCoordinates(WorldCanvasHolder &wch, casacore::String *err)
Updates screen coords using world/pixel coords and the given WorldCanvas.