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

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Mon Apr 14 13:51:13 EDT 2014


I am not entire surely sure why that change was done, but I think
here's a potential explanation:

- SetColor is really a "convenience" method. It's a shortcut to set
AmbientColor, SpecularColor, DiffuseColor. The Color ivar on
vtkProperty is not used by vtkOpenGLProperty at all when passing the
color to OpenGL.
- Since the "effective" color used by the property is the value
computed similar to what vtkProperty::ComputeCompositeColor does,
GetColor was changed to return that value.
- In fact, looking at the commit 52fd8ad8, GetColor() always returned
the "computed" value. Kyle just made that a static method and made
vtkProperty::GetColor() call that method instead.

Utkarsh


On Mon, Apr 14, 2014 at 12:57 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
> Ooops, I think Kyle has left Kitware...
>
> On Mon, Apr 14, 2014 at 12:54 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
>> GetColor should return the value set by SetColor. If we need the
>> composite color then we should explicitly ask for it.
>>
>> I'm not sure why this change was made. Kyle made it.
>>
>> Bill
>>
>>
>> On Mon, Apr 14, 2014 at 12:52 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
>>> 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
>>
>>
>>
>> --
>> Unpaid intern in BillsBasement at noware dot com
>
>
>
> --
> Unpaid intern in BillsBasement at noware dot com
> _______________________________________________
> 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
>



More information about the vtk-developers mailing list