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

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

#include <CrtfExporter.h>

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

Public Member Functions

 CrtfExporter (std::shared_ptr< casacore::CoordinateSystem > coord_sys, const casacore::IPosition &shape, int stokes_axis)
 Constructor for CrtfExporter class for exporting regions to CRTF 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
 Serialise region file lines to vector.
 
- 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

bool GetAnnRegion (CARTA::RegionType region_type, const std::vector< casacore::Quantity > &control_points, const casacore::Quantity &rotation, const CARTA::RegionStyle &region_style, casa::AnnotationBase *&ann_base, casa::AnnRegion *&ann_region)
 Create casa AnnotationBase or AnnRegion from region parameters.
 
bool AddFileLine (CARTA::RegionType region_type, std::string &file_line, const CARTA::RegionStyle &region_style)
 Add file line after adjusting line printed by CASA region.
 
bool AddTextFileLines (CARTA::RegionType region_type, std::string &file_line, const std::vector< casacore::Quantity > &control_points, const CARTA::RegionStyle &region_style)
 Add file lines for text region, as textbox file line then text file line.
 
void FixFontstyle (std::string &file_line)
 Fix fontstyle added by CASA region.
 
casa::AnnSymbol::Symbol GetAnnSymbol (CARTA::PointAnnotationShape point_shape)
 Convert CARTA point shape to CASA annotation symbol.
 
char GetAnnSymbolCharacter (CARTA::PointAnnotationShape point_shape)
 Convert CARTA point shape to CASA symbol character.
 
std::string FormatColor (const std::string &color)
 Format color for file line.
 
casa::AnnotationBase::LineStyle GetLineStyle (const CARTA::RegionStyle &region_style)
 Convert dash list to CASA line style else set default.
 
void GetFontStyle (const CARTA::RegionStyle &region_style, std::string &font, unsigned int &font_size, casa::AnnotationBase::FontStyle &font_style)
 Extract font parameters from region style else set defaults.
 
void GetSymbolStyle (const CARTA::RegionStyle &region_style, unsigned int &symbol_size, unsigned int &symbol_thickness)
 Extract CASA symbol style parameters from region style else set defaults.
 
void AddStyle (const CARTA::RegionStyle &region_style, std::string &file_line)
 Add CRTF style parameters common to all regions to file line.
 
void SetAnnotationRegionStyle (const CARTA::RegionStyle &region_style, casa::AnnotationBase *region)
 Set region style parameters in AnnotationBase region.
 
casacore::Vector< casacore::Stokes::StokesTypes > GetStokesTypes ()
 Get casacore stokes types for stokes axis set in constructor.
 
std::string GetFileHeader ()
 Get CRTF file header string.
 

Private Attributes

int _stokes_axis
 stokes axis index for current stokes, set from constructor parameter for adding stokes type to export.
 

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 CRTF format.

Constructor & Destructor Documentation

◆ CrtfExporter()

CrtfExporter::CrtfExporter ( std::shared_ptr< casacore::CoordinateSystem >  coord_sys,
const casacore::IPosition &  shape,
int  stokes_axis 
)

Constructor for CrtfExporter class for exporting regions to CRTF file.

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

Member Function Documentation

◆ AddFileLine()

bool CrtfExporter::AddFileLine ( CARTA::RegionType  region_type,
std::string &  file_line,
const CARTA::RegionStyle &  region_style 
)
private

Add file line after adjusting line printed by CASA region.

Parameters
region_typeRegion type
file_lineLine to be adjusted and added
region_styleRegion style parameters
Returns
Whether adding the file line is successful
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddRegion() [1/2]

bool CrtfExporter::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 region file line is successful

Implements carta::RegionExporter.

Here is the call graph for this function:

◆ AddRegion() [2/2]

bool CrtfExporter::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 region file line is successful

Implements carta::RegionExporter.

Here is the call graph for this function:

◆ AddStyle()

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

Add CRTF style parameters common to all regions to file line.

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

◆ AddTextFileLines()

bool CrtfExporter::AddTextFileLines ( CARTA::RegionType  region_type,
std::string &  file_line,
const std::vector< casacore::Quantity > &  control_points,
const CARTA::RegionStyle &  region_style 
)
private

Add file lines for text region, as textbox file line then text file line.

Parameters
region_typeRegion type
file_lineLine for textbox region
control_pointsRegion control points for text region
region_styleRegion style parameters
Returns
Whether adding the file lines is successful
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExportRegions() [1/2]

bool CrtfExporter::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 region lines is successful

Implements carta::RegionExporter.

Here is the call graph for this function:

◆ ExportRegions() [2/2]

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

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

Implements carta::RegionExporter.

Here is the call graph for this function:

◆ FixFontstyle()

void CrtfExporter::FixFontstyle ( std::string &  file_line)
private

Fix fontstyle added by CASA region.

Parameters
[in,out]file_lineLine to be fixed
Here is the caller graph for this function:

◆ FormatColor()

std::string CrtfExporter::FormatColor ( const std::string &  color)
private

Format color for file line.

Parameters
colorRegion color
Returns
Formatted color string
Here is the caller graph for this function:

◆ GetAnnRegion()

bool CrtfExporter::GetAnnRegion ( CARTA::RegionType  region_type,
const std::vector< casacore::Quantity > &  control_points,
const casacore::Quantity &  rotation,
const CARTA::RegionStyle &  region_style,
casa::AnnotationBase *&  ann_base,
casa::AnnRegion *&  ann_region 
)
private

Create casa AnnotationBase or AnnRegion from region parameters.

Parameters
[in]region_typeRegion type
[in]control_pointsRegion control points
[in]rotationRegion rotation
[in]region_styleRegion style parameters
[out]ann_basePointer to return new AnnotationBase region
[out]ann_regionPointer to return new AnnRegion region
Returns
Whether the region was created
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAnnSymbol()

casa::AnnSymbol::Symbol CrtfExporter::GetAnnSymbol ( CARTA::PointAnnotationShape  point_shape)
private

Convert CARTA point shape to CASA annotation symbol.

Parameters
point_shapeCARTA point shape
Returns
CASA annotation symbol
Here is the caller graph for this function:

◆ GetAnnSymbolCharacter()

char CrtfExporter::GetAnnSymbolCharacter ( CARTA::PointAnnotationShape  point_shape)
private

Convert CARTA point shape to CASA symbol character.

Parameters
point_shapeCARTA point shape
Returns
char representing CASA symbol shape
Here is the caller graph for this function:

◆ GetFileHeader()

std::string CrtfExporter::GetFileHeader ( )
private

Get CRTF file header string.

Returns
header
Here is the caller graph for this function:

◆ GetFontStyle()

void CrtfExporter::GetFontStyle ( const CARTA::RegionStyle &  region_style,
std::string &  font,
unsigned int &  font_size,
casa::AnnotationBase::FontStyle &  font_style 
)
private

Extract font parameters from region style else set defaults.

Parameters
[in]region_styleRegion style parameters
[out]fontFont name
[out]font_sizeFont size
[out]font_styleFont style enum
Here is the caller graph for this function:

◆ GetLineStyle()

casa::AnnotationBase::LineStyle CrtfExporter::GetLineStyle ( const CARTA::RegionStyle &  region_style)
private

Convert dash list to CASA line style else set default.

Parameters
region_styleRegion style parameters
Returns
CASA line style
Here is the caller graph for this function:

◆ GetStokesTypes()

casacore::Vector< casacore::Stokes::StokesTypes > CrtfExporter::GetStokesTypes ( )
private

Get casacore stokes types for stokes axis set in constructor.

Returns
casacore StokesTypes enum vector
Here is the caller graph for this function:

◆ GetSymbolStyle()

void CrtfExporter::GetSymbolStyle ( const CARTA::RegionStyle &  region_style,
unsigned int &  symbol_size,
unsigned int &  symbol_thickness 
)
private

Extract CASA symbol style parameters from region style else set defaults.

Parameters
[in]region_styleRegion style parameters
[out]symbol_sizeSymbol size
[out]symbol_thicknessSymbol outline thickness.
Here is the caller graph for this function:

◆ SetAnnotationRegionStyle()

void CrtfExporter::SetAnnotationRegionStyle ( const CARTA::RegionStyle &  region_style,
casa::AnnotationBase *  region 
)
private

Set region style parameters in AnnotationBase region.

Parameters
[in]region_styleRegion style parameters
[in,out]regionPointer to casa AnnotationBase region (AnnotationBase or AnnRegion)
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _stokes_axis

int carta::CrtfExporter::_stokes_axis
private

stokes axis index for current stokes, set from constructor parameter for adding stokes type to export.


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