41 #define G_ACCESS "GSkyRegions::operator[](std::string&)"
42 #define G_AT "GSkyRegions::at(int&)"
43 #define G_SET1 "GSkyRegions::set(int&, GSkyRegion&)"
44 #define G_SET2 "GSkyRegions::set(std::string&, GSkyRegion&)"
45 #define G_APPEND "GSkyRegions::append(GSkyRegion&)"
46 #define G_INSERT1 "GSkyRegions::insert(int&, GSkyRegion&)"
47 #define G_INSERT2 "GSkyRegions::insert(std::string&, GSkyRegion&)"
48 #define G_REMOVE1 "GSkyRegions::remove(int&)"
49 #define G_REMOVE2 "GSkyRegions::remove(std::string&)"
50 #define G_EXTEND "GSkyRegions::extend(GSkyRegions&)"
51 #define G_LOAD "GSkyRegions::load(GFilename&)"
52 #define G_SAVE "GSkyRegions::save(GFilename&)"
146 if (
this != ®ions) {
214 if (index < 0 || index >=
size()) {
237 if (index < 0 || index >=
size()) {
264 #if defined(G_RANGE_CHECK)
265 if (index < 0 || index >=
size()) {
328 #if defined(G_RANGE_CHECK)
336 if (index < 0 || index >=
size()) {
367 #if defined(G_RANGE_CHECK)
368 if (index < 0 || index >=
size()) {
400 int num = regions.
size();
406 for (
int i = 0; i < num; ++i) {
433 bool overlap =
false;
436 for (
int i = 0; i <
size(); ++i) {
460 bool overlap =
false;
463 for (
int i = 0; i <
size(); ++i) {
464 overlap =
m_regions[i]->overlaps(region);
489 bool overlap =
false;
492 for (
int i = 0; i <
size(); ++i) {
520 std::ifstream ds9file;
521 ds9file.open(filename.
url().c_str());
522 if (ds9file.is_open()) {
525 std::string fileline =
"";
526 std::string coordsys =
"galactic";
527 while (ds9file.good()) {
530 getline(ds9file,fileline);
533 if (fileline[0] ==
'#') {
538 if (std::string::npos != fileline.find(
"fk5")) {
541 else if (std::string::npos != fileline.find(
"icrs")) {
546 if (std::string::npos != fileline.find(
"circle")) {
552 if ((std::string::npos != fileline.find(
"fk5")) ||
553 (std::string::npos != fileline.find(
"icrs")) ||
554 (std::string::npos != fileline.find(
"galactic"))) {
555 region.
read(fileline);
561 std::string newfileline = coordsys;
562 newfileline.append(
"; ");
563 newfileline.append(fileline);
564 region.
read(newfileline);
571 else if (std::string::npos != fileline.find(
"box")) {
577 if ((std::string::npos != fileline.find(
"fk5")) ||
578 (std::string::npos != fileline.find(
"icrs")) ||
579 (std::string::npos != fileline.find(
"galactic"))) {
580 region.
read(fileline);
586 std::string newfileline = coordsys;
587 newfileline.append(
"; ");
588 newfileline.append(fileline);
589 region.
read(newfileline);
607 std::string msg =
"Unable to open file \""+filename.
url()+
"\". Please "
608 "specify a valid file name.";
630 std::ofstream ds9file;
631 ds9file.open(filename.
url().c_str());
634 if (ds9file.is_open()) {
637 std::string fileline;
638 fileline.append(
"# Region file format: DS9 version 4.1\n");
639 fileline.append(
"global color=green dashlist=8 3 width=1");
640 ds9file << fileline <<
"\n";
643 for (
int i = 0; i <
size(); ++i) {
644 ds9file <<
m_regions[i]->write() <<
"\n";
657 std::string msg =
"Unable to open file \""+filename.
url()+
"\". Please "
658 "specify a valid file name.";
684 result.append(
"=== GSkyRegions ===");
691 for (
int i = 0; i <
size(); ++i) {
735 for (
int i = 0; i < regions.
m_regions.size(); ++i) {
753 for (
int i = 0; i <
m_regions.size(); ++i) {
virtual GSkyRegion * clone(void) const =0
Clones object.
void clear(void)
Clear object.
Rectangular sky region class interface definition.
std::vector< GSkyRegion * > m_regions
List of regions.
Sky direction class interface definition.
GSkyRegion * insert(const int &index, const GSkyRegion ®ion)
Insert region into container.
Sky regions container class definition.
void copy_members(const GSkyRegions ®ions)
Copy class members.
Definition of interface for all GammaLib classes.
GSkyRegions * clone(void) const
Clone instance.
void read(const std::string &line)
Read region from DS9 string.
GSkyRegions & operator=(const GSkyRegions ®ions)
Assignment operator.
Interface for the circular sky region class.
Interface for the rectangular sky region class.
GSkyRegions(void)
Void constructor.
std::string print(const GChatter &chatter=NORMAL) const
Print regions.
const GFilename & filename(void) const
Return regions file name.
Abstract interface for the sky region class.
GFilename m_filename
Filename of origin.
void save(const GFilename &filename) const
Save regions into DS9 region file.
int size(void) const
Return number of regions in container.
GSkyRegion * at(const int &index)
Return pointer to region.
virtual ~GSkyRegions(void)
Destructor.
Sky region container class.
bool is_empty(void) const
Signals if there are no regions in container.
std::string url(void) const
Return Uniform Resource Locator (URL)
void clear(void)
Clear file name.
bool overlaps(const GSkyRegion ®ion) const
Check if region overlaps one of the regions.
void free_members(void)
Delete class members.
void extend(const GSkyRegions ®ions)
Append region container.
void init_members(void)
Initialise class members.
GSkyRegion * set(const int &index, const GSkyRegion ®ion)
Set region in container.
void remove(const int &index)
Remove region from container.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
bool contains(const GSkyDir &dir) const
Check if direction is contained in one of the regions.
void read(const std::string &line)
Read region from DS9 string.
Circular sky region class interface definition.
Abstract sky region base class interface definition.
void reserve(const int &num)
Reserves space for regions in container.
void load(const GFilename &filename)
Load regions from DS9 region file.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
GSkyRegion * append(const GSkyRegion ®ion)
Append region to container.