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

Base class for importing regions from file. More...

#include <RegionImporter.h>

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

Public Member Functions

 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.
 

Protected Member Functions

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

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

Base class for importing regions from file.

Constructor & Destructor Documentation

◆ RegionImporter()

RegionImporter::RegionImporter ( std::shared_ptr< casacore::CoordinateSystem >  coord_sys,
int  file_id 
)

Constructor for RegionImporter class.

Parameters
coord_sysCoordinate system of image to which regions are exported
file_idFile id of image to which regions are imported

◆ ~RegionImporter()

virtual carta::RegionImporter::~RegionImporter ( )
virtualdefault

Default destructor.

Member Function Documentation

◆ AddTextStyleToProperties()

void RegionImporter::AddTextStyleToProperties ( const CARTA::RegionStyle &  text_style,
RegionProperties textbox_properties 
)
protected

Add text region style to textbox region properties.

Parameters
[in]text_styleRegion style parameters for text region
[in,out]textbox_propertiesStruct holding region properties for textbox region
Here is the caller graph for this function:

◆ GetProperty()

std::string RegionImporter::GetProperty ( const std::string &  name,
const std::unordered_map< std::string, std::string > &  properties,
bool  check_global = false 
)
protectedvirtual

Return value of name in region properties or global properties.

Parameters
nameName of property to get
propertiesMap of style parameters
check_globalWhether to check global properties
Returns
Map value for name, or empty string if name is not found
Here is the caller graph for this function:

◆ GetRegions()

std::vector< RegionProperties > RegionImporter::GetRegions ( std::string &  error)

Return imported regions and report errors.

Parameters
[out]errorErrors from any regions which failed to import
Returns
regions as region properties struct

◆ GetTextPosition()

CARTA::TextAnnotationPosition RegionImporter::GetTextPosition ( const std::string &  position)
protected

Convert text region position to CARTA position enum.

Parameters
positionPosition in file line
Returns
CARTA text position, or default
Here is the caller graph for this function:

◆ ImportCompassStyle()

void RegionImporter::ImportCompassStyle ( std::string &  compass_properties,
std::string &  compass_coord,
CARTA::AnnotationStyle *  annotation_style 
)
protected

Set style parameters for compass region.

Parameters
[in]compass_propertiesPortion of file line with style parameters
[out]compass_coordCompass coordinate frame
[out]annotation_styleCompass style parameters
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ImportRulerStyle()

void RegionImporter::ImportRulerStyle ( std::string &  ruler_properties,
std::string &  ruler_coord 
)
protected

Get style parameters for ruler region.

Parameters
[in]ruler_propertiesPortion of file line with style parameters
[out]ruler_coordRuler coordinate frame
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsCommentLine()

bool RegionImporter::IsCommentLine ( const std::string &  file_line)
protectedvirtual

Determine whether file line starting with comment marker is a comment and not an annotation region.

Parameters
file_lineFile line to evaluate
Returns
Whether line is comment
Here is the caller graph for this function:

◆ ParseRegionParameters()

void RegionImporter::ParseRegionParameters ( std::string &  region_definition,
std::vector< std::string > &  parameters,
std::unordered_map< std::string, std::string > &  properties 
)
protectedvirtual

Parse file line into region parameters and style properties.

Parameters
[in]region_definitionFile line to parse, determine to be a region
[out]parametersRegion definition parameters
[out]propertiesMap of style parameters
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadRegionFile()

std::vector< std::string > RegionImporter::ReadRegionFile ( const std::string &  file,
bool  file_is_filename,
const char  extra_delim = '\0' 
)
protectedvirtual

Read region file into file lines.

Parameters
fileFilename to read or file contents as single string
file_is_filenameWhether file is filename or contents
extra_delimDelimiter to be used by parser besides what is set by SetParserDelim
Returns
file lines
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetParserDelim()

virtual void carta::RegionImporter::SetParserDelim ( const std::string &  delim)
inlineprotectedvirtual

Set parser delimiter to use in parsing file line.

Parameters
delimDelimiter string
Here is the caller graph for this function:

◆ WorldToPixelLength()

double RegionImporter::WorldToPixelLength ( casacore::Quantity  length,
unsigned int  pixel_axis 
)
protected

Convert length region parameter to pixels if in world coordinates.

Parameters
lengthLength quantity
pixel_axisIndex of axis for conversion
Returns
length in pixels
Here is the caller graph for this function:

Member Data Documentation

◆ _coord_sys

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

Image coordinate system.

◆ _errors

std::string carta::RegionImporter::_errors
protected

Errors for region lines which failed.

◆ _file_id

int carta::RegionImporter::_file_id
protected

File id of reference image.

◆ _global_properties

std::unordered_map<std::string, std::string> carta::RegionImporter::_global_properties
protected

Map of properties from global line of region file.

◆ _parser_delim

std::string carta::RegionImporter::_parser_delim
protected

Delimiter for parsing region file, specific to file type.

◆ _region_names

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

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

◆ _regions

std::vector<RegionProperties> carta::RegionImporter::_regions
protected

Imported regions.


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