anatomist  5.0.5
3D neuroimaging data viewer
window3D.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_WINDOW3D_WINDOW3D_H
36 #define ANA_WINDOW3D_WINDOW3D_H
37 
38 
44 
45 namespace aims
46 {
47  class Quaternion;
48 }
49 
50 namespace anatomist
51 {
52  class Light;
53  class GLWidgetManager;
54  class OrientationAnnotation;
55 
56  namespace internal
57  {
58  class AGraphicsView;
59  }
60 
61 }
62 
63 class QGLWidget;
64 class QSlider;
65 
66 
70 {
71  Q_OBJECT
72 
73 public:
74  enum ViewType
75  {
80  ThreeD
81  };
82 
84  {
89  Fast
90  };
91 
92  enum ClipMode
93  {
96  Double
97  };
98 
101  {
102  public:
104  virtual ~ObjectModifier();
105  virtual void modify( anatomist::AObject*, anatomist::GLPrimitives & ) = 0;
106  AWindow3D *window() { return _window; }
107 
108  private:
109  AWindow3D *_window;
110  };
111 
112 
113  AWindow3D( ViewType t = Oblique, QWidget* parent = 0,
114  carto::Object params = carto::none(),
115  Qt::WindowFlags f = 0 );
116  virtual ~AWindow3D();
117 
119  virtual Type type() const;
120  virtual SubType subtype() const;
121  virtual void registerObject( anatomist::AObject* obj,
122  bool temporaryObject = false,
123  int position = -1 );
124  virtual void unregisterObject( anatomist::AObject* obj );
125  virtual bool positionFromCursor( int x, int y, Point3df & pos );
127  virtual anatomist::AObject* objectAtCursorPosition( int x, int y );
129  virtual std::list<anatomist::AObject*> *objectsAtCursorPosition( int x, int y, int tolerenceRadius );
131  virtual int polygonAtCursorPosition( int x, int y,const anatomist::AObject* obj );
132 
134  int computeNearestVertexFromPolygonPoint(
135  const anatomist::ViewState & vs, int poly,
136  const anatomist::GLComponent* glc,
137  const Point3df & position, Point3df & positionNearestVertex );
138  void getInfos3DFromClickPoint( int x, int y, Point3df & position, int *poly,
139  anatomist::AObject *objselect, std::string & objtype,
140  std::vector<float> &texvalue, std::string & textype,
141  Point3df & positionNearestVertex, int* indexNearestVertex);
142 
143  bool surfpaintIsVisible();
144  void setVisibleSurfpaint(bool b);
145  bool constraintEditorIsActive();
146  void setActiveConstraintEditor(bool b);
147 
148  void loadConstraintData(
149  const std::vector<std::string> & constraintList, int constraintType,
150  anatomist::AObject *texConstraint );
151  std::vector<std::string> getConstraintList();
152  int getConstraintType() const;
153  anatomist::AObject* getConstraintTexture();
154 
155  void printPositionAndValue();
156  void displayInfoAtClickPosition( int x, int y );
157  virtual void displayClickPoint();
159  void setViewPoint( float *quaternion,
160  const float zoom );
161  anatomist::Light *light();
162  void setLight( const anatomist::Light &light );
164  void setOrientationCube( bool state );
165  bool hasOrientationCube() const;
167  void setBoundingFrame( bool state );
168  bool hasBoundingFrame() const;
170  void setRenderingMode( RenderingMode mode );
171  RenderingMode renderingMode() const;
172 
173  virtual const std::set<unsigned> & typeCount() const;
174  virtual std::set<unsigned> & typeCount();
175  virtual const std::string & baseTitle() const;
176  virtual void setPosition( const Point3df& position,
177  const anatomist::Referential* orgref );
178  virtual void setPosition( const std::vector<float> & position,
179  const anatomist::Referential* orgref );
180  virtual void updateWindowGeometry();
181 
182  static anatomist::Geometry
183  setupWindowGeometry( const std::list<carto::shared_ptr<anatomist::AObject> >
184  & objects,
185  const aims::Quaternion & slicequat,
186  const anatomist::Referential *wref = 0,
187  QGLWidget* glw = 0, bool with3d = false );
188 
189  virtual anatomist::View* view();
190  virtual const anatomist::View* view() const;
191 
193  virtual void setViewType( ViewType t );
194  ViewType viewType() const;
195  bool isViewOblique() const;
196 
197  bool perspectiveEnabled() const;
198  void enablePerspective( bool );
199 
200  const aims::Quaternion & sliceQuaternion() const;
201  void setSliceQuaternion( const aims::Quaternion & q );
202  void setSliceOrientation( const Point3df & normal );
204  void resizeView( int w, int h );
206  bool boundingBox( std::vector<float> & bmin,
207  std::vector<float> & bmax ) const;
208  ClipMode clipMode() const;
209  void setClipMode( ClipMode m );
210  float clipDistance() const;
211  void setClipDistance( float d );
212  bool transparentZEnabled() const;
213  void enableTransparentZ( bool );
214  bool cullingEnabled() const;
215  void setCulling( bool );
216  bool flatShading() const;
217  void setFlatShading( bool );
218  bool smoothing() const;
219  void setSmoothing( bool );
220  void setFog( bool );
221  bool fog() const;
222  virtual void setReferential( anatomist::Referential* ref );
223  virtual void update( const Observable* obs, void * );
224  void setLinkedCursorOnSliderChange( bool x );
225  bool linkedCursorOnSliderChange() const;
226  AWindow3D* leftEyeWindow();
227  AWindow3D* rightEyeWindow();
228  void setLeftEyeWindow( AWindow3D* );
229  void setRightEyeWindow( AWindow3D* );
230  virtual void showToolBars( int state = 2 );
231  virtual void showStatusBar( int state = 2 );
232 
233  typedef anatomist::GLWidgetManager* (*GLWidgetCreator)
234  ( anatomist::AWindow* win, QWidget* parent, const char* name,
235  const QGLWidget * shareWidget, Qt::WindowFlags f );
237  static void setGLWidgetCreator( GLWidgetCreator );
238 
239  QSlider* getSliceSlider (void) const;
240 
245  void renderAfter( anatomist::AObject* obj, anatomist::AObject* afterthis );
250  void renderBefore( anatomist::AObject* obj, anatomist::AObject* beforethis );
255  std::list<anatomist::AObject *>::iterator processRenderingOrder(
256  std::list<anatomist::AObject *> & opaque ) const;
257 
258  bool polygonsSortingEnabled() const;
259  void setPolygonsSortingEnabled( bool );
261  bool polygonsSortingDirection() const;
262  void setPolygonsSortingDirection( bool dir );
263  virtual void sortPolygons( bool force = false );
264 
265 
266 signals:
267  void refreshed();
268 
269 public slots:
270  virtual void polish();
271  void resizeView();
272  void changeSlice( int );
273  void changeTime( int );
274  void changeTimeSliders( int, int );
275  void changeReferential();
276  void muteAxial();
277  void muteCoronal();
278  void muteSagittal();
279  void muteOblique();
280  void mute3D();
281  void lightView();
282  void pointsOfView();
283  void tools();
284  void syncViews( bool keepextrema = false );
285  void focusView();
286  void toolsWinDestroyed();
287  //void painttoolsWinDestroyed();
288  void povWinDestroyed();
289  void lightWinDestroyed();
290  virtual void Refresh();
292  virtual void refreshNow();
294  void refreshTemp();
295  void refreshTempNow();
299  void refreshLightView();
300  void refreshLightViewNow();
301  void setAutoRotationCenter();
302  void askZoom();
303  // Gets the window zoom factor
304  float getZoom() const;
305 
306  // Necessary for the movie action
307  int getSliceSliderPosition() ;
308  int getTimeSliderPosition() ;
309 
310  int getSliceSliderMaxPosition() ;
311  int getTimeSliderMaxPosition() ;
312 
313  void setSliceSliderPosition( int position ) ;
314  void setTimeSliderPosition( int position ) ;
315  void switchToolbox();
316  void setLinkedCursorPos();
317  void openStereoView();
318  void toggleStatusBarVisibility();
319  bool toopTipsEnabled() const;
320  void enableToolTips( bool );
321  // Refreshs the window when resized
322  void resizeEvent( QResizeEvent * ) ;
323 
327  QImage snapshotImage( int width=0, int height=0, int bufmode=0 );
328 
330 
331 protected slots:
332  void freeResize();
333  void saveSnapshot();
334  void saveSnapshotWithCustomSize();
335 
336 
337 protected:
338  void showReferential();
339 
340  // Updates left/right annotations
341  void updateLeftRightAnnotations();
342 
344  void displayClickPos( Point3df clickPos );
345  void setupTimeSlider( const std::vector<float> & bmin,
346  const std::vector<float> & bmax );
347  void setupSliceSlider( float mins, float maxs );
348  void setupSliceSlider();
349  void updateViewTypeToolBar();
350  void updateObject( anatomist::AObject* obj, anatomist::PrimList* pl = 0,
353  void updateObject2D( anatomist::AObject* obj, anatomist::PrimList* pl = 0,
356  void updateObject3D( anatomist::AObject* obj, anatomist::PrimList* pl = 0,
359  anatomist::GLPrimitives cursorGLL() const;
360  int updateSliceSlider();
361  void updateTimeSliders();
363  void registerObjectModifier( ObjectModifier *mod );
364  void unregisterObjectModifier( ObjectModifier *mod );
368  bool autoFusion2D( anatomist::AObject *obj );
370  void removeFromAutoFusion2D( anatomist::AObject *obj );
371  bool inAutoFusion( const anatomist::AObject *obj ) const;
372 
374  static std::set<unsigned> _count3d;
375  static std::string _baseTitle;
376 
377 public :
378  void renderSelectionBuffer( anatomist::ViewState::glSelectRenderMode mode,
379  const anatomist::AObject *selectedobject = 0 );
380 
381 private:
382  struct Private;
383 
384  Private *d;
385 };
386 
387 
388 #endif
static std::string _baseTitle
Definition: window3D.h:375
ViewState holds information about how a view wants to see an object.
Definition: viewstate.h:66
Light used for OpenGL in 3D windows.
Definition: Light.h:47
static std::set< unsigned > _count3d
3D windows static counter
Definition: window3D.h:374
Base Anatomist object (abstract)
Definition: Object.h:95
Base class for OpenGL-rendering widget.
std::list< carto::rc_ptr< GLItem > > PrimList
Definition: Object.h:72
Functions that can modify on-the-fly display primitives of an object.
Definition: window3D.h:100
Abstract base class Anatomist window.
Definition: Window.h:57
3D window, OpenGL rendering
Definition: window3D.h:69
This class can be subclassed to represent an object that the programmer wants to have observed...
Definition: Observable.h:67
AWindow3D * window()
Definition: window3D.h:106
#define slots
see http://doc.qt.digia.com/qq/qq26-openglcanvas.html
Anatomist Window using Qt and controler system, providing a toolbar for controls. ...
std::list< RefGLItem > GLPrimitives
Definition: primitive.h:156
Base class for all OpenGL objects in Anatomist (with OpenGL display lists)
Definition: glcomponent.h:66
::sigc::trackable Observable
Definition: Observer.h:90
Object none()
Referential: marker for transformations, with an associated color.
Definition: Referential.h:54
reference_wrapper< T > ref(T &ref)
RenderingMode
Definition: window3D.h:83