casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RegionShape.h
Go to the documentation of this file.
1 //# RegionShape.h: Parent RegionShape class and helpers.
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 REGIONSHAPE_H_
28 #define REGIONSHAPE_H_
29 
31 
35 #include <casa/BasicSL/String.h>
36 #include <casa/Containers/Record.h>
37 
38 #include <casa/namespace.h>
39 
40 namespace casa {
41 
42  class PixelCanvas;
43 
44 // Text label associated with a RegionShape.
46  public:
47  // Static Members //
48 
49  // Defaults.
50  // <group>
52  static const int DEFAULT_POINTSIZE;
53  // </group>
54 
55 
56  // Constructor.
58 
59  // Destructor.
61 
62 
63  // Sets this label's text to the given.
64  void setText(const casacore::String& text);
65 
66  // Sets this label's font family to the given. How it is handled when
67  // being drawn depends on the underlying PixelCanvas implementation.
68  void setFont(const casacore::String& font);
69 
70  // Sets the label's font point size to the given.
71  void setSize(int size);
72 
73  // Sets the label's font color to the given. Note: while there is no
74  // formal specification for color format, Strings should be accepted in
75  // common name format ("black") or hexadecimal format ("#000000").
76  void setColor(const casacore::String& color);
77 
78  // Sets whether the label's font is italic or not. Note: only
79  // QtPixelCanvas currently supports bold.
80  void setItalic(bool italic = true);
81 
82  // Sets whether the label's font is bold or not. Note: only QtPixelCanvas
83  // currently supports bold.
84  void setBold(bool bold = true);
85 
86  // Sets the rotation angle to the given (in degrees). This angle is in
87  // pixel coordinates. Rotation is counterclockwise.
88  void setAngle(double angle);
89 
90 
91  // Returns true if this label has empty text, false otherwise.
92  bool isEmpty() const;
93 
94  // Returns the text for this label.
95  const casacore::String& text() const;
96 
97  // Returns the font family for this label.
98  const casacore::String& font() const;
99 
100  // Returns the point size for this label.
101  int size() const;
102 
103  // Returns the color for this label.
104  const casacore::String& color() const;
105 
106  // Returns true if this label's font is italic, false otherwise.
107  bool isItalic() const;
108 
109  // Returns true if this label's font is bold, false otherwise.
110  bool isBold() const;
111 
112  // Returns this label's angle.
113  double angle() const;
114 
115 
116  // Sets the font on the given PixelCanvas. Note: bold/italic only
117  // work for QtPixelCanvas.
118  void setFont(PixelCanvas* pc) const;
119 
120  // Returns the result of pc->textWidth() after setting the font.
121  int width(PixelCanvas* pc) const;
122 
123  // Returns the result of pc->textHeight() after setting the font.
124  int height(PixelCanvas* pc) const;
125 
126  // Draws itself on the given pixel canvas and returns whether the operation
127  // succeeded or not. x and y are the screen pixel coordinates to draw the
128  // label. If bottom is false, the label is centered on (x, y); otherwise
129  // the label is drawn with (x, y) at its bottom center point.
130  bool draw(PixelCanvas* pc, int x, int y, bool bottom = false,
131  casacore::String* error = NULL);
132 
133  private:
135  casacore::String m_font; // font family name
136  int m_pointSize; // font point size
137  casacore::String m_color; // font color
138  bool m_italic; // is italic?
139  bool m_bold; // is bold?
140  double m_angle; // screen rotation angle
141  };
142 
143 
144 // Parent class for all RegionShapes. Contains operations and properties
145 // common to all RegionShapes, such as:
146 // <ul><li>Line color, width</li>
147 // <li>Label (see RegionShapeLabel)</li>
148 // <li>Linethrough</li>
149 // <li>Minimum/maximum values, both world/pixel and screen</li>
150 // <li>World coordinate system (if applicable)</li>
151 // <li>Converting between different coordinate systems</li></ul>
152 // Also contains methods that must be implemented in subclasses:
153 // <ul><li>Type/name for display</li>
154 // <li>Getting/setting coordinates</li>
155 // <li>Getting/setting options</li>
156 // <li>Moving the shape</li>
157 // <li>Drawing on a world canvas</li></ul>
158 // RegionShapes can also be converted to and from a CASA record. Fields in
159 // the record MUST adhere to the properties outlined below and in the shape
160 // subclasses. While additional properties may be defined in the shape
161 // subclasses, properties at the RegionShape level are:
162 // <ul><li><b>RegionShape::PROPISWORLD</b> (<i>bool</i>): whether the shape has
163 // a world system (true) or a pixel system (false). Note: if true, the
164 // world system MUST be defined using the following property.
165 // <b>MUST ALWAYS BE DEFINED.</b></li>
166 // <li><b>RegionShape::PROPWORLDSYSTEM</b> (<i>casacore::String</i>): if the shape
167 // is in world coordinates, the world system. MUST be able to be
168 // converted to an casacore::MDirection::Types via casacore::MDirection::getType().
169 // <b>MUST BE DEFINED FOR SHAPES WITH WORLD COORDINATES.</b></li>
170 // <li><b>RegionShape::PROPLINE_COLOR</b> (<i>casacore::String</i>): line color.
171 // <b>OPTIONAL.</b></li>
172 // <li><b>RegionShape::PROPLINE_WIDTH</b> (<i>double</i>): line width.
173 // <b>OPTIONAL.</b></li>
174 // <li><b>RegionShape::PROPLINE_STYLE</b> (<i>casacore::String</i>): String
175 // representation of line style. NOTE: styles other than solid and
176 // dashed are only supported by QtPixelCanvas. <b>OPTIONAL.</b></li>
177 // <li><b>RegionShape::PROPTEXT</b> (<i>casacore::String</i>): label text.
178 // <b>OPTIONAL.</b></li>
179 // <li><b>RegionShape::PROPTEXT_COLOR</b> (<i>casacore::String</i>): label color.
180 // <b>OPTIONAL.</b></li>
181 // <li><b>RegionShape::PROPTEXT_FONT</b> (<i>casacore::String</i>): label font.
182 // <b>OPTIONAL.</b></li>
183 // <li><b>RegionShape::PROPTEXT_SIZE</b> (<i>int</i>): label point size.
184 // <b>OPTIONAL.</b></li>
185 // <li><b>RegionShape::PROPTEXT_ITALIC</b> (<i>bool</i>): whether label
186 // font is italic. <b>OPTIONAL.</b></li>
187 // <li><b>RegionShape::PROPTEXT_BOLD</b> (<i>bool</i>): whether label font
188 // is bold. <b>OPTIONAL.</b></li>
189 // <li><b>RegionShape::PROPLINETHROUGH</b> (<i>bool</li>): whether the
190 // shape has a linethrough or not. <b>OPTIONAL.</b></li>
191 // <li><b>RegionShape::PROPLINETHROUGH_COLOR</b> (<i>casacore::String</i>):
192 // linethrough color. <b>OPTIONAL.</b></li>
193 // <li><b>RegionShape::PROPLINETHROUGH_WIDTH</b> (<i>double</i>):
194 // linethrough width. <b>OPTIONAL.</b></li>
195 // <li><b>RegionShape::PROPLINETHROUGH_STYLE</b> (<i>casacore::String</i>): String
196 // representation of linethrough style. NOTE: styles other than solid
197 // and dashed are only supported by QtPixelCanvas.
198 // <b>OPTIONAL.</b></li>
199 // <li><b>RegionShape::PROPCOORDINATES</b> (<i>casacore::Array&lt;double&gt;</i>):
200 // This property will be used to call setCoordParameters, and so is
201 // specific to the shape type. <b>MUST BE DEFINED FOR SHAPE TYPES
202 // OTHER THAN RSPolygon AND RSComposite.</b></li>
203 // <li><b>RegionShape::PROPOPTIONS</b> (<i>casacore::Record</i>): the fields are set
204 // in the order defined by each shape type's option methods. Each
205 // field's name should be unique (the specifics are irrelevant since it
206 // is the order that matters), and the value should be one of the types
207 // supported by RSOption. <b>OPTIONAL.</b></li></ul>
208 // RegionShape also defines a shapeFromRecord() method that will create and
209 // return a new shape based on the given record. This record has the
210 // following additional properties:
211 // <ul><li><b>RegionShape::PROPTYPE</b> (<i>casacore::String</i>): for defining which
212 // type of shape is defined by the record. Acceptable choices:
213 // <ul><li>RegionShape::PROPTYPE_ELLIPSE</li>
214 // <li>RegionShape::PROPTYPE_CIRCLE</li>
215 // <li>RegionShape::PROPTYPE_RECTANGLE</li>
216 // <li>RegionShape::PROPTYPE_POLYGON</li>
217 // <li>RegionShape::PROPTYPE_LINE</li>
218 // <li>RegionShape::PROPTYPE_VECTOR</li>
219 // <li>RegionShape::PROPTYPE_MARKER</li>
220 // <li>RegionShape::PROPTYPE_TEXT</li>
221 // <li>RegionShape::PROPTYPE_COMPOSITE.</li></ul>
222 // <b>MUST ALWAYS BE DEFINED.</b></li></ul>
223  class RegionShape : public PassiveCachingDD {
224  public:
225  // Static Members //
226 
227  // The unit that all native coordinates are in. Currently set to "deg".
228  // If this is changed, DS9RegionFileWriter::convertValue() must also be
229  // updated.
230  static const casacore::String UNIT;
231 
232  // Value used for wrapping negative/positive unit values. Currently set
233  // to 360 for degrees.
234  static const double UNIT_WRAPAROUND;
235 
236  // Properties. See RegionShape description.
237  // <group>
255 
266  // </group>
267 
268  // Creates a record of the correct type from the given record (see
269  // RegionShape class description), or NULL if a fatal error occurred.
270  static RegionShape* shapeFromRecord(const casacore::RecordInterface& properties,
271  casacore::String& error);
272 
273  // Different types for coordinate parameters.
276  };
277 
278  std::string errorMessage( ) const { return ""; }
279 
280  // Different types for options.
281  enum OptionType {
283  };
284 
285  // Different line styles. NOTE: styles other than solid and dashed are
286  // ONLY supported by QtPixelCanvas. Custom line styles are used for
287  // custom dash lists.
288  enum LineStyle {
290  };
291 
292  // Returns all available line styles.
293  static std::vector<LineStyle> allLineStyles() {
294  static std::vector<LineStyle> v(3);
295  v[0] = SOLID;
296  v[1] = DASHED;
297  v[2] = DOTTED;
298  return v;
299  }
300 
301  // Convert between line style enum and String.
302  // <group>
305  // </group>
306 
307  // Defaults.
308  // <group>
310  static const double DEFAULT_WIDTH;
311  static const LineStyle DEFAULT_STYLE;
312  // <group>
313 
314 
315  // Non-Static Members //
316 
317  // World Constructor. Note: implementing subclasses MUST supply values
318  // for m_xMin, m_xMax, m_yMin, and m_yMax, or override xMin(), xMax(),
319  // yMin(), and yMax().
321 
322  // Pixel Constructor. Note: implementing subclasses MUST supply values
323  // for m_xMin, m_xMax, m_yMin, and m_yMax, or override xMin(), xMax(),
324  // yMin(), and yMax().
325  RegionShape();
326 
327  // casacore::Record Constructor.
328  RegionShape(const casacore::RecordInterface& properties);
329 
330  // Destructor
331  virtual ~RegionShape();
332 
333 
334  // PassiveCachingDD methods //
335 
336  // Implements PassiveCachingDD::dataUnit.
337  const casacore::Unit dataUnit() const;
339  return casacore::IPosition( );
340  }
342  return 0;
343  }
344  std::vector<int> displayAxes( ) const {
345  return std::vector<int>( );
346  }
347 
348  // Implements PassiveCachingDD::classType.
350 
351  // Implements PassiveCachingDD::newDisplayMethod.
353  AttributeBuffer* wchAttr, AttributeBuffer* ddAttr,
354  CachingDisplayData* dd);
355 
356 
357  // Common RegionShape methods //
358 
359  // Gets/sets this shape's line color.
360  // <group>
361  virtual casacore::String lineColor() const;
362  virtual void setLineColor(const casacore::String& newColor, bool alsoSetLabel= true);
363  // </group>
364 
365  // Gets/sets this shape's line width.
366  // <group>
367  virtual double lineWidth() const;
368  virtual void setLineWidth(double width);
369  // </group>
370 
371  // Gets/sets this shape's line style. See RegionShape::LineStyle.
372  // <group>
373  virtual LineStyle lineStyle() const;
374  virtual void setLineStyle(LineStyle style);
375  // </group>
376 
377  // Gets/sets this shape's label's text.
378  // <group>
379  virtual casacore::String text() const;
380  virtual void setText(const casacore::String& text);
381  // </group>
382 
383  // Gets/sets this shape's label.
384  // <group>
385  virtual const RegionShapeLabel& label() const;
386  virtual void setLabel(const RegionShapeLabel& label);
387  // </group>
388 
389  // Gets/sets this shape's linethrough properties.
390  // <group>
391  virtual bool linethrough() const;
392  virtual casacore::String linethroughColor() const;
393  virtual double linethroughWidth() const;
394  virtual LineStyle linethroughStyle() const;
395  virtual void setLinethrough(bool linethrough, casacore::String color = "red",
396  double width = 1, LineStyle style = SOLID);
397  // </group>
398 
399  // Min/max methods for world/pixel coordinates. Note that some shapes
400  // (RSMarker, RSText) may have identical mins/maxes since they only
401  // take up space in screen pixels.
402  // <group>
403  virtual double xMin() const;
404  virtual double xMax() const;
405  virtual double yMin() const;
406  virtual double yMax() const;
407  // </group>
408 
409  // Bounding box methods. Returns the min and max of the screen
410  // coordinates. Note: these are only valid after a call to
411  // drawAndUpdateBoundingBox!
412  // <group>
413  virtual double screenXMin() const;
414  virtual double screenXMax() const;
415  virtual double screenYMin() const;
416  virtual double screenYMax() const;
417  // </group>
418 
419  // Returns whether this shape's coordinates are in world or pixel.
420  virtual bool isWorld() const {
421  return m_isWorld;
422  }
423 
424  // If this shape is in world coordinates, returns the system used.
425  // Undefined for pixel coordinates.
427  return m_worldSystem;
428  }
429 
430  // Set world or pixel system.
431  virtual void setIsWorld(bool isWorld) {
432  m_isWorld = isWorld;
433  }
434 
435  // Set world system.
437  m_worldSystem = sys;
438  }
439 
440  // Returns this shape's type (color + type).
441  virtual casacore::String title() const {
442  return lineColor() + " " + type();
443  }
444 
445  // Checks whether the given WorldCanvasHolder has a direction coordinate.
446  // Updates the last WorldCanvasHolder seen to the given, then calls
447  // drawAndUpdateBoundingBox which actually draws this shape onto the
448  // world canvas.
449  bool draw(WorldCanvasHolder& wch);
450 
451  // Returns whether there was an error during the last call to draw() or
452  // not.
453  virtual bool hadDrawingError() const {
454  return m_hadDrawingError;
455  }
456 
457  // Returns the error that occurred during the last call to draw().
459  return m_drawingError;
460  }
461 
462  // Returns this shape's properties as a Record.
464 
465  // Synonym.
467  return getProperties();
468  }
469 
470  // Sets this shape's properties from the given Record.
471  void setProperties(const casacore::RecordInterface& properties);
472 
473 
474  // Pure Virtual Methods //
475 
476  // Draw this shape on the given world canvas and update the bounding box
477  // protected variables m_screenXMin, m_screenXMax, m_screenYMin,
478  // and m_screenYMax. NOTE: implementing classes should be sure to set the
479  // line style of the pixel canvas back to Display::LSSolid when finished.
480  // The protected method resetLineStyle can be used for this purpose.
482  casacore::String* error = NULL) = 0;
483 
484  // Returns the name/type of this shape, for displaying to the user.
485  virtual casacore::String type() const = 0;
486  // Pure virtual function from DisplayData...
488  return type( );
489  }
490 
491 
492  // Can be overridden by children. Returns a one-word type.
493  virtual casacore::String oneWordType() const {
494  return type();
495  }
496 
497  // Returns the current values for the coordinate parameters. The
498  // number and order depend on the shape type. For world systems
499  // (RegionShape::isWorld()), these coordinates have unit RegionShape::UNIT
500  // in the system RegionShape::worldSystem().
501  virtual std::vector<double> coordParameterValues() const = 0;
502 
503  // Returns the current values for the coordinate parameters in the given
504  // world system, by using the last WorldCanvasHolder for conversions if
505  // needed. The number and order depend on the shape type. toSystem
506  // indivates which system the given values are in and should either be:
507  // 1) RSUtils::PIXEL for pixel coordinates, or
508  // 2) a value that can be converted to a casacore::MDirection::Types via
509  // casacore::MDirection::getType().
510  // Returned coordinates have unit RegionShape::UNIT for world systems.
511  virtual std::vector<double> coordParameterValues(casacore::String toSystem) const = 0;
512 
513  // Returns the name for the coordinate parameters, in the same order
514  // as coordParameterValues().
515  virtual std::vector<casacore::String> coordParameterNames() const = 0;
516 
517  // Returns a vector indicating the types of the coordinate parameters,
518  // in the same order as coordParameterValues().
519  virtual std::vector<CoordinateParameterType> coordParameterTypes() const = 0;
520 
521  // Sets the coordinate parameter values to the given, in the same order
522  // as coordParameterValues(). For world systems (RegionShape::isWorld()),
523  // the values must be in unit RegionShape::UNIT and system
524  // RegionShape::worldSystem().
525  virtual void setCoordParameters(const std::vector<double>& vals) = 0;
526 
527  // Sets the coordinate parameter values to the given, in the same order
528  // as coordParameterValues(). valSystem indicates which system the given
529  // values are in and should either be:
530  // 1) RSUtils::PIXEL for pixel coordinates, or
531  // 2) a value that can be converted to a casacore::MDirection::Types via
532  // casacore::MDirection::getType().
533  // Values must be in unit RegionShape::UNIT for world systems.
534  virtual void setCoordParameters(const std::vector<double>& vals,
535  casacore::String valSystem) = 0;
536 
537  // Moves this shape the given delta x and delta y in the given system
538  // (empty for shape's native system).
539  virtual void move(double dx, double dy, casacore::String system = "") = 0;
540 
541  // Returns a RSHandle (four points in screen coords that are like a
542  // bounding box for the shape) for this shape. If the shape has not
543  // previously been drawn on a canvas, this may return an invalid RSHandle.
544  // The handle does NOT include the label.
545  virtual RSHandle getHandle() const = 0;
546 
547  // Returns the names for options.
548  virtual std::vector<casacore::String> optionNames() const = 0;
549 
550  // Returns the types for options.
551  virtual std::vector<OptionType> optionTypes() const = 0;
552 
553  // For options that are string choices, return the available choices.
554  // May return an empty vector if there are no string choices.
555  virtual std::vector<std::vector<casacore::String> > optionChoices() const {
556  return std::vector<std::vector<casacore::String> >();
557  }
558 
559  // Returns the current values for options.
560  virtual std::vector<RSOption> optionValues() const = 0;
561 
562  // Sets the options to the given.
563  virtual void setOptionValues(const std::vector<RSOption>& options) = 0;
564 
565  protected:
566  // Common RegionShape Members //
567 
568  // Whether this shape uses world or pixel coordinates.
569  bool m_isWorld;
570 
571  // World system (undefined if m_isWorld is false).
573 
574  // Line color.
576 
577  // Line width.
578  double m_width;
579 
580  // Line style.
582 
583  // Label.
585 
586  // Linethrough properties.
587  // <group>
588  bool m_lt;
590  double m_ltWidth;
592  // </group>
593 
594  // Bounding box, in world/pixel coords.
596 
597  // Bounding box, in screen pixels.
599 
600  // Last seen WorldCanvasHolder. Should only be used by
601  // coordParameterValues.
603 
604  // For keeping track of drawing/conversion errors.
605  // <group>
608  // </group>
609 
610 
611  // Pure Virtual Methods //
612 
613  // Puts shape-specific properties in the given record. MUST at least set
614  // PROP_TYPE.
615  virtual void getShapeSpecificProperties(casacore::Record& properties) const = 0;
616 
617  // Sets shape-specific properties from the given record.
618  virtual void setShapeSpecificProperties(const casacore::RecordInterface& props) = 0;
619 
620 
621  // Common RegionShape Methods //
622 
623  // Sets the line properties (color, width, style) of this shape for the
624  // given PixelCanvas.
625  void setLineProperties(PixelCanvas* pc);
626 
627  // Sets the linethrough properties (color, width, style) of this shape for
628  // the given PixelCanvas.
630 
631  // Used for resetting the line style on the given PixelCanvas back to
632  // solid, in case future uses are expecting solid lines.
633  void resetLineStyle(PixelCanvas* pc) const;
634 
635  // Convenience access to RSUtils conversion methods.
636  // <group>
640  WorldCanvasHolder& wch, bool wrap = true,
641  casacore::String* error = NULL) const {
642  return RSUtils::worldToPixel(worldX, worldY, pixelX, pixelY, wch,
643  m_worldSystem, wrap, error);
644  }
645 
647  const casacore::Vector<double>& pixelY,
650  bool wrap = true, casacore::String* error = NULL) const {
651  return RSUtils::pixelToWorld(pixelX, pixelY, worldX, worldY, wch,
652  m_worldSystem, wrap, error);
653  }
654 
658  WorldCanvasHolder& wch, bool wrap = true,
659  casacore::String* error = NULL) const {
660  return RSUtils::worldToLinear(worldX, worldY, linearX, linearY, wch,
661  m_worldSystem, wrap, error);
662  }
663 
667  WorldCanvasHolder& wch, bool wrap = true,
668  casacore::String* error = NULL) const {
669  casacore::Vector<double> linX(worldX.getValue().size()),
670  linY(worldY.getValue().size());
671  return RSUtils::worldToLinear(worldX, worldY, linX, linY, wch,
672  m_worldSystem, wrap, error) &&
673  RSUtils::linearToScreen(linX, linY, screenX, screenY,wch,error);
674  }
675 
677  const casacore::Vector<double>& linearY,
680  WorldCanvasHolder& wch, casacore::String* error = NULL) const {
681  return RSUtils::linearToWorld(linearX, linearY, worldX, worldY, wch,
682  m_worldSystem, std::vector<int>(),
683  std::vector<int>(), false, error);
684  }
685 
687  const casacore::Vector<double>& linearY,
690  WorldCanvasHolder& wch, const std::vector<int>& xSign,
691  const std::vector<int>& ySign, casacore::String* error = NULL) const {
692  return RSUtils::linearToWorld(linearX, linearY, worldX, worldY, wch,
693  m_worldSystem, xSign, ySign, true, error);
694  }
695 
697  const casacore::Vector<double>& screenY,
700  WorldCanvasHolder& wch, casacore::String* error = NULL) const {
701  casacore::Vector<double> linX(screenX.size()), linY(screenY.size());
702  return RSUtils::screenToLinear(screenX, screenY, linX,linY,wch,error)&&
703  RSUtils::linearToWorld(linX, linY, worldX, worldY, wch,
704  m_worldSystem, std::vector<int>(),
705  std::vector<int>(), false, error);
706  }
707 
709  const casacore::Vector<double>& screenY,
712  WorldCanvasHolder& wch, const std::vector<int>& xSign,
713  const std::vector<int>& ySign, casacore::String* error = NULL) const {
714  casacore::Vector<double> linX(screenX.size()), linY(screenY.size());
715  return RSUtils::screenToLinear(screenX, screenY, linX,linY,wch,error)&&
716  RSUtils::linearToWorld(linX, linY, worldX, worldY, wch,
717  m_worldSystem, xSign, ySign, true,error);
718  }
719  // </group>
720 
721  private:
722  // Sets default values where needed for all member variables, EXCEPT
723  // m_isWorld and m_worldSystem. Intended to be called from a constructor.
724  void initDefaults();
725  };
726 
727 
728 // Implementation of CachingDisplayMethod to be used by RegionShapes.
729 // Basically just a call to the shape's draw method.
731  public:
732  // Constructor that takes the RegionShape to draw, as well as the other
733  // parameters for the CachingDisplayMethod constructor.
735  AttributeBuffer* ddAttr, CachingDisplayData* dd);
736 
737  // Destructor.
738  ~RegionShapeDM();
739 
740  // Implementation of CachingDisplayMethod::drawIntoList.
742 
743  private:
744  RegionShape& m_shape; // Parent shape.
745  };
746 
747 }
748 
749 #endif /* REGIONSHAPE_H_ */
virtual bool linethrough() const
Gets/sets this shape&#39;s linethrough properties.
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
static bool screenToLinear(const casacore::Vector< double > &screenX, const casacore::Vector< double > &screenY, casacore::Vector< double > &linearX, casacore::Vector< double > &linearY, WorldCanvasHolder &wch, casacore::String *error=NULL)
virtual void setCoordParameters(const std::vector< double > &vals)=0
Sets the coordinate parameter values to the given, in the same order as coordParameterValues().
void initDefaults()
Sets default values where needed for all member variables, EXCEPT m_isWorld and m_worldSystem.
virtual void getShapeSpecificProperties(casacore::Record &properties) const =0
Pure Virtual Methods //.
Assistance class for auto-caching of DisplayData objects.
virtual double xMin() const
Min/max methods for world/pixel coordinates.
CoordinateParameterType
Different types for coordinate parameters.
Definition: RegionShape.h:274
virtual std::vector< RSOption > optionValues() const =0
Returns the current values for options.
static const casacore::String PROPTEXT_COLOR
Definition: RegionShape.h:244
virtual LineStyle linethroughStyle() const
static const casacore::String PROPLINE_WIDTH
Definition: RegionShape.h:241
static const int DEFAULT_POINTSIZE
Definition: RegionShape.h:52
bool draw(WorldCanvasHolder &wch)
Checks whether the given WorldCanvasHolder has a direction coordinate.
void setBold(bool bold=true)
Sets whether the label&#39;s font is bold or not.
static const casacore::String PROPTEXT
Definition: RegionShape.h:243
static const LineStyle DEFAULT_STYLE
Definition: RegionShape.h:311
static const casacore::String UNIT
Static Members //.
Definition: RegionShape.h:230
void resetLineStyle(PixelCanvas *pc) const
Used for resetting the line style on the given PixelCanvas back to solid, in case future uses are exp...
static const casacore::String PROPWORLDSYSTEM
Definition: RegionShape.h:239
virtual void setLinethrough(bool linethrough, casacore::String color="red", double width=1, LineStyle style=SOLID)
A &quot;handle&quot; is a four-point structure (usually a rectangle) that describes the boundaries in screen pi...
Definition: RSUtils.qo.h:445
static const casacore::String PROPOPTIONS
Definition: RegionShape.h:254
static casacore::String convLineStyle(LineStyle style)
Convert between line style enum and String.
virtual std::vector< casacore::String > optionNames() const =0
Returns the names for options.
virtual const RegionShapeLabel & label() const
Gets/sets this shape&#39;s label.
static const double UNIT_WRAPAROUND
Value used for wrapping negative/positive unit values.
Definition: RegionShape.h:234
bool isEmpty() const
Returns true if this label has empty text, false otherwise.
static const casacore::String PROPTYPE_MARKER
Definition: RegionShape.h:263
double angle() const
Returns this label&#39;s angle.
static const casacore::String PROPLINETHROUGH_STYLE
Definition: RegionShape.h:252
virtual double xMax() const
Display::DisplayDataType classType()
Implements PassiveCachingDD::classType.
DisplayDataType
WorldCanvasHolder - what type of DisplayData is this, need to know for drawing order.
Definition: DisplayEnums.h:355
Buffer for storing Attributes.
const casacore::String & text() const
Returns the text for this label.
bool m_lt
Linethrough properties.
Definition: RegionShape.h:588
const casacore::String & color() const
Returns the color for this label.
void setText(const casacore::String &text)
Sets this label&#39;s text to the given.
RegionShapeLabel m_label
Label.
Definition: RegionShape.h:584
bool isBold() const
Returns true if this label&#39;s font is bold, false otherwise.
bool m_hadDrawingError
For keeping track of drawing/conversion errors.
Definition: RegionShape.h:606
static const casacore::String PROPTYPE_TEXT
Definition: RegionShape.h:264
casacore::String dataType() const
Pure virtual function from DisplayData...
Definition: RegionShape.h:487
virtual std::vector< std::vector< casacore::String > > optionChoices() const
For options that are string choices, return the available choices.
Definition: RegionShape.h:555
void setAngle(double angle)
Sets the rotation angle to the given (in degrees).
std::string errorMessage() const
Definition: RegionShape.h:278
static const casacore::String PROPTYPE_CIRCLE
Definition: RegionShape.h:258
casacore::String m_color
Definition: RegionShape.h:137
virtual casacore::MDirection::Types worldSystem() const
If this shape is in world coordinates, returns the system used.
Definition: RegionShape.h:426
static const casacore::String PROPTYPE_POLYGON
Definition: RegionShape.h:260
RegionShape()
Pixel Constructor.
bool linearToWorld(const casacore::Vector< double > &linearX, const casacore::Vector< double > &linearY, casacore::Quantum< casacore::Vector< double > > &worldX, casacore::Quantum< casacore::Vector< double > > &worldY, WorldCanvasHolder &wch, casacore::String *error=NULL) const
Definition: RegionShape.h:676
casacore::Bool drawIntoList(Display::RefreshReason reason, WorldCanvasHolder &wch)
Implementation of CachingDisplayMethod::drawIntoList.
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.
static const casacore::String PROPTYPE_ELLIPSE
Definition: RegionShape.h:257
bool linearToWorld(const casacore::Vector< double > &linearX, const casacore::Vector< double > &linearY, casacore::Quantum< casacore::Vector< double > > &worldX, casacore::Quantum< casacore::Vector< double > > &worldY, WorldCanvasHolder &wch, const std::vector< int > &xSign, const std::vector< int > &ySign, casacore::String *error=NULL) const
Definition: RegionShape.h:686
virtual std::vector< OptionType > optionTypes() const =0
Returns the types for options.
virtual double linethroughWidth() const
virtual bool hadDrawingError() const
Returns whether there was an error during the last call to draw() or not.
Definition: RegionShape.h:453
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)...
LineStyle
Different line styles.
Definition: RegionShape.h:288
virtual casacore::String oneWordType() const
Can be overridden by children.
Definition: RegionShape.h:493
virtual casacore::String linethroughColor() const
Base class defining interface to pixel-based output devices.
Definition: PixelCanvas.h:161
static bool linearToScreen(const casacore::Vector< double > &linearX, const casacore::Vector< double > &linearY, casacore::Vector< double > &screenX, casacore::Vector< double > &screenY, WorldCanvasHolder &wch, casacore::String *error=NULL)
virtual ~RegionShape()
Destructor.
Types
Types of known MDirections Warning: The order defines the order in the translation matrix FromTo in ...
Definition: MDirection.h:188
Options options
defines physical units
Definition: Unit.h:189
void setFont(const casacore::String &font)
Sets this label&#39;s font family to the given.
virtual void setLabel(const RegionShapeLabel &label)
virtual double lineWidth() const
Gets/sets this shape&#39;s line width.
virtual double screenXMin() const
Bounding box methods.
casacore::MDirection::Types m_worldSystem
World system (undefined if m_isWorld is false).
Definition: RegionShape.h:572
double m_xMin
Bounding box, in world/pixel coords.
Definition: RegionShape.h:595
WorldCanvasHolder * m_lastWCH
Last seen WorldCanvasHolder.
Definition: RegionShape.h:602
static const casacore::String PROPTEXT_FONT
Definition: RegionShape.h:245
void setSize(int size)
Sets the label&#39;s font point size to the given.
Implementation of CachingDisplayMethod to be used by RegionShapes.
Definition: RegionShape.h:730
virtual void setOptionValues(const std::vector< RSOption > &options)=0
Sets the options to the given.
void setItalic(bool italic=true)
Sets whether the label&#39;s font is italic or not.
virtual void setText(const casacore::String &text)
virtual RSHandle getHandle() const =0
Returns a RSHandle (four points in screen coords that are like a bounding box for the shape) for this...
static const casacore::String PROPLINE_COLOR
Definition: RegionShape.h:240
static std::vector< LineStyle > allLineStyles()
Returns all available line styles.
Definition: RegionShape.h:293
bool draw(PixelCanvas *pc, int x, int y, bool bottom=false, casacore::String *error=NULL)
Draws itself on the given pixel canvas and returns whether the operation succeeded or not...
void setProperties(const casacore::RecordInterface &properties)
Sets this shape&#39;s properties from the given Record.
void setLineProperties(PixelCanvas *pc)
Common RegionShape Methods //.
virtual void setLineColor(const casacore::String &newColor, bool alsoSetLabel=true)
static const casacore::String PROPLINETHROUGH
Definition: RegionShape.h:249
static const casacore::String PROPTEXT_ITALIC
Definition: RegionShape.h:247
casacore::Record getProperties() const
Returns this shape&#39;s properties as a Record.
Base class for auto-caching DisplayData objects.
casacore::String m_font
Definition: RegionShape.h:135
static const casacore::String PROPTYPE
Definition: RegionShape.h:256
virtual void setLineStyle(LineStyle style)
RegionShape & m_shape
Definition: RegionShape.h:744
static bool pixelToWorld(const casacore::Vector< double > &pixelX, const casacore::Vector< double > &pixelY, casacore::Quantum< casacore::Vector< double > > &worldX, casacore::Quantum< casacore::Vector< double > > &worldY, WorldCanvasHolder &wch, casacore::MDirection::Types toSys, bool wrap=true, casacore::String *error=NULL)
double m_width
Line width.
Definition: RegionShape.h:578
void setColor(const casacore::String &color)
Sets the label&#39;s font color to the given.
virtual casacore::String lineColor() const
Common RegionShape methods //.
bool m_isWorld
Common RegionShape Members //.
Definition: RegionShape.h:569
virtual casacore::String text() const
Gets/sets this shape&#39;s label&#39;s text.
virtual double yMax() const
bool worldToLinear(const casacore::Quantum< casacore::Vector< double > > &worldX, const casacore::Quantum< casacore::Vector< double > > &worldY, casacore::Vector< double > &linearX, casacore::Vector< double > &linearY, WorldCanvasHolder &wch, bool wrap=true, casacore::String *error=NULL) const
Definition: RegionShape.h:655
static bool worldToPixel(const casacore::Quantum< casacore::Vector< double > > &worldX, const casacore::Quantum< casacore::Vector< double > > &worldY, casacore::Vector< double > &pixelX, casacore::Vector< double > &pixelY, WorldCanvasHolder &wch, casacore::MDirection::Types fromSys, bool wrap=true, casacore::String *error=NULL)
Converts the given coordinates between different systems, using the given WorldCanvas and world syste...
bool worldToPixel(const casacore::Quantum< casacore::Vector< double > > &worldX, const casacore::Quantum< casacore::Vector< double > > &worldY, casacore::Vector< double > &pixelX, casacore::Vector< double > &pixelY, WorldCanvasHolder &wch, bool wrap=true, casacore::String *error=NULL) const
Convenience access to RSUtils conversion methods.
Definition: RegionShape.h:637
static RegionShape * shapeFromRecord(const casacore::RecordInterface &properties, casacore::String &error)
Creates a record of the correct type from the given record (see RegionShape class description)...
static const casacore::String PROPLINETHROUGH_COLOR
Definition: RegionShape.h:250
CachingDisplayMethod * newDisplayMethod(WorldCanvas *wc, AttributeBuffer *wchAttr, AttributeBuffer *ddAttr, CachingDisplayData *dd)
Implements PassiveCachingDD::newDisplayMethod.
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
bool screenToWorld(const casacore::Vector< double > &screenX, const casacore::Vector< double > &screenY, casacore::Quantum< casacore::Vector< double > > &worldX, casacore::Quantum< casacore::Vector< double > > &worldY, WorldCanvasHolder &wch, casacore::String *error=NULL) const
Definition: RegionShape.h:696
bool worldToScreen(const casacore::Quantum< casacore::Vector< double > > &worldX, const casacore::Quantum< casacore::Vector< double > > &worldY, casacore::Vector< double > &screenX, casacore::Vector< double > &screenY, WorldCanvasHolder &wch, bool wrap=true, casacore::String *error=NULL) const
Definition: RegionShape.h:664
virtual bool isWorld() const
Returns whether this shape&#39;s coordinates are in world or pixel.
Definition: RegionShape.h:420
const casacore::IPosition dataShape() const
Definition: RegionShape.h:338
Text label associated with a RegionShape.
Definition: RegionShape.h:45
int width(PixelCanvas *pc) const
Returns the result of pc-&gt;textWidth() after setting the font.
virtual std::vector< casacore::String > coordParameterNames() const =0
Returns the name for the coordinate parameters, in the same order as coordParameterValues().
Parent class for all RegionShapes.
Definition: RegionShape.h:223
virtual void setWorldSystem(casacore::MDirection::Types sys)
Set world system.
Definition: RegionShape.h:436
virtual void setIsWorld(bool isWorld)
Set world or pixel system.
Definition: RegionShape.h:431
virtual casacore::String title() const
Returns this shape&#39;s type (color + type).
Definition: RegionShape.h:441
Quantities (i.e. dimensioned values)
Definition: QuantumHolder.h:44
double m_screenXMin
Bounding box, in screen pixels.
Definition: RegionShape.h:598
Class providing passive behaviour for CachingDisplayDatas.
void setLinethroughProperties(PixelCanvas *pc)
Sets the linethrough properties (color, width, style) of this shape for the given PixelCanvas...
casacore::Record toRecord() const
Synonym.
Definition: RegionShape.h:466
LineStyle m_style
Line style.
Definition: RegionShape.h:581
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
casacore::String m_ltColor
Definition: RegionShape.h:589
virtual void setLineWidth(double width)
static const casacore::String DEFAULT_FONT
Static Members //.
Definition: RegionShape.h:51
RegionShapeDM(RegionShape &shape, WorldCanvas *wc, AttributeBuffer *wcAttr, AttributeBuffer *ddAttr, CachingDisplayData *dd)
Constructor that takes the RegionShape to draw, as well as the other parameters for the CachingDispla...
casacore::String m_text
Definition: RegionShape.h:134
static const casacore::String PROPTEXT_SIZE
Definition: RegionShape.h:246
static const double DEFAULT_WIDTH
Definition: RegionShape.h:310
RefreshReason
Callback reasons for PCRefreshEvent and WCRefreshEvent.
Definition: DisplayEnums.h:267
static const casacore::String PROPTYPE_VECTOR
Definition: RegionShape.h:262
static const casacore::String PROPCOORDINATES
Definition: RegionShape.h:253
const casacore::String & font() const
Returns the font family for this label.
static bool worldToLinear(const casacore::Quantum< casacore::Vector< double > > &worldX, const casacore::Quantum< casacore::Vector< double > > &worldY, casacore::Vector< double > &linearX, casacore::Vector< double > &linearY, WorldCanvasHolder &wch, casacore::MDirection::Types fromSys, bool wrap=true, casacore::String *error=NULL)
int size() const
Returns the point size for this label.
A holder to interface between DisplayDatas and a WorldCanvas.
static const casacore::String PROPTYPE_COMPOSITE
Definition: RegionShape.h:265
casacore::String m_color
Line color.
Definition: RegionShape.h:575
Implementation of drawing in world coordinates on top of a PixelCanvas.
Definition: WorldCanvas.h:204
const casacore::String & lastDrawingError() const
Returns the error that occurred during the last call to draw().
Definition: RegionShape.h:458
static const casacore::String PROPTEXT_BOLD
Definition: RegionShape.h:248
static const casacore::String PROPISWORLD
Properties.
Definition: RegionShape.h:238
bool isItalic() const
Returns true if this label&#39;s font is italic, false otherwise.
casacore::String m_drawingError
Definition: RegionShape.h:607
virtual double screenXMax() const
String: the storage and methods of handling collections of characters.
Definition: String.h:223
~RegionShapeDM()
Destructor.
casacore::uInt dataDim() const
Definition: RegionShape.h:341
virtual double yMin() const
virtual std::vector< double > coordParameterValues() const =0
Returns the current values for the coordinate parameters.
size_t size() const
Definition: ArrayBase.h:101
virtual std::vector< CoordinateParameterType > coordParameterTypes() const =0
Returns a vector indicating the types of the coordinate parameters, in the same order as coordParamet...
const casacore::Unit dataUnit() const
PassiveCachingDD methods //.
OptionType
Different types for options.
Definition: RegionShape.h:281
Abstract base class for Record classes.
static const casacore::String DEFAULT_COLOR
Defaults.
Definition: RegionShape.h:309
static const casacore::String PROPTYPE_LINE
Definition: RegionShape.h:261
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the color(i.e.,"000000"for black) and
static bool linearToWorld(const casacore::Vector< double > &linearX, const casacore::Vector< double > &linearY, casacore::Quantum< casacore::Vector< double > > &worldX, casacore::Quantum< casacore::Vector< double > > &worldY, WorldCanvasHolder &wch, casacore::MDirection::Types toSys, const std::vector< int > &xSign, const std::vector< int > &ySign, bool wrap=true, casacore::String *error=NULL)
virtual void setShapeSpecificProperties(const casacore::RecordInterface &props)=0
Sets shape-specific properties from the given record.
virtual double screenYMax() const
virtual LineStyle lineStyle() const
Gets/sets this shape&#39;s line style.
static const casacore::String PROPLINE_STYLE
Definition: RegionShape.h:242
LineStyle m_ltStyle
Definition: RegionShape.h:591
int height(PixelCanvas *pc) const
Returns the result of pc-&gt;textHeight() after setting the font.
bool screenToWorld(const casacore::Vector< double > &screenX, const casacore::Vector< double > &screenY, casacore::Quantum< casacore::Vector< double > > &worldX, casacore::Quantum< casacore::Vector< double > > &worldY, WorldCanvasHolder &wch, const std::vector< int > &xSign, const std::vector< int > &ySign, casacore::String *error=NULL) const
Definition: RegionShape.h:708
virtual double screenYMin() const
std::vector< int > displayAxes() const
Definition: RegionShape.h:344
~RegionShapeLabel()
Destructor.
bool pixelToWorld(const casacore::Vector< double > &pixelX, const casacore::Vector< double > &pixelY, casacore::Quantum< casacore::Vector< double > > &worldX, casacore::Quantum< casacore::Vector< double > > &worldY, WorldCanvasHolder &wch, bool wrap=true, casacore::String *error=NULL) const
Definition: RegionShape.h:646
RegionShapeLabel(casacore::String text="")
Constructor.
unsigned int uInt
Definition: aipstype.h:51
static const casacore::String PROPTYPE_RECTANGLE
Definition: RegionShape.h:259
static const casacore::String PROPLINETHROUGH_WIDTH
Definition: RegionShape.h:251