--- /dev/null
+/*=========================================================================
+
+ Program: bbtk
+ Module: $RCSfile: bbvtkImagePlanes.cxx,v $
+ Language: C++
+ Date: $Date: 2008/04/01 14:26:22 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See Doc/License.txt or
+ http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+/**
+ * \file
+ * \brief
+ */
+
+
+
+#ifdef _USE_VTK_
+#include "bbvtkImagePlanes.h"
+#include "bbvtkPackage.h"
+#include "vtkCellPicker.h"
+#include "vtkProperty.h"
+
+#include "bbstdCast.h"
+namespace bbstd
+{
+ //====================================================================
+ BBTK_USER_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(Cast,
+ bbtk::AtomicBlackBox);
+ //====================================================================
+
+}
+using namespace bbstd;
+namespace bbvtk
+{
+ //====================================================================
+ // Add the specialized adaptors to the package
+ typedef vtkImagePlaneWidget* I;
+ typedef vtkInteractorObserver* O;
+
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(vtk,Cast,I,O);
+
+}
+
+
+
+namespace bbvtk
+{
+
+
+ BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,ImagePlanes)
+ BBTK_USER_BLACK_BOX_IMPLEMENTATION(ImagePlanes,bbtk::AtomicBlackBox);
+
+
+
+
+
+ void ImagePlanes::bbUserConstructor()
+ {
+ Init();
+ bbSetInputIn(0);
+ }
+ void ImagePlanes::bbUserCopyConstructor()
+ {
+ Init();
+ }
+
+ void ImagePlanes::Init()
+ {
+
+ // The shared picker enables us to use 3 planes at one time
+ // and gets the picking order right
+ vtkCellPicker* picker = vtkCellPicker::New();
+ picker->SetTolerance(0.005);
+
+ // The 3 image plane widgets are used to probe the dataset.
+ planeWidgetX = vtkImagePlaneWidget::New();
+ planeWidgetX->DisplayTextOn();
+ planeWidgetX->SetPicker(picker);
+ planeWidgetX->SetKeyPressActivationValue('x');
+ vtkProperty* prop1 = planeWidgetX->GetPlaneProperty();
+ prop1->SetColor(1, 0, 0);
+
+ planeWidgetY = vtkImagePlaneWidget::New();
+ planeWidgetY->DisplayTextOn();
+ planeWidgetY->SetPicker(picker);
+ planeWidgetY->SetKeyPressActivationValue('y');
+ vtkProperty* prop2 = planeWidgetY->GetPlaneProperty();
+ prop2->SetColor(1, 1, 0);
+ planeWidgetY->SetLookupTable(planeWidgetX->GetLookupTable());
+
+ // for the z-slice, turn off texture interpolation:
+ // interpolation is now nearest neighbour, to demonstrate
+ // cross-hair cursor snapping to pixel centers
+ planeWidgetZ = vtkImagePlaneWidget::New();
+ planeWidgetZ->DisplayTextOn();
+ planeWidgetZ->SetPicker(picker);
+ planeWidgetZ->SetKeyPressActivationValue('z');
+ vtkProperty* prop3 = planeWidgetZ->GetPlaneProperty();
+ prop3->SetColor(0, 0, 1);
+ planeWidgetZ->SetLookupTable(planeWidgetX->GetLookupTable());
+
+ bbSetOutputPlaneX(planeWidgetX);
+ bbSetOutputPlaneY(planeWidgetY);
+ bbSetOutputPlaneZ(planeWidgetZ);
+ }
+
+//---------------------------------------------------------------------
+
+ void ImagePlanes::Process()
+ {
+ if (bbGetInputIn()!=0)
+ {
+ int xMin, xMax, yMin, yMax, zMin, zMax;
+ bbGetInputIn()->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax);
+
+ planeWidgetX->SetInput(bbGetInputIn());
+ planeWidgetX->SetPlaneOrientationToXAxes();
+ planeWidgetX->SetSlicePosition((xMax+xMin)/2.);
+
+ planeWidgetY->SetInput(bbGetInputIn());
+ planeWidgetY->SetPlaneOrientationToYAxes();
+ planeWidgetY->SetSlicePosition((yMax+yMin)/2.);
+
+ planeWidgetZ->SetInput(bbGetInputIn());
+ planeWidgetZ->SetPlaneOrientationToZAxes();
+ planeWidgetZ->SetSlicePosition((zMax+zMin)/2.);
+
+ planeWidgetZ->SetWindowLevel(512,256);
+ }
+ }
+}//namespace bbtk
+
+#endif // _USE_VTK_
+
--- /dev/null
+/*=========================================================================
+
+ Program: bbtk
+ Module: $RCSfile: bbvtkImagePlanes.h,v $
+ Language: C++
+ Date: $Date: 2008/04/01 14:26:22 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See Doc/License.txt or
+ http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*//**
+ * \brief Short description in one line
+ *
+ * Long description which
+ * can span multiple lines
+ */
+/**
+ * \file
+ * \brief Pattern for the definition of a new type of Node (header)
+ */
+/**
+ * \class bbtk::NodePatern
+ * \brief Pattern for the definition of a new type of Node
+ */
+
+
+#ifdef _USE_VTK_
+
+
+#ifndef __bbvtkImagePlanes_h_INCLUDED__
+#define __bbvtkImagePlanes_h_INCLUDED__
+
+
+#include "bbtkAtomicBlackBox.h"
+
+#include "vtkImageData.h"
+//#include "vtkOutlineFilter.h"
+//#include "vtkPolyDataMapper.h"
+//#include "vtkActor.h"
+#include "vtkImagePlaneWidget.h"
+#include "vtkCellPicker.h"
+//#include "vtkProperty.h"
+
+//#include "vtkRenderer.h"
+//#include "vtkCamera.h"
+
+namespace bbvtk
+{
+
+
+
+ class /*BBTK_EXPORT*/ ImagePlanes : public bbtk::AtomicBlackBox
+ {
+ public:
+ BBTK_USER_BLACK_BOX_INTERFACE(ImagePlanes,bbtk::AtomicBlackBox);
+ // BBTK_DECLARE_INPUT(Contour,int);
+ BBTK_DECLARE_INPUT(In,vtkImageData *);
+ BBTK_DECLARE_OUTPUT(PlaneX,vtkImagePlaneWidget*);
+ BBTK_DECLARE_OUTPUT(PlaneY,vtkImagePlaneWidget*);
+ BBTK_DECLARE_OUTPUT(PlaneZ,vtkImagePlaneWidget*);
+ BBTK_PROCESS(Process);
+ void Process();
+
+ protected:
+ virtual void bbUserConstructor();
+ virtual void bbUserCopyConstructor();
+ void Init();
+ private:
+ vtkImagePlaneWidget* planeWidgetX;
+ vtkImagePlaneWidget* planeWidgetY;
+ vtkImagePlaneWidget* planeWidgetZ;
+ };
+
+ //=================================================================
+ // UserBlackBox description
+ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImagePlanes,bbtk::AtomicBlackBox);
+ BBTK_NAME("ImagePlanes");
+ BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("Creates three 3D planes with the input image mapped onto with which the user can interact. The output vtkImagePlaneWidget objects are to be inserted into a 3D scene (e.g. a Viewer3D)");
+ BBTK_CATEGORY("3D object creator");
+ BBTK_INPUT(ImagePlanes,In,"Input Image",vtkImageData *);
+ BBTK_OUTPUT(ImagePlanes,PlaneX,"The image plane in X direction",vtkImagePlaneWidget*);
+ BBTK_OUTPUT(ImagePlanes,PlaneY,"The image plane in Y direction",vtkImagePlaneWidget*);
+ BBTK_OUTPUT(ImagePlanes,PlaneZ,"The image plane in Z direction",vtkImagePlaneWidget*);
+ BBTK_END_DESCRIBE_BLACK_BOX(ImagePlanes);
+ //=================================================================
+
+
+
+
+
+}//namespace bbvtk
+
+#endif //__bbtvtkImagePlanes_h__
+
+#endif //_USE_VTK_
+
--- /dev/null
+description "Example of the box vtk::ImagePlanes."
+author "laurent.guigues@creatis.insa-lyon.fr"
+category "example"
+
+include vtk/boxes/bbLoadHola
+load vtk
+load wxvtk
+
+new LoadHola image
+new ImagePlanes planes
+new Viewer3D viewer
+connect image.Out planes.In
+connect planes.PlaneX viewer.Obs1
+connect planes.PlaneY viewer.Obs2
+connect planes.PlaneZ viewer.Obs3
+
+load std
+set viewer.WinTitle "ExampleImagePlanes"
+set viewer.WinWidth 350
+set viewer.WinHeight 400
+#set viewer.Slice 20
+
+exec viewer
+
Program: bbtk
Module: $RCSfile: bbwxvtkViewer3D.cxx,v $
Language: C++
- Date: $Date: 2008/03/03 13:14:27 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/04/01 14:26:23 $
+ Version: $Revision: 1.2 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// camera->SetParallelScale( spx*(x2-x1)/2.0 );
renderer->ResetCamera(x1,x2,y1,y2,z1,z2);
-
+ renderer->SetBackground(0.1, 0.1, 0.2);
+
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add( wxvtkrenderwindowinteractor , 1, wxEXPAND, 0);
panel->SetSizer(sizer);
bbSetInputIn3(NULL);
bbSetInputIn4(NULL);
bbSetInputIn5(NULL);
+ bbSetInputObs1(NULL);
bbSetOutputRenderer( NULL );
bbSetOutputInteractor( NULL );
}
Viewer3DWidget* w = new Viewer3DWidget(this,bbGetWxParent());
w->Update();
- bbSetOutputInteractor( w->GetInteractor() );
-
vtkRenderer *renderer = w->GetRenderer();
if (renderer!=NULL)
{
- vtkRenderer *renderer = w->GetRenderer();
if (bbGetInputIn1()!=NULL) {renderer->AddActor( bbGetInputIn1() ); }
if (bbGetInputIn2()!=NULL) {renderer->AddActor( bbGetInputIn2() ); }
if (bbGetInputIn3()!=NULL) {renderer->AddActor( bbGetInputIn3() ); }
if (bbGetInputIn4()!=NULL) {renderer->AddActor( bbGetInputIn4() ); }
if (bbGetInputIn5()!=NULL) {renderer->AddActor( bbGetInputIn5() ); }
renderer->ResetCamera();
- bbSetOutputRenderer( w->GetRenderer() );
-
-
+ bbSetOutputRenderer( renderer );
+
}
-
+ vtkRenderWindowInteractor *interactor = w->GetInteractor();
+ if (interactor!=NULL)
+ {
+ if (bbGetInputObs1()!=NULL)
+ {
+ bbGetInputObs1()->SetInteractor(interactor);
+ bbGetInputObs1()->EnabledOn();
+ }
+ if (bbGetInputObs2()!=NULL)
+ {
+ bbGetInputObs2()->SetInteractor(interactor);
+ bbGetInputObs2()->EnabledOn();
+ }
+ if (bbGetInputObs3()!=NULL)
+ {
+ bbGetInputObs3()->SetInteractor(interactor);
+ bbGetInputObs3()->EnabledOn();
+ }
+ if (bbGetInputObs4()!=NULL)
+ {
+ bbGetInputObs4()->SetInteractor(interactor);
+ bbGetInputObs4()->EnabledOn();
+ }
+ if (bbGetInputObs5()!=NULL)
+ {
+ bbGetInputObs5()->SetInteractor(interactor);
+ bbGetInputObs5()->EnabledOn();
+ }
+ bbSetOutputInteractor( w->GetInteractor() );
+ }
+
bbSetOutputWidget(w);
bbtkDebugDecTab("Core",9);
Program: bbtk
Module: $RCSfile: bbwxvtkViewer3D.h,v $
Language: C++
- Date: $Date: 2008/03/19 13:30:19 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/01 14:26:23 $
+ Version: $Revision: 1.3 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
BBTK_DECLARE_INPUT(In3, vtkProp3D *);
BBTK_DECLARE_INPUT(In4, vtkProp3D *);
BBTK_DECLARE_INPUT(In5, vtkProp3D *);
+ BBTK_DECLARE_INPUT(Obs1, vtkInteractorObserver *);
+ BBTK_DECLARE_INPUT(Obs2, vtkInteractorObserver *);
+ BBTK_DECLARE_INPUT(Obs3, vtkInteractorObserver *);
+ BBTK_DECLARE_INPUT(Obs4, vtkInteractorObserver *);
+ BBTK_DECLARE_INPUT(Obs5, vtkInteractorObserver *);
BBTK_DECLARE_OUTPUT(Renderer,vtkRenderer*);
BBTK_DECLARE_OUTPUT(Interactor,wxVTKRenderWindowInteractor*);
BBTK_PROCESS(Process);
BBTK_INPUT(Viewer3D,In3,"Input actor",vtkProp3D *);
BBTK_INPUT(Viewer3D,In4,"Input actor",vtkProp3D *);
BBTK_INPUT(Viewer3D,In5,"Input actor",vtkProp3D *);
+ BBTK_INPUT(Viewer3D,Obs1,"Input observer",vtkInteractorObserver *);
+ BBTK_INPUT(Viewer3D,Obs2,"Input observer",vtkInteractorObserver *);
+ BBTK_INPUT(Viewer3D,Obs3,"Input observer",vtkInteractorObserver *);
+ BBTK_INPUT(Viewer3D,Obs4,"Input observer",vtkInteractorObserver *);
+ BBTK_INPUT(Viewer3D,Obs5,"Input observer",vtkInteractorObserver *);
BBTK_OUTPUT(Viewer3D,Renderer,"Renderer to which actors can be added.",vtkRenderer*);
BBTK_OUTPUT(Viewer3D,Interactor,"Interactor with which vtk widgets can interact",wxVTKRenderWindowInteractor*);
BBTK_END_DESCRIBE_BLACK_BOX(Viewer3D);