[vtkusers] java repaint?

ekaditya eka.aditya at gmail.com
Tue Jul 26 23:52:25 EDT 2005


Hello David and Prabhath,
thank you so much for your response. :))

the problem with image STL file done, which is the second STL image 
replacing the first STL image.
so there is olny one object in window, but there's antoher problem raising, 
the camera is still following the first STL image.
i mean, when i interact with the second STL image, the first STL image is 
still there.
the fisrt STL image only cleared to the background color.. :(

i already try to use following code, hopefully it will reset the camera, and 
turn it to the second STL image..

public void open(String fileName)
{
renderer = renWin.GetRenderer();
renderer.RemoveActor(actor);
renderer.SetBackground(0.1, 0.2, 0.4);
 renderer.ResetCameraClippingRange();
 renderer.ResetCamera();
 renderer.InteractiveOff();

this.validate(); //extends JPanel
this.repaint();
renWin.validate();
renWin.repaint();

vtkSTLReader reader = new vtkSTLReader();
reader.SetFileName(fileName);

vtkPolyDataMapper mapper = new vtkPolyDataMapper();
mapper.SetInput(reader.GetOutput());

actor = new vtkActor();
actor.SetMapper(mapper);

renderer.AddActor(actor);
}

is there any way, so that the second STL file replacing first STL image, and 
the camara also?

thanks for your response..

On 7/26/05, David Cole <david.cole at kitware.com> wrote:
> 
> 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
> >
> >
> 
> 


-- 
--Y!M: ekaditya
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050727/2b40c068/attachment.htm>


More information about the vtkusers mailing list