Program: bbtk
Module: $RCSfile: bbtkBlackBox.cxx,v $
Language: C++
- Date: $Date: 2008/12/03 09:34:37 $
- Version: $Revision: 1.30 $
+ Date: $Date: 2008/12/03 13:35:22 $
+ Version: $Revision: 1.31 $
=========================================================================*/
/* ---------------------------------------------------------------------
{
bbtkDebugMessage("modified",2,"-> Status set to modified"<<std::endl);
this->bbSetStatus(MODIFIED);
- std::cout << "Status set to modified" <<std::endl;
}
this->bbSignalOutputModification(false);
void BlackBox::bbSignalOutputModification(bool reaction)
{
bbtkDebugMessageInc("process",5,
- "=> BlackBox::bbSignalOutputModification() ["
+ "=> BlackBox::bbSignalOutputModification("
+ <<reaction<<") ["
<<bbGetFullName()<<"]"<<std::endl);
OutputConnectorMapType::iterator change = bbGetOutputConnectorMap().end();
//=========================================================================
//=========================================================================
void BlackBox::bbSignalOutputModification(const std::string& output,
- bool reaction)
+ bool reaction)
{
bbtkDebugMessageInc("process",5,
"=> BlackBox::bbSignalOutputModification("
- <<output<<") ["
+ <<output<<","<<reaction<<") ["
<<bbGetFullName()<<"]"<<std::endl);
OutputConnectorMapType::iterator i = bbGetOutputConnectorMap().find(output);
Program: bbtk
Module: $RCSfile: bbtkBlackBox.h,v $
Language: C++
- Date: $Date: 2008/12/03 09:34:37 $
- Version: $Revision: 1.15 $
+ Date: $Date: 2008/12/03 13:35:22 $
+ Version: $Revision: 1.16 $
=========================================================================*/
/* ---------------------------------------------------------------------
/// Signals that the BlackBox has been modified through the input connector c
/// and propagates it downward
+ /// ** NOT USER INTENDED **
virtual void bbSetModifiedStatus(BlackBoxInputConnector* c = 0);
+
/// Signals that the BlackBox outputs have been modified
- /// without marking the box as MODIFIED because its output state is ok.
+ /// (without marking the box as MODIFIED because its output state is ok : don't care if you understand : use it !).
/// This method should be used by widgets in response
/// to user interaction when **ALL** outputs have been modified
- /// (after the outputs has been updated !)
+ /// (after the outputs has been updated !).
+ /// DO NOT PASS reaction = false OR WILL NOT WORK PROPERLY
+ /// ** USER INTENDED **
virtual void bbSignalOutputModification(bool reaction = true);
- /// Signals that the BlackBox output "output_name" have been modified
- /// without marking the box as MODIFIED because its output state is ok.
+ /// Signals that the BlackBox output "output_name" has been modified
+ /// (without marking the box as MODIFIED because its output state is ok : don't care if you understand : use it !).
/// This method should be used by widgets in response to user interaction
/// only when **ONE** output has been modified
/// (after the output has been updated !)
+ /// DO NOT PASS reaction = false OR WILL NOT WORK PROPERLY
+ /// ** USER INTENDED **
virtual void bbSignalOutputModification( const std::string& output_name,
bool reaction = true);
- /// Signals that the BlackBox vector of outputs "output_name"
- /// have been modified
- /// without marking the box as MODIFIED because its output state is ok.
+ /// Signals that the BlackBox vector of outputs "output_name"
+ /// have been modified.
+ /// Should be used when more than ONE output is modified but not ALL
+ /// (optimization issue).
+ /// (without marking the box as MODIFIED because its output state is ok).
/// This method should be used by widgets in response to user interaction
/// When more than one output has been changed but not all
/// (after the outputs have been updated of course!)
+ /// DO NOT PASS reaction = false OR WILL NOT WORK PROPERLY
+ /// ** USER INTENDED **
virtual void bbSignalOutputModification( const std::vector<std::string>& output_name,
bool reaction = true);
load kw
-new Slider s
+new kwSlider s
exec s
-unload kw
+#unload kw
Program: bbtk
Module: $RCSfile: bbkwLayoutSplit.h,v $
Language: C++
- Date: $Date: 2008/12/02 13:37:56 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/12/03 13:35:27 $
+ Version: $Revision: 1.3 $
=========================================================================*/
/* ---------------------------------------------------------------------
//=================================================================
// BlackBox description
BBTK_BEGIN_DESCRIBE_BLACK_BOX(LayoutSplit,bbtk::KWBlackBox);
- BBTK_NAME("LayoutSplit");
+ BBTK_NAME("kwLayoutSplit");
BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
BBTK_DESCRIPTION("Widget which splits a window in two fixed size parts (vtkKWSplitFrame)");
// Already inserted for any KwBlackBox BBTK_CATEGORY("widget");
--- /dev/null
+/*=========================================================================
+ Program: bbtk
+ Module: $RCSfile: bbkwOutputText.cxx,v $
+ Language: C++
+ Date: $Date: 2008/12/03 13:35:27 $
+ Version: $Revision: 1.1 $
+=========================================================================*/
+
+/* ---------------------------------------------------------------------
+
+* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
+* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
+*
+* This software is governed by the CeCILL-B license under French law and
+* abiding by the rules of distribution of free software. You can use,
+* modify and/ or redistribute the software under the terms of the CeCILL-B
+* license as circulated by CEA, CNRS and INRIA at the following URL
+* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+* or in the file LICENSE.txt.
+*
+* As a counterpart to the access to the source code and rights to copy,
+* modify and redistribute granted by the license, users are provided only
+* with a limited warranty and the software's author, the holder of the
+* economic rights, and the successive licensors have only limited
+* liability.
+*
+* The fact that you are presently reading this means that you have had
+* knowledge of the CeCILL-B license and that you accept its terms.
+* ------------------------------------------------------------------------ */
+
+/**
+ * \file
+ * \brief Short description in one line
+ *
+ * Long
+ * description
+ *
+ */
+
+#ifdef USE_KWWIDGETS
+
+#include "bbkwOutputText.h"
+#include "bbkwPackage.h"
+#include "bbtkUtilities.h"
+
+#include "vtkKWLabel.h"
+/*
+#include "vtkObjectFactory.h"
+#include "vtkCommand.h"
+*/
+namespace bbkw
+{
+
+ //--------------------------------------------------------------------------
+ //-------------------------------------------------------------------------
+ // KwBlackBox implementation
+ //--------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ BBTK_BLACK_BOX_IMPLEMENTATION(OutputText,bbtk::KWBlackBox);
+ BBTK_ADD_BLACK_BOX_TO_PACKAGE(kw,OutputText);
+
+ //--------------------------------------------------------------------------
+ void OutputText::bbUserConstructor()
+ {
+ bbSetInputIn("");
+ bbSetOutputWidget(0);
+ }
+
+ //--------------------------------------------------------------------------
+ void OutputText::Process()
+ {
+ vtkKWLabel* s = (vtkKWLabel*)bbGetOutputWidget();
+ if (s)
+ {
+ s->SetText( bbGetInputIn().c_str() );
+ }
+ }
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ void OutputText::CreateWidget(vtkKWFrame* parent)
+ {
+ vtkKWLabel* s = vtkKWLabel::New();
+ bbSetOutputWidget(s);
+ // s->AddObserver(vtkKWScale::ScaleValueChangingEvent,this);
+ s->SetParent((vtkKWWidget*)parent);
+ s->Create();
+
+ s->SetText(bbGetInputIn().c_str() );
+ // s->SetResolution(1.0);
+ // s->SetLength(150);
+ }
+ //--------------------------------------------------------------------------
+
+ //--------------------------------------------------------------------------
+ /*
+ void OutputText::Execute(vtkObject* caller, unsigned long, void*)
+ {
+ // std::cout << "$$$$$$$$$$$$ OutputText CB $$$$$$$$$$$$"<<std::endl;
+ vtkKWScale* scale = (vtkKWScale*)caller;
+ bbSetOutputOut( scale->GetValue() );
+ bbSetInputIn( scale->GetValue() );
+ // and signal that the output has changed
+ bbSignalOutputModification("Out");
+ }
+ */
+ //--------------------------------------------------------------------------
+
+
+
+} //namespace bbkw
+
+#endif // USE_KWWIDGETS
+
+
--- /dev/null
+/*=========================================================================
+ Program: bbtk
+ Module: $RCSfile: bbkwOutputText.h,v $
+ Language: C++
+ Date: $Date: 2008/12/03 13:35:27 $
+ Version: $Revision: 1.1 $
+=========================================================================*/
+
+/* ---------------------------------------------------------------------
+
+* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
+* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
+*
+* This software is governed by the CeCILL-B license under French law and
+* abiding by the rules of distribution of free software. You can use,
+* modify and/ or redistribute the software under the terms of the CeCILL-B
+* license as circulated by CEA, CNRS and INRIA at the following URL
+* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+* or in the file LICENSE.txt.
+*
+* As a counterpart to the access to the source code and rights to copy,
+* modify and redistribute granted by the license, users are provided only
+* with a limited warranty and the software's author, the holder of the
+* economic rights, and the successive licensors have only limited
+* liability.
+*
+* The fact that you are presently reading this means that you have had
+* knowledge of the CeCILL-B license and that you accept its terms.
+* ------------------------------------------------------------------------ */
+
+/**
+ * \file
+ * \brief Short description in one line
+ *
+ * Long description which
+ * can span multiple lines
+*/
+
+/**
+ * \class bbkw::OutputText
+ * \brief
+
+ * \class bbkw::OutputTextWidget
+ * \brief
+ */
+
+#ifdef USE_KWWIDGETS
+
+#ifndef __bbkwOutputText_h_INCLUDED__
+#define __bbkwOutputText_h_INCLUDED__
+
+// Include KWBlackBox definition
+#include "bbtkKWBlackBox.h"
+
+//#include "vtkCommand.h"
+
+
+namespace bbkw
+{
+
+ //------------------------------------------------------------------------
+ // The black box
+ class /*BBTK_EXPORT*/ OutputText : public bbtk::KWBlackBox //, public vtkCommand
+ {
+
+ BBTK_BLACK_BOX_INTERFACE(OutputText,bbtk::KWBlackBox);
+ BBTK_DECLARE_INPUT(In,std::string);
+ BBTK_PROCESS(Process);
+ BBTK_CREATE_KWWIDGET(CreateWidget);
+ void Process();
+ void CreateWidget(vtkKWFrame*);
+ // virtual void Execute(vtkObject* caller, unsigned long, void*);
+
+ protected:
+ virtual void bbUserConstructor();
+ };
+ //=================================================================
+
+ //=================================================================
+ // the black box description
+ BBTK_BEGIN_DESCRIBE_BLACK_BOX(OutputText,bbtk::KWBlackBox);
+ BBTK_NAME("kwOutputText");
+ BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+ // Already inserted for any KWBlackBox BBTK_CATEGORY("widget");
+ BBTK_DESCRIPTION("OutputText widget (vtkKWLabel)");
+ BBTK_INPUT(OutputText,In,"Text to display",std::string,"");
+ BBTK_END_DESCRIBE_BLACK_BOX(OutputText);
+ //=================================================================
+
+
+
+} //namespace bbkw
+
+#endif //__bbtkkwOutputText_h_INCLUDED__
+
+#endif // USE_KWWIDGETS
Program: bbtk
Module: $RCSfile: bbkwSlicer.h,v $
Language: C++
- Date: $Date: 2008/12/02 13:37:56 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/12/03 13:35:27 $
+ Version: $Revision: 1.3 $
=========================================================================*/
/* ---------------------------------------------------------------------
//=================================================================
// the black box description
BBTK_BEGIN_DESCRIBE_BLACK_BOX(Slicer,bbtk::KWBlackBox);
- BBTK_NAME("Slicer");
+ BBTK_NAME("kwSlicer");
BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
// Already inserted for any KWBlackBox BBTK_CATEGORY("widget");
BBTK_DESCRIPTION("Slicer widget (vtkKWSlicer)");
Program: bbtk
Module: $RCSfile: bbkwSlider.h,v $
Language: C++
- Date: $Date: 2008/12/02 13:37:56 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/12/03 13:35:27 $
+ Version: $Revision: 1.3 $
=========================================================================*/
/* ---------------------------------------------------------------------
//=================================================================
// the black box description
BBTK_BEGIN_DESCRIBE_BLACK_BOX(Slider,bbtk::KWBlackBox);
- BBTK_NAME("Slider");
+ BBTK_NAME("kwSlider");
BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
// Already inserted for any KWBlackBox BBTK_CATEGORY("widget");
BBTK_DESCRIPTION("Slider widget (vtkKWScale)");
std::string FilesFromDirectory::NormalizePath(std::string const &pathname)
{
#ifdef _WIN32
- const char FILESEPARATOR = '\\;
+ const char FILESEPARATOR = '\\';
#else
const char FILESEPARATOR = '/';
#endif
Program: bbtk
Module: $RCSfile: bbvtkImagePlanes.cxx,v $
Language: C++
- Date: $Date: 2008/12/03 09:34:39 $
- Version: $Revision: 1.14 $
+ Date: $Date: 2008/12/03 13:35:32 $
+ Version: $Revision: 1.15 $
=========================================================================*/
/* ---------------------------------------------------------------------
#include "bbvtkPackage.h"
#include "vtkCellPicker.h"
#include "vtkProperty.h"
+
#include "vtkMetaImageWriter.h"
+#include "vtkPNGWriter.h"
#include "bbstdCast.h"
+#include <vtkCommand.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"
+
+#include "vtkPlaneWidget.h"
+
+
namespace bbstd
{
+
//====================================================================
BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(Cast,
bbtk::AtomicBlackBox);
using namespace bbstd;
namespace bbvtk
{
+
+
//====================================================================
// Add the specialized adaptors to the package
typedef vtkImagePlaneWidget* I;
namespace bbvtk
{
+ //================================================================
+ class myCallbackPlane : public vtkCommand
+ {
+ public:
+ static myCallbackPlane *New()
+ {
+ return new myCallbackPlane;
+ }
+ virtual void Execute(vtkObject *caller, unsigned long, void*)
+ {
+ currentBlackBox->Process();
+ currentBlackBox->bbSignalOutputModification();
+ }
+ void SetCurrentBlackBox(ImagePlanes *cBB) {currentBlackBox = cBB;};
+ void SetVtkPlaneWidget( vtkImagePlaneWidget *planeWidget );
+ myCallbackPlane() {};
+
+ private:
+ vtkPlaneWidget *planeWidget;
+ ImagePlanes *currentBlackBox;
+ };
+ //================================================================
+
+
+
+ //================================================================
+
BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,ImagePlanes)
BBTK_BLACK_BOX_IMPLEMENTATION(ImagePlanes,bbtk::AtomicBlackBox);
void ImagePlanes::bbUserConstructor()
{
- planeWidgetX = planeWidgetY = planeWidgetZ = 0;
- imageX = imageY = imageZ = 0;
+ bbSetOutputPlaneX(0);
+ bbSetOutputPlaneY(0);
+ bbSetOutputPlaneZ(0);
+ bbSetOutputImageX(0);
+ bbSetOutputImageY(0);
+ bbSetOutputImageZ(0);
bbSetInputIn(0);
std::vector<double> vect;
- vect.push_back(512);
- vect.push_back(256);
+ vect.push_back(0);
+ vect.push_back(0);
bbSetInputWindowLevel (vect);
-
- bbSetModifiedStatus();
}
void ImagePlanes::bbUserCopyConstructor(bbtk::BlackBox::Pointer)
{
- planeWidgetX = planeWidgetY = planeWidgetZ = 0;
- imageX = imageY = imageZ = 0;
+ bbSetOutputPlaneX(0);
+ bbSetOutputPlaneY(0);
+ bbSetOutputPlaneZ(0);
+ bbSetOutputImageX(0);
+ bbSetOutputImageY(0);
+ bbSetOutputImageZ(0);
}
void ImagePlanes::Init()
{
- if (planeWidgetX != 0) return;
+
+ /// CREATION DES WIDGETS
+ if (bbGetOutputPlaneX() != 0) return;
// The shared picker enables us to use 3 planes at one time
// and gets the picking order right
picker->SetTolerance(0.005);
// The 3 image plane widgets
- planeWidgetX = vtkImagePlaneWidget::New();
+ vtkImagePlaneWidget* planeWidgetX = vtkImagePlaneWidget::New();
planeWidgetX->DisplayTextOn();
planeWidgetX->SetPicker(picker);
planeWidgetX->SetKeyPressActivationValue('x');
vtkProperty* prop1 = planeWidgetX->GetPlaneProperty();
prop1->SetColor(1, 0, 0);
- planeWidgetY = vtkImagePlaneWidget::New();
+ vtkImagePlaneWidget* planeWidgetY = vtkImagePlaneWidget::New();
planeWidgetY->DisplayTextOn();
planeWidgetY->SetPicker(picker);
planeWidgetY->SetKeyPressActivationValue('y');
prop2->SetColor(1, 1, 0);
planeWidgetY->SetLookupTable(planeWidgetX->GetLookupTable());
- planeWidgetZ = vtkImagePlaneWidget::New();
+ vtkImagePlaneWidget* planeWidgetZ = vtkImagePlaneWidget::New();
planeWidgetZ->DisplayTextOn();
planeWidgetZ->SetPicker(picker);
planeWidgetZ->SetKeyPressActivationValue('z');
bbSetOutputPlaneX(planeWidgetX);
bbSetOutputPlaneY(planeWidgetY);
bbSetOutputPlaneZ(planeWidgetZ);
+ bbSetOutputImageX(planeWidgetX->GetResliceOutput());
+ bbSetOutputImageY(planeWidgetY->GetResliceOutput());
+ bbSetOutputImageZ(planeWidgetZ->GetResliceOutput());
picker->UnRegister(NULL);
void ImagePlanes::bbUserDestructor()
{
- if (planeWidgetX) planeWidgetX->UnRegister(NULL);
- if (planeWidgetY) planeWidgetY->UnRegister(NULL);
- if (planeWidgetZ) planeWidgetZ->UnRegister(NULL);
-
+ if (bbGetOutputPlaneX()) bbGetOutputPlaneX()->UnRegister(NULL);
+ if (bbGetOutputPlaneY()) bbGetOutputPlaneY()->UnRegister(NULL);
+ if (bbGetOutputPlaneZ()) bbGetOutputPlaneZ()->UnRegister(NULL);
}
//---------------------------------------------------------------------
{
if (bbGetInputIn()!=0)
{
+ // Create the widgets if not already done
Init();
- int xMin, xMax, yMin, yMax, zMin, zMax;
- bbGetInputIn()->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax);
+ if ( bbGetInputIn() != image)
+ {
+ // Input image has changed : reinitialize planes
+ image = bbGetInputIn();
- // Initial values : center of the volume (in real world, not in pixels!)
- double xSpacing, ySpacing, zSpacing;
- bbGetInputIn()->GetSpacing(xSpacing, ySpacing, zSpacing);
-
- planeWidgetX->SetInput(bbGetInputIn());
- planeWidgetX->SetPlaneOrientationToXAxes();
- planeWidgetX->SetSlicePosition((xMax+xMin)/2.*xSpacing);
- planeWidgetX->GetResliceOutput()->Update();
- bbSetOutput("ImageX", planeWidgetX->GetResliceOutput());
-
-
- vtkMetaImageWriter *writer = vtkMetaImageWriter::New();
-
- std::string newFilenameX("newFilenameX.mhd");
- writer->SetInput(planeWidgetX->GetResliceOutput());
- writer->SetFileName(newFilenameX.c_str());
- writer->Update();
+ int xMin, xMax, yMin, yMax, zMin, zMax;
+ bbGetInputIn()->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax);
+
+ // Initial values : center of the volume (in real world, not in pixels!)
+ double xSpacing, ySpacing, zSpacing;
+ bbGetInputIn()->GetSpacing(xSpacing, ySpacing, zSpacing);
+
+ bbGetOutputPlaneX()->SetInput(bbGetInputIn());
+ bbGetOutputPlaneX()->SetPlaneOrientationToXAxes();
+ bbGetOutputPlaneX()->SetSlicePosition((xMax+xMin)/2.*xSpacing);
+
+ bbGetOutputPlaneY()->SetInput(bbGetInputIn());
+ bbGetOutputPlaneY()->SetPlaneOrientationToYAxes();
+ bbGetOutputPlaneY()->SetSlicePosition((yMax+yMin)/2.*ySpacing);
+
+ bbGetOutputPlaneZ()->SetInput(bbGetInputIn());
+ bbGetOutputPlaneZ()->SetPlaneOrientationToZAxes();
+ bbGetOutputPlaneZ()->SetSlicePosition((zMax+zMin)/2.*zSpacing);
+
+ if (bbGetInputWindowLevel()[0]!=0)
+ {
+ bbGetOutputPlaneZ()->SetWindowLevel(bbGetInputWindowLevel()[0],
+ bbGetInputWindowLevel()[1]);
+ }
+ else
+ {
+ double *range = image->GetScalarRange();
+ bbGetOutputPlaneZ()->SetWindowLevel(range[1] - range[0],
+ 0.5*(range[1]+range[0]));
+ }
+ }
- //planeWidgetX->GetResliceOutput()->Print(std::cout);
-
- planeWidgetY->SetInput(bbGetInputIn());
- planeWidgetY->SetPlaneOrientationToYAxes();
- planeWidgetY->SetSlicePosition((yMax+yMin)/2.*ySpacing);
- planeWidgetY->GetResliceOutput()->Update();
- bbSetOutput("ImageY", planeWidgetY->GetResliceOutput());
- //planeWidgetY->GetResliceOutput()->Print(std::cout);
- std::string newFilenameY("newFilenameY.mhd");
- writer->SetInput(planeWidgetY->GetResliceOutput());
- writer->SetFileName(newFilenameY.c_str());
- writer->Update();
-
- planeWidgetZ->SetInput(bbGetInputIn());
- planeWidgetZ->SetPlaneOrientationToZAxes();
- planeWidgetZ->SetSlicePosition((zMax+zMin)/2.*zSpacing);
- planeWidgetZ->GetResliceOutput()->Update();
- bbSetOutput("ImageZ", planeWidgetZ->GetResliceOutput());
- // planeWidgetZ->GetResliceOutput()->Print(std::cout);
-
- // planeWidgetZ->SetWindowLevel(512,256);
-
- std::string newFilenameZ("newFilenameZ.mhd");
- writer->SetInput(planeWidgetZ->GetResliceOutput());
- writer->SetFileName(newFilenameZ.c_str());
- writer->Update();
-
- planeWidgetZ->SetWindowLevel(bbGetInputWindowLevel()[0],bbGetInputWindowLevel()[1]);
-
- // writer->vtkMetaImageWriter::Delete();
+ // UPDATE DES SORTIES
+ bbGetOutputPlaneX()->GetResliceOutput()->Update();
+ bbGetOutputPlaneY()->GetResliceOutput()->Update();
+ bbGetOutputPlaneZ()->GetResliceOutput()->Update();
+
}
}
}//namespace bbtk
Program: bbtk
Module: $RCSfile: bbvtkImagePlanes.h,v $
Language: C++
- Date: $Date: 2008/12/03 09:34:39 $
- Version: $Revision: 1.9 $
+ Date: $Date: 2008/12/03 13:35:32 $
+ Version: $Revision: 1.10 $
=========================================================================*/
/* ---------------------------------------------------------------------
#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"
-
-#include <vtkCommand.h>
-#include "vtkPlaneWidget.h"
+class vtkImageData;
+class vtkImagePlaneWidget;
namespace bbvtk
{
virtual void bbUserDestructor();
void Init();
private:
- vtkImagePlaneWidget* planeWidgetX;
- vtkImagePlaneWidget* planeWidgetY;
- vtkImagePlaneWidget* planeWidgetZ;
- vtkImageData* imageX;
- vtkImageData* imageY;
- vtkImageData* imageZ;
-
+ vtkImageData* image;
};
//=================================================================
- class myCallbackPlane : public vtkCommand
- {
- public:
- static myCallbackPlane *New()
- {
- return new myCallbackPlane;
- }
- virtual void Execute(vtkObject *caller, unsigned long, void*)
- {
- std::cout << "entree ds myCallbackPlane::Execute()" << std::endl;
- printf("Execute Call Back on %p\n",caller);
-
- currentBlackBox->bbSetModifiedStatus();
- }
- void SetCurrentBlackBox(bbtk::AtomicBlackBox *cBB) {currentBlackBox = cBB;};
- void SetVtkPlaneWidget( vtkImagePlaneWidget *planeWidget );
- myCallbackPlane()
- {
- // std::cout << "entree Constr myCallbackPlane" << std::endl;
- };
-
- private:
- vtkPlaneWidget *planeWidget;
- bbtk::AtomicBlackBox *currentBlackBox;
- };
}//namespace bbvtk
Program: bbtk
Module: $RCSfile: bbwxvtkViewer2D.cxx,v $
Language: C++
- Date: $Date: 2008/12/03 09:34:41 $
- Version: $Revision: 1.26 $
+ Date: $Date: 2008/12/03 13:35:35 $
+ Version: $Revision: 1.27 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// wxvtkrenderwindowinteractor->Render();
// imageViewer->GetRenderer()->ResetCameraClippingRange();
-
+ imageViewer->GetRenderer()->SetBackground(0.1,0.1,0.2);
+
}
//-------------------------------------------------------------------------
{
backImageData = mDefaultImage;
mUpdateCamera = true;
- std::cout << "Viewer2DWidget::UpdateView() passe par 1" << std::endl;
}
else if ( ( mBox->bbGetInputIn() != NULL ) &&
+ // (true) ) //
(backImageData != mBox->bbGetInputIn()) )
{
backImageData = mBox->bbGetInputIn();
backImageData->Update();
imageViewer->SetInput( backImageData );
mUpdateCamera = true;
- std::cout << "Viewer2DWidget::UpdateView() passe par 2" << std::endl;
}
if (mUpdateCamera)
backImageData->GetSpacing(spx,spy,spz);
backImageData->GetExtent (x1,x2,y1,y2,z1,z2);
+ double *range = backImageData->GetScalarRange();
+ imageViewer->SetColorWindow(range[1] - range[0]);
+ imageViewer->SetColorLevel(0.5 * (range[1] + range[0]));
+
+ imageViewer->GetRenderer()->ResetCamera();
+ double bounds[6];
+ imageViewer->GetRenderer()->ComputeVisiblePropBounds(bounds);
+ imageViewer->GetRenderer()->ResetCameraClippingRange(bounds);
+
// bbtkMessage("Output",2,"Viewer2D '"<<mBox->bbGetName()<<"' - Image :"<<std::endl);
// std::cout << " extent = "<< x1<<"-"<<x2<<" x "<<y1<<"-"<<y2<<" x "<<z1<<"-"<<z2<<std::endl;
// std::cout << " spacing = "<<spx << " - "<< spy << " - "<<spz<<std::endl;
-
+ /*
vtkCamera *camera = imageViewer->GetRenderer()->GetActiveCamera();
camera->SetViewUp ( spx*0, -spy*1, spz*0 );
//
// imageViewer->GetRenderer()->ResetCamera(x1,x2,y1,y2,z1,z2);
mUpdateCamera = false;
- std::cout << "Viewer2DWidget::UpdateView() passe par 3" << std::endl;
- }
+ // std::cout << "Viewer2DWidget::UpdateView() passe par 3" << std::endl;
+ imageViewer->SetColorWindow(512);
+ imageViewer->SetColorLevel(256);
+ */
+ /*
+ for (int i=0;i<10;i++)
+ for (int j=0;j<10;j++)
+ std::cout << mBox->bbGetInputIn()->GetScalarComponentAsFloat(i,j,0,0)
+ << std::endl;
+ */
+ }
// std::cout << "OW = "<< mBox->bbGetWindow() << std::endl;
// std::cout << "CW = "<< mBox->bbGetContainingWindow() << std::endl;
int orientation = mBox->bbGetInputOrientation();
if (orientation<0 || orientation>2) {
- bbtkMessage("Output", 2, "Viewer2D : Orientation was not 0< <2 "<<std::endl);
+ bbtkMessage("Output", 2, "Viewer2D : Orientation was not 0< <2 "<<std::endl);
orientation=2; // Why not?
}
// mBox->bbIsShown() is necessary to be sure that the wxWindow is already
// std::cout << "slice = "<<z<<std::endl;
int ext[6];
backImageData->GetWholeExtent(ext);
-
- // std::cout << "ext = "<<ext[4]<<" - "<<ext[5]<<std::endl;
-
+ /*
+ std::cout << "ext = "<<ext[0]<<" - "<<ext[1]<<" ; "
+ <<ext[2]<<" - "<<ext[3]<<" ; "
+ <<ext[4]<<" - "<<ext[5]
+ <<std::endl;
+ */
switch(orientation){
case 0:
if (z<ext[0]) { z=ext[0]; }
z = ext[5]; // Why not?
}
- // std::cout << "V2D Render "<<std::endl;
- // imageViewer->SetSliceOrientation (orientation);
- // imageViewer->SetSlice( z );
-
- // wxvtkrenderwindowinteractor->Update();
- // wxvtkrenderwindowinteractor->Render();
- // imageViewer->GetRenderer()->ResetCameraClippingRange();
-
- //xvtkrenderwindowinteractor->Refresh();
+ bbtkDebugMessage("Output",3,"Viewer2D : slice = "<<z<<std::endl);
+ imageViewer->SetSliceOrientation (orientation);
wxvtkrenderwindowinteractor->Render();
- imageViewer->GetRenderer()->ResetCameraClippingRange();
- imageViewer->SetSliceOrientation (orientation);
- imageViewer->SetSlice( z );
-
-std::cout << "Viewer2DWidget::UpdateView() passe par 4" << std::endl;
-/*
- #if (VTK_MAJOR_VERSION >= 5)
- imageViewer->SetSlice( z );
- #else
- imageViewer->SetZSlice( z );
- #endif
-*/
-// imageViewer->SetSliceOrientation (orientation);
-// imageViewer->SetSlice( z );
-
- //imageViewer->UpdateDisplayExtent();
- }
-
+ imageViewer->SetSlice( z );
-}
+ }
+
+
+ }
vtkRenderer * Viewer2DWidget::GetRenderer()
void Viewer2D::Process()
{
- // LG : Bug on Linux (wxGTK) when initial slice != 0 on first time
- // (see wxvtk/bbs/appli/ExampleSimpleSlicer)
- // I think there is a problem with rendering before window
- // has been reparented ... we have to check this
-
-std::cout << "Viewer2D::Process() passe par 5" << std::endl;
-
- Viewer2DWidget* w = (Viewer2DWidget*)bbGetOutputWidget();
-
+ Viewer2DWidget* w = (Viewer2DWidget*)bbGetOutputWidget();
if (w)
- {
-std::cout << "Viewer2D::Process() passe par 6" << std::endl;
- w->UpdateView();
- bbSetOutputRenderer( ((Viewer2DWidget*)bbGetOutputWidget())->GetRenderer() );
- }
- bbSetOutputOut( bbGetInputSlice() );
-
+ {
+ w->UpdateView();
+ bbSetOutputRenderer( ((Viewer2DWidget*)bbGetOutputWidget())->GetRenderer() );
+ }
+ bbSetOutputOut( bbGetInputSlice() );
+
}
bbSetInputIn(NULL);
bbSetInputSlice(0);
bbSetOutputWidget(0);
- bbSetInputOrientation(0);
+ bbSetInputOrientation(2);
}
/**
*/
void Viewer2D::CreateWidget(wxWindow* parent)
{
- std::cout << "Viewer2D::CreateWidget() passe par 7" << std::endl;
Viewer2DWidget* w = new Viewer2DWidget(this,parent);//bbGetWxParent());
-
bbSetOutputWidget(w);
}
Program: bbtk
Module: $RCSfile: bbwxvtkViewer2D.h,v $
Language: C++
- Date: $Date: 2008/11/24 15:45:54 $
- Version: $Revision: 1.10 $
+ Date: $Date: 2008/12/03 13:35:35 $
+ Version: $Revision: 1.11 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
Viewer2DWidget(Viewer2D* box, wxWindow *parent);
~Viewer2DWidget();
void UpdateView();
- vtkRenderer *GetRenderer();
+ vtkRenderer *GetRenderer();
private:
Viewer2D *mBox;
vtkImageViewer2 *imageViewer;
wxVTKRenderWindowInteractor *wxvtkrenderwindowinteractor;
bool mUpdateCamera;
- vtkImplicitPlaneWidget * maPlane1, * maPlane2, * mbPlane1, * mbPlane2;
+ vtkImplicitPlaneWidget * maPlane1, * maPlane2, * mbPlane1, * mbPlane2;
};
//------------------------------------------------------------------------
Program: bbtk
Module: $RCSfile: bbwxvtkViewer3D.cxx,v $
Language: C++
- Date: $Date: 2008/11/25 13:18:38 $
- Version: $Revision: 1.12 $
+ Date: $Date: 2008/12/03 13:35:35 $
+ Version: $Revision: 1.13 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
vtkRenderer *renderer = w->GetRenderer();
if (renderer!=NULL)
{
+ bbSetOutputRenderer( renderer );
+
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( renderer );
+ double bounds[6];
+ renderer->ComputeVisiblePropBounds(bounds);
+ renderer->ResetCameraClippingRange(bounds);
+
}
bbSetOutputWidget(w);