|
| 1 | +##Copyright 2015 Thomas Paviot ([email protected]) |
| 2 | +## |
| 3 | +##This file is part of pythonOCC. |
| 4 | +## |
| 5 | +##pythonOCC is free software: you can redistribute it and/or modify |
| 6 | +##it under the terms of the GNU Lesser General Public License as published by |
| 7 | +##the Free Software Foundation, either version 3 of the License, or |
| 8 | +##(at your option) any later version. |
| 9 | +## |
| 10 | +##pythonOCC is distributed in the hope that it will be useful, |
| 11 | +##but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +##GNU Lesser General Public License for more details. |
| 14 | +## |
| 15 | +##You should have received a copy of the GNU Lesser General Public License |
| 16 | +##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. |
| 17 | + |
| 18 | +from OCC.Display.SimpleGui import init_display |
| 19 | +from OCC.BRepPrimAPI import BRepPrimAPI_MakeTorus |
| 20 | +from OCC.Graphic3d import (Graphic3d_EF_PDF, |
| 21 | + Graphic3d_EF_SVG, |
| 22 | + Graphic3d_EF_TEX, |
| 23 | + Graphic3d_EF_PostScript, |
| 24 | + Graphic3d_EF_EnhPostScript) |
| 25 | + |
| 26 | +display, start_display, add_menu, add_function_to_menu = init_display() |
| 27 | +my_box = BRepPrimAPI_MakeTorus(40., 20.).Shape() |
| 28 | + |
| 29 | +display.DisplayShape(my_box, update=True) |
| 30 | +f = display.View.View().GetObject() |
| 31 | + |
| 32 | + |
| 33 | +def export_to_PDF(event=None): |
| 34 | + f.Export('torus_export.pdf', Graphic3d_EF_PDF) |
| 35 | + |
| 36 | + |
| 37 | +def export_to_SVG(event=None): |
| 38 | + f.Export('torus_export.svg', Graphic3d_EF_SVG) |
| 39 | + |
| 40 | + |
| 41 | +def export_to_PS(event=None): |
| 42 | + f.Export('torus_export.ps', Graphic3d_EF_PostScript) |
| 43 | + |
| 44 | + |
| 45 | +def export_to_EnhPS(event=None): |
| 46 | + f.Export('torus_export_enh.ps', Graphic3d_EF_EnhPostScript) |
| 47 | + |
| 48 | + |
| 49 | +def export_to_TEX(event=None): |
| 50 | + f.Export('torus_export.tex', Graphic3d_EF_TEX) |
| 51 | + |
| 52 | + |
| 53 | +if __name__ == '__main__': |
| 54 | + add_menu('screencapture') |
| 55 | + add_function_to_menu('screencapture', export_to_PDF) |
| 56 | + add_function_to_menu('screencapture', export_to_SVG) |
| 57 | + add_function_to_menu('screencapture', export_to_PS) |
| 58 | + add_function_to_menu('screencapture', export_to_EnhPS) |
| 59 | + add_function_to_menu('screencapture', export_to_TEX) |
| 60 | + start_display() |
0 commit comments