anatomist 6.0.4
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
43#include <aims/vector/vector.h>
44#include <aims/rgb/rgb.h>
45#include <cartobase/object/object.h>
46#include <cartobase/smart/sharedptr.h>
47
48
49namespace anatomist
50{
51
52 class AObject;
53 class Referential;
54 class Geometry;
55
58 class ANATOMIST_API AWindow : virtual public carto::SharedObject, virtual public Observer, virtual public Observable
59 {
60 public:
61 enum Type
62 {
64 WINDOW_2D = 101,
65 WINDOW_3D = 102,
66 };
67
69 {
74 OTHER = 299
75 };
76
83
85 virtual ~AWindow();
86
89
92 virtual void iconify();
93 virtual void unIconify();
94 virtual void show();
95 virtual void hide();
96 virtual bool close() = 0;
99 virtual void showToolBars( int state = 2 );
100 virtual bool toolBarsVisible() const;
101 virtual void setFullScreen( int state = 2 );
102 virtual bool isFullScreen() const;
103 virtual void setGeometry( int x, int y, unsigned w, unsigned h ) = 0;
105 virtual void geometry( int *x, int *y, unsigned *w, unsigned *h ) = 0;
106 virtual void Refresh();
107 virtual void showReferential();
109 virtual void setupWindow() {}
111
112 virtual std::string Title() const;
113 //virtual const char* Title_c() const;
114 virtual void registerObject( AObject* object,
115 bool temporaryObject = false,
116 int position = -1 );
117 virtual void unregisterObject( AObject* object );
118
120 void setId(int id);
122 void SetRefreshFlag();
124 void ResetRefreshFlag();
125 bool lookupChanged() const { return( _lookupChanged ); }
126 void setLookupChanged( bool flg = true )
127 { _lookupChanged = flg; if( flg ) SetRefreshFlag(); }
128
129 int id() const;
131 virtual Type type() const = 0;
132 virtual SubType subtype() const { return( (SubType) 0 ); }
134 bool RefreshFlag() const;
136 std::set<AObject*> Objects() const;
137 bool hasObject( AObject * obj ) const;
139 virtual Point3df getPosition() const;
141 float getTime() const;
142 virtual std::vector<float> getFullPosition() const;
144 virtual void setPosition( const Point3df& position ,
145 const Referential *refdep );
146 virtual void setPosition( const std::vector<float> & position,
147 const Referential *refdep = 0 );
149 virtual void setTime( float time );
150 virtual void setTitle( const std::string & title );
153 Geometry* windowGeometry() const { return _geometry; }
156 virtual void updateWindowGeometry() {}
157 int Group() const { return _group; }
158 void setGroup( int group ) { _group = group; }
161 bool hasCursor() const;
163 int hasSelfCursor() const;
164
165 static void setLeftRightDisplay(bool state)
166 {
167 _leftRightDisplay = state;
168 }
169 static int leftRightDisplay()
170 {
171 return _leftRightDisplay;
172 }
173 static void setLeftRightDisplaySize(int size)
174 {
175 _leftRightDisplaySize = size;
176 }
178 {
179 return _leftRightDisplaySize;
180 }
182 const std::vector<std::string> & annotation_list)
183 {
184 _displayedAnnotations = annotation_list;
185 }
186 static std::vector<std::string> displayedAnnotations()
187 {
188 return _displayedAnnotations;
189 }
190 static void setGlobalHasCursor(bool hasCursor) { _hasCursor = hasCursor; }
191 static int hasGlobalCursor() { return( _hasCursor ); }
192 static void setCursorSize(int cursorSize) { _cursorSize = cursorSize; }
193 static int cursorSize() { return(_cursorSize); }
195 static void setUseDefaultCursorColor( bool state )
196 { _useDefaultCursorColor = state; }
197
198 static int useDefaultCursorColor() { return( _useDefaultCursorColor ); }
200 static void setCursorColor( const AimsRGB & cursCol );
204 static float selectTolerence() { return( _selectTolerence ); }
206 static void setSelectTolerence( float tol ) { _selectTolerence = tol; }
207 virtual void displayClickPoint() {}
211 virtual bool positionFromCursor( int x, int y, Point3df & pos );
212 virtual AObject* objectAt( const std::vector<float> & pos );
213
215 virtual void selectObject( const std::vector<float> & pos,
216 int modifier );
218 virtual void button3clicked( int x, int y );
220 virtual void findObjectsAt( const std::vector<float> & pos,
221 std::set<AObject *> & shown,
222 std::set<AObject *> & hidden );
223
224 virtual void update( const Observable* observable, void* arg );
225
226 static void recordCbk( void* clientdata );
227 virtual void recordImages();
228 virtual RecordingState recordingState() const { return( DISABLED ); }
229 virtual void startRecord();
230 virtual void startRecord( const std::string & filename );
231 virtual void stopRecord() {}
233 virtual void createTitle() {}
234
235 virtual const std::set<unsigned> & typeCount() const;
236 virtual std::set<unsigned> & typeCount();
237 virtual const std::string & baseTitle() const;
240 virtual bool needsRedraw() const { return( false ); }
241 bool isTemporary( AObject* o ) const;
242 const std::set<AObject *> & temporaryObjects() const
243 { return( _tempObjects ); }
244
245 protected:
248
251 virtual void unregisterObservable( Observable* obs );
257
259 int _id;
265 std::list<carto::shared_ptr<AObject> > _objects;
267 std::set<AObject *> _sobjects;
268 std::set<AObject *> _tempObjects;
270 std::vector<float> _timepos;
276 std::string _title;
286
287 private:
288 struct Private;
289
290 Private *d;
292 AWindow(const AWindow& x);
294 AWindow& operator=(const AWindow& x);
296 static bool _leftRightDisplay;
298 static int _leftRightDisplaySize;
300 static std::vector<std::string> _displayedAnnotations;
302 static bool _hasCursor;
304 static int _cursorSize;
306 static bool _useDefaultCursorColor;
308 static AimsRGB _cursorColor;
310 static float _selectTolerence;
311 };
312
313
314 //--- inline methods --------------------------------------------------------
315
316 inline
317 void AWindow::setId( int id )
318 {
319 _id = id;
320 }
321
322 inline
324 {
325 _refresh = true;
326 }
327
328 inline
330 {
331 _refresh = false;
332 }
333
334 inline
335 int AWindow::id() const
336 {
337 return _id;
338 }
339
340
341 inline
343 {
344 return _refresh;
345 }
346
347 inline
348 std::set<AObject*> AWindow::Objects() const
349 {
350 return _sobjects;
351 }
352
353 inline
354 float AWindow::getTime() const
355 {
356 return _timepos[0];
357 }
358
359 inline
360 std::string AWindow::Title() const
361 {
362 return( _title );
363 }
364
365 /*inline
366 const char* AWindow::Title_c() const
367 {
368 return( _title.c_str() );
369 }*/
370
371
372 inline bool AWindow::positionFromCursor( int, int, Point3df & )
373 {
374 return( false );
375 }
376
377
378 inline void AWindow::startRecord( const std::string & )
379 {
380 }
381
382}
383
384
385namespace carto
386{
388 DECLARE_GENERIC_OBJECT_TYPE( std::set<anatomist::AWindow *> )
389 DECLARE_GENERIC_OBJECT_TYPE( std::vector<anatomist::AWindow *> )
390 DECLARE_GENERIC_OBJECT_TYPE( std::list<anatomist::AWindow *> )
391}
392
393
394#endif
395
#define ANATOMIST_API
Base Anatomist object (abstract)
Definition Object.h:97
Abstract base class Anatomist window.
Definition Window.h:59
virtual void Refresh()
static int cursorSize()
Definition Window.h:193
static void setCursorSize(int cursorSize)
Definition Window.h:192
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:283
Referential * _referential
Referentiel.
Definition Window.h:272
std::list< carto::shared_ptr< AObject > > _objects
List of the objects contained in the window.
Definition Window.h:265
virtual bool needsRedraw() const
returns true if a refresh has been triggered and not performed yet (in subclasses: AWindow always ret...
Definition Window.h:240
std::set< AObject * > Objects() const
Get the objects.
Definition Window.h:348
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:125
virtual void startRecord()
void displayTalairach()
Affiche les coordonnees de Talairach qui correspondent a la position du curseur lie (window 2D)
Geometry * windowGeometry() const
Definition Window.h:153
bool RefreshFlag() const
Get the refresh flag status.
Definition Window.h:342
std::string _title
Title of the window.
Definition Window.h:276
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:372
virtual AObject * objectAt(const std::vector< float > &pos)
std::set< AObject * > _sobjects
Same but as a set (for fast search)
Definition Window.h:267
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:228
virtual void stopRecord()
Definition Window.h:231
static void setGlobalHasCursor(bool hasCursor)
Definition Window.h:190
float getTime() const
Get time position of cursor.
Definition Window.h:354
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:204
static void setSelectTolerence(float tol)
Set the selection tolerence distance.
Definition Window.h:206
static int useDefaultCursorColor()
Give the default color cursor flag.
Definition Window.h:198
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:132
virtual std::set< unsigned > & typeCount()
virtual void displayClickPoint()
Definition Window.h:207
virtual std::vector< float > getFullPosition() const
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:268
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:156
virtual const std::set< unsigned > & typeCount() const
Point3df _position
Click position.
Definition Window.h:285
void ResetRefreshFlag()
Set the refresh flag off.
Definition Window.h:329
virtual void iconify()
static int leftRightDisplay()
Definition Window.h:169
virtual void createTitle()
Creates a new title for the window.
Definition Window.h:233
static void setLeftRightDisplay(bool state)
Definition Window.h:165
int _id
Window identificator.
Definition Window.h:259
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:158
void setId(int id)
Set the window identifier.
Definition Window.h:317
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 ~AWindow()
Unregisters from the application and other objects.
virtual void recordImages()
virtual const std::string & baseTitle() const
static void setLeftRightDisplaySize(int size)
Definition Window.h:173
virtual void setupWindow()
Sets correct size and lookup of the window.
Definition Window.h:109
Geometry * _geometry
Geometry.
Definition Window.h:274
void SetRefreshFlag()
Set the refresh flag on.
Definition Window.h:323
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:177
virtual bool toolBarsVisible() const
static int hasGlobalCursor()
Definition Window.h:191
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:261
int id() const
Get the window identifier.
Definition Window.h:335
static std::vector< std::string > displayedAnnotations()
Definition Window.h:186
static void setDisplayedAnnotations(const std::vector< std::string > &annotation_list)
Definition Window.h:181
bool _lookupChanged
Lookup has changed (title or geometry)
Definition Window.h:263
static void setUseDefaultCursorColor(bool state)
Set the default color cursor flag.
Definition Window.h:195
virtual void unIconify()
int _instNumber
Number of instance of the window class.
Definition Window.h:281
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:270
bool isTemporary(AObject *o) const
virtual std::string Title() const
Definition Window.h:360
void setLookupChanged(bool flg=true)
Definition Window.h:126
Referential * getReferential() const
Definition Window.h:151
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()
const std::set< AObject * > & temporaryObjects() const
Definition Window.h:242
int Group() const
Definition Window.h:157
A class can implement the Observer interface when it wants to be informed of changes in observable ob...
Definition Observer.h:55
friend class Observable
Definition Observer.h:90
Referential: marker for transformations, with an associated color.
Definition Referential.h:56
friend friend class ref
#define DECLARE_GENERIC_OBJECT_TYPE(T)
carto::VoxelRGB AimsRGB
AimsVector< float, 3 > Point3df