Commit 18b439a3 authored by Emmanuel Promayon's avatar Emmanuel Promayon

FIXED code cleaning + simplification in Slice

parent b5cc95c2
......@@ -186,6 +186,27 @@ public:
*/
vtkSmartPointer<vtkActor> getActor(const RenderingModes) override;
/** Set a texture to this object. */
void setTexture(vtkSmartPointer<vtkTexture> texture) override;
/// a vtkPoint of the structured was picked (to be reimplemented in a Component inherited class if needed)
void pointPicked(vtkIdType, bool) {};
/// a vtkCell of the structured was picked (to be reimplemented in a Component inherited class if needed)
void cellPicked(vtkIdType, bool) {};
///@}
/// @name manage extra prop associated with a Geometry
/// @{
/// TODO
/// - put all this management into a dedicated interface
/// - remove it from InterfaceBitMap and InterfaceGeometry
/// - remove it from Slice and Geometry helper classes
/// - create a new associated helper class
/// - update Component class and all other code using it (if needed)
/// Note : beware that Geometry requires this to manage to at least "label" and "glyph" extra actors
/// Return the vtkProp (actors, volumes and annotations) corresponding to the given name
vtkSmartPointer<vtkProp> getProp(const QString&) override;
......@@ -204,18 +225,8 @@ public:
* @return true if effictively done
*/
bool removeProp(const QString&) override;
/** Set a texture to this object. */
void setTexture(vtkSmartPointer<vtkTexture> texture) override;
/// a vtkPoint of the structured was picked (to be reimplemented in a Component inherited class if needed)
void pointPicked(vtkIdType, bool) {};
/// a vtkCell of the structured was picked (to be reimplemented in a Component inherited class if needed)
void cellPicked(vtkIdType, bool) {};
///@}
/// @}
/// @name InterfaceGeometry Helpers inherited methods
/// @{
......@@ -307,10 +318,7 @@ private:
/// the VTK mapper
vtkSmartPointer<vtkDataSetMapper> mapper;
/// The additional map for prop (include at least "label" and "glyph"
QMap<QString, vtkSmartPointer<vtkProp> > extraProp;
/// the mapper to create the text
vtkSmartPointer<vtkTextMapper> labelActorMapper;
......@@ -386,8 +394,15 @@ private:
double oldAlphaPoints;
double oldPointsColor[4];
///@}
protected:
vtkSmartPointer< vtkPointSet > New();
/// @name manage extra prop associated with a Geometry
/// @{
/// TODO see extra prop management method section
/// The additional map for prop (include at least "label" and "glyph")
QMap<QString, vtkSmartPointer<vtkProp> > extraProp;
///@}
};
......
......@@ -85,15 +85,12 @@ public:
/** Return the vtkActor used to pick pixels in the slices. */
virtual vtkSmartPointer<vtkActor> getPixelActor() = 0;
/** Return 2D Axes at the proper slice origin */
// virtual vtkSmartPointer<vtkAxesActor> get2DAxesActor() = 0;
/** This method is called when the associated plane has been picked in the InteractiveViewer,
* the given coordinates is position where the plane was picked.
*/
virtual void pixelPicked(double, double, double) = 0;
/// update the position of the plane surrounding the currently selected slice
virtual void updatePickPlane() = 0;
/** Return the number of slices in the image data set. */
......@@ -122,10 +119,18 @@ public:
/** Returns the encapsultaed data structure: the image as a vtkImageData. */
virtual vtkSmartPointer<vtkImageData> getImageData() const = 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;
/// @name manage extra prop associated with an InterfaceBitMap
/// @{
/// TODO
/// - put all this management into a dedicated interface
/// - remove it from InterfaceBitMap and InterfaceGeometry
/// - remove it from Slice and Geometry helper classes
/// - create a new associated helper class
/// - update Component class and all other code using it (if needed)
/// Note : beware that Geometry requires this to manage to at least "label" and "glyph" extra actors
/// Return the vtkProp (actors, volumes and annotations) corresponding to the given name
virtual vtkSmartPointer<vtkProp> getProp(const QString&) = 0;
......@@ -144,7 +149,7 @@ public:
* @return true if effictively done
*/
virtual bool removeProp(const QString&) = 0;
// END TODO
/// @}
};
......
......@@ -152,29 +152,7 @@ public:
* @see Geometry
*/
virtual void setDataConnection(vtkSmartPointer<vtkAlgorithmOutput>) = 0;
/// Return the actor for the representation mode, NULL if the actor doesn't exist.
virtual vtkSmartPointer<vtkActor> getActor(const RenderingModes) = 0;
/// 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;
/** remove a given additional prop.
* @return true if effictively done
*/
virtual bool removeProp(const QString&) = 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;
/// Set a texture to this object.
virtual void setTexture(vtkSmartPointer<vtkTexture>) = 0;
......@@ -204,6 +182,40 @@ public:
* @see InteractiveViewer
*/
virtual void cellPicked(vtkIdType cellId, bool pickingIsSelecting) = 0;
/// Return the actor for the representation mode, NULL if the actor doesn't exist.
virtual vtkSmartPointer<vtkActor> getActor(const RenderingModes) = 0;
///@}
/// @name manage extra prop associated with an InterfaceGeometry
/// @{
/// TODO
/// - put all this management into a dedicated interface
/// - remove it from InterfaceBitMap and InterfaceGeometry
/// - remove it from Slice and Geometry helper classes
/// - create a new associated helper class
/// - update Component class and all other code using it (if needed)
/// Note : beware that Geometry requires this to manage to at least "label" and "glyph" extra actors
/// 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;
/** remove a given additional prop.
* @return true if effictively done
*/
virtual bool removeProp(const QString&) = 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;
///@}
/// @name Helpers methods
......
This diff is collapsed.
......@@ -62,6 +62,8 @@ namespace camitk {
* Uses vtkImageActor::SetDisplayExtent for 3D and 2D Axial, Coronal and Sagittal representaiton.
* Re-position the camera for the 2D views.
*
* Slice also manages two other actors to visualize user picking inside the image:
* -
*
* \verbatim
* 3D Volume 2D Slice
......@@ -101,12 +103,6 @@ namespace camitk {
class CAMITK_API Slice : public InterfaceBitMap {
public:
/* -------------------------------------------------------------------- */
/**@{ */
/**@name Constructors / Destructors */
/**@{ */
/* -------------------------------------------------------------------- */
/** Common slices orientation: axial, sagittal, coronal axial_neuro.
* Axial, Sagittal and Coronal orientation are given in Radiologist point of view.
* The neurologist point of view is displayed in axial_neuro.
......@@ -137,17 +133,17 @@ public:
ARBITRARY
};
/// @name Constructors / Destructors
/// @{
/// Constructor
Slice(vtkSmartPointer<vtkImageData> volume, SliceOrientation AXIAL_ORIENTATION, vtkSmartPointer<vtkWindowLevelLookupTable> lookupTable = nullptr);
/// virtual destructor
~Slice() override;
/* -------------------------------------------------------------------- */
/**@} */
/**@name InterfaceBitMap implementation */
/**@{ */
/* -------------------------------------------------------------------- */
/// @}
/// @name InterfaceBitMap implementation
/// @{
/// set the original volume image data (the source vtkImageData before any reslice) and refresh the vtk pipeline
void setOriginalVolume(vtkSmartPointer<vtkImageData> img) override;
......@@ -161,31 +157,18 @@ public:
/** Return the vtkImageActor (vtkProp) representing a slice to be displayed in the 3D viewers. */
vtkSmartPointer<vtkImageActor> get3DImageActor() const override;
/** Return the vtkActor used to pick pixels in the slices. */
/** Return the vtkActor visualizing the plane of the slices. */
vtkSmartPointer<vtkActor> getPickPlaneActor() const override;
/** Return the vtkActor used to pick pixels in the slices. */
/** Return the vtkActor visualizing the picked pixels in the slices. */
vtkSmartPointer<vtkActor> getPixelActor() override;
/** Return 2D Axes at the proper slice origin */
virtual vtkSmartPointer<vtkAxesActor> get2DAxesActor();
/** This method is called when the associated plane has been picked in the InteractiveViewer,
* the given coordinates is position where the plane was picked.
*/
void pixelPicked(double, double, double) override;
/** Compute the volume coordinates (xyz) from the resliced coordinates (ijk)
* @param ijk: given resliced coordiantes (generally from a pixel picked in the pickPlane)
* @param xyz: output (should be allocated before calling this function)
* volume coordinates (with image at the origin in RAI convention) computed from the input
*/
/// Todo: put this method in abstract slice
void reslicedToVolumeCoords(const double* ijk, double* xyz);
/// Todo, idem...
void volumeToReslicedCoords(const double* xyz, double* ijk);
/// update the position of the plane surrounding the currently selected slice
void updatePickPlane() override;
/** Return the number of slices in the image data set. */
......@@ -214,9 +197,17 @@ public:
/// get the current image data
vtkSmartPointer<vtkImageData> getImageData() const override;
// BEGIN 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;
// @}
/// @name manage extra prop associated with a Slice
/// @{
/// TODO
/// - put all this management into a dedicated interface
/// - remove it from InterfaceBitMap and InterfaceGeometry
/// - remove it from Slice and Geometry helper classes
/// - create a new associated helper class
/// - update Component class and all other code using it (if needed)
/// Note : beware that Geometry requires this to manage to at least "label" and "glyph" extra actors
/// Return the vtkProp (actors, volumes and annotations) corresponding to the given name
vtkSmartPointer<vtkProp> getProp(const QString&) override;
......@@ -236,15 +227,14 @@ public:
* @return true if effictively done
*/
bool removeProp(const QString&) override;
// END TODO
/// @}
protected:
/* -------------------------------------------------------------------- */
/**@} */
/**@name Protected utility methods */
/**@{ */
/* -------------------------------------------------------------------- */
/// @name Protected utility methods
/// @{
/** Initialize Attributes */
virtual void init();
......@@ -252,11 +242,20 @@ protected:
/** Initialize actors and everything they need.*/
virtual void initActors();
/* -------------------------------------------------------------------- */
/**@} */
/**@name Attributes / Members of the class */
/**@{ */
/* ---------------------------------------------------------------------*/
/** Compute the volume coordinates (xyz) from the resliced coordinates (ijk)
* @param ijk: given resliced coordinates (generally from a pixel picked in the pickPlane)
* @param xyz: output (should be allocated before calling this function) volume coordinates (with image at the origin in RAI convention) computed from the input
*/
void reslicedToVolumeCoords(const double* ijk, double* xyz);
/// Compute the resliced coordinates (ijk) from the volume coordinates (xyz)
/// @param xyz: given volume coordinates (with image at the origin in RAI convention)
/// @param ijk: output (should be allocated before calling this function) resliced coordinates computed from the input
void volumeToReslicedCoords(const double* xyz, double* ijk);
/// @}
/// @name Attributes / Members of the class
/// @{
/** Direction of the reslice */
SliceOrientation sliceOrientation;
......@@ -268,7 +267,7 @@ protected:
/// 0 & 1 -> x; 2 and 3 -> y; 4 & 5 -> z
int extent[6];
/** Keep track of the slice number */
/** Keep track of the slice number */
int currentSliceIndex;
/// Common lookup table
......@@ -284,22 +283,23 @@ protected:
double originalSize[3];
/// To be able to extract a slice
vtkSmartPointer<vtkImageMapToColors> imgToMapFilter;
vtkSmartPointer<vtkImageMapToColors> imgToMapFilter;
/// 3D actor
vtkSmartPointer<vtkImageActor> image3DActor;
vtkSmartPointer<vtkImageActor> image3DActor;
/// 2D actor
vtkSmartPointer<vtkImageActor> image2DActor;
/**@} */
vtkSmartPointer<vtkImageActor> image2DActor;
/// @}
/// @name Used to visualize the current picking
/// @{
/**@} */
/**@name Uses for picking */
/**@{ */
/** A plane used for picking. This plane has the same size and position as the displayed slice. However, it is a
* real vtkActor that can be easily picked (using 'p' ot 'Ctrl+left click'). */
/** A plane used for picking.
* This plane has the same size and position as the displayed slice. However, it is a
* real vtkActor that can be easily picked (using 'p' ot 'Ctrl+left click').
*/
vtkSmartPointer<vtkPlaneSource> pickPlane;
/** Mapper of the the pickPlane. */
......@@ -308,7 +308,6 @@ protected:
/** Actor representing the pickPlane. */
vtkSmartPointer<vtkActor> pickPlaneActor;
/**
* Init the pixel actor for pixel picking
*/
......@@ -326,16 +325,31 @@ protected:
**/
void updatePixelActorPosition(double x, double y, double z);
/// update the pixel actor to the middle of the current slice
void updatePixelActorPosition();
/** Actor representing a pixel, displayed over the image. */
vtkSmartPointer<vtkActor> pixelActor;
void update2DAxesActorPosition();
void init2DAxesActor();
vtkSmartPointer<vtkAxesActor> axes2DActor;
/** Compute the out of plane shift depending on the orientation
* As the camera is facing the slice from one direction or another depending on the orientation,
* the extra decoration (pixel actor and plane actor) should be shifted a little bit towards
* the camera to guarantee their visibility without any depth/z-buffer problems.
*
* This method computes the value of the shift in world's unit depending on the orientation and
* slice thickness.
*/
double getOutOfPlaneShift();
/// @}
/// @name manage extra prop associated with a Slice
/// @{
/// TODO see extra prop management method section
/// The additional map for prop
QMap<QString, vtkSmartPointer<vtkProp> > extraProp;
/// @}
};
}
......
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