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

#include <visualisation/specificClasses/Viewer3DImage.h>

Inherits DGtal::Viewer3D< DGtal::Z3i::Space, DGtal::Z3i::KSpace >.

Public Types

enum  ModeVisu { BoundingBox , InterGrid , Grid , Empty }
 

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

Image3D * my3dImage
 
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

◆ Image2D

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.

◆ Image3D

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.

◆ MyRotatorSliceImageAdapter

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.

◆ SliceImageAdapter

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

◆ ModeVisu

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

◆ Viewer3DImage() [1/2]

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.

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  }
ModeVisu myMode
Definition: Viewer3DImage.h:82
double myAngleRotation
Definition: Viewer3DImage.h:76
double myTotalAngleRotationY
Definition: Viewer3DImage.h:78
double myTotalAngleRotationZ
Definition: Viewer3DImage.h:79
double myTotalAngleRotationX
Definition: Viewer3DImage.h:77
bool myDisplayingInfo
Definition: Viewer3DImage.h:80
DGtal::Z3i::Point myImageOrigin
Definition: Viewer3DImage.h:81

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().

◆ Viewer3DImage() [2/2]

template<typename Space = DGtal::Z3i::Space, typename KSpace = DGtal::Z3i::KSpace>
Viewer3DImage< Space, KSpace >::Viewer3DImage ( Image3D *  an3DImage)
inline

Definition at line 54 of file Viewer3DImage.h.

54  {
55  my3dImage = an3DImage;
56  Viewer3DImage();
57  }
Image3D * my3dImage
Definition: Viewer3DImage.h:68
Viewer3DImage(ModeVisu aMode=BoundingBox)
Definition: Viewer3DImage.h:40

References Viewer3DImage< Space, KSpace >::my3dImage, and Viewer3DImage< Space, KSpace >::Viewer3DImage().

Member Function Documentation

◆ helpString()

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

Definition at line 128 of file Viewer3DImage.cpp.

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 }

◆ init()

template<typename Space , typename KSpace >
void Viewer3DImage< Space, KSpace >::init
protectedvirtual

Definition at line 40 of file Viewer3DImage.cpp.

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

◆ keyPressEvent()

template<typename Space , typename KSpace >
void Viewer3DImage< Space, KSpace >::keyPressEvent ( QKeyEvent *  e)
protectedvirtual

Definition at line 154 of file Viewer3DImage.cpp.

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 }
DGtal::ConstImageAdapter< Image3D, DGtal::Z2i::Domain, DGtal::functors::SliceRotator2D< DGtal::Z3i::Domain >, Image3D::Value, DGtal::functors::Identity > MyRotatorSliceImageAdapter
Definition: Viewer3DImage.h:33

◆ setVolImage()

template<typename Space , typename KSpace >
void Viewer3DImage< Space, KSpace >::setVolImage ( Image3D *  an3DImage)

Definition at line 55 of file Viewer3DImage.cpp.

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

Field Documentation

◆ my3dImage

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().

◆ myAngleRotation

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().

◆ myCurrentSliceDim

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().

◆ myDisplayingInfo

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().

◆ myImageOrigin

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.

◆ myMode

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().

◆ myScaleX

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.

◆ myScaleY

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.

◆ myScaleZ

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.

◆ mySliceXPos

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().

◆ mySliceYPos

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().

◆ mySliceZPos

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().

◆ myTotalAngleRotationX

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().

◆ myTotalAngleRotationY

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().

◆ myTotalAngleRotationZ

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: