27 #ifndef DS9FILEREADER_H_
28 #define DS9FILEREADER_H_
30 #include <QStringList>
116 QString
c = cs.toLower();
324 void set(
double val1,
double val2,
double val3,
bool minusZero =
false);
333 double value()
const;
337 std::vector<double>
values()
const;
340 unsigned int size()
const;
415 static std::vector<casacore::String> v(26);
447 static std::vector<casacore::String> v =
properties();
448 for(
unsigned int i = 0; i < v.size(); i++)
if(v[i] == prp)
return true;
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) ||
479 v.indexOf(QRegExp(
"(?:\\d|[A-F]|[a-f]){6}")) == 0);
482 if(split.size() < 3)
return false;
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";
490 if(split.size() < 2)
return false;
491 return (split[0] ==
"0" || split[0] ==
"1") &&
492 (split[1] ==
"0" || split[1] ==
"1");
495 if(split.size() < 2)
return false;
497 split[0].toUInt(&valid);
498 if(!valid)
return false;
499 split[1].toUInt(&valid);
503 if(split.size() < 2)
return false;
504 split[0] = split[0].toLower();
505 split[1] = split[1].toLower();
507 (split[1] ==
"image" || split[1] ==
"physical" ||
508 split[1] ==
"degrees" || split[1] ==
"arcmin" ||
509 split[1] ==
"arcsec");
520 QString(value.
c_str()).toInt(&valid);
524 Qt::CaseInsensitive);
532 else if(property ==
PROP_EDIT)
return true;
533 else if(property ==
PROP_MOVE)
return true;
542 else if(property ==
PROP_DASH)
return false;
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";
557 else if(property ==
PROP_TAG)
return "";
661 bool read(std::vector<RegionShape*>& shapes);
676 bool processLine(
const QString& line, stringstream& invalid);
684 stringstream& invalid,
bool include =
true);
699 stringstream& invalid);
static const QRegExp REGEXP_NUMSYS
static const QString FILE_TEXT_END3
static const casacore::String PROP_FONT
static CoordinateUnit coordinateUnit(const casacore::String &unit)
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
static const casacore::String PROP_MARKER_SIZE
bool define(const casacore::String &property, bool value)
Defines the given bool property with the given value.
bool readProperties(casacore::Record &record, QString &line)
Reads properties in the given line into the given record.
static const QRegExp REGEXP_HDMS
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.
Contains common enums, constants, and methods for DS9 files.
static const casacore::String FILE_HMS_M
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
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
bool checkCoordinates()
Returns true if this region'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
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
static const casacore::String PROP_COMPASS_ELABEL
static const casacore::String FILE_ARCSEC
static const QRegExp REGEXP_HMS
static const casacore::String FILE_RADIANS
void pushCompositeRegion(const DS9Region ®ion)
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
static const QString FILE_GLOBAL
static const casacore::String FILE_DMS_M
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
std::vector< casacore::String > split(const casacore::String &string, const casacore::String &splitter, bool ignoreConsecutiveSplitters=false)
static const QString FILE_PANDA
static CoordinateSystem defaultCoordinateSystem()
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
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's.
static const QString FILE_LINE
static const casacore::String FILE_DMS_S
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's properties are valid, false otherwise.
static const QString FILE_DETECTOR
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
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.
static const casacore::String PROP_COLOR
static const QString FILE_POINT
LatticeExprNode toDouble(const LatticeExprNode &expr)
bool readPointType(QString &comment, DS9::RegionType &type)
For "point" regions.
static std::vector< casacore::String > properties()
Note: when adding new properties: 1) add to properties(), DS9RegionFileWriter::globalProperties() (if...
static const QString FILE_FK5
static const casacore::String PROP_DELETE
A hierarchical collection of named fields of various types.
bool processComment(DS9Region ®ion, 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.
~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
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
static const casacore::String FILE_PHYSICAL_PIXELS
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
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.
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
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.
DS9FileReader()
Constructor.
Holds information for read DS9 regions.
static const QString FILE_EQUAL
static const casacore::String FILE_DMS_D
static const QString FILE_GALACTIC
std::vector< DS9Region > m_regions
Read regions.
static const QString FILE_ANNULUS
region types, first word
static QStringList coordinateSystemFirstWords()
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.
static const QString FILE_LINESEP
casacore::Record m_globals
Current read global properties.
static const casacore::String PROP_BACKGROUND
friend class DS9RegionFileReader;