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