chiark / gitweb /
Quick and ugly change which fixes slicing with pypy. Cleanup will follow.
[cura.git] / Cura / cura.py
1 #!/usr/bin/python
2 """
3 This page is in the table of contents.
4 ==Overview==
5 ===Introduction===
6 Cura is a GPL tool chain to forge a gcode skein for a model. Based on Skeinforge.
7
8 The slicing code is the same as Skeinforge. But the UI has been revamped to be... sane.
9
10 """
11 from __future__ import absolute_import
12
13 import sys
14 import warnings
15 from optparse import OptionParser
16
17 from Cura.util import profile
18
19 __author__ = 'Daid'
20 __credits__ = """
21 David Braam (daid303@gmail.com)
22 Enrique Perez (perez_enrique@yahoo.com)
23 Adrian Bowyer <http://forums.reprap.org/profile.php?12,13>
24 Brendan Erwin <http://forums.reprap.org/profile.php?12,217>
25 Greenarrow <http://forums.reprap.org/profile.php?12,81>
26 Ian England <http://forums.reprap.org/profile.php?12,192>
27 John Gilmore <http://forums.reprap.org/profile.php?12,364>
28 Jonwise <http://forums.reprap.org/profile.php?12,716>
29 Kyle Corbitt <http://forums.reprap.org/profile.php?12,90>
30 Michael Duffin <http://forums.reprap.org/profile.php?12,930>
31 Marius Kintel <http://reprap.soup.io/>
32 Nophead <http://www.blogger.com/profile/12801535866788103677>
33 PJR <http://forums.reprap.org/profile.php?12,757>
34 Reece.Arnott <http://forums.reprap.org/profile.php?12,152>
35 Wade <http://forums.reprap.org/profile.php?12,489>
36 Xsainnz <http://forums.reprap.org/profile.php?12,563>
37 Zach Hoeken <http://blog.zachhoeken.com/>
38 Ilya Kulakov (kulakov.ilya@gmail.com)
39
40 Organizations:
41 Ultimaker <http://www.ultimaker.com>
42 Art of Illusion <http://www.artofillusion.org/>"""
43
44 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
45
46
47 def main():
48         parser = OptionParser(usage="usage: %prog [options] <filename>.stl")
49         parser.add_option("-i", "--ini", action="store", type="string", dest="profileini",
50                 help="Load settings from a profile ini file")
51         parser.add_option("-P", "--project", action="store_true", dest="openprojectplanner",
52                 help="Open the project planner")
53         parser.add_option("-F", "--flat", action="store_true", dest="openflatslicer",
54                 help="Open the 2D SVG slicer (unfinished)")
55         parser.add_option("-r", "--print", action="store", type="string", dest="printfile",
56                 help="Open the printing interface, instead of the normal cura interface.")
57         parser.add_option("-p", "--profile", action="store", type="string", dest="profile",
58                 help="Internal option, do not use!")
59         parser.add_option("-s", "--slice", action="store_true", dest="slice",
60                 help="Slice the given files instead of opening them in Cura")
61         (options, args) = parser.parse_args()
62
63         if options.profile is not None:
64                 profile.loadGlobalProfileFromString(options.profile)
65         if options.profileini is not None:
66                 profile.loadGlobalProfile(options.profileini)
67
68         if options.openprojectplanner is not None:
69                 from Cura.gui import projectPlanner
70                 projectPlanner.main()
71         elif options.openflatslicer is not None:
72                 from Cura.gui import flatSlicerWindow
73                 flatSlicerWindow.main()
74         elif options.printfile is not None:
75                 from Cura.gui import printWindow
76                 printWindow.startPrintInterface(options.printfile)
77         elif options.slice is not None:
78                 from Cura.util import sliceRun
79                 sliceRun.runSlice(args)
80         else:
81                 if len(args) > 0:
82                         profile.putPreference('lastFile', ';'.join(args))
83
84                 import wx._core
85                 from Cura.gui import splashScreen
86
87                 class CuraApp(wx.App):
88                         def MacOpenFile(self, path):
89                                 try:
90                                         pass
91                                 except Exception as e:
92                                         warnings.warn("File at {p} cannot be read: {e}".format(p=path, e=str(e)))
93
94                 def mainWindowRunCallback(splash):
95                         from Cura.gui import mainWindow
96                         if splash is not None:
97                                 splash.Show(False)
98                         mainWindow.main()
99
100                 app = CuraApp(False)
101                 # Apple discurage usage of splash screens on a mac.
102                 if sys.platform.startswith('darwin'):
103                         mainWindowRunCallback(None)
104                 else:
105                         splashScreen.splashScreen(mainWindowRunCallback)
106                 app.MainLoop()
107
108 if __name__ == '__main__':
109         main()