Commit 7554457b authored by Yumin Yuan's avatar Yumin Yuan

ENH: Remove current observer when reset an object

parent e8a5cef5
......@@ -76,6 +76,14 @@ void vtkColorTransferFunctionItem::ComputeBounds(double* bounds)
//-----------------------------------------------------------------------------
void vtkColorTransferFunctionItem::SetColorTransferFunction(vtkColorTransferFunction* t)
{
if (t == this->ColorTransferFunction)
{
return;
}
if (this->ColorTransferFunction)
{
this->ColorTransferFunction->RemoveObserver(this->Callback);
}
vtkSetObjectBodyMacro(ColorTransferFunction, vtkColorTransferFunction, t);
if (t)
{
......
......@@ -123,11 +123,6 @@ void vtkCompositeControlPointsItem::SetColorTransferFunction(vtkColorTransferFun
{
return;
}
// Observation will be set Superclass::SetColorTransferFunction
if (this->ColorTransferFunction)
{
this->ColorTransferFunction->RemoveObserver(this->Callback);
}
// We need to set the color transfer function here (before
// Superclass::SetPiecewiseFunction) to be able to have a valid
// color transfer function for MergeColorTransferFunction().
......
......@@ -79,6 +79,14 @@ void vtkCompositeTransferFunctionItem::ComputeBounds(double* bounds)
//-----------------------------------------------------------------------------
void vtkCompositeTransferFunctionItem::SetOpacityFunction(vtkPiecewiseFunction* opacity)
{
if (opacity == this->OpacityFunction)
{
return;
}
if (this->OpacityFunction)
{
this->OpacityFunction->RemoveObserver(this->Callback);
}
vtkSetObjectBodyMacro(OpacityFunction, vtkPiecewiseFunction, opacity);
if (opacity)
{
......
......@@ -74,6 +74,14 @@ void vtkLookupTableItem::ComputeBounds(double* bounds)
//-----------------------------------------------------------------------------
void vtkLookupTableItem::SetLookupTable(vtkLookupTable* t)
{
if (t == this->LookupTable)
{
return;
}
if (this->LookupTable)
{
this->LookupTable->RemoveObserver(this->Callback);
}
vtkSetObjectBodyMacro(LookupTable, vtkLookupTable, t);
if (t)
{
......
......@@ -92,6 +92,10 @@ void vtkPiecewiseControlPointsItem::SetPiecewiseFunction(vtkPiecewiseFunction* t
{
return;
}
if (this->PiecewiseFunction)
{
this->PiecewiseFunction->RemoveObserver(this->Callback);
}
vtkSetObjectBodyMacro(PiecewiseFunction, vtkPiecewiseFunction, t);
if (this->PiecewiseFunction)
{
......
......@@ -78,6 +78,14 @@ void vtkPiecewiseFunctionItem::ComputeBounds(double* bounds)
//-----------------------------------------------------------------------------
void vtkPiecewiseFunctionItem::SetPiecewiseFunction(vtkPiecewiseFunction* t)
{
if (t == this->PiecewiseFunction)
{
return;
}
if (this->PiecewiseFunction)
{
this->PiecewiseFunction->RemoveObserver(this->Callback);
}
vtkSetObjectBodyMacro(PiecewiseFunction, vtkPiecewiseFunction, t);
if (t)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment