[vtkusers] java repaint?

David Cole david.cole at kitware.com
Tue Jul 26 10:39:00 EDT 2005


Save a reference to the actor and then call 
"renWin.GetRenderer().RemoveActor(actor);" to get rid of it prior to 
adding the actor for the second file. RemoveActor is the inverse of 
AddActor.

ekaditya wrote:

>
> hi all,
>
> i'm newbie in VTK. now i'm using java.1.5 and vtk4.2 for my application.
> i have problem when rendering the STL file.
> first, i using GUI to select the STL file,
>  private void openActionPerformed(java.awt.event.ActionEvent evt) {
>     // TODO add your handling code here:
>         JFileChooser chooser = new JFileChooser();
>         chooser.showOpenDialog(this);
>       
>         File file = chooser.getSelectedFile();
>         if(file != null)
>         {
>             String fileName = file.getPath();
>           
>             mainPanel.open(fileName);
>             //System.out.println(fileName);
>         }
>     }
>
> and then mainPanel, which is using vtkPanel to render the STL,
>  public void open(String fileName)
>    {
>        //this.setLayout(new BorderLayout());
>        vtkSTLReader reader = new vtkSTLReader();
>        reader.SetFileName(fileName);
>        //System.out.println("dalam fungsi" + fileName);
>
>        vtkPolyDataMapper mapper = new vtkPolyDataMapper();
>        mapper.SetInput(reader.GetOutput());
>
>        vtkActor actor = new vtkActor();
>        actor.SetMapper(mapper);
>      
>        //renWin.GetRenderer().AddActor(actor);
>        renWin.GetRenderer().AddActor(actor);
>      
>        renWin.validate();
>        renWin.repaint();
>    }
>
> when i try to open the STL file, it's fine.
> but the problem comes when i try to open other STL file.
> the first STL image don't changed with the second STL image, but they 
> together in one window.
> how to make the second STL image replacing the first STL image?
>
> thank's for your responese..
>
> -- 
> --Y!M: ekaditya
>
>------------------------------------------------------------------------
>
>_______________________________________________
>This is the private VTK discussion list. 
>Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers
>  
>




More information about the vtkusers mailing list