<br><br><div><span class="gmail_quote">On 4/18/06, <b class="gmail_sendername">Ashley Sher</b> <<a href="mailto:tany0029@ntu.edu.sg">tany0029@ntu.edu.sg</a>> wrote:</span><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
I'm implementing exactly what you're trying to do.<br><br>I was thinking maybe it's more suitable to use vtkPropPicker as the default<br>picker?<br><br>Something like that,<br><br>vtkPropPicker *pPropPicker = vtkPropPicker::New();
<br>vtkCallbackCommand *PickCallBackCommand = vtkCallbackCommand::New();<br>PickCallBackCommand->SetCallback(MyVtkView::PickCallBack);<br>pPropPicker->AddObserver(vtkCommand::EndPickEvent, PickCallBackCommand);<br>MyVtkInteractor->SetPicker(pPropPicker);
<br><br>I have not finish implementing it so not too sure if it works well too.<br>Keep me update once you've tried it?<br><br>Thx!</blockquote><div><br>
</div></div>Ashley, Marc - nice talking to you!<br>
<br>
OK.. unfortunately I did not see Marc's message yesterday so I hacked up smthng that works..<br>
I wasn't aware you could tell the callback about the renderer, so I used a class as a namespace<br>
to hold a few important pointers for me. I did realize I need a picker, and vtkPropPicker was my first<br>
pick :-) unfortunately no luck.. I will be trying Marc's approach as it's clean and simple.<br>
<br>
Ashley, this is what I have for now and it's working:<br>
<br>
renderer is a vtkRenderer;<br>
renderWindow has a renderer;<br>
interactor has a renderWindow;<br>
....<br>
<br>
vtkInteractorStyle* style = vtkInteractorStyle::New();<br>
<br>
// i had no luck with other styles, except this one and vtkInteractorStyleUser<br>
<br>
LeftClickCallback* callback = LeftClickCallback::New(); // per Marc's instructions<br>
<br>
style->AddObserver( vtkCommand::LeftButtonPressEvent, callback );<br>
<br>
global.interactor->SetInteractorStyle( style );<br>
<br>
callback->Delete();<br>
style->Delete();<br>
<br>
// ... then later inside LeftClickCallback::Execute<br>
<br>
void LeftClickCallback::Execute( vtkObject* caller, unsigned long eventId, void* callData )<br>
{<br>
vtkInteractorStyle* style = vtkInteractorStyle::SafeDownCast(caller);<br>
<br>
if( style ) // is this necessary?<br>
{<br>
vtkPicker* p = vtkPicker::New(); // didn't work with vtkPropPicker<br>
<br>
// i've got only one
renderer, renderWindow, interactor pipeline so i don't have to ask
style where the event occured<br>
// i know it ocured in my global.interactor.<br>
<br>
p->Pick(
(global.interactor->GetEventPosition())[0],
(global.interactor->GetEventPosition())[1], 0, global.renderer );<br>
vtkActor* a = p->GetActors()->GetLastActor();<br>
<br>
// here i do something to my actor.. adjust it's color, blah blah..<br>
// my next problem is adjusting size.. hm... i don't see any size properties..<br>
<br>
p->Delete();<br>
g.renderWindow->Render(); // update screen<br>
}<br>
}<br>
...<br>
<br>
Ashley, Marc, Kjeld - thank you all for your time and generous help.<br>
Hopefully I'll be able to reciprocate someday.<br>
<br>
Cheers!!<br>
-- <br><a href="mailto:stoptv@gmail.com">stoptv@gmail.com</a><br>
<br>