[vtk-developers] A weird 6.x specific bug with ModifiedEvents

Bill Lorensen bill.lorensen at gmail.com
Mon Apr 14 12:52:36 EDT 2014


So here is the bug the sample code uncovers:

SetColor
1) Sets the Color ivar to the requested color
2) SetColor calls SetAmbientColor which triggers the Modified event
    The Modified event call GetColor which calls ComputeCompositeColor
and computes a composite color
    The composite color is not correct
3) Color continues to get corrupted with SetDiffuseColor and SetSpecularColor.



On Mon, Apr 14, 2014 at 12:40 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
> I do not think that GetColor should change the value of Color. If we
> need the composite color, we could have a method GetCompositeColor().
> No SetCompositeColor.
>
> Bill
>
>
> On Mon, Apr 14, 2014 at 12:24 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
>> Really bad stuff. ComputeCompositeColor "sets" this->Color directly.
>> ComputeCompositeColor was added about a year ago...
>>
>>
>>
>> On Mon, Apr 14, 2014 at 12:18 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
>>> This is indeed weird.
>>>
>>> GetColor does not return the value set by SetColor. It calls
>>> ComputeCompositeColor.
>>>
>>> Also, SetColor calls SetAmbientColor, SetDiffuseColor and
>>> SetSpecularColor. Each should cause a Modified event. In fact if you
>>> remove the o.GetColor() call in the Modified callback, you will see
>>> three modified events and each call will change one more of the color
>>> s (ambeint, diffuse, specular).
>>>
>>>
>>> Very strange.
>>>
>>> Bill
>>>
>>>
>>> On Mon, Apr 14, 2014 at 11:35 AM, Prabhu Ramachandran
>>> <prabhu at aero.iitb.ac.in> wrote:
>>>> Hi everyone,
>>>>
>>>> I just discovered a weird bug with VTK 6.1 and 6.0 that doesn't happen with
>>>> VTK 5.x.  Here is a tiny Python script:
>>>>
>>>> ##################################################
>>>> import vtk
>>>> def f(o, e):
>>>>     print e, o.GetAmbientColor(), o.GetColor(),
>>>>     print o.GetDiffuseColor(), o.GetSpecularColor()
>>>>
>>>> p = vtk.vtkProperty()
>>>> p.AddObserver('ModifiedEvent', f)
>>>> p.SetColor(0,0,0)
>>>> print p.GetColor()
>>>> ##################################################
>>>>
>>>> If you comment out the AddObserver line, everything works correctly but with
>>>> it, you can never set the color of the property!  This doesn't seem to be
>>>> specific to Python and happens with a small C++ example as well.
>>>>
>>>> Thoughts?
>>>>
>>>> cheers,
>>>> Prabhu
>>>> _______________________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://www.vtk.org/mailman/listinfo/vtk-developers
>>>>
>>>
>>>
>>>
>>> --
>>> Unpaid intern in BillsBasement at noware dot com
>>
>>
>>
>> --
>> Unpaid intern in BillsBasement at noware dot com
>
>
>
> --
> Unpaid intern in BillsBasement at noware dot com



-- 
Unpaid intern in BillsBasement at noware dot com



More information about the vtk-developers mailing list