//=========================================================================
ColorLayerImageView::ColorLayerImageView( )
{
+ _z2 = 0;
+ _fix_dinamic = true;
}
//=========================================================================
//=========================================================================
+//----------------------------------------------------------------------------
+void ColorLayerImageView::SetSliceFixDinamic(bool fix_dinamic)
+{
+ _fix_dinamic = fix_dinamic;
+}
+
+//----------------------------------------------------------------------------
+void ColorLayerImageView::SetZ2(int z2)
+{
+ _z2 = z2;
+}
+
+//----------------------------------------------------------------------------
+int ColorLayerImageView::GetZ() // virtual
+{
+ int result=0;
+ if (_fix_dinamic==false)
+ {
+ result = _z2;
+ } else {
+ result = LayerImageBase::GetZ();
+ }
+
+ return result;
+}
+
+
//----------------------------------------------------------------------------
void ColorLayerImageView::ConfigLookupTable() // virtual
{
if ((ii>=delta0) && (ii<=delta1)) // iBlue
{
thresholdTable->SetTableValue( i , 0 , 0 , iBlue/delta , 1);
+ if (ii==0)
+ {
+ thresholdTable->SetTableValue( i , 0 , 0 , iBlue/delta , 0);
+ } else {
+ thresholdTable->SetTableValue( i , 0 , 0 , iBlue/delta , 1);
+ }
iBlue++;
}
if ((ii>=delta1) && (ii<=delta2)) // iYellow
public:
ColorLayerImageView( );
~ColorLayerImageView();
-
+ void SetSliceFixDinamic(bool fix_dinamic);
+ void SetZ2(int z2);
+ virtual int GetZ();
+
private:
+ int _z2;
+ bool _fix_dinamic;
virtual void ConfigLookupTable();
+
protected:
};
#include "ColorLayerImageViewPanel.h"
-
+#include "OpenImageDialog.h"
/**
_thresholdGo = true;
_cb_ShowHide = new wxCheckBox(this, wxID_ANY, _T("Show/Hide layer") );
_cb_ShowHide->SetValue(_thresholdGo);
-
+
+ _cb_SliceFixDinamic = new wxCheckBox(this, wxID_ANY, _T("Slice Fix/Dinamic") );
+ _cb_SliceFixDinamic->SetValue(true);
+
+ _sl_SliceImage = new wxSlider(this, wxID_ANY, 0, 1000, 1000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+ _sl_SliceImage->Enable(false);
+
_interpolationCheckBox = new wxCheckBox(this, -1, _T("Image interpolation") );
_interpolationCheckBox->SetValue(true);
_opacity = new wxSlider(this, wxID_ANY, 6, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
Connect( _cb_ShowHide->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdShow );
Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdInterpolation );
Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ColorLayerImageViewPanel::onChangeOpacity );
-
+ Connect( _cb_SliceFixDinamic->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceFixDinamic );
+ Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+ Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_LINEUP , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+ Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_LINEDOWN , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+ Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_PAGEUP , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+ Connect( _sl_SliceImage->GetId(), wxEVT_SCROLL_PAGEDOWN , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+
+
wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
if (type==1)
{
sizer -> Add( _cb_ShowHide, 1, wxGROW );
sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
sizer -> Add( _interpolationCheckBox, 1, wxGROW );
-
+
+ sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
+ sizer -> Add( new wxStaticText(this,-1,_T("Slice ")) , 1, wxGROW );
+ sizer -> Add( _sl_SliceImage, 1, wxGROW );
+ sizer -> Add( _cb_SliceFixDinamic, 1, wxGROW );
+
this->SetSizer( sizer );
this->SetAutoLayout( true );
this->Layout();
//----------------------------------------------------------------------------
void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event)
{
- printf("EED UPS.... ");
+// EED ???
+// creaImageIO::WxSimpleDlg w(0,_T("Select your image"),"creaContours_Descriptor.dscp","creatisContours DB");
+// w.ShowModal();
+
+ creaMaracasVisuKernel::OpenImageDialog diag = creaMaracasVisuKernel::OpenImageDialog();
+ _colorLayerImageView->SetImage( diag.getImageData() );
+
+ int ext[6];
+ diag.getImageData()->GetWholeExtent(ext);
+ _sl_SliceImage->SetRange( 0 , ext[5]-ext[4] );
+
+ _colorLayerImageView->onThreshold();
+ _colorLayerImageView->GetwxVtkBaseView()->Refresh();
}
}
+//----------------------------------------------------------------------------
+void ColorLayerImageViewPanel::onSliceFixDinamic(wxCommandEvent& event)
+{
+ bool fixdin = _cb_SliceFixDinamic->GetValue();
+ _colorLayerImageView->SetSliceFixDinamic( fixdin );
+ if (fixdin==false)
+ {
+ _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() );
+ }
+ _sl_SliceImage->Enable(!fixdin);
+ _colorLayerImageView->onThreshold();
+ _colorLayerImageView->GetwxVtkBaseView()->Refresh();
+}
+
+//----------------------------------------------------------------------------
+void ColorLayerImageViewPanel::onSliceImage(wxScrollEvent& event)
+{
+ _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() );
+ _colorLayerImageView->onThreshold();
+ _colorLayerImageView->GetwxVtkBaseView()->Refresh();
+}
+
//----------------------------------------------------------------------------
void ColorLayerImageViewPanel::onChangeOpacity(wxScrollEvent& event)
{
wxSlider *_opacity;
wxCheckBox *_interpolationCheckBox;
wxCheckBox *_cb_ShowHide;
-
+ wxCheckBox *_cb_SliceFixDinamic;
+ wxSlider *_sl_SliceImage;
void onReadImage(wxCommandEvent& event);
void onThresholdChange(wxCommandEvent& event);
void onThresholdShow(wxCommandEvent& event);
void onThresholdInterpolation(wxCommandEvent& event);
void onChangeOpacity(wxScrollEvent& event);
+ void onSliceFixDinamic(wxCommandEvent& event);
+ void onSliceImage(wxScrollEvent& event);
};
#endif
}
//----------------------------------------------------------------------------
-int LayerImageBase::GetZ()
+int LayerImageBase::GetZ() // virtual
{
return _Z;
}
return _thresholdTable;
}
+//----------------------------------------------------------------------------
+int LayerImageBase::CleanZ(int z)
+{
+ int ext[6];
+ _image->GetWholeExtent(ext);
+
+ if (z<0)
+ {
+ z=0;
+ }
+
+ if ( z > (ext[5]-ext[4]) )
+ {
+ z=ext[5]-ext[4];
+ }
+ return z;
+}
//----------------------------------------------------------------------------
void LayerImageBase::onThreshold()
{
- int z = GetZ();
-
- if (!GetActorPresent())
- {
- if (_thresholdTable==NULL)
- {
- //Lookup Table
- _thresholdTable = vtkLookupTable::New();
- } // _thresholdTable
-
- if (_thresholdMapper==NULL)
- {
- _thresholdMapper = vtkImageMapToColors::New( );
- }
-
- if (_thresholdActor==NULL)
- {
- _thresholdActor = vtkImageActor::New( );
- _thresholdActor->SetOpacity( 0.6 );
- _thresholdActor->InterpolateOn( );
- _thresholdActor->SetPosition( 0,0, 900-1 );
- } // _thresholdActor
-
-
- _baseView->GetRenderer()->AddActor( _thresholdActor );
- _actorPresent = true;
- } // !GetActorPresent()
-
- ConfigLookupTable(); // virtual method
- _imageReslicer->SetInput( GetImage() );
- _imageReslicer->SetInformationInput( GetImage() );
- _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
- _imageReslicer->SetOutputDimensionality(2);
- _imageReslicer->SetInterpolationModeToLinear();
- _imageReslicer->SetResliceAxesOrigin(0,0,z);
-
- vtkImageData *img = _imageReslicer->GetOutput();
- img->Update();
- img->UpdateInformation();
-
- _thresholdMapper->SetInput( img );
- _thresholdMapper->SetLookupTable( _thresholdTable );
- _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
+
+ if (_image!=NULL)
+ {
+ int z=CleanZ( GetZ() );
+
+ if (!GetActorPresent())
+ {
+ if (_thresholdTable==NULL)
+ {
+ //Lookup Table
+ _thresholdTable = vtkLookupTable::New();
+ } // _thresholdTable
+
+ if (_thresholdMapper==NULL)
+ {
+ _thresholdMapper = vtkImageMapToColors::New( );
+ }
+
+ if (_thresholdActor==NULL)
+ {
+ _thresholdActor = vtkImageActor::New( );
+ _thresholdActor->SetOpacity( 0.6 );
+ _thresholdActor->InterpolateOn( );
+ _thresholdActor->SetPosition( 0,0, 900-1 );
+ } // _thresholdActor
+ _baseView->GetRenderer()->AddActor( _thresholdActor );
+ _actorPresent = true;
+ } // !GetActorPresent()
+
+ ConfigLookupTable(); // virtual method
+ _imageReslicer->SetInput( GetImage() );
+ _imageReslicer->SetInformationInput( GetImage() );
+ _imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
+ _imageReslicer->SetOutputDimensionality(2);
+ _imageReslicer->SetInterpolationModeToLinear();
+ _imageReslicer->SetResliceAxesOrigin(0,0,z);
+
+ vtkImageData *img = _imageReslicer->GetOutput();
+ img->Update();
+ img->UpdateInformation();
+
+ _thresholdMapper->SetInput( img );
+ _thresholdMapper->SetLookupTable( _thresholdTable );
+ _thresholdActor->SetInput( _thresholdMapper->GetOutput() );
+ } // _image
}
wxVtkBaseView *_baseView;
virtual void ConfigLookupTable() = 0;
- int GetZ();
bool GetActorPresent();
+ int CleanZ(int z);
+
protected:
+ virtual int GetZ();
vtkLookupTable* GetThresholdTable();
vtkImageData* GetImage();
};