casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RegionEnums.h
Go to the documentation of this file.
1 #ifndef REGION_REGIONENUM_H_
2 #define REGION_REGIONENUM_H_
3 
4 #include <string>
5 #include <set>
6 #include <stdio.h>
7 
8 namespace casa {
9  namespace viewer {
10 
11  class Region;
12 
13  namespace region {
14  typedef std::set<Region*> region_list_type;
15 
16  template<class T> void dump( const std::string &prefix, const std::set<T*> &s ) {
17  fprintf( stderr, "%s ", prefix.c_str( ) );
18  for ( typename std::set<T*>::const_iterator i=s.begin( ); i != s.end( ); ++i ) {
19  fprintf( stderr, "0x%x ", *i );
20  }
21  fprintf( stderr, "\n" );
22  }
23 
24 
25  /* enum states { undisplayed, inactive, highlighted, selected }; */
26  // LSDoubleDashed is only used to preserve state (it is a Display::LineStyle option)
29  enum TextFontStyle { ItalicText = 1 << 0, BoldText = 1 << 1 };
32 
33  // state returned from mouse functions for regions...
34  enum MouseState { MouseRefresh = 1 << 0, MouseSelected = 1 << 1, MouseHandle = 1 << 2 };
35 
39  return select == SelectRect ? RectRegion :
40  select == SelectPoint ? PointRegion :
41  select == SelectEllipse ? EllipseRegion :
42  select == SelectPoly ? PolyRegion :
43  select == SelectPolyline ? PolylineRegion :
44  select == SelectPVLine ? PVLineRegion : NonRegion;
45  }
46 
47 
48  enum PointLocation { PointInside = 1 << 0, PointHandle = 1 << 1, PointOutside = 1 << 2 };
49 
53  };
54 
55  class PointInfo {
56  public:
57  PointInfo( double x, double y, unsigned int location, unsigned int handle=0 ) :
58  x_(x), y_(y), location_(location), handle_(handle) { }
59  PointInfo( const PointInfo &other) : x_(other.x_), y_(other.y_), location_(other.location_), handle_(other.handle_) { }
60  unsigned int handle( ) const {
61  return handle_;
62  }
63  unsigned int &handle( ) {
64  return handle_;
65  }
66  unsigned int location( ) const {
67  return location_;
68  }
69  unsigned int operator&( region::PointLocation mask ) const {
70  return location_ & mask;
71  }
72  const PointInfo &operator=( const PointInfo &other ) {
73  x_ = other.x_;
74  y_ = other.y_;
75  location_ = other.location_;
76  handle_ = other.handle_;
77  return *this;
78  }
79  double x( ) const {
80  return x_;
81  }
82  double y( ) const {
83  return y_;
84  }
85  double &x( ) {
86  return x_;
87  }
88  double &y( ) {
89  return y_;
90  }
91  private:
92  double x_, y_;
93  unsigned int location_;
94  unsigned int handle_;
95  };
96 
97  }
98  }
99 }
100 
101 #endif
MouseState
state returned from mouse functions for regions...
Definition: RegionEnums.h:34
const PointInfo & operator=(const PointInfo &other)
Definition: RegionEnums.h:72
Elements::const_iterator const_iterator
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
unsigned int handle() const
Definition: RegionEnums.h:60
unsigned int operator&(region::PointLocation mask) const
Definition: RegionEnums.h:69
RegionTypes select_to_region(RegionSelect select)
Definition: RegionEnums.h:38
PointInfo(const PointInfo &other)
Definition: RegionEnums.h:59
unsigned int location() const
Definition: RegionEnums.h:66
PointInfo(double x, double y, unsigned int location, unsigned int handle=0)
Definition: RegionEnums.h:57
LineStyle
LSDoubleDashed is only used to preserve state (it is a Display::LineStyle option) ...
Definition: RegionEnums.h:27
std::set< Region * > region_list_type
Definition: RegionEnums.h:14
void dump(const std::string &prefix, const std::set< T * > &s)
Definition: RegionEnums.h:16