[vtkusers] Exporting with vtkGL2PSExporter

Laura Balbastre laura.balbastre.soler at gmail.com
Tue Apr 2 11:33:16 EDT 2013


Hi all,

I've been trying to export a scene using vtkGL2PSExporter. It works
sometimes (maybe 80%), but not always. Moreover, I'm not able to reproduce
the pattern that causes it not to work.

Furthermore, after succeeding in exporting the .svg picture, I loose the
control of the figure's interactor, so I can't rotate it anymore.

The scenario is the following: When right-click on the figure a menu opens
with an option to "Export...". It opens a Dialog which allows us to specify
the format, the name and the directory where we want to save the .svg.

I attach you the detailed code.

Thanks in advance,

Laura

@Override
 public void mousePressed(MouseEvent e) {
if (ren.VisibleActorCount() == 0)
            return;
        Lock();
        rw.SetDesiredUpdateRate(5.0);
        lastX = e.getX();
        lastY = e.getY();

        ctrlPressed = (e.getModifiers() & InputEvent.CTRL_MASK) ==
InputEvent.CTRL_MASK ? 1 : 0;
        shiftPressed = (e.getModifiers() & InputEvent.SHIFT_MASK) ==
InputEvent.SHIFT_MASK ? 1 : 0;

        iren.SetEventInformationFlipY(e.getX(), e.getY(), ctrlPressed,
shiftPressed, '0', 0, "0");

        if ((e.getModifiers() & InputEvent.BUTTON1_MASK) ==
InputEvent.BUTTON1_MASK) {
            iren.LeftButtonPressEvent();
        } else if ((e.getModifiers() & InputEvent.BUTTON2_MASK) ==
InputEvent.BUTTON2_MASK) {
            iren.MiddleButtonPressEvent();
        } else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) ==
InputEvent.BUTTON3_MASK) {
JPopupMenu popup = new JPopupMenu();
 JMenuItem menuItem5 = new JMenuItem("Export As...");
popup.add(menuItem5);
popup.show(e.getComponent(), e.getX(), e.getY());
 final Chart3dCanvas canvas = this;

menuItem5.addActionListener(new ActionListener() {
 @Override
public void actionPerformed(ActionEvent arg0) {
 Display.getDefault().asyncExec(new Runnable() {
 @Override
 public void run() {
Shell shell = new Shell(SWT.TITLE);
 shell.setText("Export As...");
ExportAs id = new ExportAs(shell);

 if (id.open() == Window.OK) {
vtkGL2PSExporter exp = new vtkGL2PSExporter();
exp.SetRenderWindow(ren.GetRenderWindow());
 exp.SetSortToOff();
exp.CompressOff();
exp.DrawBackgroundOn();
 exp.Write3DPropsAsRasterImageOff();

String route = id.getDirectory() + id.getName();
 exp.SetFilePrefix(route.toString());
if(id.isSvg()) {
exp.SetFileFormatToSVG();
 exp.Write();
}
if(id.isPdf()) {
 exp.SetFileFormatToPDF();
exp.Write();
}
 }
});
}
});
 }
        }
UnLock();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130402/1d4ac8af/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: export.java
Type: application/octet-stream
Size: 2412 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130402/1d4ac8af/attachment.obj>


More information about the vtkusers mailing list