CARTA Backend
The backend component of CARTA
Loading...
Searching...
No Matches
carta::RegionExporter Class Referenceabstract

Base class for exporting regions to file. More...

#include <RegionExporter.h>

Inheritance diagram for carta::RegionExporter:
[legend]
Collaboration diagram for carta::RegionExporter:
[legend]

Public Member Functions

 RegionExporter (std::shared_ptr< casacore::CoordinateSystem > coord_sys, const casacore::IPosition &shape)
 Constructor for RegionExporter class.
 
virtual ~RegionExporter ()=default
 Default destructor.
 
bool CanExportToFile (const std::string &filename, bool overwrite, CARTA::ExportRegionAck &export_ack)
 Determine if export file can be created or overwritten.
 
bool AddRegion (int file_id, std::shared_ptr< Region > region, const CARTA::RegionStyle &region_style, bool export_pixels)
 Add file line for region.
 
void ExportRegions (const std::string &filename, std::string &message, CARTA::ExportRegionAck &export_ack)
 Export region file lines to file or contents.
 

Protected Member Functions

virtual bool AddRegion (const RegionState &region_state, const CARTA::RegionStyle &region_style)=0
 Add file line for region in pixel coordinates.
 
virtual bool AddRegion (CARTA::RegionType region_type, const std::vector< casacore::Quantity > &control_points, const casacore::Quantity &rotation, const CARTA::RegionStyle &region_style)=0
 Add file line for region in world coordinates or in matched image.
 
virtual bool ExportRegions (const std::string &filename, std::string &error)=0
 Write region file lines to filename.
 
virtual bool ExportRegions (std::vector< std::string > &contents, std::string &error)=0
 Serialise region file lines to vector.
 
bool AddRegion (const RegionState &region_state, const CARTA::RegionStyle &region_style, const casacore::RecordInterface &region_record, bool export_pixels)
 Add file line for region in world coordinates or for matched image.
 
void AddCompassStyle (const CARTA::RegionStyle &region_style, const std::string &coord_frame, std::string &file_line)
 Append compass style parameters to region file line.
 

Protected Attributes

std::shared_ptr< casacore::CoordinateSystem > _coord_sys
 Image coordinate system.
 
casacore::IPosition _image_shape
 Image shape.
 
std::unordered_map< CARTA::RegionType, std::string > _region_names
 Region names for conversion from CARTA type to CRTF or DS9 name.
 
std::string _image_coord_frame
 casacore image reference frame from coordinate system.
 
std::string _file_coord_frame
 Coordinate frame for file lines.
 
std::vector< std::string > _file_lines
 Formatted lines for header, globals, and regions for region file.
 

Private Member Functions

bool ConvertRecordToPoint (const casacore::RecordInterface &region_record, bool export_pixels, std::vector< casacore::Quantity > &control_points)
 Convert casacore Record to point region control points.
 
bool ConvertRecordToRectangle (const casacore::RecordInterface &region_record, bool export_pixels, std::vector< casacore::Quantity > &control_points)
 Convert casacore Record to rectangle region control points.
 
bool ConvertRecordToEllipse (const RegionState &region_state, const casacore::RecordInterface &region_record, bool export_pixels, std::vector< casacore::Quantity > &control_points, casacore::Quantity &qrotation)
 Convert casacore Record to ellipse/circle region control points and rotation.
 
bool ConvertRecordToPolygonLine (const casacore::RecordInterface &region_record, bool export_pixels, std::vector< casacore::Quantity > &control_points)
 Convert casacore Record to polygon/polyline region control points.
 
casacore::Vector< casacore::Double > FloatVectorToDouble (const casacore::Vector< casacore::Float > &float_vector)
 Convert casacore Vector from float to double.
 

Detailed Description

Base class for exporting regions to file.

Constructor & Destructor Documentation

◆ RegionExporter()

RegionExporter::RegionExporter ( std::shared_ptr< casacore::CoordinateSystem >  coord_sys,
const casacore::IPosition &  shape 
)

Constructor for RegionExporter class.

Parameters
coord_syscasacore::CoordinateSystem of image from which region is exported
shapecasacore::IPosition shape of image from which region is exported
Here is the call graph for this function:

◆ ~RegionExporter()

virtual carta::RegionExporter::~RegionExporter ( )
virtualdefault

Default destructor.

Member Function Documentation

◆ AddCompassStyle()

void RegionExporter::AddCompassStyle ( const CARTA::RegionStyle &  region_style,
const std::string &  coord_frame,
std::string &  file_line 
)
protected

Append compass style parameters to region file line.

Parameters
[in]region_styleRegion style parameters
[in]coord_frameCoordinate frame for compass region
[in,out]file_lineLine to be appended
Here is the caller graph for this function:

◆ AddRegion() [1/4]

virtual bool carta::RegionExporter::AddRegion ( CARTA::RegionType  region_type,
const std::vector< casacore::Quantity > &  control_points,
const casacore::Quantity &  rotation,
const CARTA::RegionStyle &  region_style 
)
protectedpure virtual

Add file line for region in world coordinates or in matched image.

Parameters
region_typeRegion type
control_pointsRegion control points in world coordinates
rotationRegion rotation
region_styleRegion style parameters
Returns
Whether adding the region file line is successful

Implemented in carta::CrtfExporter, and carta::Ds9Exporter.

◆ AddRegion() [2/4]

virtual bool carta::RegionExporter::AddRegion ( const RegionState region_state,
const CARTA::RegionStyle &  region_style 
)
protectedpure virtual

Add file line for region in pixel coordinates.

Parameters
region_stateRegion definition parameters
region_styleRegion style parameters
Returns
Whether adding the region file line is successful

Implemented in carta::CrtfExporter, and carta::Ds9Exporter.

◆ AddRegion() [3/4]

bool RegionExporter::AddRegion ( const RegionState region_state,
const CARTA::RegionStyle &  region_style,
const casacore::RecordInterface &  region_record,
bool  export_pixels 
)
protected

Add file line for region in world coordinates or for matched image.

Parameters
region_stateRegion definition parameters
region_styleRegion style parameters
region_recordcasacore Record created from LCRegion applied to image
export_pixelsWhether to export region in pixel or world coordinates
Returns
Whether region is exported successfully
Here is the call graph for this function:

◆ AddRegion() [4/4]

bool RegionExporter::AddRegion ( int  file_id,
std::shared_ptr< Region region,
const CARTA::RegionStyle &  region_style,
bool  export_pixels 
)

Add file line for region.

Parameters
file_idFile id for image from which region is exported
regionRegion to export
region_styleRegion style parameters
export_pixelsWhether to export region in pixel or world coordinates
Returns
Whether adding the region file line is successful
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CanExportToFile()

bool RegionExporter::CanExportToFile ( const std::string &  filename,
bool  overwrite,
CARTA::ExportRegionAck &  export_ack 
)

Determine if export file can be created or overwritten.

Parameters
[in]filenameName of region file
[in]overwriteWhether existing file can be overwritten
[out]export_ackCARTA ExportRegionAck message to complete if error.
Returns
Whether export file can be written.

◆ ConvertRecordToEllipse()

bool RegionExporter::ConvertRecordToEllipse ( const RegionState region_state,
const casacore::RecordInterface &  region_record,
bool  export_pixels,
std::vector< casacore::Quantity > &  control_points,
casacore::Quantity &  qrotation 
)
private

Convert casacore Record to ellipse/circle region control points and rotation.

Parameters
[in]region_stateRegion definition parameters
[in]region_recordcasacore Record created from casacore LCRegion
[in]export_pixelsWhether to set control points in pixel or world coordinates
[out]control_pointsRegion control points
[out]qrotationRegion rotation
Returns
Whether the conversion is successful
Here is the caller graph for this function:

◆ ConvertRecordToPoint()

bool RegionExporter::ConvertRecordToPoint ( const casacore::RecordInterface &  region_record,
bool  export_pixels,
std::vector< casacore::Quantity > &  control_points 
)
private

Convert casacore Record to point region control points.

Parameters
[in]region_recordcasacore Record created from casacore LCRegion
[in]export_pixelsWhether to set control points in pixel or world coordinates
[out]control_pointsRegion control points
Returns
Whether the conversion is successful
Here is the caller graph for this function:

◆ ConvertRecordToPolygonLine()

bool RegionExporter::ConvertRecordToPolygonLine ( const casacore::RecordInterface &  region_record,
bool  export_pixels,
std::vector< casacore::Quantity > &  control_points 
)
private

Convert casacore Record to polygon/polyline region control points.

Parameters
[in]region_recordcasacore Record created from casacore LCRegion
[in]export_pixelsWhether to set control points in pixel or world coordinates
[out]control_pointsRegion control points
Returns
Whether the conversion is successful
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ConvertRecordToRectangle()

bool RegionExporter::ConvertRecordToRectangle ( const casacore::RecordInterface &  region_record,
bool  export_pixels,
std::vector< casacore::Quantity > &  control_points 
)
private

Convert casacore Record to rectangle region control points.

Parameters
[in]region_recordcasacore Record created from casacore LCRegion
[in]export_pixelsWhether to set control points in pixel or world coordinates
[out]control_pointsRegion control points
Returns
Whether the conversion is successful
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExportRegions() [1/3]

virtual bool carta::RegionExporter::ExportRegions ( const std::string &  filename,
std::string &  error 
)
protectedpure virtual

Write region file lines to filename.

Parameters
[in]filenameName of region file
[out]errorMessage describing error if export fails
Returns
Whether writing any region lines is successful

Implemented in carta::CrtfExporter, and carta::Ds9Exporter.

◆ ExportRegions() [2/3]

void RegionExporter::ExportRegions ( const std::string &  filename,
std::string &  message,
CARTA::ExportRegionAck &  export_ack 
)

Export region file lines to file or contents.

Parameters
[in]filenameFilename to use for export; if empty, export to contents in ack message
[in]messageAny errors from adding regions to add to ack message.
[out]export_ackResponse message to complete
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExportRegions() [3/3]

virtual bool carta::RegionExporter::ExportRegions ( std::vector< std::string > &  contents,
std::string &  error 
)
protectedpure virtual

Serialise region file lines to vector.

Parameters
[out]contentsVector for lines
[out]errorMessage describing error if export fails
Returns
Whether writing any region lines is successful

Implemented in carta::CrtfExporter, and carta::Ds9Exporter.

◆ FloatVectorToDouble()

casacore::Vector< casacore::Double > RegionExporter::FloatVectorToDouble ( const casacore::Vector< casacore::Float > &  float_vector)
private

Convert casacore Vector from float to double.

Parameters
float_vectorFloat vector to convert
Returns
vector
Here is the caller graph for this function:

Member Data Documentation

◆ _coord_sys

std::shared_ptr<casacore::CoordinateSystem> carta::RegionExporter::_coord_sys
protected

Image coordinate system.

◆ _file_coord_frame

std::string carta::RegionExporter::_file_coord_frame
protected

Coordinate frame for file lines.

◆ _file_lines

std::vector<std::string> carta::RegionExporter::_file_lines
protected

Formatted lines for header, globals, and regions for region file.

◆ _image_coord_frame

std::string carta::RegionExporter::_image_coord_frame
protected

casacore image reference frame from coordinate system.

◆ _image_shape

casacore::IPosition carta::RegionExporter::_image_shape
protected

Image shape.

◆ _region_names

std::unordered_map<CARTA::RegionType, std::string> carta::RegionExporter::_region_names
protected

Region names for conversion from CARTA type to CRTF or DS9 name.


The documentation for this class was generated from the following files: