CARTA Backend
The backend component of CARTA
Loading...
Searching...
No Matches
carta::Ds9Exporter Class Reference

A class for exporting regions in DS9 format. More...

#include <Ds9Exporter.h>

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

Public Member Functions

 Ds9Exporter (std::shared_ptr< casacore::CoordinateSystem > coord_sys, const casacore::IPosition &shape, bool export_pixels)
 Constructor for Ds9Exporter class for exporting regions to DS9 file.
 
- Public Member Functions inherited from carta::RegionExporter
 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

bool AddRegion (const RegionState &region_state, const CARTA::RegionStyle &region_style) override
 Add file line for region in pixel coordinates.
 
bool AddRegion (CARTA::RegionType region_type, const std::vector< casacore::Quantity > &control_points, const casacore::Quantity &rotation, const CARTA::RegionStyle &region_style) override
 Add file line for region in world coordinates or in matched image.
 
bool ExportRegions (const std::string &filename, std::string &error) override
 Write region file lines to filename.
 
bool ExportRegions (std::vector< std::string > &contents, std::string &error) override
 Set contents to region file lines.
 
- Protected Member Functions inherited from carta::RegionExporter
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.
 

Private Member Functions

void InitGlobalProperties ()
 Set global properties to DS9 defaults.
 
void SetFileCoordFrame ()
 Set frame to use for file lines from image coordinate system.
 
std::string CasacoreFrameToDs9 (const std::string &casacore_frame)
 Convert casacore coordinate frame string to DS9 frame.
 
std::vector< std::string > GetFileHeader ()
 Return DS9 file header lines.
 
std::string GetRegionPixelLine (CARTA::RegionType region_type, const std::vector< casacore::Quantity > &control_points, float rotation, const CARTA::RegionStyle &region_style)
 Create region file line using pixel coordinates.
 
std::string GetRegionWorldLine (CARTA::RegionType region_type, const std::vector< casacore::Quantity > &control_points, float rotation, const CARTA::RegionStyle &region_style)
 Create region file line using world coordinates.
 
void AddStyle (const CARTA::RegionStyle &region_style, std::string &file_line)
 Add DS9 style parameters common to all region types to file line.
 
void AddTextboxStyle (const CARTA::RegionStyle &region_style, std::string &file_line)
 Add textbox region style to file line.
 
void AddFontStyle (const CARTA::RegionStyle &region_style, std::string &file_line)
 Add font style parameters to file line.
 
void AddAnnotationStyle (CARTA::RegionType region_type, const CARTA::RegionStyle &region_style, std::string &file_line)
 Add annotation style parameters to file line.
 
void AddAnnPointStyle (const CARTA::RegionStyle &region_style, std::string &file_line)
 Add annotation point region style to file line.
 

Private Attributes

bool _export_pixels
 Whether to export in pixel or world coordinates.
 
std::unordered_map< std::string, std::string > _global_properties
 Default DS9 properties.
 

Static Private Attributes

static std::unordered_map< std::string, std::string > _coordinate_frames
 Casacore to DS9 coordinate frame.
 

Additional Inherited Members

- Protected Attributes inherited from carta::RegionExporter
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.
 

Detailed Description

A class for exporting regions in DS9 format.

Constructor & Destructor Documentation

◆ Ds9Exporter()

Ds9Exporter::Ds9Exporter ( std::shared_ptr< casacore::CoordinateSystem >  coord_sys,
const casacore::IPosition &  shape,
bool  export_pixels 
)

Constructor for Ds9Exporter class for exporting regions to DS9 file.

Parameters
coord_syscasacore::CoordinateSystem of image from which region is exported
shapecasacore::IPosition describing shape of image from which region is exported
export_pixelsWhether to export in pixel or world coordinates.
Here is the call graph for this function:

Member Function Documentation

◆ AddAnnotationStyle()

void Ds9Exporter::AddAnnotationStyle ( CARTA::RegionType  region_type,
const CARTA::RegionStyle &  region_style,
std::string &  file_line 
)
private

Add annotation style parameters to file line.

Parameters
[in]region_typeRegion type
[in]region_styleRegion style parameters
[in,out]file_lineFile line to append
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddAnnPointStyle()

void Ds9Exporter::AddAnnPointStyle ( const CARTA::RegionStyle &  region_style,
std::string &  file_line 
)
private

Add annotation point region style to file line.

Parameters
[in]region_styleRegion style parameters
[in,out]file_lineFile line to append
Here is the caller graph for this function:

◆ AddFontStyle()

void Ds9Exporter::AddFontStyle ( const CARTA::RegionStyle &  region_style,
std::string &  file_line 
)
private

Add font style parameters to file line.

Parameters
[in]region_styleRegion style parameters
[in,out]file_lineFile line to append
Here is the caller graph for this function:

◆ AddRegion() [1/2]

bool Ds9Exporter::AddRegion ( CARTA::RegionType  region_type,
const std::vector< casacore::Quantity > &  control_points,
const casacore::Quantity &  rotation,
const CARTA::RegionStyle &  region_style 
)
overrideprotectedvirtual

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 file line is successful

Implements carta::RegionExporter.

Here is the call graph for this function:

◆ AddRegion() [2/2]

bool Ds9Exporter::AddRegion ( const RegionState region_state,
const CARTA::RegionStyle &  region_style 
)
overrideprotectedvirtual

Add file line for region in pixel coordinates.

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

Implements carta::RegionExporter.

Here is the call graph for this function:

◆ AddStyle()

void Ds9Exporter::AddStyle ( const CARTA::RegionStyle &  region_style,
std::string &  file_line 
)
private

Add DS9 style parameters common to all region types to file line.

Parameters
[in]region_styleRegion style parameters
[in,out]file_lineFile line to append
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddTextboxStyle()

void Ds9Exporter::AddTextboxStyle ( const CARTA::RegionStyle &  region_style,
std::string &  file_line 
)
private

Add textbox region style to file line.

Parameters
[in]region_styleRegion style parameters
[in,out]file_lineFile line to append
Here is the caller graph for this function:

◆ CasacoreFrameToDs9()

std::string Ds9Exporter::CasacoreFrameToDs9 ( const std::string &  casacore_frame)
private

Convert casacore coordinate frame string to DS9 frame.

Parameters
casacore_frameCoordinate frame in casacore format
Returns
Coordinate frame in DS9 format
Here is the caller graph for this function:

◆ ExportRegions() [1/2]

bool Ds9Exporter::ExportRegions ( const std::string &  filename,
std::string &  error 
)
overrideprotectedvirtual

Write region file lines to filename.

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

Implements carta::RegionExporter.

Here is the call graph for this function:

◆ ExportRegions() [2/2]

bool Ds9Exporter::ExportRegions ( std::vector< std::string > &  contents,
std::string &  error 
)
overrideprotectedvirtual

Set contents to region file lines.

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

Implements carta::RegionExporter.

Here is the call graph for this function:

◆ GetFileHeader()

std::vector< std::string > Ds9Exporter::GetFileHeader ( )
private

Return DS9 file header lines.

Here is the caller graph for this function:

◆ GetRegionPixelLine()

std::string Ds9Exporter::GetRegionPixelLine ( CARTA::RegionType  region_type,
const std::vector< casacore::Quantity > &  control_points,
float  rotation,
const CARTA::RegionStyle &  region_style 
)
private

Create region file line using pixel coordinates.

Parameters
region_typeRegion type
control_pointsRegion control points in pixel coordinates
rotationRegion rotation in degrees
region_styleRegion style parameters
Returns
file line for region
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetRegionWorldLine()

std::string Ds9Exporter::GetRegionWorldLine ( CARTA::RegionType  region_type,
const std::vector< casacore::Quantity > &  control_points,
float  rotation,
const CARTA::RegionStyle &  region_style 
)
private

Create region file line using world coordinates.

Parameters
region_typeRegion type
control_pointsRegion control points in world coordinates
rotationRegion rotation in degrees
region_styleRegion style parameters
Returns
file line for region
Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitGlobalProperties()

void carta::Ds9Exporter::InitGlobalProperties ( )
private

Set global properties to DS9 defaults.

◆ SetFileCoordFrame()

void Ds9Exporter::SetFileCoordFrame ( )
private

Set frame to use for file lines from image coordinate system.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _coordinate_frames

std::unordered_map< std::string, std::string > Ds9Exporter::_coordinate_frames
staticprivate
Initial value:
{
{"B1950", "fk4"}, {"J2000", "fk5"}, {"GALACTIC", "galactic"}, {"ECLIPTIC", "ecliptic"}, {"ICRS", "icrs"}}

Casacore to DS9 coordinate frame.

◆ _export_pixels

bool carta::Ds9Exporter::_export_pixels
private

Whether to export in pixel or world coordinates.

◆ _global_properties

std::unordered_map<std::string, std::string> carta::Ds9Exporter::_global_properties
private

Default DS9 properties.


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