anatomist  5.0.5
3D neuroimaging data viewer
objectmenu.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 
35 #ifndef ANA_OBJECT_OBJECTMENU_H
36 #define ANA_OBJECT_OBJECTMENU_H
37 
38 #include <cartobase/smart/rcptr.h>
40 #include <string>
41 #include <vector>
42 #include <set>
43 
44 class Tree;
45 
46 namespace anatomist
47 {
48 
49  class AObject;
50 
52  {
53  public:
55  virtual ~ObjectMenuCallback();
56 
60  virtual void doit( const std::set<AObject *> & obj ) = 0;
61  virtual bool operator == ( const ObjectMenuCallback & ) const;
62  virtual bool operator != ( const ObjectMenuCallback & ) const;
63  };
64 
65 
67  {
68  public:
69  typedef void (*CallbackFunc)( const std::set<AObject *> & );
70  ObjectMenuCallbackFunc( CallbackFunc cbk );
71  virtual ~ObjectMenuCallbackFunc();
72 
73  virtual void doit( const std::set<AObject *> & obj );
74  virtual bool operator == ( const ObjectMenuCallback & ) const;
75 
76  private:
77  CallbackFunc _func;
78  };
79 
80 
81  class ObjectMenu : public carto::RCObject
82  {
83  public:
84  ObjectMenu();
85  ObjectMenu( const ObjectMenu & );
86  ObjectMenu( Tree & t);
87  ~ObjectMenu();
88 
89  ObjectMenu & operator = ( const ObjectMenu & );
90 
92  void insertItem( const std::vector<std::string> & inside,
93  const std::string & text );
98  void insertItem( const std::vector<std::string> & inside,
99  const std::string & text, ObjectMenuCallback* cbk );
101  void insertItem( const std::vector<std::string> & inside,
102  const std::string & text,
104  Tree* item( const std::vector<std::string> & pos,
105  bool createSubtrees = true );
106  Tree* tree();
107  const Tree* tree() const;
109  Tree* releaseTree();
110 
111  private:
112  struct Private;
113  Private *d;
114  };
115 
116 
118  {
119  public:
121  virtual ~ObjectMenuRegistrerClass();
122 
123  virtual ObjectMenu* doit( const AObject*, ObjectMenu* ) = 0;
124  };
125 
126 
128  {
129  public:
130  typedef ObjectMenu* (*RegistrerFunc)( const AObject*, ObjectMenu* );
131  ObjectMenuRegistrerFuncClass( RegistrerFunc );
132  virtual ~ObjectMenuRegistrerFuncClass();
133 
134  virtual ObjectMenu* doit( const AObject*, ObjectMenu* );
135 
136  private:
137  RegistrerFunc _f;
138  };
139 
140 }
141 
142 namespace carto
143 {
145 }
146 #endif
147 
#define DECLARE_GENERIC_OBJECT_TYPE(T)
Base Anatomist object (abstract)
Definition: Object.h:95
virtual bool operator==(const ObjectMenuCallback &) const
RCObject & operator=(const RCObject &)
void(* CallbackFunc)(const std::set< AObject *> &)
Definition: objectmenu.h:69
virtual bool operator!=(const ObjectMenuCallback &) const
virtual void doit(const std::set< AObject *> &obj)=0
executes the callback