anatomist  5.1.2
3D neuroimaging data viewer
levelsetaction.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 #ifndef ROI_LEVELSET_ACTION_H
34 #define ROI_LEVELSET_ACTION_H
35 
42 
43 #include <aims/bucket/bucketMap.h>
44 #include <QWidget>
45 #include <queue>
46 
47 
48 namespace anatomist
49 {
50 
51  class Bucket ;
52  class AObject ;
53  class AGraphObject ;
54  class RoiLevelSetActionView_Private ;
55 
57  public:
60  THREED
61  } ;
64  virtual void update (const Observable *observable, void *arg) ;
65 
66  int maxSize() { return (int) myMaxSize ; }
67  int percentageOfMaximum() { return (int) myPercentageOfMaximum ; }
68 
69  private:
70  friend class RoiLevelSetAction ;
71 
73  static RoiLevelSetActionSharedData * _instance ;
74 
75  bool myLevelSetActivation ;
76  bool myLevelSetDeactivation ;
77  anatomist::AObject * myCurrentImage ;
78  DimensionMode myDimensionMode ;
79  float myLowLevel ;
80  float myHighLevel ;
81  float myImageMax ;
82  float myImageMin ;
83  float myMaxSize ;
84  float myPercentageOfMaximum ;
85  std::string myMixMethod ;
86  float myMixFactor ;
87  bool myGettingCurrentImage ;
88  bool myActivatingLevelSet ;
89  bool myUpdating ;
90 
91  } ;
92 
93  class RoiLevelSetAction : public Action//, public Observer, public Observable
94  {
95  public:
98  THREED
99  } ;
100 
102  virtual ~RoiLevelSetAction() ;
103  virtual void update( const anatomist::Observable *, void * ) ;
104 
105  virtual std::string name() const;
106 
109  void lowLevelChanged( float newLowLevel ) ;
110  void highLevelChanged( float newHighLevel ) ;
111 
112  int dimensionMode() { return _sharedData->myDimensionMode ; }
113  float lowLevel() { return _sharedData->myLowLevel ; }
114  float highLevel() { return _sharedData->myHighLevel ; }
115  float imageMax() { return _sharedData->myImageMax ; }
116  float imageMin() { return _sharedData->myImageMin ; }
117  bool levelSetActivation() { return _sharedData->myLevelSetActivation ; }
118  float mixFactor() { return _sharedData->myMixFactor ; }
119  float maxSize() { return _sharedData->myMaxSize ; }
120  float percentageOfMaximum() { return _sharedData->myPercentageOfMaximum ; }
121  std::string mixMethod() { return _sharedData->myMixMethod ; }
122 
125  void setMixMethod( const std::string& ) ;
126  void setMixFactor( float ) ;
127  void setMaxSize( float maxSize ) ;
129 
130  void replaceRegion( int x, int y, int globalX, int globalY ) ;
131  void addToRegion( int x, int y, int globalX, int globalY ) ;
132  void removeFromRegion( int x, int y, int globalX, int globalY ) ;
133 
134  float realMin( ) const ;
135  float realMax( ) const ;
136 
137  virtual QWidget * actionView( QWidget * ) ;
138  virtual bool viewableAction( ) const { return true ; }
139 
140  static Action* creator() ;
141 
142 
143  protected:
145 
146 
147  private:
148  RoiLevelSetActionSharedData * _sharedData ;
149  void updateObjPal() ;
150  AObject * getCurrentImage() ;
151  void fillRegion( int x, int y, anatomist::AGraphObject * region,
152  std::list< std::pair< Point3d, ChangesItem> >& changes, bool add ) ;
153  bool fillPoint( const Point3d& pc, int t,
155  anatomist::AGraphObject * region, float realLowLevel,
156  float realHighLevel,
157  anatomist::AObject** toChange,
158  std::queue<Point3d>& trialPoints, bool replace = false ) ;
159  bool in( const Point3d&, Point3d p ) ;
160 
161  struct PointLess : public std::binary_function< Point3d, Point3d , bool>
162  {
163  bool operator () ( const Point3d & p1, const Point3d & p2 ) const
164  {
165  return( p1[2] < p2[2]
166  || ( (p1[2] == p2[2]) && (p1[1] < p2[1]) )
167  || ( (p1[2] == p2[2])
168  && (p1[1] == p2[1]) && (p1[0] < p2[0]) ) ) ;
169  }
170  };
171 
172 
173  };
174 };
175 
176 
177 
178 class RoiLevelSetActionView : public QWidget, public anatomist::Observer
179 {
180  Q_OBJECT
181 
182 public:
184  QWidget * parent ) ;
186 
187  virtual void update( const anatomist::Observable *, void * ) ;
188 
189 public slots:
190  void levelSetActivationChanged( int button ) ;
191  void lowLevelChanged( int newLowLevel ) ;
192  void highLevelChanged( int newHighLevel ) ;
193  void dimensionModeChanged( int newDimensionMode ) ;
194  void maxSizeChanged( const QString& newMaxSize ) ;
195  void percentageOfMaxChanged(const QString&) ;
196  void mixFactorChanged( int newMixFactor ) ;
197  void mixMethodChanged( const QString& newMixMethod ) ;
198 
199 private:
200  float myChangingFlag ;
201  float myUpdatingFlag ;
202  anatomist::RoiLevelSetActionView_Private * _private ;
203 };
204 
205 
206 
207 #endif
#define slots
void mixMethodChanged(const QString &newMixMethod)
void lowLevelChanged(int newLowLevel)
void percentageOfMaxChanged(const QString &)
void levelSetActivationChanged(int button)
void mixFactorChanged(int newMixFactor)
RoiLevelSetActionView(anatomist::RoiLevelSetAction *myAction, QWidget *parent)
void dimensionModeChanged(int newDimensionMode)
void maxSizeChanged(const QString &newMaxSize)
void highLevelChanged(int newHighLevel)
virtual void update(const anatomist::Observable *, void *)
This method is called whenever the observed object is changed.
virtual ~RoiLevelSetActionView()
Anatomist graph object: a list that manages destruction of its sub-elements.
Definition: GraphObject.h:53
Base Anatomist object (abstract)
Definition: Object.h:96
This class can be subclassed to represent an object that the programmer wants to have observed.
Definition: Observable.h:68
A class can implement the Observer interface when it wants to be informed of changes in observable ob...
Definition: Observer.h:55
virtual void update(const Observable *observable, void *arg)
This method is called whenever the observed object is changed.
static RoiLevelSetActionSharedData * instance()
virtual bool viewableAction() const
void replaceRegion(int x, int y, int globalX, int globalY)
void setPercentageOfMaximum(float percentageOfMaximum)
void highLevelChanged(float newHighLevel)
virtual void unregisterObservable(anatomist::Observable *)
void setMaxSize(float maxSize)
static Action * creator()
void setMixMethod(const std::string &)
void addToRegion(int x, int y, int globalX, int globalY)
virtual QWidget * actionView(QWidget *)
virtual std::string name() const
void removeFromRegion(int x, int y, int globalX, int globalY)
virtual void update(const anatomist::Observable *, void *)
void lowLevelChanged(float newLowLevel)