27 #ifndef REGIONSHAPES_H_
28 #define REGIONSHAPES_H_
49 RSEllipse(
double x,
double y,
double xRadius,
double yRadius,
53 RSEllipse(
double x,
double y,
double xRadius,
double yRadius,
76 double& yRadius,
double& angle,
107 return std::vector<casacore::String>();
110 return std::vector<OptionType>();
113 return std::vector<RSOption>();
149 RSCircle(
double x,
double y,
double xRadius);
212 double radiusX,
double radiusY,
223 RSRectangle(
double x,
double y,
double width,
double height,
227 RSRectangle(
double x,
double y,
double width,
double height,
249 double& height,
double& angle,
280 return std::vector<casacore::String>();
283 return std::vector<OptionType>();
286 return std::vector<RSOption>();
368 else return "polygon";
463 static std::vector<ArrowType> v(4);
473 std::vector<casacore::String> v(types.size());
474 for(
unsigned int i = 0; i < v.size(); i++) v[i] =
arrowType(types[i]);
484 return "filled triangle";
490 return "filled double v";
499 for(
unsigned int i = 0; i < t.
size(); i++) t[i] = tolower(t[i]);
501 else if(t ==
"triangle")
return Triangle;
502 else if(t ==
"v")
return V;
516 RSLine(
double x1,
double y1,
double x2,
double y2,
523 RSLine(
double x1,
double y1,
double x2,
double y2,
int arrowLength,
524 bool arrow1 =
false,
bool arrow2 =
false,
584 virtual std::vector<casacore::String>
optionNames()
const;
587 virtual std::vector<OptionType>
optionTypes()
const;
590 virtual std::vector<std::vector<casacore::String> >
optionChoices()
const;
621 static bool arrowPoints(
double x1,
double y1,
double x2,
double y2,
622 double length,
double& resX1,
double& resY1,
623 double& resX2,
double& resY2);
627 double length,
double& resX1,
double& resY1,
628 double& resX2,
double& resY2);
642 bool arrow =
true, ArrowType arrowType = FilledDoubleV);
646 RSVector(
double x,
double y,
double length,
double angle,
int arrowLength,
647 bool arrow =
true, ArrowType arrowType = FilledDoubleV);
669 void getVectorCoordinates(
double& x,
double& y,
double& angle,
670 double& length,
int& arrowLength,
698 std::vector<std::vector<casacore::String> >
optionChoices()
const;
712 properties.
define(PROPTYPE, PROPTYPE_VECTOR);
733 RSMarker(
double x,
double y,
const std::vector<Display::Marker>& markers,
742 RSMarker(
double x,
double y,
const std::vector<Display::Marker>& markers,
753 std::vector<Display::Marker> markers()
const;
755 void setMarkers(
const std::vector<Display::Marker>& markers);
774 void getMarkerCoordinates(
double& x,
double& y,
int& pixelHeight,
808 std::vector<std::vector<casacore::String> >
optionChoices()
const;
824 properties.
define(PROPTYPE, PROPTYPE_MARKER);
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";
866 return "circle and x";
868 return "circle and dot";
877 for(
unsigned int i = 0; i < m.
size(); i++) m[i] = tolower(str[i]);
890 else if(m ==
"filled inverted triangle")
900 static std::vector<Display::Marker> v(15);
952 void getTextCoordinates(
double& x,
double& y,
double& angle,
983 return std::vector<casacore::String>();
986 return std::vector<OptionType>();
989 return std::vector<RSOption>();
1003 properties.
define(PROPTYPE, PROPTYPE_TEXT);
1072 void addShape(RegionShape*
shape);
1073 void addShapes(
const std::vector<RegionShape*> shapes);
1077 bool childrenAreDependent()
const;
1083 void setChildrenAreDependent(
bool dependent =
true);
1087 std::vector<RegionShape*> children();
1088 std::vector<const RegionShape*> children()
const;
1094 void setLineColor(
const casacore::String& newColor,
bool alsoSetLabel =
true);
1095 void setLineWidth(
double width);
1097 void setLabel(
const RegionShapeLabel& label);
1120 void getCompositeCoordinates(
double& centerX,
double& centerY,
1148 std::vector<casacore::String>
optionNames()
const;
1185 bool addShapeHelper(RegionShape*
shape);
1188 void addShapeUpkeep();
1192 void convertMinMax(
double& xmin,
double& xmax,
double& ymin,
double& ymax,
1193 unsigned int index)
const;
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()
FilledPentagon, FilledHexagon,.
virtual std::vector< RSOption > optionValues() const =0
Returns the current values for options.
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.
virtual std::vector< RSOption > optionValues() const
Returns the current values for options.
virtual void setShapeSpecificProperties(const casacore::RecordInterface &)
Implements RegionShape::setShapeSpecificProperties.
A "handle" is a four-point structure (usually a rectangle) that describes the boundaries in screen pi...
void getShapeSpecificProperties(casacore::Record &properties) const
Implements RegionShape::getShapeSpecificProperties.
static const casacore::String PROPCHILDREN
virtual std::vector< casacore::String > optionNames() const =0
Returns the names for options.
virtual void move(double dx, double dy, casacore::String system="")
Implements RegionShape::move.
virtual void setShapeSpecificProperties(const casacore::RecordInterface &)
Implements RegionShape::setShapeSpecificProperties.
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.
virtual Type type()
Return the type enum.
casacore::String oneWordType() const
Overrides RegionShape::oneWordType.
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.
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.
static const casacore::String PROPTYPE_CIRCLE
size_type size() const
Capacity, size.
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.
virtual ~RSEllipse()
Destructor.
casacore::String type() const
Implements RegionShape::type.
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.
virtual std::vector< OptionType > optionTypes() const
Returns the types for options.
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
std::vector< OptionType > optionTypes() const
virtual std::vector< OptionType > optionTypes() const =0
Returns the types for options.
vector< Display::Marker > m_markers
Subclass of RegionShape used for drawing composite regions.
void getShapeSpecificProperties(casacore::Record &properties) const
Overrides RSEllipse::getShapeSpecificProperties.
std::vector< RSOption > optionValues() const
Returns the current values for options.
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's native system)...
std::vector< CoordinateParameterType > coordParameterTypes() const
Implements RegionShape::coordParameterPositions.
casacore::Vector< double > m_screenY
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.
Types
Types of known MDirections Warning: The order defines the order in the translation matrix FromTo in ...
std::vector< RSOption > optionValues() const
Implements RegionShape::optionValues.
casacore::Vector< casacore::Double > m_x
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 //.
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.
void updatePoints()
Translates m_spec into m_x and m_y.
casacore::String m_custName
void setOptionValues(const vector< RSOption > &)
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.
Subclass of RegionShape used for drawing ellipses.
void getShapeSpecificProperties(casacore::Record &properties) const
Overrides RSLine::getShapeSpecificProperties.
void setShapeSpecificProperties(const casacore::RecordInterface &)
Implements RegionShape::setShapeSpecificProperties.
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
std::vector< CoordinateParameterType > coordParameterTypes() const
Implements RegionShape::coordParameterPositions.
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()
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.
vector< double > m_screenSpec
either world or pixel coords
void getShapeSpecificProperties(casacore::Record &properties) const
Implements RegionShape::getShapeSpecificProperties.
casacore::String type() const
Implements RegionShape::type.
void getShapeSpecificProperties(casacore::Record &properties) const
Implements RegionShape::getShapeSpecificProperties.
static ArrowType arrowType(const casacore::String &type)
Subclass of RegionShape used for drawing markers.
friend class WorldCanvasHolder
Protected interface for WorldCanvasHolder, can be called by the friends of DisplayData, but are nobody else's business.
void getPolygonCoordinates(double ¢erX, double ¢erY, 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.
casacore::Vector< casacore::Double > m_y
A hierarchical collection of named fields of various types.
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.
Parent class for all RegionShapes.
std::vector< casacore::String > optionNames() const
Implements RegionShape option methods.
std::vector< double > coordParameterValues() const
Implements RegionShape::coordParameterValues.
std::vector< casacore::String > optionNames() const
Implements RegionShape option methods.
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 //.
casacore::Vector< casacore::Double > m_screenX
virtual void setCoordParameters(const std::vector< double > &vals)
Implements RegionShape::setCoordParameters.
casacore::Vector< double > m_x
either world or pixel coords
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
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
LineStyle
LSDoubleDashed is only used to preserve state (it is a Display::LineStyle option) ...
virtual bool updateScreenCoordinates(WorldCanvasHolder &wch, casacore::String *err)
Updates screen coords using world/pixel coords and the given WorldCanvas.
vector< RegionShape * > m_shapes
casacore::Vector< double > m_screenX
in order: [upL, boL, boR, upR]
virtual void getShapeSpecificProperties(casacore::Record &properties) const
Implements RegionShape::getShapeSpecificProperties.
casacore::String type() const
Overrides RSEllipse::type.
casacore::Vector< double > m_y
static std::vector< ArrowType > allArrowTypes()
Returns all possible arrow types.
vector< double > m_screenSpec
Subclass of RSLine that takes a length and angle instead of a second point.
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.
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.
virtual ~RSLine()
Destructor.
String: the storage and methods of handling collections of characters.
static casacore::String markerToString(Display::Marker marker)
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)
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.
RSHandle getHandle() const
Implements RegionShape::getHandle.
void setOptionValues(const vector< RSOption > &)
Sets the options to the given.
static const casacore::String PROPTYPE_LINE
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.
void define(const RecordFieldId &, Bool value)
Define a value for the given field.
Subclass of RegionShape used for drawing text.
casacore::String type() const
Overrides RSLine::type.
Subclass of RegionShape used for drawing polygons.
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
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.
virtual std::vector< CoordinateParameterType > coordParameterTypes() const
Implements RegionShape::coordParameterPositions.
std::vector< casacore::String > optionNames() const
Implements RegionShape::optionNames.
static const casacore::String PROPYCOORDINATES
virtual std::vector< std::vector< casacore::String > > optionChoices() const
Implements RegionShape::optionChoices.
virtual void setOptionValues(const vector< RSOption > &)
Sets the options to the given.
casacore::Vector< casacore::Double > m_screenY
static const casacore::String PROPTYPE_RECTANGLE
static casacore::String arrowType(ArrowType type)
Converts to/from the casacore::String representation of arrow types.
void setCoordParameters(const std::vector< double > &vals)
Implements RegionShape::setCoordParameters.
static const casacore::String PROPXCOORDINATES
Static Members //.
virtual casacore::String type() const
Implements RegionShape::type.
Bool empty() const
Test for empty.
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.