//=========================================================================
ThresholdImageView::ThresholdImageView( )
{
- _actorPresent = false;
+ _actorPresent = false;
+ _Z = 0;
+ _minValue = 0;
+ _maxValue = 1000;
+ _image = NULL;
+ _imageReslicer = NULL;
+ _thresholdTable = NULL;
+ _thresholdMapper = NULL;
+ _thresholdActor = NULL;
+ _baseColorR = 1;
+ _baseColorG = 0;
+ _baseColorB = 0;
}
//=========================================================================
//----------------------------------------------------------------------------
void ThresholdImageView::SetImage(vtkImageData* image)
{
+ printf("ThresholdImageView::SetImage %p\n", image);
_image = image;
}
_baseView = baseview;
}
+//----------------------------------------------------------------------------
+wxVtkBaseView *ThresholdImageView::GetwxVtkBaseView()
+{
+ return _baseView;
+}
+
//----------------------------------------------------------------------------
void ThresholdImageView::SetZ(int z)
{
}
//----------------------------------------------------------------------------
-void ThresholdImageView::SetminMax(int min, int max)
+void ThresholdImageView::SetminMaxValue(int min, int max)
{
- _min = min;
- _max = max;
+ _minValue = min;
+ _maxValue = max;
}
//----------------------------------------------------------------------------
vtkImageData *img = _image;
img->GetScalarRange(range);
+ if (range[1]==0)
+ {
+ range[1]=255;
+ }
+
int minTot = floor (range[0]);
int maxTot = ceil (range[1]);
-//EED _pannew->onThresholdInstantChange(minMax);
- int minVal = floor (_min);
- int maxVal = floor (_max);
+ int minVal = floor (_minValue);
+ int maxVal = floor (_maxValue);
+
if (!_actorPresent)
{
{
_imageReslicer = vtkImageReslice::New();
_imageReslicer->SetInput( img );
- _imageReslicer->SetInformationInput(img);
+ _imageReslicer->SetInformationInput(img);
_imageReslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0 ,0,0,1);
_imageReslicer->SetOutputDimensionality(2);
_imageReslicer->SetInterpolationModeToLinear();
{
if( i >= minVal && i <= maxVal )
{
- _thresholdTable->SetTableValue(i, 1.0, 0.0, 0.0, 1);
+ _thresholdTable->SetTableValue(i,_baseColorR,_baseColorG,_baseColorB, 1);
}
else if( i >= minTot && i < minVal )
{
{
if( i >= minVal && i <= maxVal )
{
- _thresholdTable->SetTableValue(i, 1.0, 0.0, 0.0, 1);
+ _thresholdTable->SetTableValue(i,_baseColorR,_baseColorG,_baseColorB, 1);
}
else if( i >= minTot && i < minVal )
{
_thresholdMapper->SetInput( img );
_thresholdActor->SetInput( _thresholdMapper->GetOutput() );
}
- /*
- vtkImageViewer2* viewer = vtkImageViewer2::New();
- viewer->SetInput( upperImageActor->GetInput() );
- viewer->SetColorLevel((range[1]-range[0])/2);
- viewer->SetColorWindow(range[1]);
- viewer->GetRenderer()->AddActor( upperImageActor );
- viewer->Render();
- */
-//EED _theViewPanel->RefreshInterface();
}
}
+//----------------------------------------------------------------------------
+void ThresholdImageView::SetBaseColor(double r, double g, double b)
+{
+ _baseColorR = r;
+ _baseColorG = g;
+ _baseColorB = b;
+}
// EOF
/**
** Begin of the threshold panel
**/
-ThresholdImageViewPanel::ThresholdImageViewPanel(wxWindow* parent)
+ThresholdImageViewPanel::ThresholdImageViewPanel(wxWindow* parent, int min, int max, int type)
: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
{
_thresholdImageView = new ThresholdImageView();
- wxButton *thresholdGoBtn = new wxButton(this,wxID_ANY,_T("Show/Hide Color"), wxDefaultPosition, wxSize(200,30) );
+// wxButton *thresholdGoBtn = new wxButton(this,wxID_ANY,_T("Show/Hide Color"), wxDefaultPosition, wxSize(200,30) );
+
+ _thresholdGo = true;
+ _cb_ShowHide = new wxCheckBox(this, wxID_ANY, _T("Show/Hide layer") );
+ _cb_ShowHide->SetValue(_thresholdGo);
+
_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);
- _thresholdGo = false;
- double range[2];
+// double range[2];
// interfMainPanel::getInstance()->getImageRange(range);
- int min = (int)floor (range[0]);
- int max = (int)ceil (range[1]);
+// int min = (int)floor (range[0]);
+// int max = (int)ceil (range[1]);
+
+ if (type==0)
+ {
+ }
+
+ if (type==1)
+ {
+ _mBarThreshold = new mBarRange(this,70,65);
+ _mBarThreshold->SetMin(0);
+ _mBarThreshold->SetStart(0);
+ _mBarThreshold-> SetOrientation( true );
+ _mBarThreshold-> setActiveStateTo(true);
+ _mBarThreshold-> setVisibleLabels( true );
+ _mBarThreshold-> setDeviceEndMargin(10);
+ _mBarThreshold-> setRepresentedValues( min , max );
+ _mBarThreshold-> setDeviceBlitStart(10,10);
+ _mBarThreshold-> setIfWithActualDrawed( false );
+ _mBarThreshold-> SetStart( min );
+ _mBarThreshold-> SetEnd( max );
+ }
- _mBarThreshold = new mBarRange(this,70,65);
- _mBarThreshold->SetMin(0);
- _mBarThreshold->SetStart(0);
- _mBarThreshold-> SetOrientation( true );
- _mBarThreshold-> setActiveStateTo(true);
- _mBarThreshold-> setVisibleLabels( true );
- _mBarThreshold-> setDeviceEndMargin(10);
- _mBarThreshold-> setRepresentedValues( min , max );
- _mBarThreshold-> setDeviceBlitStart(10,10);
- _mBarThreshold-> setIfWithActualDrawed( false );
- _mBarThreshold-> SetStart( min );
- _mBarThreshold-> SetEnd( max );
- Connect( thresholdGoBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdGo );
+ Connect( _cb_ShowHide->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdShow );
Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ThresholdImageViewPanel::onThresholdInterpolation );
wxFlexGridSizer * sizer = new wxFlexGridSizer(1);
- sizer -> Add( new wxStaticText(this,-1,_T("Image Threshold")) , 1, wxGROW );
- sizer -> Add( _mBarThreshold, 1, wxGROW );
- sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
+ if (type==1)
+ {
+ sizer -> Add( new wxStaticText(this,-1,_T("Image Threshold")) , 1, wxGROW );
+ sizer -> Add( _mBarThreshold, 1, wxGROW );
+ sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
+ }
sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level")) , 1, wxGROW );
sizer -> Add( _opacity, 1, wxGROW );
sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
- sizer -> Add( thresholdGoBtn, 1, wxGROW );
+ sizer -> Add( _cb_ShowHide, 1, wxGROW );
sizer -> Add( new wxStaticText(this,-1,_T(" ")) , 1, wxGROW );
sizer -> Add( _interpolationCheckBox, 1, wxGROW );
}
//----------------------------------------------------------------------------
-ThresholdImageViewPanel::~ThresholdImageViewPanel(){
+ThresholdImageViewPanel::~ThresholdImageViewPanel()
+{
}
{
if (_thresholdGo)
{
+ _thresholdImageView->SetminMaxValue( _mBarThreshold->GetStart(), _mBarThreshold->GetEnd() );
_thresholdImageView->onThresholdChange();
-
+ _thresholdImageView->GetwxVtkBaseView()->Refresh();
//std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal << std::endl;
}
}
//----------------------------------------------------------------------------
-void ThresholdImageViewPanel::onThresholdGo(wxCommandEvent& event)
+void ThresholdImageViewPanel::onThresholdShow(wxCommandEvent& event)
{
- if (!_thresholdGo)
+ _thresholdGo = _cb_ShowHide->GetValue();
+ if (_thresholdGo)
{
_thresholdImageView->onThreshold();
- _thresholdGo=true;
}
else
{
_thresholdImageView->onThresholdRemove( );
- _thresholdGo=false;
}
+ _thresholdImageView->GetwxVtkBaseView()->Refresh();
}
//----------------------------------------------------------------------------
}
}
-//----------------------------------------------------------------------------
-void ThresholdImageViewPanel::onThresholdInstantChange(double range[])
-{
- range[0] = _mBarThreshold->GetStart();
- range[1] = _mBarThreshold->GetEnd();
-}
-
//----------------------------------------------------------------------------
void ThresholdImageViewPanel::onThresholdInterpolation(wxCommandEvent& event)
{
_thresholdImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue());
+ _thresholdImageView->GetwxVtkBaseView()->Refresh();
+
}
//----------------------------------------------------------------------------
{
int opacity = _opacity->GetValue();
_thresholdImageView->onThresholdChangeOpacity(opacity);
+ _thresholdImageView->GetwxVtkBaseView()->Refresh();
}
+//----------------------------------------------------------------------------
+bool ThresholdImageViewPanel::IsVisible()
+{
+ return _thresholdGo;
+}
+
BEGIN_EVENT_TABLE(ThresholdImageViewPanel, wxPanel)
EVT_COMMAND(wxID_ANY, wxEVT_TSBAR_START, ThresholdImageViewPanel::onThresholdChange)