Base class for importing regions from file.
More...
#include <RegionImporter.h>
|
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 ®ion_definition, std::vector< std::string > ¶meters, 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.
|
|
|
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.
|
|
Base class for importing regions from file.
◆ RegionImporter()
RegionImporter::RegionImporter |
( |
std::shared_ptr< casacore::CoordinateSystem > |
coord_sys, |
|
|
int |
file_id |
|
) |
| |
Constructor for RegionImporter class.
- Parameters
-
coord_sys | Coordinate system of image to which regions are exported |
file_id | File id of image to which regions are imported |
◆ ~RegionImporter()
virtual carta::RegionImporter::~RegionImporter |
( |
| ) |
|
|
virtualdefault |
◆ AddTextStyleToProperties()
void RegionImporter::AddTextStyleToProperties |
( |
const CARTA::RegionStyle & |
text_style, |
|
|
RegionProperties & |
textbox_properties |
|
) |
| |
|
protected |
Add text region style to textbox region properties.
- Parameters
-
[in] | text_style | Region style parameters for text region |
[in,out] | textbox_properties | Struct holding region properties for textbox region |
◆ 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
-
name | Name of property to get |
properties | Map of style parameters |
check_global | Whether to check global properties |
- Returns
- Map value for name, or empty string if name is not found
◆ GetRegions()
std::vector< RegionProperties > RegionImporter::GetRegions |
( |
std::string & |
error | ) |
|
Return imported regions and report errors.
- Parameters
-
[out] | error | Errors 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
-
position | Position in file line |
- Returns
- CARTA text position, or default
◆ 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_properties | Portion of file line with style parameters |
[out] | compass_coord | Compass coordinate frame |
[out] | annotation_style | Compass style parameters |
◆ ImportRulerStyle()
void RegionImporter::ImportRulerStyle |
( |
std::string & |
ruler_properties, |
|
|
std::string & |
ruler_coord |
|
) |
| |
|
protected |
Get style parameters for ruler region.
- Parameters
-
[in] | ruler_properties | Portion of file line with style parameters |
[out] | ruler_coord | Ruler coordinate frame |
◆ 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_line | File line to evaluate |
- Returns
- Whether line is comment
◆ 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_definition | File line to parse, determine to be a region |
[out] | parameters | Region definition parameters |
[out] | properties | Map of style parameters |
◆ 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
-
file | Filename to read or file contents as single string |
file_is_filename | Whether file is filename or contents |
extra_delim | Delimiter to be used by parser besides what is set by SetParserDelim |
- Returns
- file lines
◆ SetParserDelim()
virtual void carta::RegionImporter::SetParserDelim |
( |
const std::string & |
delim | ) |
|
|
inlineprotectedvirtual |
Set parser delimiter to use in parsing file line.
- Parameters
-
◆ WorldToPixelLength()
double RegionImporter::WorldToPixelLength |
( |
casacore::Quantity |
length, |
|
|
unsigned int |
pixel_axis |
|
) |
| |
|
protected |
Convert length region parameter to pixels if in world coordinates.
- Parameters
-
length | Length quantity |
pixel_axis | Index of axis for conversion |
- Returns
- length in pixels
◆ _coord_sys
std::shared_ptr<casacore::CoordinateSystem> carta::RegionImporter::_coord_sys |
|
protected |
◆ _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
The documentation for this class was generated from the following files: