[vtkusers] Actor -- isMovable?
Cory Quammen
cquammen at cs.unc.edu
Thu Nov 5 07:52:57 EST 2009
Piotr,
The interactor style you have let's you switch between two modes. In
one mode, you are moving the camera. Mouse motions in the window will
affect the camera, but it will not change the actors position or
orientation in world space. Sure, they appear to move on the screen,
but what you see really comes from the camera moving. In this mode,
calling PickableOff() won't have any effect because you aren't picking
any actors.
The other mode, however, lets you pick individual actors and change
their position, orientation, and scale in world space. For this mode,
you *can* pick actors and change these properties. Calling
PickableOff() will have an effect here; it will prevent you from
picking and subsequently modifying the actor position, orientation,
and scale.
In your code, the first mode is what you have. To see what the second
mode is like, you might try
widget_3d.GetRenderWindow().GetInteractor().GetInteractorStyle().SetCurrentStyleToTrackballActor()
This mode will let you manipulate individual actors, unless of course
you set them to PickableOff(). This seems to me close to what are you
going for.
I hope that helps,
Cory
On Thu, Nov 5, 2009 at 5:48 AM, Piotr Byzia <piotr.byzia at gmail.com> wrote:
> Hi Karthik,
> I disabled the interactor style, however I still can rotate my actor (by the
> mouse interaction).
> This's what I've done:
> widget_3d.GetRenderWindow().GetInteractor().GetInteractorStyle().EnabledOff()
> my_actor.PickableOff()
> widget_3d is an instance of
> QVTKRenderWindowInteractor.QVTKRenderWindowInteractor(self)
> Below is an output
> for widget_3d.GetRenderWindow().GetInteractor().GetInteractorStyle()
> Let me know if there is any other information which might help.
> vtkInteractorStyleSwitch (0E995418)
> Debug: Off
> Modified Time: 945
> Reference Count: 2
> Registered Events: (none)
> Current Renderer: 00000000
> Default Renderer: 00000000
> Enabled: 0
> Priority: 0
> Interactor: 0E9418D0
> Key Press Activation: Off
> Key Press Activation Value: i
> Auto Adjust Camera Clipping Range On
> Pick Color: (1, 0, 0)
> CurrentRenderer: 00000000
> Picked Renderer: (none)
> Current Actor: (none)
> Interactor: 0E9418D0
> Prop Picked: No
> State: 0
> UseTimers: 0
> HandleObservers: 1
> MouseWheelMotionFactor: 1
> Timer Duration: 10
> CurrentStyle 0E9A3818
> vtkInteractorStyleTrackballCamera
> Debug: Off
> Modified Time: 1703
> Reference Count: 1
> Registered Events:
> Registered Observers:
> vtkObserver (0E9912B8)
> Event: 41
> EventName: EndInteractionEvent
> Command: 0E9A58E0
> Priority: 0
> Tag: 2
> vtkObserver (0E9906B0)
> Event: 39
> EventName: StartInteractionEvent
> Command: 0E9A58E0
> Priority: 0
> Tag: 1
> Current Renderer: 00000000
> Default Renderer: 00000000
> Enabled: 0
> Priority: 0
> Interactor: 0E9418D0
> Key Press Activation: Off
> Key Press Activation Value: i
> Auto Adjust Camera Clipping Range On
> Pick Color: (1, 0, 0)
> CurrentRenderer: 00000000
> Picked Renderer: (none)
> Current Actor: (none)
> Interactor: 0E9418D0
> Prop Picked: No
> State: 0
> UseTimers: 0
> HandleObservers: 1
> MouseWheelMotionFactor: 1
> Timer Duration: 10
> MotionFactor: 10
>
>
> On 04.11.2009, at 18:25, Karthik Krishnan wrote:
>
> try to disable the interactor style set on teh interactor
>
> interactor->GetInteractorStyle()->EnabledOff()
>
> On Wed, Nov 4, 2009 at 10:35 AM, Piotr Byzia <piotr.byzia at gmail.com> wrote:
>>
>> Cory and Karthik,
>>
>> Thank you for your suggestions.
>>
>> By moving, I meant an interaction with a mouse.
>> Indeed, I have no interaction style defined explicitly, but it seems that
>> Python interface has some default one set up, because I was able to run
>> this:
>>
>> lines_actor.PickableOff()
>> print lines_actor.GetPickable()
>> lines_actor.PickableOn()
>> print lines_actor.GetPickable()
>> lines_actor.SetPickable(0)
>> print lines_actor.GetPickable()
>>
>> which produced:
>> 0
>> 1
>> 0
>>
>> (I apologize if this is something obvious for you, I just started
>> experimenting with VTK)
>> So, vtkActor() has an interaction style by default, thus I was able to
>> call PickableOff() on it.
>> However it does not work, while I was able to pick and move around
>> (rotate) lines_actor with the mouse.
>>
>> I had the same issue with lines_actor.DragableOff().
>>
>> What is surprising, lines_actor.VisibilityOff() works fine! (lines_actor
>> was not visible on the scene)
>>
>> Do you possibly have ideas what can interfere with the PickableOff() ??
>>
>> Thanks for any suggestions,
>> Piotr Byzia
>>
>>
>> On 04.11.2009, at 14:16, Cory Quammen wrote:
>>
>>> Hi Piotr,
>>>
>>> Perhaps you could clarify what you mean by moving an actor. It doesn't
>>> sound like you have an interactor style that is manipulating the
>>> actors by picking with the mouse. If you did, however, you could call
>>> PickableOff() on the actor, which will prevent you from picking it and
>>> thereby prevent movement of the actor.
>>>
>>> How exactly are you moving the actors now?
>>>
>>> Cory
>>>
>>> On Wed, Nov 4, 2009 at 7:21 AM, Piotr Byzia <piotr.byzia at gmail.com>
>>> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I want to set an actor to be movable or non-movable, depending on
>>>> settings
>>>> which I control through PyQT GUI.
>>>> In other words, having a few actors on the scene I want to set
>>>> checkboxes in
>>>> my GUI that would freeze a given actor, and the rest of them to react as
>>>> usual to the mouse movements / clicks.
>>>>
>>>> Regarding visibility of the actor I'm using
>>>> GetProperty().SetOpacity(0.0) on
>>>> an instance of any given actor.
>>>> I can't see anything related to movement in the GetProperty()
>>>> properties, I
>>>> believe it's somewhere else?
>>>>
>>>> Here are most important parts of the code I'm using to generate a single
>>>> actor:
>>>>
>>>> self.ren = vtk.vtkRenderer()
>>>> self.ren.SetBackground(0, 0, 0)
>>>> self.widget_3d.GetRenderWindow().AddRenderer(self.ren)
>>>>
>>>> apd=vtk.vtkAppendPolyData()
>>>>
>>>> for i in xrange(len(coordinates)):
>>>> line=vtk.vtkLineSource()
>>>>
>>>> line.SetPoint1(coordinates[i][0]) # 1st atom coordinates for a given
>>>> bond
>>>> line.SetPoint2(coordinates[i][1]) # 2nd atom coordinates for a given
>>>> bond
>>>> line.SetResolution(21)
>>>> apd.AddInput(line.GetOutput())
>>>>
>>>> mapper = vtk.vtkPolyDataMapper()
>>>> mapper.SetInput(apd.GetOutput())
>>>> lines_actor = vtk.vtkActor()
>>>> lines_actor.SetMapper(mapper)
>>>> lines_actor.GetProperty().SetColor(0.7, 0.0, 0.0)
>>>> lines_actor.GetProperty().SetOpacity(1.0)
>>>>
>>>> self.ren.AddActor(lines_actor)
>>>>
>>>>
>>>> I found SetCurrentStyleToTrackballActor(), but I want to control this
>>>> behavior from my GUI.
>>>> Besides, trackball mode is very inconvenient in my case, with molecules
>>>> in
>>>> "lines" representation (it's hard to pick a single line).
>>>>
>>>> Thanks,
>>>> Piotr Byzia
>>>> _______________________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Please keep messages on-topic and check the VTK FAQ at:
>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>>
>>>
>>>
>>>
>>> --
>>> Cory Quammen
>>> Center for Computer Integrated Systems for Microscopy and Manipulation
>>> (CISMM)
>>> Department of Computer Science
>>> University of North Carolina at Chapel Hill
>>> http://www.cs.unc.edu/~cquammen
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
>
--
Cory Quammen
Center for Computer Integrated Systems for Microscopy and Manipulation (CISMM)
Department of Computer Science
University of North Carolina at Chapel Hill
http://www.cs.unc.edu/~cquammen
More information about the vtkusers
mailing list