casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DS9FileReader.h
Go to the documentation of this file.
1 //# DS9FileReader.h: Implementation for DS9 region file reader etc.
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 DS9FILEREADER_H_
28 #define DS9FILEREADER_H_
29 
30 #include <QStringList>
31 
35 
36 #include <casa/namespace.h>
37 
38 namespace casa {
39 
40 // Contains common enums, constants, and methods for DS9 files.
41  class DS9 {
42  public:
43  // Units.
44  // <group>
48  };
49 
63 
65  if(unit == FILE_ARCMIN) return ArcMin;
66  else if(unit == FILE_ARCSEC) return ArcSec;
67  else if(unit == FILE_DEGREES) return Degrees;
68  else if(unit == FILE_IMAGE_PIXELS) return ImagePixels;
69  else if(unit == FILE_PHYSICAL_PIXELS) return PhysicalPixels;
70  else if(unit == FILE_RADIANS) return Radians;
71 
72  else return UNSET;
73  }
74 
75  static const QRegExp REGEXP_HDMS;
76  static const QRegExp REGEXP_HMS;
77  static const QRegExp REGEXP_DMS;
78  static const QRegExp REGEXP_NUMSYS;
79  // </group>
80 
81 
82  // casacore::Coordinate systems.
83  // <group>
87  };
88 
90  return Physical;
91  }
92 
93  static const QString FILE_AMPLIFIER;
94  static const QString FILE_B1950;
95  static const QString FILE_DETECTOR;
96  static const QString FILE_ECLIPTIC;
97  static const QString FILE_FK4;
98  static const QString FILE_FK5;
99  static const QString FILE_GALACTIC;
100  static const QString FILE_ICRS;
101  static const QString FILE_IMAGE;
102  static const QString FILE_J2000;
103  static const QString FILE_LINEAR;
104  static const QString FILE_PHYSICAL;
105 
106  static QStringList coordinateSystemFirstWords() {
107  QStringList list;
109  list << FILE_ECLIPTIC << FILE_FK4 << FILE_FK5 << FILE_GALACTIC;
110  list << FILE_ICRS << FILE_IMAGE << FILE_J2000 << FILE_LINEAR;
111  list << FILE_PHYSICAL;
112  return list;
113  }
114 
115  static CoordinateSystem coordinateSystem(const QString& cs) {
116  QString c = cs.toLower();
117  if(c == FILE_AMPLIFIER) return Amplifier;
118  else if(c == FILE_B1950 || c == FILE_FK4) return FK4;
119  else if(c == FILE_DETECTOR) return Detector;
120  else if(c == FILE_ECLIPTIC) return Ecliptic;
121  else if(c == FILE_FK5 || c == FILE_J2000 || c == FILE_ICRS) return FK5;
122  else if(c == FILE_GALACTIC) return Galactic;
123  else if(c == FILE_IMAGE) return Image;
124  else if(c == FILE_LINEAR) return Linear;
125  else if(c == FILE_PHYSICAL) return Physical;
126 
127  else return defaultCoordinateSystem();
128  }
129 
131  switch(c) {
132  case Physical:
133  return FILE_PHYSICAL;
134  case Image:
135  return FILE_IMAGE;
136  case FK4:
137  return FILE_FK4;
138  case FK5:
139  return FILE_FK5;
140  case Galactic:
141  return FILE_GALACTIC;
142  case Ecliptic:
143  return FILE_ECLIPTIC;
144  case Linear:
145  return FILE_LINEAR;
146  case Amplifier:
147  return FILE_AMPLIFIER;
148  case Detector:
149  return FILE_DETECTOR;
150 
151  default:
152  return "";
153  }
154  }
155  // </group>
156 
157 
158  // Regions.
159  // <group>
160  enum RegionType {
165  };
166 
167  // region types, first word
168  static const QString FILE_ANNULUS;
169  static const QString FILE_ARROW; // only for "arrow point"
170  static const QString FILE_BOX;
171  static const QString FILE_BOXCIRCLE; // only for "boxcircle point"
172  static const QString FILE_BPANDA;
173  static const QString FILE_CIRCLE;
174  static const QString FILE_COMPASS;
175  static const QString FILE_COMPOSITE;
176  static const QString FILE_CROSS; // only for "cross point"
177  static const QString FILE_DIAMOND; // only for "diamond point"
178  static const QString FILE_ELLIPSE;
179  static const QString FILE_EPANDA;
180  static const QString FILE_LINE;
181  static const QString FILE_PANDA;
182  static const QString FILE_POINT;
183  static const QString FILE_POLYGON;
184  static const QString FILE_PROJECTION;
185  static const QString FILE_RULER;
186  static const QString FILE_TEXT;
187  static const QString FILE_VECTOR;
188  static const QString FILE_X; // only for "x point"
189 
190  static QStringList regionFirstWords() {
191  QStringList list;
195  list << FILE_LINE << FILE_PANDA << FILE_POINT << FILE_POLYGON;
197  list << FILE_X;
198  return list;
199  }
200 
201  static QString regionType(RegionType type) {
202  switch(type) {
203  case Circle:
204  return FILE_CIRCLE;
205  case Annulus:
206  return FILE_ANNULUS;
207  case Ellipse:
208  case EllipseAnnulus:
209  return FILE_ELLIPSE;
210  case Box:
211  case BoxAnnulus:
212  return FILE_BOX;
213  case Polygon:
214  return FILE_POLYGON;
215  case Line:
216  return FILE_LINE;
217  case Vector:
218  return FILE_VECTOR;
219  case Text:
220  return FILE_TEXT;
221  case Ruler:
222  return FILE_RULER;
223  case CirclePoint:
224  return FILE_CIRCLE + " " + FILE_POINT;
225  case BoxPoint:
226  return FILE_BOX + " " + FILE_POINT;
227  case DiamondPoint:
228  return FILE_DIAMOND + " " + FILE_POINT;
229  case CrossPoint:
230  return FILE_CROSS + " " + FILE_POINT;
231  case XPoint:
232  return FILE_X + " " + FILE_POINT;
233  case ArrowPoint:
234  return FILE_ARROW + " " + FILE_POINT;
235  case BoxCirclePoint:
236  return FILE_BOXCIRCLE+ " " +FILE_POINT;
237  case Compass:
238  return FILE_COMPASS;
239  case Projection:
240  return FILE_PROJECTION;
241  case Panda:
242  return FILE_PANDA;
243  case EllipticalPanda:
244  return FILE_EPANDA;
245  case BoxPanda:
246  return FILE_BPANDA;
247  case Composite:
248  return FILE_COMPOSITE;
249 
250  default:
251  return "";
252  }
253  }
254 
255  static QString pointType(RegionType type) {
256  switch(type) {
257  case CirclePoint:
258  return FILE_CIRCLE;
259  case BoxPoint:
260  return FILE_BOX;
261  case DiamondPoint:
262  return FILE_DIAMOND;
263  case CrossPoint:
264  return FILE_CROSS;
265  case XPoint:
266  return FILE_X;
267  case ArrowPoint:
268  return FILE_ARROW;
269  case BoxCirclePoint:
270  return FILE_BOXCIRCLE;
271 
272  default:
273  return "";
274  }
275  }
276  // </group>
277 
278  // DS9 defaults.
279  // <group>
280  static const int MARKER_SIZE;
281  static const int ARROW_SIZE;
282  // </group>
283 
284  // Miscellaneous.
285  // <group>
286  static const QString FILE_COMMENT;
287  static const QString FILE_COMPOSITE_OR;
288  static const QString FILE_EQUAL;
289  static const QString FILE_GLOBAL;
290  static const QString FILE_LINESEP;
291  static const QString FILE_MINUS;
292  static const QString FILE_PLUS;
293  static const QString FILE_TEXT_END1;
294  static const QString FILE_TEXT_END2;
295  static const QString FILE_TEXT_END3;
296  static const QString FILE_TEXT_START1;
297  static const QString FILE_TEXT_START2;
298  static const QString FILE_TEXT_START3;
299  // </group>
300  };
301 
302 
303 // Class to represent a single coordinate (value + unit).
305  public:
306  // Constructor which takes a system and a unit.
308 
309  // Destructor.
310  ~DS9Coordinate();
311 
312 
313  // Sets the coordinate system to the given.
315 
316  // Sets the coordinate unit to the given.
318 
319  // Sets the single value to the given.
320  void set(double value);
321 
322  // Sets the HMS/DMS value to the given. minusZero is used when the first
323  // value is zero, but the whole value is negative.
324  void set(double val1, double val2, double val3, bool minusZero = false);
325 
326  // Returns the coordinate system.
328 
329  // Returns the unit.
330  DS9::CoordinateUnit unit() const;
331 
332  // Returns the first value. No conversion is used.
333  double value() const;
334 
335  // Returns the value(s). Size will be 1 for normal coordinates, 3 for
336  // HMS/DMS. No conversion is used.
337  std::vector<double> values() const;
338 
339  // Returns 1 for normal coordinates or 3 for HMS/DMS.
340  unsigned int size() const;
341 
342  // Returns true if this coordinate is valid, false otherwise. If the
343  // coordinate is invalid (such as an unset unit), the method will attempt
344  // to fix it.
345  bool isValid() const;
346 
347  // Returns a casacore::String version for use with DS9Region::toPrintString.
349 
350  // Returns the value in degrees.
351  double toDegrees() const;
352 
353  private:
354  DS9::CoordinateSystem m_system; // coordinate system
355  DS9::CoordinateUnit m_unit; // coordinate unit
356  vector<double> m_values; // values
357  bool m_minusZero; // minusZero flag for HMS/DMS
358  };
359 
360 
361 // Holds information for read DS9 regions. A DS9Region consists of a type,
362 // a list of coordinates, a coordinate system, and a set of properties.
363 // Composite regions also have a list of children regions. For simplicity,
364 // properties are either bool properties or casacore::String properties. All properties
365 // have defaults which are set during construction.
366  class DS9Region { /*: public RFRegion*/
367  //friend class DS9RegionFileReader;
368 
369  public:
370  // Public Static Members/Methods //
371 
372  // Properties.
373  // <group>
400  // </group>
401 
402  // Note: when adding new properties:
403  // 1) add to properties(), DS9RegionFileWriter::globalProperties() (if
404  // necessary)
405  // 2) add to isBoolProperty()
406  // 3) for strings, add to valueIsValid
407  // 4) add to defaultBoolValue() or defaultStringValue()
408  // 5) if special printing is required, edit toPrintString,
409  // DS9RegionFileWriter::writeGlobals()
410  // 6) if special input is required, edit
411  // DS9RegionFileReader::readProperties()
412 
413  // Returns all valid properties.
414  static std::vector<casacore::String> properties() {
415  static std::vector<casacore::String> v(26);
416  v[0] = PROP_INCLUDE;
417  v[1] = PROP_TEXT;
418  v[2] = PROP_COLOR;
419  v[3] = PROP_FONT;
420  v[4] = PROP_SELECT;
421  v[5] = PROP_EDIT;
422  v[6] = PROP_MOVE;
423  v[7] = PROP_ROTATE;
424  v[8] = PROP_DELETE;
425  v[9] = PROP_FIXED;
426  v[10] = PROP_LINE;
427  v[11] = PROP_RULER;
428  v[12] = PROP_SOURCE;
429  v[13] = PROP_BACKGROUND;
430  v[14] = PROP_TEXTANGLE;
431  v[15] = PROP_WIDTH;
432  v[16] = PROP_MARKER_SIZE;
433  v[17] = PROP_HIGHLITE;
434  v[18] = PROP_TAG;
435  v[19] = PROP_VECTOR;
436  v[20] = PROP_COMPASS;
437  v[21] = PROP_COMPASS_NLABEL;
438  v[22] = PROP_COMPASS_ELABEL;
439  v[23] = PROP_COMPOSITE;
440  v[24] = PROP_DASH;
441  v[25] = PROP_DASHLIST;
442  return v;
443  }
444 
445  // Returns true if the given casacore::String is a valid property, false otherwise.
446  static bool isProperty(const casacore::String& prp) {
447  static std::vector<casacore::String> v = properties();
448  for(unsigned int i = 0; i < v.size(); i++) if(v[i] == prp) return true;
449  return false;
450  }
451 
452  // Returns true if the given casacore::String is a valid bool property, false
453  // otherwise.
454  static bool isBoolProperty(const casacore::String& property) {
455  if(!isProperty(property)) return false;
456  else return property != PROP_TEXT && property != PROP_COLOR &&
457  property != PROP_FONT && property != PROP_LINE &&
458  property != PROP_RULER && property != PROP_TEXTANGLE &&
459  property != PROP_WIDTH && property != PROP_MARKER_SIZE &&
460  property != PROP_TAG && property != PROP_COMPASS &&
461  property != PROP_COMPASS_NLABEL &&
462  property != PROP_COMPASS_ELABEL &&
463  property != PROP_DASHLIST;
464  }
465 
466  // Returns true if the given value is valid for the given casacore::String property
467  // and region type, false otherwise.
468  static bool valueIsValid(const casacore::String& property, const casacore::String& value,
470  if(property == PROP_COLOR) {
471  if(value == "white" || value == "black" || value == "red" ||
472  value == "green" || value == "blue" || value == "cyan" ||
473  value == "magenta" || value == "yellow" || value == "gray" ||
474  value == "grey") return true;
475  QString v(value.c_str());
476  return (v.size() == 7 &&
477  v.indexOf(QRegExp("#(?:\\d|[A-F]|[a-f]){6}")) == 0) ||
478  (v.size() == 6 &&
479  v.indexOf(QRegExp("(?:\\d|[A-F]|[a-f]){6}")) == 0);
480  } else if(property == PROP_FONT) {
481  QStringList split = QString(value.c_str()).split(QRegExp("\\s+"));
482  if(split.size() < 3) return false;
483  bool valid;
484  split[1].toInt(&valid);
485  if(!valid) return false;
486  return split[2] == "bold" || split[2] == "normal" ||
487  split[2] == "italic" || split[2] == "italics";
488  } else if(property == PROP_LINE) {
489  QStringList split = QString(value.c_str()).split(QRegExp("\\s+"));
490  if(split.size() < 2) return false;
491  return (split[0] == "0" || split[0] == "1") &&
492  (split[1] == "0" || split[1] == "1");
493  } else if(property == PROP_DASHLIST) {
494  QStringList split = QString(value.c_str()).split(QRegExp("\\s+"));
495  if(split.size() < 2) return false;
496  bool valid;
497  split[0].toUInt(&valid);
498  if(!valid) return false;
499  split[1].toUInt(&valid);
500  return valid;
501  } else if(property == PROP_RULER) {
502  QStringList split = QString(value.c_str()).split(QRegExp("\\s+"));
503  if(split.size() < 2) return false;
504  split[0] = split[0].toLower();
505  split[1] = split[1].toLower();
506  return DS9::coordinateSystemFirstWords().contains(split[0]) &&
507  (split[1] == "image" || split[1] == "physical" ||
508  split[1] == "degrees" || split[1] == "arcmin" ||
509  split[1] == "arcsec");
510  } else if(property == PROP_TEXTANGLE) {
511  bool valid;
512  QString(value.c_str()).toDouble(&valid);
513  return type == DS9::Text && valid;
514  } else if(property == PROP_WIDTH) {
515  bool valid;
516  QString(value.c_str()).toDouble(&valid);
517  return valid;
518  } else if(property == PROP_MARKER_SIZE) {
519  bool valid;
520  QString(value.c_str()).toInt(&valid);
521  return valid;
522  } else if(property == PROP_COMPASS) {
523  return DS9::coordinateSystemFirstWords().contains(value.c_str(),
524  Qt::CaseInsensitive);
525  } else return !isBoolProperty(property);
526  }
527 
528  // Returns the default value for the given bool property.
529  static bool defaultBoolValue(const casacore::String& property) {
530  if(property == PROP_INCLUDE) return true;
531  else if(property == PROP_SELECT) return true;
532  else if(property == PROP_EDIT) return true;
533  else if(property == PROP_MOVE) return true;
534  else if(property == PROP_ROTATE) return true;
535  else if(property == PROP_DELETE) return true;
536  else if(property == PROP_FIXED) return false;
537  else if(property == PROP_SOURCE) return true;
538  else if(property == PROP_BACKGROUND) return false;
539  else if(property == PROP_HIGHLITE) return true;
540  else if(property == PROP_VECTOR) return true;
541  else if(property == PROP_COMPOSITE) return false;
542  else if(property == PROP_DASH) return false;
543  else return false;
544  }
545 
546  // Returns the default value for the given casacore::String property.
548  if(property == PROP_TEXT) return "";
549  else if(property == PROP_COLOR) return "green";
550  else if(property == PROP_FONT) return "helvetica 10 normal";
551  else if(property == PROP_LINE) return "0 0";
552  else if(property == PROP_RULER) return "pixels";
553  else if(property == PROP_TEXTANGLE) return "0";
554  else if(property == PROP_WIDTH) return "1";
555  else if(property == PROP_MARKER_SIZE)
557  else if(property == PROP_TAG) return "";
558  else if(property == PROP_COMPASS) return "image";
559  else if(property == PROP_COMPASS_NLABEL) return "N";
560  else if(property == PROP_COMPASS_ELABEL) return "E";
561  else if(property == PROP_DASHLIST) return "8 3";
562  else return "";
563  }
564 
565 
566  // Non-Static //
567 
568  // Constructor, which types a type and a coordinate system.
570 
571  // Destructor.
572  ~DS9Region();
573 
574 
575  // Returns a human-readable representation of this region.
577 
578  // Returns a name.
579  casacore::String name() const;
580 
581  // Converts this region to a RegionShape. Not all DS9 region types are
582  // supported and thus this may return NULL. For unsupported regions, see
583  // cookbook documentation.
584  RegionShape* toRegionShape() const;
585 
586 
587  // Returns the region type.
588  DS9::RegionType type() const;
589 
590  // Sets/adds the given properties to this region's. Returns false if an
591  // error occured.
593 
594  // Defines the given bool property with the given value. Returns false if
595  // the given property is invalid.
596  bool define(const casacore::String& property, bool value);
597 
598  // Defines the given casacore::String property with the given value. Returns false
599  // if the given property or value is invalid.
600  bool define(const casacore::String& property, const casacore::String& value);
601 
602  // Returns true if the given property is defined, false otherwise.
603  bool isDefined(const casacore::String& property);
604 
605  // Returns the value for the given bool property.
606  bool boolValue(const casacore::String& property);
607 
608  // Returns the casacore::String value for the given casacore::String property.
610 
611  // Adds the given coordinate to the region.
612  void pushCoordinate(const DS9Coordinate& coord);
613 
614  // Adds the given region to this composite region (does nothing for non-
615  // composite regions).
616  void pushCompositeRegion(const DS9Region& region);
617 
618  // Returns true if this region's coordinates are valid, false otherwise.
619  // If the coordinates are invalid, this method will attempt to fix them
620  // first.
621  bool checkCoordinates();
622 
623  // Returns true if this region's properties are valid, false otherwise.
624  // If the properties are invalid, this method will attempt to fix them
625  // first.
626  bool checkProperties();
627 
628  // Returns the last error found during toRegionShape(). This error is only
629  // valid if toRegionShape() returns NULL which indicates an error was
630  // encountered.
631  const RFError& lastError() const;
632 
633  private:
634  DS9::RegionType m_type; // Region type.
635  DS9::CoordinateSystem m_system; // Region coordinate system.
636  vector<DS9Coordinate> m_coords; // Region coordinates.
637  casacore::Record m_props; // Region properties.
638  vector<DS9Region> m_compositeRegions; // Composite children.
639 
640  // Last encountered error during toRegionShape.
642 
643  // Convenience method for setting the last error during toRegionShape.
644  void setError(const casacore::String& error, bool isFatal = false) const;
645  };
646 
647 
648 // Implementation of RSFileReader for DS9 regions.
649  class DS9FileReader : public RSFileReader {
650  public:
651  // Constructor.
652  DS9FileReader();
653 
654  // Destructor.
655  ~DS9FileReader();
656 
657 
658  // RSFileReader methods //
659 
660  // Implements RSFileReader::read.
661  bool read(std::vector<RegionShape*>& shapes);
662 
663  private:
664  // Whether a coordinate system has been set in the file, and what it is.
665  pair<DS9::CoordinateSystem, bool> m_nextSystem;
666 
667  // Read regions.
668  std::vector<DS9Region> m_regions;
669 
670  // Current read global properties.
672 
673 
674  // Processes the given line and returns whether an error occurred or not.
675  // If an error occurred, the details are appended to invalid.
676  bool processLine(const QString& line, stringstream& invalid);
677 
678  // Processes the given region and returns whether an error occurred or not.
679  // If an error occurred, the details are appended to invalid. line should
680  // contain the comma-, parentheses-, or whitespace-separated text before
681  // the comment symbol, while "comment" should contain all text after the
682  // comment symbol. The include flag is used to set the include property.
683  bool processRegion(QStringList& line, QString& comment,
684  stringstream& invalid, bool include = true);
685 
686  // Processes the given coordinate system and returns whether an error
687  // occurred or not. If an error occurred, the details are appended to
688  // invalid.
689  bool processCoordSys(QString& line, stringstream& invalid);
690 
691  // Processes the given global line and returns whether an error occurred or
692  // not. If an error occurred, the details are appended to invalid.
693  bool processGlobal(QString& line, stringstream& invalid);
694 
695  // Processes the given comment into properties for the given region, and
696  // returns whether an error occurred or not. If an error occurred, the
697  // details are appended to invalid.
698  bool processComment(DS9Region& region, QString& comment,
699  stringstream& invalid);
700 
701  // For "point" regions. Parses the given comment for a point=type property
702  // and places the correct type into "type". Returns whether the operation
703  // succeeded or not.
704  bool readPointType(QString& comment, DS9::RegionType& type);
705 
706  // Reads properties in the given line into the given record.
707  bool readProperties(casacore::Record& record, QString& line);
708  };
709 
710 }
711 
712 #endif /*DS9FILEREADER_H_*/
static const QRegExp REGEXP_NUMSYS
Definition: DS9FileReader.h:78
static const QString FILE_TEXT_END3
static const casacore::String PROP_FONT
static CoordinateUnit coordinateUnit(const casacore::String &unit)
Definition: DS9FileReader.h:64
static bool isProperty(const casacore::String &prp)
Returns true if the given casacore::String is a valid property, false otherwise.
std::vector< double > values() const
Returns the value(s).
A 1-D Specialization of the Array class.
static const casacore::String PROP_SELECT
casacore::String name() const
Returns a name.
void pushCoordinate(const DS9Coordinate &coord)
Adds the given coordinate to the region.
static const QString FILE_EPANDA
CoordinateUnit
Units.
Definition: DS9FileReader.h:45
static const casacore::String PROP_MARKER_SIZE
bool define(const casacore::String &property, bool value)
Defines the given bool property with the given value.
DS9::RegionType m_type
bool readProperties(casacore::Record &record, QString &line)
Reads properties in the given line into the given record.
static const QRegExp REGEXP_HDMS
Definition: DS9FileReader.h:75
double value() const
Returns the first value.
bool processLine(const QString &line, stringstream &invalid)
Processes the given line and returns whether an error occurred or not.
Geometric parameters needed for a sky projection to a plane.
Definition: Projection.h:95
Contains common enums, constants, and methods for DS9 files.
Definition: DS9FileReader.h:41
static const casacore::String FILE_HMS_M
Definition: DS9FileReader.h:58
static const QString FILE_ICRS
static const QString FILE_POLYGON
bool processRegion(QStringList &line, QString &comment, stringstream &invalid, bool include=true)
Processes the given region and returns whether an error occurred or not.
static const casacore::String FILE_DEGREES
Definition: DS9FileReader.h:52
bool processCoordSys(QString &line, stringstream &invalid)
Processes the given coordinate system and returns whether an error occurred or not.
DS9::CoordinateSystem m_system
casacore::String toPrintString() const
Returns a human-readable representation of this region.
static QStringList regionFirstWords()
static const casacore::String FILE_ARCMIN
Definition: DS9FileReader.h:50
bool checkCoordinates()
Returns true if this region&#39;s coordinates are valid, false otherwise.
vector< DS9Region > m_compositeRegions
static const QString FILE_COMPOSITE_OR
static const QString FILE_RULER
static const QString FILE_ECLIPTIC
Definition: DS9FileReader.h:96
virtual Type type()
Return the type enum.
static const QString FILE_TEXT_START2
static bool defaultBoolValue(const casacore::String &property)
Returns the default value for the given bool property.
DS9Region(DS9::RegionType type, DS9::CoordinateSystem coordSys)
Non-Static //.
static const QString FILE_FK4
Definition: DS9FileReader.h:97
static const casacore::String PROP_COMPASS_ELABEL
static const casacore::String FILE_ARCSEC
Definition: DS9FileReader.h:51
static const QRegExp REGEXP_HMS
Definition: DS9FileReader.h:76
static const casacore::String FILE_RADIANS
Definition: DS9FileReader.h:62
void pushCompositeRegion(const DS9Region &region)
Adds the given region to this composite region (does nothing for non- composite regions).
static const QString FILE_MINUS
static const QString FILE_DIAMOND
static const QString FILE_CIRCLE
~DS9Region()
Destructor.
static const QString FILE_GLOBAL
static const casacore::String FILE_DMS_M
Definition: DS9FileReader.h:55
static const QString FILE_J2000
Abstract superclass for any class that reads a format that produces RegionShapes from a file...
static const casacore::String PROP_DASH
static const casacore::String PROP_VECTOR
static const QRegExp REGEXP_DMS
Definition: DS9FileReader.h:77
std::vector< casacore::String > split(const casacore::String &string, const casacore::String &splitter, bool ignoreConsecutiveSplitters=false)
static const QString FILE_PANDA
static CoordinateSystem defaultCoordinateSystem()
Definition: DS9FileReader.h:89
vector< DS9Coordinate > m_coords
static const casacore::String PROP_SOURCE
void set(DS9::CoordinateSystem system)
Sets the coordinate system to the given.
DS9::CoordinateUnit m_unit
static const QString FILE_COMMENT
Miscellaneous.
static QString coordinateSystem(CoordinateSystem c)
static const QString FILE_AMPLIFIER
Definition: DS9FileReader.h:93
static const QString FILE_TEXT_END2
DS9Coordinate(DS9::CoordinateSystem s, DS9::CoordinateUnit u=DS9::UNSET)
Constructor which takes a system and a unit.
static QString regionType(RegionType type)
static const QString FILE_TEXT_START3
static const casacore::String PROP_TEXT
static const QString FILE_BOX
static const QString FILE_BPANDA
static const QString FILE_ELLIPSE
casacore::String toPrintString() const
Returns a casacore::String version for use with DS9Region::toPrintString.
static const int MARKER_SIZE
DS9 defaults.
void setError(const casacore::String &error, bool isFatal=false) const
Convenience method for setting the last error during toRegionShape.
bool setProperties(const casacore::RecordInterface &properties)
Sets/adds the given properties to this region&#39;s.
static const QString FILE_LINE
static const casacore::String FILE_DMS_S
Definition: DS9FileReader.h:56
static const QString FILE_PROJECTION
~DS9FileReader()
Destructor.
static const casacore::String PROP_TEXTANGLE
static const QString FILE_BOXCIRCLE
DS9::CoordinateSystem m_system
vector< double > m_values
bool checkProperties()
Returns true if this region&#39;s properties are valid, false otherwise.
static const QString FILE_DETECTOR
Definition: DS9FileReader.h:95
static const casacore::String PROP_TAG
bool processGlobal(QString &line, stringstream &invalid)
Processes the given global line and returns whether an error occurred or not.
Class to represent a single coordinate (value + unit).
static const QString FILE_PHYSICAL
static const QString FILE_LINEAR
static const casacore::String PROP_INCLUDE
static const casacore::String FILE_HMS_S
Definition: DS9FileReader.h:59
static const QString FILE_COMPOSITE
static const casacore::String PROP_COMPASS
static bool valueIsValid(const casacore::String &property, const casacore::String &value, DS9::RegionType type)
Returns true if the given value is valid for the given casacore::String property and region type...
static const QString FILE_VECTOR
const Char * c_str() const
Get char array.
Definition: String.h:555
static const casacore::String PROP_COLOR
static const QString FILE_POINT
LatticeExprNode toDouble(const LatticeExprNode &expr)
bool readPointType(QString &comment, DS9::RegionType &type)
For &quot;point&quot; regions.
static std::vector< casacore::String > properties()
Note: when adding new properties: 1) add to properties(), DS9RegionFileWriter::globalProperties() (if...
static const QString FILE_FK5
Definition: DS9FileReader.h:98
static const casacore::String PROP_DELETE
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool processComment(DS9Region &region, QString &comment, stringstream &invalid)
Processes the given comment into properties for the given region, and returns whether an error occurr...
Parent class for all RegionShapes.
Definition: RegionShape.h:223
~DS9Coordinate()
Destructor.
DS9::CoordinateUnit unit() const
Returns the unit.
const RFError & lastError() const
Returns the last error found during toRegionShape().
static const casacore::String PROP_LINE
pair< DS9::CoordinateSystem, bool > m_nextSystem
Whether a coordinate system has been set in the file, and what it is.
static const casacore::String FILE_IMAGE_PIXELS
Definition: DS9FileReader.h:60
casacore::Record m_props
bool isValid() const
Returns true if this coordinate is valid, false otherwise.
RegionShape * toRegionShape() const
Converts this region to a RegionShape.
bool isDefined(const casacore::String &property)
Returns true if the given property is defined, false otherwise.
static const casacore::String PROP_MOVE
static const QString FILE_ARROW
static const QString FILE_B1950
Definition: DS9FileReader.h:94
static const casacore::String FILE_PHYSICAL_PIXELS
Definition: DS9FileReader.h:61
casacore::String stringValue(const casacore::String &property)
Returns the casacore::String value for the given casacore::String property.
static const casacore::String PROP_EDIT
static const casacore::String PROP_COMPOSITE
DS9::CoordinateSystem system() const
Returns the coordinate system.
static bool isBoolProperty(const casacore::String &property)
Returns true if the given casacore::String is a valid bool property, false otherwise.
static const QString FILE_X
static const casacore::String PROP_WIDTH
Implementation of RSFileReader for DS9 regions.
DS9::RegionType type() const
Returns the region type.
static const casacore::String PROP_DASHLIST
static const int ARROW_SIZE
static const casacore::String FILE_HMS_H
Definition: DS9FileReader.h:57
const Double c
Fundamental physical constants (SI units):
static const QString FILE_COMPASS
static casacore::String defaultStringValue(const casacore::String &property)
Returns the default value for the given casacore::String property.
RFError m_lastError
Last encountered error during toRegionShape.
double toDegrees() const
Returns the value in degrees.
static const QString FILE_TEXT
String: the storage and methods of handling collections of characters.
Definition: String.h:223
static const casacore::String PROP_HIGHLITE
static const QString FILE_CROSS
static const QString FILE_TEXT_START1
static const QString FILE_TEXT_END1
static const casacore::String PROP_COMPASS_NLABEL
Abstract base class for Record classes.
bool boolValue(const casacore::String &property)
Returns the value for the given bool property.
static const casacore::String PROP_ROTATE
static const casacore::String FILE_DELIMITER
Definition: DS9FileReader.h:53
bool read(std::vector< RegionShape * > &shapes)
RSFileReader methods //.
unsigned int size() const
Returns 1 for normal coordinates or 3 for HMS/DMS.
static const QString FILE_IMAGE
CoordinateSystem
casacore::Coordinate systems.
Definition: DS9FileReader.h:84
DS9FileReader()
Constructor.
Holds information for read DS9 regions.
static const QString FILE_EQUAL
static const casacore::String FILE_DMS_D
Definition: DS9FileReader.h:54
static const QString FILE_GALACTIC
Definition: DS9FileReader.h:99
std::vector< DS9Region > m_regions
Read regions.
static const QString FILE_ANNULUS
region types, first word
static QStringList coordinateSystemFirstWords()
RegionType
Regions.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
static const QString FILE_PLUS
static const casacore::String PROP_RULER
static QString pointType(RegionType type)
static CoordinateSystem coordinateSystem(const QString &cs)
static const casacore::String PROP_FIXED
static String toString(const T &value)
Convert a value to a String.
Definition: String.h:614
static const QString FILE_LINESEP
casacore::Record m_globals
Current read global properties.
static const casacore::String PROP_BACKGROUND
friend class DS9RegionFileReader;