Ejemplo n.º 1
0
void MainWindow::updateSliceImageY(unsigned int sliceNumber, bool init){

  DGtal::functors::Projector<DGtal::Z2i::Space>  invFunctor; invFunctor.initRemoveOneDim(1);
  DGtal::Z2i::Domain domain2D(invFunctor(myImage3D->domain().lowerBound()),
                              invFunctor(myImage3D->domain().upperBound()));
  DGtal::functors::Projector<DGtal::Z3i::Space> aSliceFunctor(sliceNumber); aSliceFunctor.initAddOneDim(1);
  SliceImageAdapter sliceImage(*myImage3D, domain2D, aSliceFunctor, functors::Identity());
  
  double gridSize = ((double)INIT_SCALE1_ZOOM_FACTOR)/ui->_zoomYSlider->value();
  QImage anImage = getImage(sliceImage, gridSize); 
  setImageProjY(QPixmap::fromImage(anImage));
  if(init){
    (*myViewer) << sliceImage;
    (*myViewer) << DGtal::UpdateImagePosition< Space, KSpace >(1, DGtal::Viewer3D<>::yDirection, 0.0, sliceNumber, 0.0);
    (*myViewer) << Viewer3D<>::updateDisplay;
  }else{
    (*myViewer) << DGtal::UpdateImageData< SliceImageAdapter > (1, sliceImage, 0,0, 0, 0,  DGtal::Viewer3D<>::yDirection);
    (*myViewer) << DGtal::UpdateImagePosition< Space, KSpace >(1, DGtal::Viewer3D<>::yDirection, 0.0, sliceNumber, 0.0);
    (*myViewer).updateList(init);
    (*myViewer).update();      
  }



}
Ejemplo n.º 2
0
void MainWindow::updateZoomImageZ(unsigned int sliceNumber, double gridSize){
  DGtal::functors::Projector<DGtal::Z2i::Space>  invFunctor; invFunctor.initRemoveOneDim(2);
  DGtal::Z2i::Domain domain2D(invFunctor(myImage3D->domain().lowerBound()),
                              invFunctor(myImage3D->domain().upperBound()));
  DGtal::functors::Projector<DGtal::Z3i::Space> aSliceFunctor(sliceNumber); aSliceFunctor.initAddOneDim(2);
  SliceImageAdapter sliceImage(*myImage3D, domain2D, aSliceFunctor, functors::Identity());
  QImage anImage = getImage(sliceImage, gridSize); 
  setImageProjZ(QPixmap::fromImage(anImage));
}
Ejemplo n.º 3
0
void 
Viewer3DImage< Space, KSpace>::setVolImage(Image3D * an3DImage){
  my3dImage = an3DImage;

  switch (myMode) {
  case BoundingBox:
    (*this) << DGtal::SetMode3D("ConstImageAdapter", "BoundingBox");
    break;
  case InterGrid:
    (*this) << DGtal::SetMode3D("ConstImageAdapter", "InterGrid");
    break;
  case Grid:
    (*this) << DGtal::SetMode3D("ConstImageAdapter", "Grid");
    break;
  case Empty:
    (*this) << DGtal::SetMode3D("ConstImageAdapter", "");
    break;
  }

  myImageOrigin = my3dImage->domain().lowerBound();
  (*this).updateList(false);
  (*this).update();
  
  mySliceXPos=myImageOrigin[0];
  mySliceYPos=myImageOrigin[1];
  mySliceZPos=myImageOrigin[2];

 // Adding X slice in the viewer.
  DGtal::functors::Projector<DGtal::Z2i::Space>  invFunctorX; invFunctorX.initRemoveOneDim(0);
  DGtal::Z2i::Domain domain2DX(invFunctorX(my3dImage->domain().lowerBound()), 
			       invFunctorX(my3dImage->domain().upperBound()));
  
    
  DGtal::functors::SliceRotator2D<DGtal::Z3i::Domain> aSliceFunctorX(0, my3dImage->domain(), mySliceXPos,2, myAngleRotation );
  const DGtal::functors::Identity identityFunctor{};
  MyRotatorSliceImageAdapter sliceImageX( *my3dImage, domain2DX, aSliceFunctorX, identityFunctor ); 
    
  std::cout << "image:" << sliceImageX.className();
  (*this) << sliceImageX;
  (*this) << DGtal::UpdateImagePosition< Space, KSpace >(0, DGtal::Viewer3D<>::xDirection, mySliceXPos,myImageOrigin[1], myImageOrigin[2]);


  // Adding Y slice in the viewer.
  DGtal::functors::Projector<DGtal::Z2i::Space>  invFunctorY; invFunctorY.initRemoveOneDim(1);
  DGtal::Z2i::Domain domain2DY(invFunctorY(my3dImage->domain().lowerBound()), 
			       invFunctorY(my3dImage->domain().upperBound()));
 
  DGtal::functors::Projector<DGtal::Z3i::Space> aSliceFunctorY(mySliceYPos); aSliceFunctorY.initAddOneDim(1);
  SliceImageAdapter sliceImageY(*my3dImage, domain2DY, aSliceFunctorY, identityFunctor ); 
  (*this) << sliceImageY;
  (*this) << DGtal::UpdateImagePosition< Space, KSpace >(1, DGtal::Viewer3D<>::yDirection, myImageOrigin[0], mySliceYPos, myImageOrigin[2]);



 
 
   // Adding Z slice in the viewer.
  DGtal::functors::Projector<DGtal::Z2i::Space>  invFunctorZ; invFunctorZ.initRemoveOneDim(2);
  DGtal::Z2i::Domain domain2DZ(invFunctorZ(my3dImage->domain().lowerBound()), 
			       invFunctorZ(my3dImage->domain().upperBound()));
 
  DGtal::Z3i::Point centerZ((my3dImage->domain().upperBound())[0]/2, (my3dImage->domain().upperBound())[1]/2, mySliceZPos);
    
  DGtal::functors::SliceRotator2D<DGtal::Z3i::Domain> aSliceFunctorZ(2, my3dImage->domain(), mySliceZPos, 2, myAngleRotation, centerZ );
  MyRotatorSliceImageAdapter sliceImageZ( *my3dImage, domain2DZ, aSliceFunctorZ, identityFunctor ); 
  (*this) << sliceImageZ;
  (*this) << DGtal::UpdateImagePosition< Space, KSpace > (2, DGtal::Viewer3D<>::zDirection, myImageOrigin[0], myImageOrigin[1], mySliceZPos);
  (*this) << DGtal::Viewer3D<>::updateDisplay;    
  
}
Ejemplo n.º 4
0
void
Viewer3DImage< Space, KSpace>::keyPressEvent ( QKeyEvent *e )
{
  
  bool handled = false;
  if( e->key() == Qt::Key_M){
    myDisplayingInfo = !myDisplayingInfo;
    handled=true;
  } 
  if( e->key() == Qt::Key_I){
    std::cout << "Image generation" << std::endl;
    handled=true;
  }
  
  if( e->key() == Qt::Key_X){
    std::cout << "Current axis set to X" << std::endl;
    (*this).displayMessage(QString("Current axis set to X"), 100000); 
    myCurrentSliceDim=0;
    handled=true;
  }  
  if( e->key() == Qt::Key_Y){
    (*this).displayMessage(QString("Current axis set to Y"), 100000); 
    myCurrentSliceDim=1;
    handled=true;
  }
  if( e->key() == Qt::Key_Z){
    (*this).displayMessage(QString("Current axis set to Z"), 100000); 
    myCurrentSliceDim=2;
    handled=true;
  }
  if( e->key() == Qt::Key_Up ||  e->key() == Qt::Key_Down){
    int dirStep = (e->key() == Qt::Key_Up)? 5: -5; 
    if((e->modifiers() & Qt::ShiftModifier)){
      dirStep/=5;
    }
    if((e->modifiers() & Qt::MetaModifier)){
      myAngleRotation =(e->key() == Qt::Key_Down)? 0.1: -0.1;
      dirStep=0;
    }else{
      myAngleRotation=0.0;
    }
    int aSliceNum=0;
    int aSliceMax=0;
    bool stoped=false;
    if(myCurrentSliceDim==0){
      aSliceMax=my3dImage->domain().upperBound()[0]+1;
      if(mySliceXPos+dirStep<aSliceMax&&mySliceXPos+dirStep>=myImageOrigin[0]){
	 mySliceXPos+=dirStep;
      }else{
	stoped=true;
      }

      aSliceNum=mySliceXPos;
    }else if(myCurrentSliceDim==1){
      aSliceMax=my3dImage->domain().upperBound()[1]+1;
      if(mySliceYPos+dirStep<aSliceMax&&mySliceYPos+dirStep>=myImageOrigin[1]){
	 mySliceYPos+=dirStep;
      }else{
	stoped=true;
      }
      aSliceNum=mySliceYPos;
    }else if(myCurrentSliceDim==2){
      aSliceMax=my3dImage->domain().upperBound()[2]+1;
       if(mySliceZPos+dirStep<aSliceMax&&mySliceZPos+dirStep>=myImageOrigin[2]){
	 mySliceZPos+=dirStep;
       }else{
	 stoped=true;
       }
       aSliceNum=mySliceZPos;
    }

    if(!stoped){
      double myTotalAngleRotation=0.0;
      if(myCurrentSliceDim==0){
	myTotalAngleRotationX+=myAngleRotation;
	myTotalAngleRotation = myTotalAngleRotationX;
      }else if (myCurrentSliceDim==1){
	myTotalAngleRotationY+=myAngleRotation;
	myTotalAngleRotation = myTotalAngleRotationY;
      }else if (myCurrentSliceDim==2){
	myTotalAngleRotationZ+=myAngleRotation;
	myTotalAngleRotation = myTotalAngleRotationZ;
      }
      
      DGtal::functors::SliceRotator2D<DGtal::Z3i::Domain> aSliceFunctor(myCurrentSliceDim, my3dImage->domain(), 
							      aSliceNum, 2, myTotalAngleRotation);
      // Adding X slice in the viewer.
      DGtal::functors::Projector<DGtal::Z2i::Space>  invFunctor; invFunctor.initRemoveOneDim(myCurrentSliceDim);
      DGtal::Z2i::Domain domain2D(invFunctor(my3dImage->domain().lowerBound()), 
				  invFunctor(my3dImage->domain().upperBound()));
     
      const DGtal::functors::Identity identityFunctor{};
      MyRotatorSliceImageAdapter sliceImage( *my3dImage, domain2D, aSliceFunctor, identityFunctor ); 
      
      (*this) << DGtal::UpdateImageData<MyRotatorSliceImageAdapter>(myCurrentSliceDim, sliceImage, 
                                                                   (myCurrentSliceDim==0)? dirStep: 0.0, 
                                                                   (myCurrentSliceDim==1)? dirStep: 0.0,
                                                                   (myCurrentSliceDim==2)? dirStep: 0.0, 
							   myAngleRotation, DGtal::Viewer3D<>::zDirection);
      (*this).updateList(false);
      (*this).update();      
    }
    if(myDisplayingInfo){
      std::stringstream sstring;
      sstring << "slice X: " << mySliceXPos ;
      sstring << " slice Y: " << mySliceYPos ;
      sstring << " slice Z: " << mySliceZPos ;
      (*this).displayMessage(QString(sstring.str().c_str()), 100000);
    }



    
    handled=true;
  }
   
  if ( !handled )
    DGtal::Viewer3D<>::keyPressEvent ( e );
  
}