anatomist  5.1.2
3D neuroimaging data viewer
Window.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_WINDOW_H
36 #define ANA_WINDOW_WINDOW_H
37 
38 //--- header files ------------------------------------------------------------
39 
42 #include <aims/vector/vector.h>
43 #include <aims/rgb/rgb.h>
46 
47 
48 namespace anatomist
49 {
50 
51  class AObject;
52  class Referential;
53  class Geometry;
54 
57  class ANATOMIST_API AWindow : virtual public carto::SharedObject, virtual public Observer
58  {
59  public:
60  enum Type
61  {
62  CTRL_WINDOW = 100,
63  WINDOW_2D = 101,
64  WINDOW_3D = 102,
65  };
66 
67  enum SubType
68  {
69  AXIAL_WINDOW = 200,
70  SAGITTAL_WINDOW = 201,
71  CORONAL_WINDOW = 202,
72  OBLIQUE_WINDOW = 203,
73  OTHER = 299
74  };
75 
77  {
78  OFF,
79  ON,
80  DISABLED
81  };
82 
84  virtual ~AWindow();
85 
91  virtual void iconify();
92  virtual void unIconify();
93  virtual void show();
94  virtual void hide();
95  virtual bool close() = 0;
98  virtual void showToolBars( int state = 2 );
99  virtual bool toolBarsVisible() const;
100  virtual void setFullScreen( int state = 2 );
101  virtual bool isFullScreen() const;
102  virtual void setGeometry( int x, int y, unsigned w, unsigned h ) = 0;
104  virtual void geometry( int *x, int *y, unsigned *w, unsigned *h ) = 0;
105  virtual void Refresh();
106  virtual void showReferential();
108  virtual void setupWindow() {}
110 
111  virtual std::string Title() const;
112  //virtual const char* Title_c() const;
113  virtual void registerObject( AObject* object,
114  bool temporaryObject = false,
115  int position = -1 );
116  virtual void unregisterObject( AObject* object );
117 
119  void setId(int id);
121  void SetRefreshFlag();
123  void ResetRefreshFlag();
124  bool lookupChanged() const { return( _lookupChanged ); }
125  void setLookupChanged( bool flg = true )
126  { _lookupChanged = flg; if( flg ) SetRefreshFlag(); }
128  int id() const;
130  virtual Type type() const = 0;
131  virtual SubType subtype() const { return( (SubType) 0 ); }
133  bool RefreshFlag() const;
135  std::set<AObject*> Objects() const;
136  bool hasObject( AObject * obj ) const;
138  virtual Point3df getPosition() const;
140  float getTime() const;
141  virtual std::vector<float> getFullPosition() const;
143  virtual void setPosition( const Point3df& position ,
144  const Referential *refdep );
145  virtual void setPosition( const std::vector<float> & position,
146  const Referential *refdep = 0 );
148  virtual void setTime( float time );
149  virtual void setTitle( const std::string & title );
150  Referential* getReferential() const { return _referential; }
151  virtual void setReferential( Referential* ref );
152  Geometry* windowGeometry() const { return _geometry; }
155  virtual void updateWindowGeometry() {}
156  int Group() const { return _group; }
157  void setGroup( int group ) { _group = group; }
158  void setHasCursor( int hasCursor );
160  bool hasCursor() const;
162  int hasSelfCursor() const;
163 
164  static void setLeftRightDisplay(bool state)
165  {
166  _leftRightDisplay = state;
167  }
168  static int leftRightDisplay()
169  {
170  return _leftRightDisplay;
171  }
172  static void setLeftRightDisplaySize(int size)
173  {
174  _leftRightDisplaySize = size;
175  }
176  static int leftRightDisplaySize()
177  {
178  return _leftRightDisplaySize;
179  }
181  const std::vector<std::string> & annotation_list)
182  {
183  _displayedAnnotations = annotation_list;
184  }
185  static std::vector<std::string> displayedAnnotations()
186  {
187  return _displayedAnnotations;
188  }
189  static void setGlobalHasCursor(bool hasCursor) { _hasCursor = hasCursor; }
190  static int hasGlobalCursor() { return( _hasCursor ); }
191  static void setCursorSize(int cursorSize) { _cursorSize = cursorSize; }
192  static int cursorSize() { return(_cursorSize); }
194  static void setUseDefaultCursorColor( bool state )
195  { _useDefaultCursorColor = state; }
197  static int useDefaultCursorColor() { return( _useDefaultCursorColor ); }
199  static void setCursorColor( const AimsRGB & cursCol );
203  static float selectTolerence() { return( _selectTolerence ); }
205  static void setSelectTolerence( float tol ) { _selectTolerence = tol; }
206  virtual void displayClickPoint() {}
210  virtual bool positionFromCursor( int x, int y, Point3df & pos );
211  virtual AObject* objectAt( const std::vector<float> & pos );
212 
214  virtual void selectObject( const std::vector<float> & pos,
215  int modifier );
217  virtual void button3clicked( int x, int y );
219  virtual void findObjectsAt( const std::vector<float> & pos,
220  std::set<AObject *> & shown,
221  std::set<AObject *> & hidden );
222 
223  virtual void update( const Observable* observable, void* arg );
224 
225  static void recordCbk( void* clientdata );
226  virtual void recordImages();
227  virtual RecordingState recordingState() const { return( DISABLED ); }
228  virtual void startRecord();
229  virtual void startRecord( const std::string & filename );
230  virtual void stopRecord() {}
232  virtual void createTitle() {}
233 
234  virtual const std::set<unsigned> & typeCount() const;
235  virtual std::set<unsigned> & typeCount();
236  virtual const std::string & baseTitle() const;
239  virtual bool needsRedraw() const { return( false ); }
240  bool isTemporary( AObject* o ) const;
241  const std::set<AObject *> & temporaryObjects() const
242  { return( _tempObjects ); }
243 
244  protected:
247 
250  virtual void unregisterObservable( Observable* obs );
256 
258  int _id;
260  bool _refresh;
264  std::list<carto::shared_ptr<AObject> > _objects;
266  std::set<AObject *> _sobjects;
267  std::set<AObject *> _tempObjects;
269  std::vector<float> _timepos;
275  std::string _title;
282  int _group;
285 
286  private:
287  struct Private;
288 
289  Private *d;
291  AWindow(const AWindow& x);
293  AWindow& operator=(const AWindow& x);
295  static bool _leftRightDisplay;
297  static int _leftRightDisplaySize;
299  static std::vector<std::string> _displayedAnnotations;
301  static bool _hasCursor;
303  static int _cursorSize;
305  static bool _useDefaultCursorColor;
307  static AimsRGB _cursorColor;
309  static float _selectTolerence;
310  };
311 
312 
313  //--- inline methods --------------------------------------------------------
314 
315  inline
316  void AWindow::setId( int id )
317  {
318  _id = id;
319  }
320 
321  inline
323  {
324  _refresh = true;
325  }
326 
327  inline
329  {
330  _refresh = false;
331  }
332 
333  inline
334  int AWindow::id() const
335  {
336  return _id;
337  }
338 
339 
340  inline
341  bool AWindow::RefreshFlag() const
342  {
343  return _refresh;
344  }
345 
346  inline
347  std::set<AObject*> AWindow::Objects() const
348  {
349  return _sobjects;
350  }
351 
352  inline
353  float AWindow::getTime() const
354  {
355  return _timepos[0];
356  }
357 
358  inline
359  std::string AWindow::Title() const
360  {
361  return( _title );
362  }
363 
364  /*inline
365  const char* AWindow::Title_c() const
366  {
367  return( _title.c_str() );
368  }*/
369 
370 
371  inline bool AWindow::positionFromCursor( int, int, Point3df & )
372  {
373  return( false );
374  }
375 
376 
377  inline void AWindow::startRecord( const std::string & )
378  {
379  }
380 
381 }
382 
383 
384 namespace carto
385 {
387  DECLARE_GENERIC_OBJECT_TYPE( std::set<anatomist::AWindow *> )
388  DECLARE_GENERIC_OBJECT_TYPE( std::vector<anatomist::AWindow *> )
389  DECLARE_GENERIC_OBJECT_TYPE( std::list<anatomist::AWindow *> )
390 }
391 
392 
393 #endif
394 
#define ANATOMIST_API
Base Anatomist object (abstract)
Definition: Object.h:96
Abstract base class Anatomist window.
Definition: Window.h:58
virtual void Refresh()
static int cursorSize()
Definition: Window.h:192
static void setCursorSize(int cursorSize)
Definition: Window.h:191
bool hasCursor() const
takes both the global and own flags into account
void setWindowGeometry(Geometry *geom)
int _group
Group number, for linked windows.
Definition: Window.h:282
Referential * _referential
Referentiel.
Definition: Window.h:271
std::list< carto::shared_ptr< AObject > > _objects
List of the objects contained in the window.
Definition: Window.h:264
virtual bool needsRedraw() const
returns true if a refresh has been triggered and not performed yet (in subclasses: AWindow always ret...
Definition: Window.h:239
std::set< AObject * > Objects() const
Get the objects.
Definition: Window.h:347
virtual void unregisterObservable(Observable *obs)
Called when an observable is destroyed, only called by Observable: don't use this function directly.
virtual void setPosition(const std::vector< float > &position, const Referential *refdep=0)
bool hasObject(AObject *obj) const
bool lookupChanged() const
Definition: Window.h:124
virtual void startRecord()
void displayTalairach()
Affiche les coordonnees de Talairach qui correspondent a la position du curseur lie (window 2D)
static std::vector< std::string > displayedAnnotations()
Definition: Window.h:185
bool RefreshFlag() const
Get the refresh flag status.
Definition: Window.h:341
std::string _title
Title of the window.
Definition: Window.h:275
virtual void setFullScreen(int state=2)
virtual bool positionFromCursor(int x, int y, Point3df &pos)
Translates mouse position to Anatomist geometry position.
Definition: Window.h:371
std::set< AObject * > _sobjects
Same but as a set (for fast search)
Definition: Window.h:266
Referential * getReferential() const
Definition: Window.h:150
virtual void registerObject(AObject *object, bool temporaryObject=false, int position=-1)
AWindow()
AWindow constructor registers itself in the application.
virtual RecordingState recordingState() const
Definition: Window.h:227
virtual void stopRecord()
Definition: Window.h:230
static void setGlobalHasCursor(bool hasCursor)
Definition: Window.h:189
float getTime() const
Get time position of cursor.
Definition: Window.h:353
virtual const std::set< unsigned > & typeCount() const
virtual void showToolBars(int state=2)
Shows or hides all tools (menu, toolbars) around the main view area.
static float selectTolerence()
Selection tolerence distance.
Definition: Window.h:203
static void setSelectTolerence(float tol)
Set the selection tolerence distance.
Definition: Window.h:205
static int useDefaultCursorColor()
Give the default color cursor flag.
Definition: Window.h:197
static void recordCbk(void *clientdata)
virtual void selectObject(const std::vector< float > &pos, int modifier)
Selects (highlights) object at a given 4D space position.
virtual SubType subtype() const
Definition: Window.h:131
virtual void displayClickPoint()
Definition: Window.h:206
virtual void geometry(int *x, int *y, unsigned *w, unsigned *h)=0
Get position and dimensions of the window.
std::set< AObject * > _tempObjects
Definition: Window.h:267
virtual void update(const Observable *observable, void *arg)
This method is called whenever the observed object is changed.
virtual void updateWindowGeometry()
adapts geometry to the current contents and referential
Definition: Window.h:155
Point3df _position
Click position.
Definition: Window.h:284
void ResetRefreshFlag()
Set the refresh flag off.
Definition: Window.h:328
virtual void iconify()
static int leftRightDisplay()
Definition: Window.h:168
virtual std::vector< float > getFullPosition() const
virtual void createTitle()
Creates a new title for the window.
Definition: Window.h:232
static void setLeftRightDisplay(bool state)
Definition: Window.h:164
int _id
Window identificator.
Definition: Window.h:258
virtual void findObjectsAt(const std::vector< float > &pos, std::set< AObject * > &shown, std::set< AObject * > &hidden)
finds objects at given position (internal)
virtual void setTitle(const std::string &title)
virtual void setPosition(const Point3df &position, const Referential *refdep)
Set position of cursor.
virtual bool close()=0
void setGroup(int group)
Definition: Window.h:157
void setId(int id)
Set the window identifier.
Definition: Window.h:316
int hasSelfCursor() const
returns the own flag of the window (see hasGlobalCursor) (tri-state)
virtual Type type() const =0
Get the window type (2D, 3D or control)
virtual void showReferential()
virtual void setTime(float time)
Set time position of cursor.
void setHasCursor(int hasCursor)
virtual AObject * objectAt(const std::vector< float > &pos)
virtual ~AWindow()
Unregisters from the application and other objects.
virtual void recordImages()
static void setLeftRightDisplaySize(int size)
Definition: Window.h:172
Geometry * windowGeometry() const
Definition: Window.h:152
virtual void setupWindow()
Sets correct size and lookup of the window.
Definition: Window.h:108
const std::set< AObject * > & temporaryObjects() const
Definition: Window.h:241
Geometry * _geometry
Geometry.
Definition: Window.h:273
void SetRefreshFlag()
Set the refresh flag on.
Definition: Window.h:322
virtual bool isFullScreen() const
void manageAutoReferential()
automatically set the contained objects referential to the window if it has not been set manually,...
static int leftRightDisplaySize()
Definition: Window.h:176
virtual bool toolBarsVisible() const
static int hasGlobalCursor()
Definition: Window.h:190
virtual void unregisterObject(AObject *object)
void setWindowTitle()
Set the title of the window.
virtual Point3df getPosition() const
Get position of cursor.
bool _refresh
Should the window be refreshed?
Definition: Window.h:260
int id() const
Get the window identifier.
Definition: Window.h:334
static void setDisplayedAnnotations(const std::vector< std::string > &annotation_list)
Definition: Window.h:180
bool _lookupChanged
Lookup has changed (title or geometry)
Definition: Window.h:262
virtual std::set< unsigned > & typeCount()
static void setUseDefaultCursorColor(bool state)
Set the default color cursor flag.
Definition: Window.h:194
virtual void unIconify()
int _instNumber
Number of instance of the window class.
Definition: Window.h:280
static void setCursorColor(const AimsRGB &cursCol)
Set the color cursor.
virtual void button3clicked(int x, int y)
handles button3 click (menu)
std::vector< float > _timepos
Cursor time + next dimensions.
Definition: Window.h:269
bool isTemporary(AObject *o) const
virtual std::string Title() const
Definition: Window.h:359
void setLookupChanged(bool flg=true)
Definition: Window.h:125
static AimsRGB cursorColor()
Give the color cursor.
virtual void hide()
virtual void setGeometry(int x, int y, unsigned w, unsigned h)=0
virtual void setReferential(Referential *ref)
virtual void show()
virtual const std::string & baseTitle() const
int Group() const
Definition: Window.h:156
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
Referential: marker for transformations, with an associated color.
Definition: Referential.h:55
#define DECLARE_GENERIC_OBJECT_TYPE(T)