[vtkusers] Altering a rendered actor

Kerry Loux louxkr at gmail.com
Thu May 22 08:59:25 EDT 2008


Thanks to everyone who helped with this, I think I've got it (partially):

In my test app, I'm creating a cone with radius = 0.5 and height = 1.  I
zoom out (it starts so close to the camera that it is partially clipped) and
then click a button to change the position from [0.0, 0.0, 0.0] to [5.0,
5.0. 0.0].  Nothing that I was trying worked, but I thought I'd give Lu's
advice another chance and just do this:

pConeActor->SetPosition(5.0,5.0,0.0);
m_pVTKWindow->Render();

It worked.  I tried putting some of the other things back in there to figure
out what was breaking it, and it seemed that any/all of them would make it
not work.  I went back to the simple solution above, and it also was no
longer working.  I thought I was loosing it, so I ran the app a bunch of
times and oriented the cone several different ways before I clicked the
button.  It worked sometimes, but not always, and it seemed to have to do
with how far I zoomed out.  I changed the code to set the position to [1.0,
1.0, 0.0] and now it works every time.  Is there some clipping plane stuff
going on here?  In all cases the actor appears as soon as I start to
rotate/translate/zoom with the mouse.

Thanks,

Kerry

On Wed, May 21, 2008 at 9:41 PM, Yick Lu <jati.lue at gmail.com> wrote:

> Hi, Kerry
>
> Did you get it?
>
> My method is: everytime when actor's position is set, call the render
> method of corresponding vtkRenderWindowInteractor right at once. In this
> case, I don't need any vtkevent.
>
>
>
> Lu Yi
>
>
>
>
>
> On Wed, May 21, 2008 at 8:47 PM, Kerry Loux <louxkr at gmail.com> wrote:
>
>> Thanks for your response, Lu.
>>
>> Yes, that's what I'm doing, but my problem is only with re-rendering the
>> image.  After updating the actor's position and orientation, the image
>> doesn't update until I click on the screen to rotate or zoom, etc.  It seems
>> as though I'm missing the "update the screen" call.  I have since found that
>> if I call the Render() method of the renderWindowInteractor (actually a
>> wxVTKRenderWindowInteractor) the actor disappears from the original
>> position, but it still isn't redrawn until I click on the window.  The only
>> way I've found that updates the screen without clicking on it is to invoke a
>> clicking event with the InvokeEvent() method.  This is undesirable because
>> then my screen rotates until I click on it.  I've tried the following to get
>> the screen to update:
>>
>> pConeActor->SetPosition(5.0,5.0,0.0);// Set new position - for this
>> sample, original position was [0.0, 0.0, 0.0]
>> m_pVTKWindow->Render();
>>
>> This removes the actor from the original position, but doesn't draw it in
>> it's new position until I click on the screen, as stated above.
>>
>>
>> pConeActor->SetPosition(5.0,5.0,0.0);
>> m_pVTKWindow->Render();
>> m_pVTKWindow->InvokeEvent(vtkCommand::ModifiedEvent, NULL);
>>
>> The addition of the InvokeEvent call here makes no difference.
>>
>>
>> pConeActor->SetPosition(5.0,5.0,0.0);
>> m_pVTKWindow->Render();
>> m_pVTKWindow->Update();// I've tried this with Update first, then Render
>> as well
>>
>> The Update() call here makes no difference.
>>
>>
>> pConeActor->SetPosition(5.0,5.0,0.0);
>> m_pVTKWindow->Render();
>> m_pVTKWindow->InvokeEvent(vtkCommand::LeftButtonPressEvent, NULL);
>>
>> This does make the image redraw, but it also makes it spin (as though you
>> were pressing the left mouse button...).  That makes the obvious next step:
>>
>> pConeActor->SetPosition(5.0,5.0,0.0);
>> m_pVTKWindow->Render();
>> m_pVTKWindow->InvokeEvent(vtkCommand::LeftButtonPressEvent, NULL);
>> m_pVTKWindow->InvokeEvent(vtkCommand::LeftButtonReleaseEvent, NULL);
>>
>> But this doesn't do anything different than the first few attempts.  I've
>> been looking at the code that handles the LeftButtonPressEvent
>> (vtkSubjectHelper::InvokeEvent in vtkObject.cxx) to try and figure out what
>> part of that function makes the screen update, but so far I haven't been
>> successful.  Any help or advice is still appreciated!
>>
>> Thanks,
>>
>> Kerry
>>
>>
>>
>> On Tue, May 20, 2008 at 8:14 PM, Yick Lu <jati.lue at gmail.com> wrote:
>>
>>> Maybe you can try "events"
>>>
>>> The event handler function should be like this:
>>>
>>> Typing Event Handler( eventArgs )
>>> {
>>> //check character at the beginning
>>>
>>> pActor->Setpostion();//define new position
>>> pRenderer->Render();
>>>
>>> }
>>>
>>> The event is invoked as user type anything in the textbox. But make sure
>>> the inputed character is checked and valid.
>>>
>>>
>>> --
>>> Lu Yi
>>>
>>
>>
>
>
> --
> Lu Yi
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080522/ef9e79fe/attachment.htm>


More information about the vtkusers mailing list