[vtk-developers] How to assign a vtkContourWidget and vtkBorderWidget to specific actor

darkcminor darkcminor at gmail.com
Mon Dec 9 16:26:32 EST 2013


To assign other vtkwidget (i.e. boxWidget) to particular actor it seems to be
possible to do it like: 
/
            //Source process object in the pipeline (it produces vtkPolyData
output) 
            vtkConeSource cone = new vtkConeSource(); 
            cone.SetHeight(3.0); 
            cone.SetRadius(1.0); 
            cone.SetResolution(10); 
            //Mapper process object in the pipeline (it receives the
vtkPolyData as the input) 
            vtkPolyDataMapper coneMapper; 
            coneMapper = vtkPolyDataMapper.New(); 
            coneMapper.SetInputConnection(cone.GetOutputPort()); 
            //We create an actor to represent the cone. The actor is
responsible of the rendering 
            vtkActor coneActor = new vtkActor(); 
            coneActor.SetMapper(coneMapper); 
            //The renderer acts like a viewport, being part or all of the
window 
            //On it, we add the actor 
            vtkRenderer myRenderer; 
            myRenderer = vtkRenderer.New(); 
            myRenderer.GetActiveCamera().SetViewUp(-1, 0, 0); 
            myRenderer.AddActor(coneActor); 
            myRenderer.SetBackground(0.1, 0.2, 0.4); 
            //We create the window where the rederer will be added 
            vtkRenderWindow renWin; 
            renWin = vtkRenderWindow.New(); 
            renWin.AddRenderer(myRenderer); 
            renWin.SetSize(640, 480); 
            //We create an Interactor object, and associate the RenderWindow
to it. 
            //This vtkRenderWindowInteractor initiates an instance of
vtkInteractorStyle object, which translate the events into 
            //operations, it defines the behavior of the scene 
            vtkRenderWindowInteractor myInteractor = new
vtkRenderWindowInteractor(); 
            myInteractor.SetRenderWindow(renWin); 
            //We define a specific behavior binding a InteractorStyle object
to the Interactor object 
            vtkInteractorStyleTrackballCamera style = new
vtkInteractorStyleTrackballCamera(); 
            //vtkInteractorStyleFlight style = new
vtkInteractorStyleFlight(); 
            myInteractor.SetInteractorStyle(style); 

            //////////////////////////////////// 
            //vtkBoxWidget stuff 
            // use a vtkBoxWidget to transform the underlying coneActor (by 
            // manipulating its transformation matrix). 
            // The SetInteractor method is how 3D widgets are associated
with the render 
            // window interactor. Internally, SetInteractor sets up a bunch
of callbacks 
            // using the Command/Observer mechanism (AddObserver()). The
place factor 
            // controls the initial size of the widget with respect to the
bounding box 
            // of the input to the widget. 
            vtkBoxWidget myBox = new vtkBoxWidget(); 
            myBox.SetInteractor(myInteractor); 
            myBox.SetPlaceFactor(1); 

            myBox.OutlineCursorWiresOff(); 
            myBox.RotationEnabledOff(); 
            // 
            // Place the interactor initially. The input to a 3D widget is
used to 
            // initially position and scale the widget. The
EndInteractionEvent is 
            // observed which invokes the SelectPolygons callback. 
            ///////////////////////HERE//////////////////       
            myBox.SetProp3D(coneActor); 
           /////////////////////////////////////////////// 
            myBox.PlaceWidget(); 
            myBox.InteractionEvt += new
vtkObject.vtkObjectEventHandler(MyCallback);

/

How to do the same for vtkContourWidget and vtkBorderWidget I have searched
for an analog but had no luck. 

Could you please post a simple example as the previous one?



--
View this message in context: http://vtk.1045678.n5.nabble.com/How-to-assign-a-vtkContourWidget-and-vtkBorderWidget-to-specific-actor-tp5724932.html
Sent from the VTK - Dev mailing list archive at Nabble.com.



More information about the vtk-developers mailing list