DGtalTools  0.9.2
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Types
Viewer3DImage< Space, KSpace > Class Template Reference

#include <visualisation/specificClasses/Viewer3DImage.h>

Inherits Viewer3D< Space, KSpace >.

Public Types

Public Member Functions

 Viewer3DImage (ModeVisu aMode=BoundingBox)
 
 Viewer3DImage (Image3D *an3DImage)
 
void setVolImage (Image3D *an3DImage)
 

Protected Member Functions

virtual QString helpString () const
 
virtual void keyPressEvent (QKeyEvent *e)
 
virtual void init ()
 

Protected Attributes

Image3Dmy3dImage
 
float myScaleX
 
float myScaleY
 
float myScaleZ
 
int mySliceXPos
 
int mySliceYPos
 
int mySliceZPos
 
int myCurrentSliceDim
 
double myAngleRotation
 
double myTotalAngleRotationX
 
double myTotalAngleRotationY
 
double myTotalAngleRotationZ
 
bool myDisplayingInfo
 
DGtal::Z3i::Point myImageOrigin
 
ModeVisu myMode
 

Private Types

typedef DGtal::ImageContainerBySTLVector< DGtal::Z3i::Domain, unsigned char > Image3D
 
typedef DGtal::ImageContainerBySTLVector< DGtal::Z2i::Domain, unsigned char > Image2D
 
typedef DGtal::ConstImageAdapter< Image3D, Image2D::Domain, DGtal::functors::Projector< DGtal::Z3i::Space >, Image3D::Value, DGtal::functors::Identity > SliceImageAdapter
 
typedef DGtal::ConstImageAdapter< Image3D, DGtal::Z2i::Domain, DGtal::functors::SliceRotator2D< DGtal::Z3i::Domain >, Image3D::Value, DGtal::functors::Identity > MyRotatorSliceImageAdapter
 

Detailed Description

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
class Viewer3DImage< Space, KSpace >

Prevents repeated inclusion of headers.

Definition at line 23 of file Viewer3DImage.h.

Member Typedef Documentation

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
typedef DGtal::ImageContainerBySTLVector<DGtal::Z2i::Domain, unsigned char> Viewer3DImage< Space, KSpace >::Image2D
private

Definition at line 27 of file Viewer3DImage.h.

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
typedef DGtal::ImageContainerBySTLVector<DGtal::Z3i::Domain, unsigned char> Viewer3DImage< Space, KSpace >::Image3D
private

Definition at line 26 of file Viewer3DImage.h.

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
typedef DGtal::ConstImageAdapter<Image3D, DGtal::Z2i::Domain, DGtal::functors::SliceRotator2D< DGtal::Z3i::Domain >, Image3D::Value, DGtal::functors::Identity > Viewer3DImage< Space, KSpace >::MyRotatorSliceImageAdapter
private

Definition at line 33 of file Viewer3DImage.h.

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
typedef DGtal::ConstImageAdapter<Image3D, Image2D::Domain, DGtal::functors::Projector< DGtal::Z3i::Space>, Image3D::Value, DGtal::functors::Identity > Viewer3DImage< Space, KSpace >::SliceImageAdapter
private

Definition at line 30 of file Viewer3DImage.h.

Member Enumeration Documentation

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
enum Viewer3DImage::ModeVisu
Enumerator
BoundingBox 
InterGrid 
Grid 
Empty 

Definition at line 38 of file Viewer3DImage.h.

Constructor & Destructor Documentation

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
Viewer3DImage< Space, KSpace >::Viewer3DImage ( ModeVisu  aMode = BoundingBox)
inline

Definition at line 40 of file Viewer3DImage.h.

References Viewer3DImage< Space, KSpace >::myAngleRotation, Viewer3DImage< Space, KSpace >::myCurrentSliceDim, Viewer3DImage< Space, KSpace >::myDisplayingInfo, Viewer3DImage< Space, KSpace >::myMode, Viewer3DImage< Space, KSpace >::mySliceXPos, Viewer3DImage< Space, KSpace >::mySliceYPos, Viewer3DImage< Space, KSpace >::mySliceZPos, Viewer3DImage< Space, KSpace >::myTotalAngleRotationX, Viewer3DImage< Space, KSpace >::myTotalAngleRotationY, and Viewer3DImage< Space, KSpace >::myTotalAngleRotationZ.

Referenced by Viewer3DImage< Space, KSpace >::Viewer3DImage().

40  : DGtal::Viewer3D<Space, KSpace>(), myImageOrigin(DGtal::Z3i::Point(0,0,0)){
41  mySliceXPos=0;
42  mySliceYPos=0;
43  mySliceZPos=0;
47  myAngleRotation=0.0;
49  myMode=aMode;
50  myDisplayingInfo=true;
51  }
double myTotalAngleRotationY
Definition: Viewer3DImage.h:78
ModeVisu myMode
Definition: Viewer3DImage.h:82
double myTotalAngleRotationZ
Definition: Viewer3DImage.h:79
DGtal::Z3i::Point myImageOrigin
Definition: Viewer3DImage.h:81
double myTotalAngleRotationX
Definition: Viewer3DImage.h:77
double myAngleRotation
Definition: Viewer3DImage.h:76
bool myDisplayingInfo
Definition: Viewer3DImage.h:80
template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
Viewer3DImage< Space, KSpace >::Viewer3DImage ( Image3D an3DImage)
inline

Member Function Documentation

template<typename Space , typename KSpace >
QString Viewer3DImage< Space, KSpace >::helpString ( ) const
protectedvirtual

Definition at line 128 of file Viewer3DImage.cpp.

Referenced by Viewer3DImage< Space, KSpace >::Viewer3DImage().

129 {
130  QString text ( "<h2> Viewer3DImage</h2>" );
131  text += "Use the mouse to move the camera around the object. ";
132  text += "You can respectively revolve around, zoom and translate with the three mouse buttons. ";
133  text += "Left and middle buttons pressed together rotate around the camera view direction axis<br><br>";
134  text += "Pressing <b>Alt</b> and one of the function keys (<b>F1</b>..<b>F12</b>) defines a camera keyFrame. ";
135  text += "Simply press the function key again to restore it. Several keyFrames define a ";
136  text += "camera path. Paths are saved when you quit the application and restored at next start.<br><br>";
137  text += "Press <b>F</b> to display the frame rate, <b>A</b> for the world axis, ";
138  text += "<b>Alt+Return</b> for full screen mode and <b>Control+S</b> to save a snapshot. ";
139  text += "See the <b>Keyboard</b> tab in this window for a complete shortcut list.<br><br>";
140  text += "Double clicks automates single click actions: A left button double click aligns the closer axis with the camera (if close enough). ";
141  text += "A middle button double click fits the zoom of the camera and the right button re-centers the scene.<br><br>";
142  text += "A left button double click while holding right button pressed defines the camera <i>Revolve Around Point</i>. ";
143  text += "See the <b>Mouse</b> tab and the documentation web pages for details.<br><br>";
144  text += "Press <b>Escape</b> to exit the viewer.";
145  return text;
146 }
template<typename Space , typename KSpace >
void Viewer3DImage< Space, KSpace >::init ( )
protectedvirtual

Definition at line 40 of file Viewer3DImage.cpp.

Referenced by Viewer3DImage< Space, KSpace >::Viewer3DImage().

40  {
41  DGtal::Viewer3D<>::init();
42  QGLViewer::setKeyDescription ( Qt::Key_X, "Change the current axis to X for the current 2D image slice setting." );
43  QGLViewer::setKeyDescription ( Qt::Key_Y, "Change the current axis to Y for the current 2D image slice setting." );
44  QGLViewer::setKeyDescription ( Qt::Key_Z, "Change the current axis to Z for the current 2D image slice setting." );
45  QGLViewer::setKeyDescription ( Qt::Key_Up, "Move the current 2D image slice to 5 in the positive direction of the current axis." );
46  QGLViewer::setKeyDescription ( Qt::Key_Down, "Move the current 2D image slice to 5 in the negative direction of the current axis." );
47  QGLViewer::setKeyDescription ( Qt::Key_Shift, "Change the slice move with step 1 (5 by default)" );
48  QGLViewer::setKeyDescription ( Qt::Key_M, "Hide/Display message informations (slice numbers, selected axis)" );
49 }
template<typename Space , typename KSpace >
void Viewer3DImage< Space, KSpace >::keyPressEvent ( QKeyEvent *  e)
protectedvirtual

Definition at line 154 of file Viewer3DImage.cpp.

Referenced by Viewer3DImage< Space, KSpace >::Viewer3DImage().

155 {
156 
157  bool handled = false;
158  if( e->key() == Qt::Key_M){
160  handled=true;
161  }
162  if( e->key() == Qt::Key_I){
163  std::cout << "Image generation" << std::endl;
164  handled=true;
165  }
166 
167  if( e->key() == Qt::Key_X){
168  std::cout << "Current axis set to X" << std::endl;
169  (*this).displayMessage(QString("Current axis set to X"), 100000);
171  handled=true;
172  }
173  if( e->key() == Qt::Key_Y){
174  (*this).displayMessage(QString("Current axis set to Y"), 100000);
176  handled=true;
177  }
178  if( e->key() == Qt::Key_Z){
179  (*this).displayMessage(QString("Current axis set to Z"), 100000);
181  handled=true;
182  }
183  if( e->key() == Qt::Key_Up || e->key() == Qt::Key_Down){
184  int dirStep = (e->key() == Qt::Key_Up)? 5: -5;
185  if((e->modifiers() & Qt::ShiftModifier)){
186  dirStep/=5;
187  }
188  if((e->modifiers() & Qt::MetaModifier)){
189  myAngleRotation =(e->key() == Qt::Key_Down)? 0.1: -0.1;
190  dirStep=0;
191  }else{
192  myAngleRotation=0.0;
193  }
194  int aSliceNum=0;
195  int aSliceMax=0;
196  bool stoped=false;
197  if(myCurrentSliceDim==0){
198  aSliceMax=my3dImage->domain().upperBound()[0]+1;
199  if(mySliceXPos+dirStep<aSliceMax&&mySliceXPos+dirStep>=myImageOrigin[0]){
200  mySliceXPos+=dirStep;
201  }else{
202  stoped=true;
203  }
204 
205  aSliceNum=mySliceXPos;
206  }else if(myCurrentSliceDim==1){
207  aSliceMax=my3dImage->domain().upperBound()[1]+1;
208  if(mySliceYPos+dirStep<aSliceMax&&mySliceYPos+dirStep>=myImageOrigin[1]){
209  mySliceYPos+=dirStep;
210  }else{
211  stoped=true;
212  }
213  aSliceNum=mySliceYPos;
214  }else if(myCurrentSliceDim==2){
215  aSliceMax=my3dImage->domain().upperBound()[2]+1;
216  if(mySliceZPos+dirStep<aSliceMax&&mySliceZPos+dirStep>=myImageOrigin[2]){
217  mySliceZPos+=dirStep;
218  }else{
219  stoped=true;
220  }
221  aSliceNum=mySliceZPos;
222  }
223 
224  if(!stoped){
225  double myTotalAngleRotation=0.0;
226  if(myCurrentSliceDim==0){
228  myTotalAngleRotation = myTotalAngleRotationX;
229  }else if (myCurrentSliceDim==1){
231  myTotalAngleRotation = myTotalAngleRotationY;
232  }else if (myCurrentSliceDim==2){
234  myTotalAngleRotation = myTotalAngleRotationZ;
235  }
236 
237  DGtal::functors::SliceRotator2D<DGtal::Z3i::Domain> aSliceFunctor(myCurrentSliceDim, my3dImage->domain(),
238  aSliceNum, 2, myTotalAngleRotation);
239  // Adding X slice in the viewer.
240  DGtal::functors::Projector<DGtal::Z2i::Space> invFunctor; invFunctor.initRemoveOneDim(myCurrentSliceDim);
241  DGtal::Z2i::Domain domain2D(invFunctor(my3dImage->domain().lowerBound()),
242  invFunctor(my3dImage->domain().upperBound()));
243 
244  const DGtal::functors::Identity identityFunctor{};
245  MyRotatorSliceImageAdapter sliceImage( *my3dImage, domain2D, aSliceFunctor, identityFunctor );
246 
247  (*this) << DGtal::UpdateImageData<MyRotatorSliceImageAdapter>(myCurrentSliceDim, sliceImage,
248  (myCurrentSliceDim==0)? dirStep: 0.0,
249  (myCurrentSliceDim==1)? dirStep: 0.0,
250  (myCurrentSliceDim==2)? dirStep: 0.0,
251  myAngleRotation, DGtal::Viewer3D<>::zDirection);
252  (*this).updateList(false);
253  (*this).update();
254  }
255  if(myDisplayingInfo){
256  std::stringstream sstring;
257  sstring << "slice X: " << mySliceXPos ;
258  sstring << " slice Y: " << mySliceYPos ;
259  sstring << " slice Z: " << mySliceZPos ;
260  (*this).displayMessage(QString(sstring.str().c_str()), 100000);
261  }
262 
263 
264 
265 
266  handled=true;
267  }
268 
269  if ( !handled )
270  DGtal::Viewer3D<>::keyPressEvent ( e );
271 
272 }
double myTotalAngleRotationY
Definition: Viewer3DImage.h:78
Image3D * my3dImage
Definition: Viewer3DImage.h:68
double myTotalAngleRotationZ
Definition: Viewer3DImage.h:79
DGtal::Z3i::Point myImageOrigin
Definition: Viewer3DImage.h:81
double myTotalAngleRotationX
Definition: Viewer3DImage.h:77
DGtal::ConstImageAdapter< Image3D, DGtal::Z2i::Domain, DGtal::functors::SliceRotator2D< DGtal::Z3i::Domain >, Image3D::Value, DGtal::functors::Identity > MyRotatorSliceImageAdapter
Definition: Viewer3DImage.h:33
double myAngleRotation
Definition: Viewer3DImage.h:76
bool myDisplayingInfo
Definition: Viewer3DImage.h:80
template<typename Space , typename KSpace >
void Viewer3DImage< Space, KSpace >::setVolImage ( Image3D an3DImage)

Definition at line 54 of file Viewer3DImage.cpp.

Referenced by Viewer3DImage< Space, KSpace >::Viewer3DImage().

54  {
55  my3dImage = an3DImage;
56 
57  switch (myMode) {
58  case BoundingBox:
59  (*this) << DGtal::SetMode3D("ConstImageAdapter", "BoundingBox");
60  break;
61  case InterGrid:
62  (*this) << DGtal::SetMode3D("ConstImageAdapter", "InterGrid");
63  break;
64  case Grid:
65  (*this) << DGtal::SetMode3D("ConstImageAdapter", "Grid");
66  break;
67  case Empty:
68  (*this) << DGtal::SetMode3D("ConstImageAdapter", "");
69  break;
70  }
71 
72  myImageOrigin = my3dImage->domain().lowerBound();
73  (*this).updateList(false);
74  (*this).update();
75 
79 
80  // Adding X slice in the viewer.
81  DGtal::functors::Projector<DGtal::Z2i::Space> invFunctorX; invFunctorX.initRemoveOneDim(0);
82  DGtal::Z2i::Domain domain2DX(invFunctorX(my3dImage->domain().lowerBound()),
83  invFunctorX(my3dImage->domain().upperBound()));
84 
85 
86  DGtal::functors::SliceRotator2D<DGtal::Z3i::Domain> aSliceFunctorX(0, my3dImage->domain(), mySliceXPos,2, myAngleRotation );
87  const DGtal::functors::Identity identityFunctor{};
88  MyRotatorSliceImageAdapter sliceImageX( *my3dImage, domain2DX, aSliceFunctorX, identityFunctor );
89 
90  std::cout << "image:" << sliceImageX.className();
91  (*this) << sliceImageX;
92  (*this) << DGtal::UpdateImagePosition< Space, KSpace >(0, DGtal::Viewer3D<>::xDirection, mySliceXPos,myImageOrigin[1], myImageOrigin[2]);
93 
94 
95  // Adding Y slice in the viewer.
96  DGtal::functors::Projector<DGtal::Z2i::Space> invFunctorY; invFunctorY.initRemoveOneDim(1);
97  DGtal::Z2i::Domain domain2DY(invFunctorY(my3dImage->domain().lowerBound()),
98  invFunctorY(my3dImage->domain().upperBound()));
99 
100  DGtal::functors::Projector<DGtal::Z3i::Space> aSliceFunctorY(mySliceYPos); aSliceFunctorY.initAddOneDim(1);
101  SliceImageAdapter sliceImageY(*my3dImage, domain2DY, aSliceFunctorY, identityFunctor );
102  (*this) << sliceImageY;
103  (*this) << DGtal::UpdateImagePosition< Space, KSpace >(1, DGtal::Viewer3D<>::yDirection, myImageOrigin[0], mySliceYPos, myImageOrigin[2]);
104 
105 
106 
107 
108 
109  // Adding Z slice in the viewer.
110  DGtal::functors::Projector<DGtal::Z2i::Space> invFunctorZ; invFunctorZ.initRemoveOneDim(2);
111  DGtal::Z2i::Domain domain2DZ(invFunctorZ(my3dImage->domain().lowerBound()),
112  invFunctorZ(my3dImage->domain().upperBound()));
113 
114  DGtal::Z3i::Point centerZ((my3dImage->domain().upperBound())[0]/2, (my3dImage->domain().upperBound())[1]/2, mySliceZPos);
115 
116  DGtal::functors::SliceRotator2D<DGtal::Z3i::Domain> aSliceFunctorZ(2, my3dImage->domain(), mySliceZPos, 2, myAngleRotation, centerZ );
117  MyRotatorSliceImageAdapter sliceImageZ( *my3dImage, domain2DZ, aSliceFunctorZ, identityFunctor );
118  (*this) << sliceImageZ;
119  (*this) << DGtal::UpdateImagePosition< Space, KSpace > (2, DGtal::Viewer3D<>::zDirection, myImageOrigin[0], myImageOrigin[1], mySliceZPos);
120 
121 
122  (*this) << DGtal::Viewer3D<>::updateDisplay;
123 }
Image3D * my3dImage
Definition: Viewer3DImage.h:68
ModeVisu myMode
Definition: Viewer3DImage.h:82
DGtal::ConstImageAdapter< Image3D, Image2D::Domain, DGtal::functors::Projector< DGtal::Z3i::Space >, Image3D::Value, DGtal::functors::Identity > SliceImageAdapter
Definition: Viewer3DImage.h:30
DGtal::Z3i::Point myImageOrigin
Definition: Viewer3DImage.h:81
DGtal::ConstImageAdapter< Image3D, DGtal::Z2i::Domain, DGtal::functors::SliceRotator2D< DGtal::Z3i::Domain >, Image3D::Value, DGtal::functors::Identity > MyRotatorSliceImageAdapter
Definition: Viewer3DImage.h:33
double myAngleRotation
Definition: Viewer3DImage.h:76

Field Documentation

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
Image3D* Viewer3DImage< Space, KSpace >::my3dImage
protected

Definition at line 68 of file Viewer3DImage.h.

Referenced by Viewer3DImage< Space, KSpace >::Viewer3DImage().

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
double Viewer3DImage< Space, KSpace >::myAngleRotation
protected

Definition at line 76 of file Viewer3DImage.h.

Referenced by Viewer3DImage< Space, KSpace >::Viewer3DImage().

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
int Viewer3DImage< Space, KSpace >::myCurrentSliceDim
protected

Definition at line 75 of file Viewer3DImage.h.

Referenced by Viewer3DImage< Space, KSpace >::Viewer3DImage().

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
bool Viewer3DImage< Space, KSpace >::myDisplayingInfo
protected

Definition at line 80 of file Viewer3DImage.h.

Referenced by Viewer3DImage< Space, KSpace >::Viewer3DImage().

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
DGtal::Z3i::Point Viewer3DImage< Space, KSpace >::myImageOrigin
protected

Definition at line 81 of file Viewer3DImage.h.

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
ModeVisu Viewer3DImage< Space, KSpace >::myMode
protected

Definition at line 82 of file Viewer3DImage.h.

Referenced by Viewer3DImage< Space, KSpace >::Viewer3DImage().

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
float Viewer3DImage< Space, KSpace >::myScaleX
protected

Definition at line 69 of file Viewer3DImage.h.

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
float Viewer3DImage< Space, KSpace >::myScaleY
protected

Definition at line 70 of file Viewer3DImage.h.

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
float Viewer3DImage< Space, KSpace >::myScaleZ
protected

Definition at line 71 of file Viewer3DImage.h.

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
int Viewer3DImage< Space, KSpace >::mySliceXPos
protected

Definition at line 72 of file Viewer3DImage.h.

Referenced by Viewer3DImage< Space, KSpace >::Viewer3DImage().

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
int Viewer3DImage< Space, KSpace >::mySliceYPos
protected

Definition at line 73 of file Viewer3DImage.h.

Referenced by Viewer3DImage< Space, KSpace >::Viewer3DImage().

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
int Viewer3DImage< Space, KSpace >::mySliceZPos
protected

Definition at line 74 of file Viewer3DImage.h.

Referenced by Viewer3DImage< Space, KSpace >::Viewer3DImage().

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
double Viewer3DImage< Space, KSpace >::myTotalAngleRotationX
protected

Definition at line 77 of file Viewer3DImage.h.

Referenced by Viewer3DImage< Space, KSpace >::Viewer3DImage().

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
double Viewer3DImage< Space, KSpace >::myTotalAngleRotationY
protected

Definition at line 78 of file Viewer3DImage.h.

Referenced by Viewer3DImage< Space, KSpace >::Viewer3DImage().

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
double Viewer3DImage< Space, KSpace >::myTotalAngleRotationZ
protected

Definition at line 79 of file Viewer3DImage.h.

Referenced by Viewer3DImage< Space, KSpace >::Viewer3DImage().


The documentation for this class was generated from the following files: