anatomist  4.7.0
3D neuroimaging data viewer
winFactory.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_WINDOW_WINFACTORY
36 #define ANA_WINDOW_WINFACTORY
37 
38 
40 
41 
42 namespace anatomist
43 {
44 
45  class AWindow;
46 
49  {
50  public:
51  virtual ~AWindowCreator();
52  virtual AWindow* operator() ( void *dock, carto::Object ) const = 0;
53  };
54 
55 
60  {
61  public:
62  typedef AWindow* (*WinCreator)( void *dock, carto::Object );
63 
64  //AWindowFactory();
65  //virtual ~AWindowFactory();
66 
67  static AWindow* createWindow( const std::string & type, void *dock = 0,
68  carto::Object params = carto::none() );
69  static AWindow* createWindow( int type, void *dock = 0,
70  carto::Object params = carto::none() );
71  static bool initTypes();
72  static std::string typeString( int type, int subtype = 0 );
73  static int typeID( const std::string & type );
74  static bool exist( int type );
75  static bool exist( const std::string & type );
76  static int registerType( const std::string & type, WinCreator creator,
77  bool visibleinCtrlWin=false );
78  static int registerType( const std::string & type, AWindowCreator *c,
79  bool visibleinCtrlWin=false );
80  static std::set<std::string> types();
81  static const std::map<std::string, int> & typeID() { return( TypeID ); }
82  static const std::map<int, std::string> & typeNames()
83  { return( TypeNames ); }
84  static const std::map<int, carto::rc_ptr<AWindowCreator> > & creators()
85  { return( Creators ); }
86  static bool hasControlWindowButton( int type );
87  static void setHasControlWindowButton( int type, bool visible );
88 
89  protected:
90  static AWindow* createAxial( void *, carto::Object );
91  static AWindow* createSagittal( void *, carto::Object );
92  static AWindow* createCoronal( void *, carto::Object );
93  static AWindow* create3D( void *, carto::Object );
94  static void applyCommonOptions( AWindow* win, carto::Object params );
95 
96  static std::map<int, std::string> TypeNames;
97  static std::map<std::string, int> TypeID;
98  static std::map<int, carto::rc_ptr<AWindowCreator> > Creators;
99  static std::set<int> CtrlWinVisibleTypes;
100 
101  friend class StaticInitializers;
102 
103  private:
104  };
105 
106 
109  {
110  public:
112  : _func( func ) {}
113  virtual ~AWindowCreatorFunc();
114 
115  virtual AWindow* operator() ( void *dock, carto::Object ) const;
116 
117  private:
119  };
120 
121 }
122 
123 
124 #endif
static const std::map< std::string, int > & typeID()
Definition: winFactory.h:81
Virtual functor for AWindowFactory.
Definition: winFactory.h:48
Virtual functor for AWindowFactory, using a function pointer.
Definition: winFactory.h:108
Abstract base class Anatomist window.
Definition: Window.h:57
static std::set< int > CtrlWinVisibleTypes
Definition: winFactory.h:99
static std::map< std::string, int > TypeID
Definition: winFactory.h:97
Window creator: (string) type -> new window.
Definition: winFactory.h:59
static std::map< int, carto::rc_ptr< AWindowCreator > > Creators
Definition: winFactory.h:98
static const std::map< int, carto::rc_ptr< AWindowCreator > > & creators()
Definition: winFactory.h:84
static std::map< int, std::string > TypeNames
Definition: winFactory.h:96
AWindow *(* WinCreator)(void *dock, carto::Object)
Definition: winFactory.h:62
static const std::map< int, std::string > & typeNames()
Definition: winFactory.h:82
Object none()
AWindowCreatorFunc(AWindowFactory::WinCreator func)
Definition: winFactory.h:111
virtual AWindow * operator()(void *dock, carto::Object) const =0