Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 78775699 authored by saubatn's avatar saubatn
Browse files

FIXED : Volume rendered from 2D images is now a vtkprop of the image...

FIXED : Volume rendered from 2D images is now a vtkprop of the image component. The arbirtrary slice holds the volume rendered prop and is displayed with the arbitrary slice, if computed. As a consequence, the volume rendered prop is deleted once the component is closed. Also the prop is only computed once. It should correctly work for the Labex ECCAMI.
TODO: Use a InterfaceRepresentation interface to correctly delegate the get/remove... prop methods in Component.h using the delegation pattern. Also, the volume rendered 3D image could be a kind of "Single Component" and being displayed as axial/coronal ... slice (right clicking a check-box in a pop-up menu). To be decided next.


git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@214 ec899d31-69d1-42ba-9299-647d76f65fb3
parent e34b03e7
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2012 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2012 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#include "VolumeRenderingAction.h"
......@@ -230,19 +230,21 @@ void VolumeRenderingAction::process(ImageComponent * comp) {
// Remove old volume from the component and the 3D viewer
QString volumeName = comp->getImageName() + "_vol_rendered";
vtkSmartPointer<vtkProp> oldVolume = comp->getProp(volumeName);
vtkSmartPointer<vtkProp> oldVolume = comp->getArbitrarySlices()->getProp(volumeName);
if (oldVolume) {
comp->removeProp(volumeName);
comp->getArbitrarySlices()->removeProp(volumeName);
//InteractiveViewer::get3DViewer()->getRendererWidget()->removeProp(oldVolume);
}
// Add the new computed volume to the component and display it in the 3D viewer
comp->addProp(volumeName, volume);
comp->getProp(volumeName)->SetVisibility(true);
comp->getArbitrarySlices()->addProp(volumeName, volume);
comp->getArbitrarySlices()->getProp(volumeName)->SetVisibility(true);
//InteractiveViewer::get3DViewer()->getRendererWidget()->addProp(volume);
//InteractiveViewer::get3DViewer()->refresh();
comp->refresh();
comp->getArbitrarySlices()->setVisibility(InteractiveViewer::get3DViewer(), true);
InteractiveViewer::get3DViewer()->refresh();
// Create new component
// new ImageComponent(volumeMapper->GetInput(), comp->getImageName() + "_vr");
......
......@@ -481,15 +481,51 @@ public:
delegateGet1(myGeometry, getActor, vtkSmartPointer<vtkActor>, const RenderingModes)
delegateGet1(myGeometry, getProp, vtkSmartPointer<vtkProp>, const QString &)
// TODO : uses an object myRepresentation (which is a Geometry or a Slice)
// to use a single delegate macro
virtual vtkSmartPointer<vtkProp> getProp(const QString &param)
{
if (myGeometry)
return myGeometry->getProp(param);
else if(mySlice)
return mySlice->getProp(param);
return NULL;
}
virtual unsigned int getNumberOfProp() const {
if (myGeometry)
return myGeometry->getNumberOfProp();
else if (mySlice)
return mySlice->getNumberOfProp();
return 0;
}
virtual vtkSmartPointer<vtkProp> getProp(unsigned int index) {
if (myGeometry)
return myGeometry->getProp(index);
else if (mySlice)
return mySlice->getProp(index);
return 0;
}
virtual bool addProp(const QString &name, vtkSmartPointer<vtkProp> prop) {
if (myGeometry)
return myGeometry->addProp(name, prop);
else if (mySlice)
return mySlice->addProp(name, prop);
return false;
}
virtual bool removeProp(const QString & name) {
if (myGeometry)
return myGeometry->removeProp(name);
else if (mySlice)
return mySlice->removeProp(name);
return false;
}
// END TODO
delegateConstGet0(myGeometry, getNumberOfProp, unsigned int)
delegateGet1(myGeometry, getProp, vtkSmartPointer<vtkProp>, unsigned int)
delegateGet2(myGeometry, addProp, bool, const QString &, vtkSmartPointer<vtkProp>)
delegateGet1(myGeometry, removeProp, bool, const QString &)
/** an inherited class can redefine this method something specific.
* Default behaviour: do nothing.
......
......@@ -28,6 +28,9 @@
// -- vtk stuff
#include <vtkSmartPointer.h>
#include <vtkProp.h>
#include <QMap>
#include <QString>
// -- vtk stuff Classes
class vtkImageActor;
......@@ -103,7 +106,7 @@ class InterfaceBitMap {
virtual vtkSmartPointer<vtkImageActor> get3DImageActor() const = 0;
/** Return the vtkActor used to pick pixels in the slices. */
// /** Return the vtkActor used to pick pixels in the slices. */
virtual vtkSmartPointer<vtkActor> getPickPlaneActor() const = 0;
/** Return the vtkActor used to pick pixels in the slices. */
......@@ -149,6 +152,30 @@ class InterfaceBitMap {
/// move the pixel selection green indicator (pixelActor) to the given real position
virtual void setPixelRealPosition(double, double, double) = 0;
// TODO : put all of this into a dedicated interface
/// The additional map for prop (include at least "label" and "glyph"
QMap<QString, vtkSmartPointer<vtkProp> > extraProp;
/// Return the vtkProp (actors, volumes and annotations) corresponding to the given name
virtual vtkSmartPointer<vtkProp> getProp(const QString &) = 0;
/// return the number of additional prop
virtual unsigned int getNumberOfProp() const = 0;
/// return an additional prop by its index
virtual vtkSmartPointer<vtkProp> getProp(unsigned int) = 0;
/** insert an additional prop, defining it by its name (default visibility = false)
* @return true if the additional prop was added (i.e. another additional prop of the same name does not exist)
*/
virtual bool addProp(const QString &, vtkSmartPointer<vtkProp>) = 0;
/** remove a given additional prop.
* @return true if effictively done
*/
virtual bool removeProp(const QString &) = 0;
// END TODO
};
......
......@@ -30,6 +30,7 @@
// -- vtk stuff
#include <vtkImageData.h>
#include <vtkProperty.h>
#include <vtkViewport.h>
namespace camitk
......@@ -737,5 +738,57 @@ vtkSmartPointer<vtkActor> Slice::getPixelActor()
return pixelActor;
}
// TODO : put those methods into a dedicated interface
//------------------------------- addProp ----------------------------------------
bool Slice::addProp(const QString& name, vtkSmartPointer< vtkProp > prop ) {
if (!extraProp.contains(name)) {
extraProp.insert(name, prop);
return true;
}
else
return false;
}
//------------------------------- getProp ----------------------------------------
vtkSmartPointer< vtkProp > Slice::getProp(const QString& name) {
if (extraProp.contains(name))
return extraProp.value(name);
else
return NULL;
}
//------------------------------- getNumberOfProp ----------------------------------------
unsigned int Slice::getNumberOfProp() const {
return extraProp.values().size();
}
//------------------------------- getProp ----------------------------------------
vtkSmartPointer< vtkProp > Slice::getProp(unsigned int index) {
return extraProp.values().at(index);
}
//------------------------------- removeProp ----------------------------------------
bool Slice::removeProp(const QString& name) {
if (extraProp.contains(name)) {
// remove the prop from any renderer/consummers
vtkSmartPointer<vtkProp> prop = extraProp.value(name);
prop->VisibilityOff();
for (int i = 0;i < prop->GetNumberOfConsumers();i++) {
vtkViewport *viewer = vtkViewport::SafeDownCast(prop->GetConsumer(i));
if (viewer)
viewer->RemoveViewProp(prop);
}
// remove it from the maps
extraProp.remove(name);
return true;
}
else
return false;
}
}
......@@ -189,6 +189,30 @@ public:
/// move the pixel selection green indicator (pixelActor) to the given real position
virtual void setPixelRealPosition(double, double, double);
// TODO : put all of this into a dedicated interface
/// The additional map for prop (include at least "label" and "glyph"
QMap<QString, vtkSmartPointer<vtkProp> > extraProp;
/// Return the vtkProp (actors, volumes and annotations) corresponding to the given name
virtual vtkSmartPointer<vtkProp> getProp(const QString &);
/// return the number of additional prop
virtual unsigned int getNumberOfProp() const;
/// return an additional prop by its index
virtual vtkSmartPointer<vtkProp> getProp(unsigned int);
/** insert an additional prop, defining it by its name (default visibility = false)
* @return true if the additional prop was added (i.e. another additional prop of the same name does not exist)
*/
virtual bool addProp(const QString &, vtkSmartPointer<vtkProp>);
/** remove a given additional prop.
* @return true if effictively done
*/
virtual bool removeProp(const QString &);
// END TODO
protected:
/* -------------------------------------------------------------------- */
......
......@@ -436,7 +436,14 @@ void InteractiveViewer::refresh(Viewer * v) {
}
else {
if (comp->getRepresentation() == Component::SLICE)
{
addActor(comp, comp->get3DImageActor());
// TODO : Nicolas, handle vtk prop for volume rendering in a dedicated interface
// => Create a specific vtkactor for each vtk image data
for (unsigned int i=0; i<comp->getNumberOfProp(); i++)
addActor(comp, comp->getProp(i));
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment