Program: wxMaracas
Module: $RCSfile: wxMaracas_N_ViewersWidget.cxx,v $
Language: C++
- Date: $Date: 2009/11/30 20:52:51 $
- Version: $Revision: 1.13 $
+ Date: $Date: 2010/02/04 10:54:49 $
+ Version: $Revision: 1.14 $
Copyright: (c) 2002, 2003
License:
wxwindow1->ConfigureVTK();
wxwindow2->ConfigureVTK();
spliter -> SplitVertically( wxwindow1 , wxwindow2 );
- wxwindow = spliter;
+ wxwindow = spliter;
}else if (nTypeView->size()==3)
{
wxSplitterWindow *spliter = new wxSplitterWindow( this , -1);
#include "vtkCutter.h"
#include "vtkTransform.h"
#include "vtkmyPWCallback_3DPointWidget.h"
+#include "vtkProperty.h"
+#include "vtkCellPicker.h"
wxVtkMPR3DView::wxVtkMPR3DView( wxVtk3DBaseView *wxvtk3Dbaseview )
{
_wxvtk3Dbaseview = wxvtk3Dbaseview;
_vtkmpr3Ddataviewer = NULL;
_wxvtkmpr3DviewCntrlPanel = NULL;
- //_myCallback=NULL;
- _pointWidget=NULL;
- _planeWidget=NULL;
- _vtkplane=NULL;
- _probe=NULL;
- _contourMapper=NULL;
+ //_myCallback = NULL;
+ _pointWidget = NULL;
+ _planeWidget = NULL;
+ _vtkplane = NULL;
+ _probe = NULL;
+ _contourMapper = NULL;
+
+
+ //EED Fev 3 2010
+ //Free Planes
}
-void wxVtkMPR3DView::RemoveActor(vtkActor* actor){
- _wxvtk3Dbaseview->GetRenderer()->RemoveActor(actor);
+//-------------------------------------------------------------------
+wxVtkMPR3DView::~wxVtkMPR3DView()
+{
+ VisiblePointWidget( false );
+ VisiblePlaneWidget( false );
+
+ if(_pointWidget!=NULL){
+ _pointWidget->Delete();
+ }
+ if(_planeWidget!=NULL){
+ _planeWidget->Delete();
+ }
+
+ if(_vtkplane!=NULL){
+ _vtkplane->Delete();
+ _probe->Delete();
+ _contourMapper->Delete();
+ _contourPlaneActor->Delete();
+ }
+
+}
+//-------------------------------------------------------------------
+void wxVtkMPR3DView::RemoveActor(vtkActor* actor)
+{
+ _wxvtk3Dbaseview->GetRenderer()->RemoveActor(actor);
}
-void wxVtkMPR3DView::ResetCamera(int* ext, double* origin,double* spc){
- if(ext == NULL){
+//-------------------------------------------------------------------
+void wxVtkMPR3DView::ResetCamera(int* ext, double* origin,double* spc)
+{
+ if(ext == NULL){
_wxvtk3Dbaseview->GetRenderer()->ResetCamera ();
_wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
}else{
_wxvtk3Dbaseview->GetCamera()->Dolly(1.5);
}
}
-void wxVtkMPR3DView::Configure(){
+//-------------------------------------------------------------------
+void wxVtkMPR3DView::Configure(){
_wxvtk3Dbaseview->Configure();
_wxvtkmpr3DviewCntrlPanel->UpdateControlPanel();
// PlaneWidget
- if(_planeWidget!=NULL){
+ if(_planeWidget!=NULL)
+ {
_planeWidget->Delete();
}
_planeWidget = vtkPlaneWidget::New();
}
_planeWidget->GetPolyData(_vtkplane);
-
-
vtkImageData *imageData = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
_probe->SetSource( imageData );
-
-
_contourMapper->SetScalarRange( imageData->GetScalarRange() );
-
+ ConfigureFreePlanes();
+}
+
+//-------------------------------------------------------------------
+void wxVtkMPR3DView::ConfigureFreePlanes()
+{
-
+ // 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
+ _planeWidgetX = GetPlaneWidget('x', 1, 0, 0, picker);
+ _planeWidgetY = GetPlaneWidget('y', 1, 1, 0, picker);
+ _planeWidgetZ = GetPlaneWidget('z', 0, 0, 1, picker);
+
+ _planeWidgetY->SetLookupTable(_planeWidgetX->GetLookupTable());
+ _planeWidgetZ->SetLookupTable(_planeWidgetX->GetLookupTable());
+
+ picker->UnRegister(NULL);
+
}
+
//-------------------------------------------------------------------
-wxVtkMPR3DView::~wxVtkMPR3DView()
+vtkImagePlaneWidget* wxVtkMPR3DView::GetPlaneWidget(unsigned char activationkey, double r, double g, double b, vtkCellPicker* picker)
{
- VisiblePointWidget( false );
- VisiblePlaneWidget( false );
+ vtkProperty* prop1 = 0;
+ vtkImagePlaneWidget* planeWidget = 0;
+ planeWidget = vtkImagePlaneWidget::New();
+ planeWidget->EnabledOff();
+ planeWidget->SetInteractor( GetWxvtk3Dbaseview()->GetWxVTKRenderWindowInteractor() );
+ vtkImageData *image = GetVtkMPR3DDataViewer()->GetVtkMPRBaseData()->GetImageData();
+ planeWidget->SetInput( image );
+
- if(_pointWidget!=NULL){
- _pointWidget->Delete();
+ int xMin, xMax, yMin, yMax, zMin, zMax;
+ image->GetExtent(xMin, xMax, yMin, yMax, zMin, zMax);
+ double xSpacing, ySpacing, zSpacing;
+ image->GetSpacing(xSpacing, ySpacing, zSpacing);
+
+ if (activationkey=='x')
+ {
+ planeWidget->SetPlaneOrientationToXAxes();
+ planeWidget->SetSlicePosition((xMax+xMin)/2.*xSpacing);
}
- if(_planeWidget!=NULL){
- _planeWidget->Delete();
+
+ if (activationkey=='y')
+ {
+ planeWidget->SetPlaneOrientationToYAxes();
+ planeWidget->SetSlicePosition((yMax+yMin)/2.*ySpacing);
}
-
- if(_vtkplane!=NULL){
- _vtkplane->Delete();
- _probe->Delete();
- _contourMapper->Delete();
- _contourPlaneActor->Delete();
+
+ if (activationkey=='z')
+ {
+ planeWidget->SetPlaneOrientationToZAxes();
+ planeWidget->SetSlicePosition((zMax+zMin)/2.*zSpacing);
}
+
+ planeWidget->DisplayTextOn();
+ planeWidget->SetPicker(picker);
+ planeWidget->SetKeyPressActivationValue(activationkey);
+ prop1 = planeWidget->GetPlaneProperty();
+ prop1->SetColor(r, g, b);
+ return planeWidget;
+}
+//-------------------------------------------------------------------
+void wxVtkMPR3DView::FreePlaneVisible(int plane, bool ok)
+{
+
+ if ((plane==1) && (ok==true)) _planeWidgetX->EnabledOn();
+ if ((plane==2) && (ok==true)) _planeWidgetY->EnabledOn();
+ if ((plane==3) && (ok==true)) _planeWidgetZ->EnabledOn();
+ if ((plane==1) && (ok==false)) _planeWidgetX->EnabledOff();
+ if ((plane==2) && (ok==false)) _planeWidgetY->EnabledOff();
+ if ((plane==3) && (ok==false)) _planeWidgetZ->EnabledOff();
}
-void wxVtkMPR3DView::setColorTransferFunction(vtkColorTransferFunction* colortable){
+
+//-------------------------------------------------------------------
+void wxVtkMPR3DView::FreePlaneInteraction(bool ok)
+{
+ if (ok==true)
+ {
+ _planeWidgetX->InteractionOn();
+ _planeWidgetY->InteractionOn();
+ _planeWidgetZ->InteractionOn();
+ } else {
+ _planeWidgetX->InteractionOff();
+ _planeWidgetY->InteractionOff();
+ _planeWidgetZ->InteractionOff();
+ }
+}
+
+
+//-------------------------------------------------------------------
+void wxVtkMPR3DView::setColorTransferFunction(vtkColorTransferFunction* colortable)
+{
GetVtkMPR3DDataViewer ()->setColorTransferFunction(colortable);
}
+
//-------------------------------------------------------------------
void wxVtkMPR3DView::Refresh() // virtual
{
}
}
+
//-------------------------------------------------------------------
void wxVtkMPR3DView::RefreshView() // virtual
{
#include "vtkProbeFilter.h"
#include "vtkPlaneWidget.h"
#include "vtkPointWidget.h"
+#include "vtkImagePlaneWidget.h"
//class vtkmyPWCallback_3DPointWidget;
void setColorTransferFunction(vtkColorTransferFunction* colortable);
+
+ //Free planes
+ //-------------------------------------------------------------------
+ void ConfigureFreePlanes();
+ vtkImagePlaneWidget* GetPlaneWidget(unsigned char activationkey, double r, double g, double b, vtkCellPicker* picker);
+ void FreePlaneVisible(int plane, bool ok);
+ void FreePlaneInteraction(bool ok);
+
+
private:
wxVtk3DBaseView *_wxvtk3Dbaseview;
vtkMPR3DDataViewer *_vtkmpr3Ddataviewer;
vtkProbeFilter *_probe;
vtkPolyDataMapper *_contourMapper;
+ //Free planes
+ vtkImagePlaneWidget *_planeWidgetX;
+ vtkImagePlaneWidget *_planeWidgetY;
+ vtkImagePlaneWidget *_planeWidgetZ;
protected:
_ckBoxXYZ = new wxCheckBox(panel,-1,_T("XYZ "));
_ckBoxPlane = new wxCheckBox(panel,-1,_T("Plane"));
+ _ckFreePlaneX= new wxCheckBox(panel,-1,_T("Free plane X "));;
+ _ckFreePlaneY= new wxCheckBox(panel,-1,_T("Free plane Y "));;
+ _ckFreePlaneZ= new wxCheckBox(panel,-1,_T("Free plane Z "));;
+ _ckFreePlaneInteraction= new wxCheckBox(panel,-1,_T("Free pnale interaction "));;
+
+
+ //EED: If-else statements added 30 Nov 2009
+ _ckFreePlaneX->SetValue(false);
+ _ckFreePlaneY->SetValue(false);
+ _ckFreePlaneZ->SetValue(false);
+ _ckFreePlaneInteraction->SetValue(true);
+
+
ckBoxX->SetValue(false);
ckBoxY->SetValue(false);
ckBoxZ->SetValue(false);
Connect(_positionZ->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnPositionZ );
Connect(btnColorTable->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnEditColorTable );
- Connect(_ckBoxXYZ->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisXYZ );
- Connect(_ckBoxPlane->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisiblePlane );
+ Connect(_ckBoxXYZ->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleAxisXYZ );
+ Connect(_ckBoxPlane->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisiblePlane );
+ Connect(_ckFreePlaneX->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleFreePlaneX );
+ Connect(_ckFreePlaneY->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleFreePlaneY );
+ Connect(_ckFreePlaneZ->GetId() , wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleFreePlaneZ );
+ Connect(_ckFreePlaneInteraction->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &wxVtkMPR3DViewCntrlPanel::OnVisibleFreePlaneInteraction );
+
wxFlexGridSizer *sizer;
// wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
//CPR: If-else statements added 30 Nov 2009
wxFlexGridSizer *sizerH4;
wxFlexGridSizer *sizerH5;
+ wxFlexGridSizer *sizerH6;
if(align)
{
sizer = new wxFlexGridSizer(2);
sizerH5->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND , 0);
sizerH5->Add( btnColorTable , 0,wxALIGN_CENTER_VERTICAL|wxSHAPED, 0 );
//sizerH5->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
+
}
else
{
sizerH4 = new wxFlexGridSizer(10);
sizerH5 = new wxFlexGridSizer(10);
+ sizerH6 = new wxFlexGridSizer(10);
sizerH4->Add( _positionX , 1, wxGROW , 0 );
sizerH4->Add( ckBoxX , 0, wxALIGN_CENTER_VERTICAL|wxSHAPED, 0 );
sizerH5->Add( _ckBoxXYZ , 1, wxALL|wxEXPAND, 0);
sizerH5->Add( _ckBoxPlane , 1, wxALL|wxEXPAND, 0);
sizerH5->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND, 0);
+
}
-
+ sizerH6 = new wxFlexGridSizer(10);
+ sizerH6->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND , 0);
+ sizerH6->Add( _ckFreePlaneX , 1, wxALL|wxEXPAND , 0);
+ sizerH6->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND , 0);
+ sizerH6->Add( _ckFreePlaneY , 1, wxALL|wxEXPAND , 0);
+ sizerH6->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND , 0);
+ sizerH6->Add( _ckFreePlaneZ , 1, wxALL|wxEXPAND , 0);
+ sizerH6->Add( new wxStaticText(panel, -1,_T(" ")) , 1, wxALL|wxEXPAND , 0);
+ sizerH6->Add( _ckFreePlaneInteraction , 1, wxALL|wxEXPAND , 0);
+
//EED 28 sep 2006
// wxFlexGridSizer *sizerH6 = new wxFlexGridSizer(10);
// wxFlexGridSizer *sizerH7 = new wxFlexGridSizer(10);
sizer->Add( sizerH4, 1, wxALL|wxGROW, 2);
sizer->Add( sizerH5, 1, wxALL|wxEXPAND,2);
+ sizer->Add( sizerH6, 1, wxALL|wxEXPAND,2);
panel->SetSize(400,50);
panel->SetAutoLayout(true);
}
+//-------------------------------------------------------------------
+void wxVtkMPR3DViewCntrlPanel::OnVisibleFreePlaneX(wxCommandEvent& event)
+{
+ _wxvtkmpr3Dview->FreePlaneVisible( 1, event.IsChecked() );
+}
+
+//-------------------------------------------------------------------
+void wxVtkMPR3DViewCntrlPanel::OnVisibleFreePlaneY(wxCommandEvent& event)
+{
+ _wxvtkmpr3Dview->FreePlaneVisible( 2, event.IsChecked() );
+}
+
+
+//-------------------------------------------------------------------
+void wxVtkMPR3DViewCntrlPanel::OnVisibleFreePlaneZ(wxCommandEvent& event)
+{
+ _wxvtkmpr3Dview->FreePlaneVisible( 3, event.IsChecked() );
+}
+
+
+//-------------------------------------------------------------------
+void wxVtkMPR3DViewCntrlPanel::OnVisibleFreePlaneInteraction(wxCommandEvent& event)
+{
+ _wxvtkmpr3Dview->FreePlaneInteraction( event.IsChecked() );
+}
+
+
//-------------------------------------------------------------------
void wxVtkMPR3DViewCntrlPanel::OnVisibleAxisX(wxCommandEvent& event)
{
void OnVisibleAxisXYZ(wxCommandEvent& event);
void OnVisiblePlane(wxCommandEvent& event);
void OnEditColorTable(wxCommandEvent& event);
+
+ void OnVisibleFreePlaneX(wxCommandEvent& event);
+ void OnVisibleFreePlaneY(wxCommandEvent& event);
+ void OnVisibleFreePlaneZ(wxCommandEvent& event);
+ void OnVisibleFreePlaneInteraction(wxCommandEvent& event);
+
+
+
virtual void Refresh();
void UpdateControlPanel();
wxCheckBox *_ckBoxXYZ;
wxCheckBox *_ckBoxPlane;
+
+ wxCheckBox *_ckFreePlaneX;
+ wxCheckBox *_ckFreePlaneY;
+ wxCheckBox *_ckFreePlaneZ;
+ wxCheckBox *_ckFreePlaneInteraction;
protected: