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

A class for importing region files in CRTF format. More...

#include <CrtfImporter.h>

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

Public Member Functions

 CrtfImporter (std::shared_ptr< casacore::CoordinateSystem > image_coord_sys, int file_id, const std::string &file, bool file_is_filename)
 Constructor for CrtfImporter class for importing regions in CRTF region file.
 
- Public Member Functions inherited from carta::RegionImporter
 RegionImporter (std::shared_ptr< casacore::CoordinateSystem > coord_sys, int file_id)
 Constructor for RegionImporter class.
 
virtual ~RegionImporter ()=default
 Default destructor.
 
std::vector< RegionPropertiesGetRegions (std::string &error)
 Return imported regions and report errors.
 

Private Member Functions

void SetFileLineRegions (std::vector< std::string > &file_lines)
 Parse each line of file to import regions.
 
std::string GetRegionDirectionFrame (const std::unordered_map< std::string, std::string > &properties)
 Get direction frame coord value in region properties.
 
RegionState ImportAnnSymbolText (std::vector< std::string > &parameters, std::string &coord_frame)
 Import point or text region.
 
RegionState ImportAnnBox (std::vector< std::string > &parameters, std::string &coord_frame)
 Import rectangle region.
 
RegionState ImportAnnEllipse (std::vector< std::string > &parameters, std::string &coord_frame)
 Import ellipse region.
 
RegionState ImportAnnPoly (std::vector< std::string > &parameters, std::string &coord_frame)
 Import polygon or line-based region.
 
CARTA::RegionStyle ImportStyle (CARTA::RegionType region_type, std::unordered_map< std::string, std::string > &properties)
 Import region style parameters for region type.
 
void ImportFontStyle (std::unordered_map< std::string, std::string > &properties, CARTA::AnnotationStyle *annotation_style)
 Set annotation style font parameters.
 
void ImportPointStyle (const std::string &symbol_char, std::unordered_map< std::string, std::string > &properties, CARTA::AnnotationStyle *annotation_style)
 Set annotation style point parameters.
 
bool GetBoxControlPoints (std::vector< std::string > &parameters, std::string &coord_frame, std::vector< CARTA::Point > &control_points, float &rotation)
 Convert box definition with all corner points to control points.
 
bool GetCenterBoxPoints (const std::string &region, casacore::Quantity &cx, casacore::Quantity &cy, casacore::Quantity &width, casacore::Quantity &height, std::string &coord_frame, std::vector< CARTA::Point > &control_points)
 Convert box definition with center and width/height to control points.
 
bool GetRectBoxPoints (casacore::Quantity &blcx, casacore::Quantity &blcy, casacore::Quantity &trcx, casacore::Quantity &trcy, std::string &coord_frame, std::vector< CARTA::Point > &control_points)
 Convert box definition with blc, trc corners to control points.
 

Additional Inherited Members

- Protected Member Functions inherited from carta::RegionImporter
virtual std::vector< std::string > ReadRegionFile (const std::string &file, bool file_is_filename, const char extra_delim='\0')
 Read region file into file lines.
 
virtual bool IsCommentLine (const std::string &file_line)
 Determine whether file line starting with comment marker is a comment and not an annotation region.
 
virtual void SetParserDelim (const std::string &delim)
 Set parser delimiter to use in parsing file line.
 
virtual void ParseRegionParameters (std::string &region_definition, std::vector< std::string > &parameters, std::unordered_map< std::string, std::string > &properties)
 Parse file line into region parameters and style properties.
 
virtual std::string GetProperty (const std::string &name, const std::unordered_map< std::string, std::string > &properties, bool check_global=false)
 Return value of name in region properties or global properties.
 
CARTA::TextAnnotationPosition GetTextPosition (const std::string &position)
 Convert text region position to CARTA position enum.
 
void AddTextStyleToProperties (const CARTA::RegionStyle &text_style, RegionProperties &textbox_properties)
 Add text region style to textbox region properties.
 
double WorldToPixelLength (casacore::Quantity length, unsigned int pixel_axis)
 Convert length region parameter to pixels if in world coordinates.
 
void ImportCompassStyle (std::string &compass_properties, std::string &compass_coord, CARTA::AnnotationStyle *annotation_style)
 Set style parameters for compass region.
 
void ImportRulerStyle (std::string &ruler_properties, std::string &ruler_coord)
 Get style parameters for ruler region.
 
- Protected Attributes inherited from carta::RegionImporter
std::shared_ptr< casacore::CoordinateSystem > _coord_sys
 Image coordinate system.
 
int _file_id
 File id of reference image.
 
std::string _parser_delim
 Delimiter for parsing region file, specific to file type.
 
std::unordered_map< std::string, std::string > _global_properties
 Map of properties from global line of region file.
 
std::unordered_map< CARTA::RegionType, std::string > _region_names
 Region names for conversion CRTF or DS9 name to CARTA type.
 
std::string _errors
 Errors for region lines which failed.
 
std::vector< RegionProperties_regions
 Imported regions.
 

Detailed Description

A class for importing region files in CRTF format.

Constructor & Destructor Documentation

◆ CrtfImporter()

CrtfImporter::CrtfImporter ( std::shared_ptr< casacore::CoordinateSystem >  image_coord_sys,
int  file_id,
const std::string &  file,
bool  file_is_filename 
)

Constructor for CrtfImporter class for importing regions in CRTF region file.

Parameters
image_coord_syscasacore::CoordinateSystem of image from which region is exported
file_idId of image to which region is imported, for RegionState
fileFile name or contents to import
file_is_filenameIndicates whether file parameter contains name or contents.
Here is the call graph for this function:

Member Function Documentation

◆ GetBoxControlPoints()

bool CrtfImporter::GetBoxControlPoints ( std::vector< std::string > &  parameters,
std::string &  coord_frame,
std::vector< CARTA::Point > &  control_points,
float &  rotation 
)
private

Convert box definition with all corner points to control points.

Parameters
[in]parametersRegion definition parameters
[in]coord_frameDirection frame used to define parameter points
[out]control_pointsPoints in pixel coordinates
[out]rotationBox rotation in degrees
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetCenterBoxPoints()

bool CrtfImporter::GetCenterBoxPoints ( const std::string &  region,
casacore::Quantity &  cx,
casacore::Quantity &  cy,
casacore::Quantity &  width,
casacore::Quantity &  height,
std::string &  coord_frame,
std::vector< CARTA::Point > &  control_points 
)
private

Convert box definition with center and width/height to control points.

Parameters
[in]regionName of region
[in]cxCenter x
[in]cyCenter y
[in]widthRectangle width
[in]heightRectangle height
[in]coord_frameDirection frame used to define casacore Quantities
[out]control_pointsRectangle control points
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetRectBoxPoints()

bool CrtfImporter::GetRectBoxPoints ( casacore::Quantity &  blcx,
casacore::Quantity &  blcy,
casacore::Quantity &  trcx,
casacore::Quantity &  trcy,
std::string &  coord_frame,
std::vector< CARTA::Point > &  control_points 
)
private

Convert box definition with blc, trc corners to control points.

Parameters
[in]blcxBox bottom left corner x
[in]blcyBox bottom left corner y
[in]trcxBox top right corner x
[in]trcyBox top right corner y
[in]coord_frameDirection frame used to define corners
[out]control_pointsRectangle control points
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetRegionDirectionFrame()

std::string CrtfImporter::GetRegionDirectionFrame ( const std::unordered_map< std::string, std::string > &  properties)
private

Get direction frame coord value in region properties.

Parameters
propertiesMap of style parameters
Returns
Region direction frame
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ImportAnnBox()

RegionState CrtfImporter::ImportAnnBox ( std::vector< std::string > &  parameters,
std::string &  coord_frame 
)
private

Import rectangle region.

Parameters
parametersRegion definition parameters
coord_frameDirection frame used to define parameters
Returns
region state struct
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ImportAnnEllipse()

RegionState CrtfImporter::ImportAnnEllipse ( std::vector< std::string > &  parameters,
std::string &  coord_frame 
)
private

Import ellipse region.

Parameters
parametersRegion definition parameters
coord_frameDirection frame used to define parameters
Returns
region state struct
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ImportAnnPoly()

RegionState CrtfImporter::ImportAnnPoly ( std::vector< std::string > &  parameters,
std::string &  coord_frame 
)
private

Import polygon or line-based region.

Parameters
parametersRegion definition parameters
coord_frameDirection frame used to define parameters
Returns
region state struct
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ImportAnnSymbolText()

RegionState CrtfImporter::ImportAnnSymbolText ( std::vector< std::string > &  parameters,
std::string &  coord_frame 
)
private

Import point or text region.

Parameters
parametersRegion definition parameters
coord_frameDirection frame used to define parameters
Returns
region state struct
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ImportFontStyle()

void CrtfImporter::ImportFontStyle ( std::unordered_map< std::string, std::string > &  properties,
CARTA::AnnotationStyle *  annotation_style 
)
private

Set annotation style font parameters.

Parameters
[in]propertiesMap of style parameters
[out]annotation_styleAnnotation style parameters
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ImportPointStyle()

void CrtfImporter::ImportPointStyle ( const std::string &  symbol_char,
std::unordered_map< std::string, std::string > &  properties,
CARTA::AnnotationStyle *  annotation_style 
)
private

Set annotation style point parameters.

Parameters
[in]symbol_charcharacter describing a casa Symbol shape
[in]propertiesMap of style parameters
[out]annotation_styleAnnotation style parameters
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ImportStyle()

CARTA::RegionStyle CrtfImporter::ImportStyle ( CARTA::RegionType  region_type,
std::unordered_map< std::string, std::string > &  properties 
)
private

Import region style parameters for region type.

Parameters
region_typeRegion type
propertiesMap of style parameters
Returns
Region style parameters
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetFileLineRegions()

void CrtfImporter::SetFileLineRegions ( std::vector< std::string > &  file_lines)
private

Parse each line of file to import regions.

Parameters
file_linesLines read from region file
Here is the call graph for this function:
Here is the caller graph for this function:

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