**/
ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, int max,int opacity, int type)
//: wxPanel(parent, -1, wxDefaultPosition, wxSize(600,100), wxBORDER_SUNKEN)
-
: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
-
-
{
-
_spcBase[0] = _spcBase[1] = _spcBase[2] = 0;
_dimBase[0] = _dimBase[1] = _dimBase[2] = 0;
-
_cb_ShowHide = NULL;
_sl_SliceImageX = NULL;
_sl_SliceImageY = NULL;
_sl_SliceImageZ = NULL;
_histogram = NULL;
_histogramMinMaxLevel = NULL;
-
wxFlexGridSizer * sizer = NULL;
_colorLayerImageViewManager = new ColorLayerImageViewManager();
-
if (type==1)
{
sizer = new wxFlexGridSizer(1);
} // type==1
-
if (type==2)
{
sizer = new wxFlexGridSizer(2);
_interpolationCheckBox = new wxCheckBox(this, -1, _T("Interpolate") );
_interpolationCheckBox->SetValue(true);
_opacity = new wxSlider(this, wxID_ANY, opacity, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
-
Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdInterpolation );
Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ColorLayerImageViewPanel::onChangeOpacity );
// sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level")) , 1, wxEXPAND );
} // type==2
-
this->SetSizer( sizer );
// this->SetAutoLayout( true );
// this->Layout();
{
}
-
//----------------------------------------------------------------------------
ColorLayerImageViewManager* ColorLayerImageViewPanel::GetColorLayerImageViewManager()
{
return _colorLayerImageViewManager;
}
-
//----------------------------------------------------------------------------
void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
{
if (img!=NULL)
- {
-
+ {
if (_histogramMinMaxLevel!=NULL)
{
_histogramMinMaxLevel->Configure( img );
}
_colorLayerImageViewManager->SetImage( img );
-
double spcOriginalLayer[3];
int dimensionOriginalLayer[3];
-
double spcBase[3];
int dimensionBase[3];
-
double newSpc[3];
-
GetColorLayerImageViewManager()->GetSpcOriginalLayer(0,spcOriginalLayer);
GetColorLayerImageViewManager()->GetDimensionOriginalLayer(0,dimensionOriginalLayer);
-
GetColorLayerImageViewManager()->GetSpcBase(0,spcBase);
GetColorLayerImageViewManager()->GetDimensionBase(0,dimensionBase);
-
if (_sl_SliceImageX!=NULL)
{
_sl_SliceImageX->SetRange( 0 , dimensionOriginalLayer[0] );
_sl_SliceImageZ->SetRange( 0 , dimensionOriginalLayer[2] );
}
-
if ( (spcOriginalLayer[0]!=spcBase[0]) ||
(spcOriginalLayer[1]!=spcBase[1]) ||
(spcOriginalLayer[2]!=spcBase[2]) ||
_colorLayerImageViewManager->onThreshold();
RefreshView();
} // _ative
-
}
-
void ColorLayerImageViewPanel::RefreshView()
{
//EED01 _colorLayerImageView->Refresh();
// w.ShowModal();
printf("EED ColorLayerImageViewPanel::onReadImage ....WARNING... Read dlg. all images creaImageIO ... ???\n");
- creaMaracasVisuKernel::OpenImageDialog diag = creaMaracasVisuKernel::OpenImageDialog();
-
- vtkImageChangeInformation *change = vtkImageChangeInformation::New();
- vtkImageData *img = diag.getImageData();
int ext[6];
double spc[6];
double origin[3];
+ origin[0] = 0;
+ origin[1] = 0;
+ origin[2] = 0;
+
+ creaMaracasVisuKernel::OpenImageDialog diag = creaMaracasVisuKernel::OpenImageDialog();
+ vtkImageChangeInformation *change = vtkImageChangeInformation::New();
+ vtkImageData *img = diag.getImageData();
img -> GetExtent( ext );
img -> GetSpacing( spc );
change -> SetInputData( img );
- origin[0]=0;
- origin[1]=0;
- origin[2]=0;
change -> SetOutputSpacing( spc[0] , spc[1] , spc [2] );
change -> SetOutputExtentStart(0,0,0);
change -> SetOutputOrigin( origin );
int minVal = floor (_minValue);
int maxVal = floor (_maxValue);
- vtkLookupTable* thresholdTable = GetThresholdTable();
- thresholdTable->SetNumberOfTableValues(maxTot+1);
- thresholdTable->SetTableRange(range);
+ vtkLookupTable *thresholdTable = GetThresholdTable();
+ thresholdTable->SetNumberOfTableValues( (maxTot-minTot) );
thresholdTable->SetAlphaRange(0, 1);
thresholdTable->SetValueRange(0, 1);
thresholdTable->SetSaturationRange(0, 0);
//Assign a fake color for the upper image, and set the white as transparent
int i;
- for(i = minTot; i <= maxTot; i++)
+ int minVal2;
+ int maxVal2;
+ int minTot2;
+ int maxTot2;
+
+ minVal2=minVal-minTot;
+ maxVal2=maxVal-minTot;
+ minTot2=minTot-minTot;
+ maxTot2=maxTot-minTot;
+
+// thresholdTable->SetTableRange(minVal,maxVal);
+//EED You need to do this loop just the first time
+// for(i = minTot2; i <= maxTot2; i++)
+// {
+// thresholdTable->SetTableValue(i,_baseColorR,_baseColorG,_baseColorB, 1);
+// } // for
+
+ thresholdTable->SetTableRange(range);
+ for(i = minTot2; i <= maxTot2; i++)
{
- if( i >= minVal && i <= maxVal )
+ if( i >= minVal2 && i <= maxVal2 )
{
thresholdTable->SetTableValue(i,_baseColorR,_baseColorG,_baseColorB, 1);
- }
- else if( i >= minTot && i < minVal )
+ } else if( i >= minTot2 && i < minVal2 )
{
thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
- }
- else if( i > maxVal && i < maxTot )
+ } else if( i > maxVal2 && i < maxTot2 )
{
thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
- }
- else
- {
+ } else {
thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
}
} // for
thresholdTable->Build( );
-
}