anatomist  5.1.2
3D neuroimaging data viewer
roichangeprocessor.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 
34 #ifndef ROI_CHANGE_PROCESSOR
35 #define ROI_CHANGE_PROCESSOR
36 
37 #include <aims/bucket/bucket.h>
38 #include <anatomist/graph/Graph.h>
41 #include <aims/vector/vector.h>
42 #include <stack>
43 
44 namespace anatomist
45 {
46  class AObject ;
47 
48  struct ChangesItem{
51  } ;
52 
56  } ;
57 
58  class RoiChangeProcessor : public Observable {
59  public:
62 
63  void applyChange( std::list<std::pair<Point3d, ChangesItem> > * change ) ;
64  void undo() ;
65  void redo() ;
66 
67  void setUndoable( bool undoable ) ;
68  bool undoable()
69  {
70  AGraph * graph = getGraph(0) ;
71  if( graph == 0 ){
72  //cout << "Undoable :: graph nul" << endl ;
73  return false ;
74  }
75  return !( myChangesToUndo[graph].empty() ) ;
76  }
77  void setRedoable( bool redoable ) ;
78  bool redoable() {
79  AGraph * graph = getGraph(0) ;
80  if( graph == 0 ){
81  //cout << "Redoable :: graph nul" << endl ;
82  return false ;
83  }
84  return !( myChangesToRedo[graph].empty() ) ;
85  }
86  void noMoreUndoable() ;
90 
91  private:
92  void change( bool forward ) ;
93  RoiChangeProcessor( int maxNumberOfUndo = 20 ) : myUndoable(false), myRedoable(false),
94  myMaxNumberOfUndo(maxNumberOfUndo), myCurrentChanges(0),
95  myCurrentGraph(0) {}
96 
97  bool updateCurrentRegion( AWindow * ) ;
98  std::set<anatomist::AObject*> selectedObjectsInWindow( AWindow* ) ;
99 
100  static RoiChangeProcessor * _instance ;
101 
102  bool myUndoable ;
103  bool myRedoable ;
104  int myMaxNumberOfUndo ;
105  std::map< AGraph*, std::list< std::list< std::pair< Point3d, anatomist::ChangesItem> >* > >
106  myChangesToUndo ;
107  std::map< AGraph*, std::list< std::list< std::pair< Point3d, anatomist::ChangesItem> >* > >
108  myChangesToRedo ;
109  std::list< std::pair< Point3d, anatomist::ChangesItem> > * myCurrentChanges ;
110  AGraph * myCurrentGraph ;
111  Bucket * myCurrentRegion ;
112  } ;
113 }
114 
115 #endif
Anatomist graph object: a list that manages destruction of its sub-elements.
Definition: GraphObject.h:53
AGraph object class.
Definition: Graph.h:57
Base Anatomist object (abstract)
Definition: Object.h:96
Abstract base class Anatomist window.
Definition: Window.h:58
Bucket class.
Definition: Bucket.h:56
This class can be subclassed to represent an object that the programmer wants to have observed.
Definition: Observable.h:68
void setRedoable(bool redoable)
anatomist::AGraph * getGraph(AWindow *)
anatomist::AGraphObject * getGraphObject(AWindow *)
static RoiChangeProcessor * instance()
void setUndoable(bool undoable)
Bucket * getCurrentRegion(AWindow *)
void applyChange(std::list< std::pair< Point3d, ChangesItem > > *change)