anatomist  5.1.2
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 #if QT_VERSION >= 0x060000
64 class QOpenGLWidget;
65 #else
66 class QGLWidget;
67 #endif
68 class QSlider;
69 
70 
74 {
75  Q_OBJECT
76 
77 public:
78  enum ViewType
79  {
84  ThreeD
85  };
86 
88  {
93  Fast
94  };
95 
96  enum ClipMode
97  {
100  Double
101  };
102 
105  {
106  public:
108  virtual ~ObjectModifier();
110  AWindow3D *window() { return _window; }
111 
112  private:
113  AWindow3D *_window;
114  };
115 
116 
117  AWindow3D( ViewType t = Oblique, QWidget* parent = 0,
118  carto::Object params = carto::none(),
119  Qt::WindowFlags f = Qt::WindowFlags() );
120  virtual ~AWindow3D();
121 
123  virtual Type type() const;
124  virtual SubType subtype() const;
125  virtual void registerObject( anatomist::AObject* obj,
126  bool temporaryObject = false,
127  int position = -1 );
128  virtual void unregisterObject( anatomist::AObject* obj );
129  virtual bool positionFromCursor( int x, int y, Point3df & pos );
131  virtual anatomist::AObject* objectAtCursorPosition( int x, int y );
133  virtual std::list<anatomist::AObject*> *objectsAtCursorPosition( int x, int y, int tolerenceRadius );
135  virtual int polygonAtCursorPosition( int x, int y,const anatomist::AObject* obj );
136 
139  const anatomist::ViewState & vs, int poly,
140  const anatomist::GLComponent* glc,
141  const Point3df & position, Point3df & positionNearestVertex );
142  void getInfos3DFromClickPoint( int x, int y, Point3df & position, int *poly,
143  anatomist::AObject *objselect, std::string & objtype,
144  std::vector<float> &texvalue, std::string & textype,
145  Point3df & positionNearestVertex, int* indexNearestVertex,
146  std::vector<std::string> & texlabels );
152  void getInfos3DFromPosition( const std::vector<float> & position, int poly,
153  anatomist::AObject *objselect, std::string & objtype,
154  std::vector<float> &texvalue, std::string & textype,
155  Point3df & positionNearestVertex, int* indexNearestVertex,
156  std::vector<std::string> & texlabels );
157 
159  void setVisibleSurfpaint(bool b);
162 
164  const std::vector<std::string> & constraintList, int constraintType,
165  anatomist::AObject *texConstraint );
166  std::vector<std::string> getConstraintList();
167  int getConstraintType() const;
169 
171  void displayInfoAtClickPosition( int x, int y );
172  std::string displayInfoAtClickPositionAsText( int x, int y,
173  bool html = false );
174  virtual void displayClickPoint();
176  void setViewPoint( float *quaternion,
177  const float zoom );
181  void setOrientationCube( bool state );
182  bool hasOrientationCube() const;
184  void setBoundingFrame( bool state );
185  bool hasBoundingFrame() const;
189 
190  virtual const std::set<unsigned> & typeCount() const;
191  virtual std::set<unsigned> & typeCount();
192  virtual const std::string & baseTitle() const;
193  virtual void setPosition( const Point3df& position,
194  const anatomist::Referential* orgref );
195  virtual void setPosition( const std::vector<float> & position,
196  const anatomist::Referential* orgref );
197  virtual void updateWindowGeometry();
198 
199  static anatomist::Geometry
201  & objects,
202  const aims::Quaternion & slicequat,
203  const anatomist::Referential *wref = 0,
204 #if QT_VERSION >= 0x060000
205  QOpenGLWidget* glw = 0, bool with3d = false );
206 #else
207  QGLWidget* glw = 0, bool with3d = false );
208 #endif
209 
210  virtual anatomist::View* view();
211  virtual const anatomist::View* view() const;
212 
214  virtual void setViewType( ViewType t );
216  bool isViewOblique() const;
217 
218  bool perspectiveEnabled() const;
219  void enablePerspective( bool );
220 
223  void setSliceOrientation( const Point3df & normal );
225  void resizeView( int w, int h );
227  bool boundingBox( std::vector<float> & bmin,
228  std::vector<float> & bmax ) const;
231  float clipDistance() const;
232  void setClipDistance( float d );
233  bool transparentZEnabled() const;
234  void enableTransparentZ( bool );
235  bool cullingEnabled() const;
236  void setCulling( bool );
237  bool flatShading() const;
238  void setFlatShading( bool );
239  bool smoothing() const;
240  void setSmoothing( bool );
241  void setFog( bool );
242  bool fog() const;
244  virtual void update( const Observable* obs, void * );
251  virtual void showToolBars( int state = 2 );
252  virtual void showStatusBar( int state = 2 );
253 
254  typedef anatomist::GLWidgetManager* (*GLWidgetCreator)
255  ( anatomist::AWindow* win, QWidget* parent, const char* name,
256 #if QT_VERSION >= 0x060000
257  const QOpenGLWidget * shareWidget, Qt::WindowFlags f );
258 #else
259  const QGLWidget * shareWidget, Qt::WindowFlags f );
260 #endif
263 
264  QSlider* getSliceSlider (void) const;
265 
280  std::list<anatomist::AObject *>::iterator processRenderingOrder(
281  std::list<anatomist::AObject *> & opaque ) const;
282 
287  void setPolygonsSortingDirection( bool dir );
288  virtual void sortPolygons( bool force = false );
289 
290 
291 signals:
292  void refreshed();
293  void sliderChanged( int dim, int slice );
295 
296 public slots:
297  virtual void polish();
298  void resizeView();
299  void changeSlice( int );
300  void changeTime( int );
301  void changeTimeSliders( int, int );
303  void muteAxial();
304  void muteCoronal();
305  void muteSagittal();
306  void muteOblique();
307  void mute3D();
308  void lightView();
309  void pointsOfView();
310  void tools();
311  void syncViews( bool keepextrema = false );
312  void focusView();
314  //void painttoolsWinDestroyed();
317  virtual void Refresh();
319  virtual void refreshNow();
321  void refreshTemp();
329  void askZoom();
330  // Gets the window zoom factor
331  float getZoom() const;
332 
333  // Necessary for the movie action
336 
339 
340  void setSliceSliderPosition( int position ) ;
341  void setTimeSliderPosition( int position ) ;
346  bool toopTipsEnabled() const;
347  void enableToolTips( bool );
348  // Refreshs the window when resized
349  void resizeEvent( QResizeEvent * ) ;
350 
354  QImage snapshotImage( int width=0, int height=0, int bufmode=0 );
356 
358 
359 protected slots:
360  void freeResize();
361  void saveSnapshot();
363 
364 
365 protected:
367 
368  // Updates left/right annotations
370 
372  void displayClickPos( Point3df clickPos );
373  void setupTimeSlider( const std::vector<float> & bmin,
374  const std::vector<float> & bmax );
375  void setupSliceSlider( float mins, float maxs );
399  bool inAutoFusion( const anatomist::AObject *obj ) const;
400 
402  static std::set<unsigned> _count3d;
403  static std::string _baseTitle;
404 
405 public :
407  const anatomist::AObject *selectedobject = 0 );
408 
409 private:
410  struct Private;
411 
412  Private *d;
413 };
414 
415 
416 #endif
#define slots
Functions that can modify on-the-fly display primitives of an object.
Definition: window3D.h:105
AWindow3D * window()
Definition: window3D.h:110
ObjectModifier(AWindow3D *w)
virtual void modify(anatomist::AObject *, anatomist::GLPrimitives &)=0
3D window, OpenGL rendering
Definition: window3D.h:74
virtual void showToolBars(int state=2)
Shows or hides all tools (menu, toolbars) around the main view area.
void showReferential()
virtual std::list< anatomist::AObject * > * objectsAtCursorPosition(int x, int y, int tolerenceRadius)
pick several objects at the cursor 2D position
void pointsOfView()
virtual const std::string & baseTitle() const
void setVisibleSurfpaint(bool b)
bool isViewOblique() const
void refreshTemp()
Redraws temporary objects only.
virtual std::set< unsigned > & typeCount()
void muteOblique()
static void setGLWidgetCreator(GLWidgetCreator)
hook to create inherited QAGLWidgets (Vtk-enabled for instance)
void updateTimeSliders()
void setFlatShading(bool)
void sliderChanged(int dim, int slice)
void tools()
bool smoothing() const
float clipDistance() const
void setClipMode(ClipMode m)
int getSliceSliderPosition()
void openStereoView()
ViewType viewType() const
void setOrientationCube(bool state)
Compass handling methods.
void muteCoronal()
void syncViews(bool keepextrema=false)
void askZoom()
void freeResize()
void registerObjectModifier(ObjectModifier *mod)
Allows changing display lists from normal objects DLists.
bool cullingEnabled() const
virtual void unregisterObject(anatomist::AObject *obj)
bool hasBoundingFrame() const
bool constraintEditorIsActive()
virtual const std::set< unsigned > & typeCount() const
void enablePerspective(bool)
void setRenderingMode(RenderingMode mode)
Rendering mode (normal, wireframe, fast)
void renderSelectionBuffer(anatomist::ViewState::glSelectRenderMode mode, const anatomist::AObject *selectedobject=0)
QImage snapshotImage(int width=0, int height=0, int bufmode=0)
Get a snapshot of the window, after a refresh if needed.
AWindow3D * leftEyeWindow()
void lightWinDestroyed()
void resizeView()
virtual void registerObject(anatomist::AObject *obj, bool temporaryObject=false, int position=-1)
int getConstraintType() const
void updateObject(anatomist::AObject *obj, anatomist::PrimList *pl=0, anatomist::ViewState::glSelectRenderMode selectmode=anatomist::ViewState::glSELECTRENDER_NONE)
bool surfpaintIsVisible()
anatomist::GLWidgetManager *(* GLWidgetCreator)(anatomist::AWindow *win, QWidget *parent, const char *name, const QGLWidget *shareWidget, Qt::WindowFlags f)
Definition: window3D.h:255
int getSliceSliderMaxPosition()
std::list< anatomist::AObject * >::iterator processRenderingOrder(std::list< anatomist::AObject * > &opaque) const
calculates the objects rendering order, according to various constraints (opaque/transparent,...
virtual void setPosition(const std::vector< float > &position, const anatomist::Referential *orgref)
void setFog(bool)
void muteSagittal()
virtual anatomist::AObject * objectAtCursorPosition(int x, int y)
pick the object at the cursor 2D position
bool fog() const
int getTimeSliderMaxPosition()
void enableToolTips(bool)
void changeTime(int)
void updateObject2D(anatomist::AObject *obj, anatomist::PrimList *pl=0, anatomist::ViewState::glSelectRenderMode selectmode=anatomist::ViewState::glSELECTRENDER_NONE)
virtual int polygonAtCursorPosition(int x, int y, const anatomist::AObject *obj)
pick a polygon on a selected object at the cursor 2D position
anatomist::AObject * getConstraintTexture()
bool hasOrientationCube() const
void setPolygonsSortingEnabled(bool)
virtual void Refresh()
void setActiveConstraintEditor(bool b)
static anatomist::Geometry setupWindowGeometry(const std::list< carto::shared_ptr< anatomist::AObject > > &objects, const aims::Quaternion &slicequat, const anatomist::Referential *wref=0, QGLWidget *glw=0, bool with3d=false)
void saveSnapshotWithCustomSize()
void switchToolbox()
virtual void polish()
bool inAutoFusion(const anatomist::AObject *obj) const
void resizeEvent(QResizeEvent *)
void loadConstraintData(const std::vector< std::string > &constraintList, int constraintType, anatomist::AObject *texConstraint)
const aims::Quaternion & sliceQuaternion() const
void lightView()
void unregisterObjectModifier(ObjectModifier *mod)
void renderAfter(anatomist::AObject *obj, anatomist::AObject *afterthis)
adds a rendering order constraint: obj will be rendered immediately after afterthis.
void printPositionAndValue()
virtual void sortPolygons(bool force=false)
AWindow3D(ViewType t=Oblique, QWidget *parent=0, carto::Object params=carto::none(), Qt::WindowFlags f=Qt::WindowFlags())
void getInfos3DFromClickPoint(int x, int y, Point3df &position, int *poly, anatomist::AObject *objselect, std::string &objtype, std::vector< float > &texvalue, std::string &textype, Point3df &positionNearestVertex, int *indexNearestVertex, std::vector< std::string > &texlabels)
virtual void setPosition(const Point3df &position, const anatomist::Referential *orgref)
Set position of cursor.
AWindow3D * rightEyeWindow()
virtual void setReferential(anatomist::Referential *ref)
void setSmoothing(bool)
float getZoom() const
QSlider * getSliceSlider(void) const
void toolsWinDestroyed()
void toggleStatusBarVisibility()
int computeNearestVertexFromPolygonPoint(const anatomist::ViewState &vs, int poly, const anatomist::GLComponent *glc, const Point3df &position, Point3df &positionNearestVertex)
print all infos about vertex picked on a polygon selected
void orientationChanged()
virtual SubType subtype() const
void setBoundingFrame(bool state)
Frame handling methods.
void muteAxial()
void setRightEyeWindow(AWindow3D *)
int getTimeSliderPosition()
virtual void updateWindowGeometry()
adapts geometry to the current contents and referential
void saveSnapshot()
void changeTimeSliders(int, int)
@ Oblique
Definition: window3D.h:80
@ Coronal
Definition: window3D.h:83
@ Sagittal
Definition: window3D.h:82
@ ThreeD
Definition: window3D.h:84
void renderBefore(anatomist::AObject *obj, anatomist::AObject *beforethis)
adds a rendering order constraint: obj will be rendered immediately before beforethis.
virtual void setViewType(ViewType t)
Mute into a new view type (Axial, Sagittal, Coronal or Oblique)
bool toopTipsEnabled() const
@ NoClip
Definition: window3D.h:98
@ Single
Definition: window3D.h:99
void setPolygonsSortingDirection(bool dir)
void focusView()
void setTimeSliderPosition(int position)
void updateObject3D(anatomist::AObject *obj, anatomist::PrimList *pl=0, anatomist::ViewState::glSelectRenderMode selectmode=anatomist::ViewState::glSELECTRENDER_NONE)
virtual void update(const Observable *obs, void *)
std::vector< std::string > getConstraintList()
static std::string _baseTitle
Definition: window3D.h:403
anatomist::GLPrimitives cursorGLL() const
bool polygonsSortingEnabled() const
void setAutoRotationCenter()
void setViewPoint(float *quaternion, const float zoom)
set the view of the scene
ClipMode clipMode() const
virtual void showStatusBar(int state=2)
std::string displayInfoAtClickPositionAsText(int x, int y, bool html=false)
void displayClickPos(Point3df clickPos)
Display the click point.
void getInfos3DFromPosition(const std::vector< float > &position, int poly, anatomist::AObject *objselect, std::string &objtype, std::vector< float > &texvalue, std::string &textype, Point3df &positionNearestVertex, int *indexNearestVertex, std::vector< std::string > &texlabels)
same as above but from a 3+D position.
bool linkedCursorOnSliderChange() const
void resizeView(int w, int h)
Tries to resize the viewing area to given size.
virtual Type type() const
Get the window type (2D, 3D or control)
virtual bool positionFromCursor(int x, int y, Point3df &pos)
Translates mouse position to Anatomist geometry position.
void setClipDistance(float d)
void setCulling(bool)
void setLinkedCursorPos()
void setSliceQuaternion(const aims::Quaternion &q)
virtual carto::rc_ptr< anatomist::ViewState > viewState()
void refreshTempNow()
bool perspectiveEnabled() const
void mute3D()
void setupTimeSlider(const std::vector< float > &bmin, const std::vector< float > &bmax)
void setSliceSliderPosition(int position)
void refreshed()
void setLeftEyeWindow(AWindow3D *)
void displayInfoAtClickPosition(int x, int y)
bool flatShading() const
void setLinkedCursorOnSliderChange(bool x)
void setupSliceSlider(float mins, float maxs)
void enableTransparentZ(bool)
void changeSlice(int)
bool boundingBox(std::vector< float > &bmin, std::vector< float > &bmax) const
Get bounding box in N-dimension mode (new in anatomist 4.6)
int updateSliceSlider()
RenderingMode renderingMode() const
void updateViewTypeToolBar()
virtual void refreshNow()
Refresh the window (redraw the contained objects).
void refreshLightViewNow()
RenderingMode
Definition: window3D.h:88
@ Normal
Definition: window3D.h:89
@ Outlined
Definition: window3D.h:91
@ Wireframe
Definition: window3D.h:90
@ HiddenWireframe
Definition: window3D.h:92
virtual ~AWindow3D()
void updateLeftRightAnnotations()
void setLight(const anatomist::Light &light)
bool transparentZEnabled() const
void changeReferential()
void setSliceOrientation(const Point3df &normal)
void povWinDestroyed()
void refreshLightView()
Only redraws existing objects (in most cases, just calls existing OpenGL lists, except for observer-d...
void setupSliceSlider()
virtual void displayClickPoint()
bool polygonsSortingDirection() const
returns false for back-to-front, true for front-to-back
void removeFromAutoFusion2D(anatomist::AObject *obj)
delete or modify the auto Fusion2D object when removing an object
bool autoFusion2D(anatomist::AObject *obj)
build or modify the auto Fusion2D object when adding a new object.
virtual const anatomist::View * view() const
virtual anatomist::View * view()
static std::set< unsigned > _count3d
3D windows static counter
Definition: window3D.h:402
anatomist::Light * light()
Anatomist Window using Qt and controler system, providing a toolbar for controls.
Base Anatomist object (abstract)
Definition: Object.h:96
Abstract base class Anatomist window.
Definition: Window.h:58
Base class for all OpenGL objects in Anatomist (with OpenGL display lists)
Definition: glcomponent.h:67
Base class for OpenGL-rendering widget.
Light used for OpenGL in 3D windows.
Definition: Light.h:48
This class can be subclassed to represent an object that the programmer wants to have observed.
Definition: Observable.h:68
Referential: marker for transformations, with an associated color.
Definition: Referential.h:55
see http://doc.qt.digia.com/qq/qq26-openglcanvas.html
friend friend class ref
std::list< carto::rc_ptr< GLItem > > PrimList
Definition: Object.h:72
std::list< RefGLItem > GLPrimitives
Definition: primitive.h:156
Object none()
::sigc::trackable Observable
Definition: Observer.h:90
ViewState holds information about how a view wants to see an object.
Definition: viewstate.h:67
@ glSELECTRENDER_NONE
no selection
Definition: viewstate.h:71