Program: bbtk
Module: $RCSfile: bbwxvtkViewer2D.cxx,v $
Language: C++
- Date: $Date: 2008/12/15 13:13:49 $
- Version: $Revision: 1.33 $
+ Date: $Date: 2009/04/17 09:04:13 $
+ Version: $Revision: 1.34 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#ifdef USE_WXWIDGETS
#ifdef USE_VTK
-
#include "bbwxvtkViewer2D.h"
#include "bbwxvtkPackage.h"
//#include <wx/dialog.h>
#include <vtkInteractorStyleImage.h>
#include <vtkCommand.h>
-
-
namespace bbwxvtk
{
-
-
-
-
//--------------------------------------------------------------------------
class Viewer2DWidget : public wxPanel
{
~Viewer2DWidget();
void UpdateView();
vtkRenderer *GetRenderer();
+
private:
bool mFirstTime;
Viewer2D *mBox;
for (int i=0;i<dim[0];i++)
for (int j=0;j<dim[1];j++)
for (int k=0;k<dim[2];k++)
- mDefaultImage->SetScalarComponentFromFloat(i,j,k,0,0);
+ mDefaultImage->SetScalarComponentFromFloat(i,j,k,0,0);
for (int i=0;i<dim[0];i++)
{
mUpdateCamera = true;
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
- sizer-> Add( wxvtkrenderwindowinteractor , 1, wxEXPAND, 0);
- panel-> SetSizer(sizer);
- panel-> SetAutoLayout(true);
- panel-> Layout();
+ sizer->Add( wxvtkrenderwindowinteractor, 1, wxEXPAND, 0);
+ panel->SetSizer(sizer);
+ panel->SetAutoLayout(true);
+ panel->Layout();
// wxvtkrenderwindowinteractor->Refresh();
delete wxvtkrenderwindowinteractor;
// std::cout << "Viewer2DWidget::~Viewer2DWidget() OK" << std::endl;
}
-
- //-------------------------------------------------------------------------
-
+ //-------------------------------------------------------------------------
void Viewer2DWidget::UpdateView()
{
// std::cout << "Viewer2DWidget::UpdateView() " << std::endl;
- // std::cout << "slice="<<mBox->bbGetInputSlice()<<std::endl;
-
-
+ // std::cout << "slice="<<mBox->bbGetInputSlice()<<std::endl;
+ mUpdateCamera = false; //JPR
if ( ( mBox->bbGetInputIn() == NULL ) &&
( backImageData != mDefaultImage ) )
{
//
- // std::cout << "** Viewer2DWidget::UpdateView() : NULL Input (reset)" <<std::endl;
+ // std::cout << "** Viewer2DWidget::UpdateView() : NULL Input (reset)" <<std::endl;
backImageData = mDefaultImage;
mUpdateCamera = true;
-
}
else if ( ( mBox->bbGetInputIn() != NULL ) &&
(( mBox->bbGetInputStatus("In") != bbtk::UPTODATE ) ||
( mFirstTime))
)
//(backImageData != mBox->bbGetInputIn()) )
- {
-
- // std::cout << "** Viewer2DWidget::UpdateView() : Input changed" <<std::endl;
+ {
+ // std::cout << "** Viewer2DWidget::UpdateView() : Input changed" <<std::endl;
mFirstTime = false;
- backImageData = mBox->bbGetInputIn();
- backImageData->Update();
- imageViewer->SetInput( backImageData );
- mUpdateCamera = true;
+ if (backImageData != mBox->bbGetInputIn()) // Don't update if just Slice changed
+ {
+ backImageData = mBox->bbGetInputIn();
+ backImageData->Update();
+ imageViewer->SetInput( backImageData );
+ mUpdateCamera = true;
+ }
}
if (mUpdateCamera)
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
imageViewer->SetSliceOrientation (orientation);
imageViewer->SetSlice( z );
- }
-
-
+ }
}
BBTK_ADD_BLACK_BOX_TO_PACKAGE(wxvtk,Viewer2D);
BBTK_BLACK_BOX_IMPLEMENTATION(Viewer2D,bbtk::WxBlackBox);
-
void Viewer2D::Process()
{
// std::cout << "Viewer2D::Process" << std::endl;
{
w->UpdateView();
}
- bbSetOutputOut( bbGetInputSlice() );
-
+ bbSetOutputOut( bbGetInputSlice() );
}
w->UpdateView();
bbSetOutputWidget(w);
bbSetOutputRenderer( ((Viewer2DWidget*)bbGetOutputWidget())->GetRenderer() );
-
}
Program: bbtk
Module: $RCSfile: bbwxvtkViewer2D.h,v $
Language: C++
- Date: $Date: 2008/12/11 15:30:17 $
- Version: $Revision: 1.15 $
+ Date: $Date: 2009/04/17 09:04:13 $
+ Version: $Revision: 1.16 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* \brief
*/
-
#ifdef USE_WXWIDGETS
#ifdef USE_VTK
-
#ifndef __bbwxvtkViewer2D_h__
#define __bbwxvtkViewer2D_h__
#include "bbtkWxBlackBox.h"
#include "wxVTKRenderWindowInteractor.h"
-
-
namespace bbwxvtk
{
-
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------
class /*BBTK_EXPORT*/ Viewer2D : public bbtk::WxBlackBox
{
BBTK_BLACK_BOX_INTERFACE(Viewer2D,bbtk::WxBlackBox);
- BBTK_DECLARE_INPUT(Slice,int);
- BBTK_DECLARE_INPUT(Orientation,int);
- BBTK_DECLARE_INPUT(In,vtkImageData *);
- BBTK_DECLARE_OUTPUT(Out,int);
+
+ BBTK_DECLARE_INPUT(Slice, int);
+ BBTK_DECLARE_INPUT(Orientation, int);
+ BBTK_DECLARE_INPUT(In, vtkImageData *);
+ BBTK_DECLARE_OUTPUT(Out, int);
+
BBTK_DECLARE_OUTPUT(Renderer,vtkRenderer*);
BBTK_PROCESS(Process);
BBTK_CREATE_WIDGET(CreateWidget);
BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr");
BBTK_DESCRIPTION("2D Viewer widget (vtk)");
BBTK_CATEGORY("viewer");
- BBTK_INPUT(Viewer2D,Slice,"Initial Slice number",int,"");
- BBTK_INPUT(Viewer2D,Orientation,"Slicing orientation : 0:yz / 1:xz / 2:xy",int,"");
- BBTK_INPUT(Viewer2D,In,"Input Image",vtkImageData *,"");
- BBTK_OUTPUT(Viewer2D,Out,"Current Slice number",int,"");
- BBTK_OUTPUT(Viewer2D,Renderer,"vtk Renderer",vtkRenderer*,"");
+ BBTK_INPUT(Viewer2D, Slice, "Initial Slice number", int, "");
+ BBTK_INPUT(Viewer2D, Orientation, "Slicing orientation : 0:yz / 1:xz / 2:xy", int, "");
+ BBTK_INPUT(Viewer2D, In, "Input Image", vtkImageData *, "");
+ BBTK_OUTPUT(Viewer2D,Out, "Current Slice number", int, "");
+ BBTK_OUTPUT(Viewer2D,Renderer, "vtk Renderer", vtkRenderer*, "");
BBTK_END_DESCRIBE_BLACK_BOX(Viewer2D);
//=================================================================
-
}//namespace bbwxvtk
#endif //__bbwxvtkViewer2D_h__