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