Commit 5615dc71a031d949374f7ab7dfabe6cfc8ad160d
Committed by
Jürgen Knödlseder
1 parent
52025293
big fixes
Showing
5 changed files
with
27 additions
and
18 deletions
include/GSkyRegionCircle.hpp
| ... | ... | @@ -131,6 +131,7 @@ GSkyDir GSkyRegionCircle::centre(void) const |
| 131 | 131 | * |
| 132 | 132 | * @param[in] dir Center of region. |
| 133 | 133 | ***************************************************************************/ |
| 134 | +inline | |
| 134 | 135 | void GSkyRegionCircle::centre(const GSkyDir& dir) |
| 135 | 136 | { |
| 136 | 137 | // Set centre |
| ... | ... | @@ -147,6 +148,7 @@ void GSkyRegionCircle::centre(const GSkyDir& dir) |
| 147 | 148 | * @param[in] ra Right ascension value. |
| 148 | 149 | * @param[in] dec declination value. |
| 149 | 150 | ***************************************************************************/ |
| 151 | +inline | |
| 150 | 152 | void GSkyRegionCircle::centre(const double& ra, const double& dec) |
| 151 | 153 | { |
| 152 | 154 | // Set centre values | ... | ... |
include/GSkyRegions.hpp
| ... | ... | @@ -32,7 +32,7 @@ |
| 32 | 32 | #include <vector> |
| 33 | 33 | #include "GBase.hpp" |
| 34 | 34 | #include "GSkyRegion.hpp" |
| 35 | - | |
| 35 | +#include "GException.hpp" | |
| 36 | 36 | |
| 37 | 37 | /***********************************************************************//** |
| 38 | 38 | * @class GSkyRegions |
| ... | ... | @@ -168,4 +168,4 @@ void GSkyRegions::reserve(const int& num) |
| 168 | 168 | return; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | -#endif /* GSKYREGIONS_HPP */ | |
| 172 | 171 | \ No newline at end of file |
| 172 | +#endif /* GSKYREGIONS_HPP */ | ... | ... |
pyext/GSkyRegion.i
| ... | ... | @@ -47,7 +47,7 @@ public: |
| 47 | 47 | // Pure virtual methods |
| 48 | 48 | virtual void clear(void) = 0; |
| 49 | 49 | virtual GSkyRegion* clone(void) const = 0; |
| 50 | - virtual void read(const std::string regstring) const = 0; | |
| 50 | + virtual void read(const std::string regstring) = 0; | |
| 51 | 51 | virtual std::string write() const = 0; |
| 52 | 52 | virtual bool contains(const GSkyDir& dir) const = 0; |
| 53 | 53 | virtual bool overlaps(const GSkyRegion& reg) const = 0; | ... | ... |
pyext/GSkyRegionCircle.i
| ... | ... | @@ -55,7 +55,7 @@ public: |
| 55 | 55 | void radius(const double& radius); |
| 56 | 56 | void centre(const GSkyDir& centre); |
| 57 | 57 | void centre(const double& ra,const double& dec); |
| 58 | - void read(const std::string line) const; | |
| 58 | + void read(const std::string line); | |
| 59 | 59 | std::string write() const; |
| 60 | 60 | bool contains(const GSkyDir& dir) const; |
| 61 | 61 | bool contains(const GSkyRegion& reg) const; | ... | ... |
src/sky/GSkyRegions.cpp
| ... | ... | @@ -31,7 +31,10 @@ |
| 31 | 31 | #endif |
| 32 | 32 | #include "GBase.hpp" |
| 33 | 33 | #include "GSkyRegion.hpp" |
| 34 | +#include "GSkyRegionCircle.hpp" | |
| 34 | 35 | #include "GSkyRegions.hpp" |
| 36 | +#include "GTools.hpp" | |
| 37 | + | |
| 35 | 38 | |
| 36 | 39 | /* __ Method name definitions ____________________________________________ */ |
| 37 | 40 | #define G_ACCESS1 "GSkyRegions::operator[](int&)" |
| ... | ... | @@ -650,7 +653,7 @@ bool GSkyRegions::contains(const std::string& name) const |
| 650 | 653 | * |
| 651 | 654 | * Loads all regions from a DS9 region file. See the read() method for more |
| 652 | 655 | * information about the expected structure of the XML file. |
| 653 | - * @todo | |
| 656 | + | |
| 654 | 657 | ***************************************************************************/ |
| 655 | 658 | void GSkyRegions::load(const std::string& filename) |
| 656 | 659 | { |
| ... | ... | @@ -658,7 +661,8 @@ void GSkyRegions::load(const std::string& filename) |
| 658 | 661 | clear(); |
| 659 | 662 | |
| 660 | 663 | // Open file. Throw an exception if opening failed. |
| 661 | - ifstream ds9file(filename); | |
| 664 | + std::ifstream ds9file; | |
| 665 | + ds9file.open(filename.c_str()); | |
| 662 | 666 | if (ds9file.is_open()) { |
| 663 | 667 | |
| 664 | 668 | // Loop over file lines |
| ... | ... | @@ -670,7 +674,7 @@ void GSkyRegions::load(const std::string& filename) |
| 670 | 674 | getline (ds9file,fileline); |
| 671 | 675 | |
| 672 | 676 | // If line is a comment then continue |
| 673 | - if (fileline[0] == "#") continue; | |
| 677 | + if (fileline[0] == '#') continue; | |
| 674 | 678 | |
| 675 | 679 | // Check for global definition of coordinate system |
| 676 | 680 | if (std::string::npos != fileline.find("fk5")) { |
| ... | ... | @@ -678,12 +682,12 @@ void GSkyRegions::load(const std::string& filename) |
| 678 | 682 | } |
| 679 | 683 | |
| 680 | 684 | // If region is a circle |
| 681 | - if (std::string::npos != fileline.find("circle") { | |
| 685 | + if (std::string::npos != fileline.find("circle")) { | |
| 682 | 686 | // Create instance of GSkyRegion object |
| 683 | 687 | GSkyRegionCircle region; |
| 684 | 688 | // If coordinate system and region defined on the same line |
| 685 | - if (std::string::npos != fileline.find("fk5")) || | |
| 686 | - (std::string::npos != fileline.find("galactic")) { | |
| 689 | + if ((std::string::npos != fileline.find("fk5")) || | |
| 690 | + (std::string::npos != fileline.find("galactic"))) { | |
| 687 | 691 | region.read(fileline); |
| 688 | 692 | append(region); |
| 689 | 693 | // else, prepend the coordinate system |
| ... | ... | @@ -695,7 +699,7 @@ void GSkyRegions::load(const std::string& filename) |
| 695 | 699 | append(region); |
| 696 | 700 | } |
| 697 | 701 | // Free object (the append method made a deep copy) |
| 698 | - delete region; | |
| 702 | + delete ®ion; | |
| 699 | 703 | } |
| 700 | 704 | } |
| 701 | 705 | |
| ... | ... | @@ -722,15 +726,18 @@ void GSkyRegions::load(const std::string& filename) |
| 722 | 726 | void GSkyRegions::save(const std::string& filename) const |
| 723 | 727 | { |
| 724 | 728 | // Open file. Throw an exception if opening failed. |
| 725 | - ofstream ds9file(filename); | |
| 726 | - if (ds9file.is_open()) { | |
| 729 | + std::ofstream ds9file; | |
| 730 | + ds9file.open(filename.c_str()); | |
| 731 | + | |
| 732 | + if (ds9file.is_open()) { | |
| 727 | 733 | |
| 728 | 734 | // Write global definition |
| 729 | - std::string fileline="# Region file format: DS9 version 4.1\n"+ | |
| 730 | - "global color=green dashlist=8 3 width=1"+ | |
| 731 | - "font=\"helvetica 10 normal\" select=1"+ | |
| 732 | - "highlite=1 dash=0 fixed=0 edit=1 move=1"+ | |
| 733 | - "delete=1 include=1 source=1\n"; | |
| 735 | + std::string fileline; | |
| 736 | + fileline.append("# Region file format: DS9 version 4.1\n"); | |
| 737 | + fileline.append("global color=green dashlist=8 3 width=1"); | |
| 738 | +// fileline.append("font=\"helvetica 10 normal\" select=1"); | |
| 739 | +// "highlite=1 dash=0 fixed=0 edit=1 move=1"+ | |
| 740 | +// "delete=1 include=1 source=1\n"; | |
| 734 | 741 | ds9file << fileline; |
| 735 | 742 | |
| 736 | 743 | // Loop over regions in container | ... | ... |