mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-06 06:09:19 +08:00
No longer use the current_profile.ini to share the profile between the backend slicer and the frontend. No longer have simple-mode overwrite the current profile from normal mode.
This commit is contained in:
parent
e17c4387c9
commit
88337f1675
@ -16,6 +16,7 @@ import sys
|
||||
import platform
|
||||
from optparse import OptionParser
|
||||
|
||||
from util import profile
|
||||
from util import sliceRun
|
||||
|
||||
__author__ = 'Daid'
|
||||
@ -43,9 +44,11 @@ Art of Illusion <http://www.artofillusion.org/>"""
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
|
||||
def main():
|
||||
parser = OptionParser()
|
||||
parser = OptionParser(usage="usage: %prog [options] <filename>.stl")
|
||||
parser.add_option("-p", "--profile", action="store", type="string", dest="profile", help="Use these profile settings instead of loading current_profile.ini")
|
||||
(options, args) = parser.parse_args()
|
||||
sys.argv = [sys.argv[0]] + args
|
||||
if options.profile != None:
|
||||
profile.loadGlobalProfileFromString(options.profile)
|
||||
if len( args ) > 0:
|
||||
sliceRun.runSlice(args)
|
||||
else:
|
||||
|
@ -265,8 +265,6 @@ class mainWindow(configBase.configWindowBase):
|
||||
def OnSlice(self, e):
|
||||
if self.filename == None:
|
||||
return
|
||||
profile.saveGlobalProfile(profile.getDefaultProfilePath())
|
||||
|
||||
#Create a progress panel and add it to the window. The progress panel will start the Skein operation.
|
||||
spp = sliceProgessPanel.sliceProgessPanel(self, self, self.filename)
|
||||
self.sizer.Add(spp, (len(self.progressPanelList)+2,0), span=(1,4), flag=wx.EXPAND)
|
||||
|
@ -162,6 +162,9 @@ class simpleModeWindow(configBase.configWindowBase):
|
||||
def OnSlice(self, e):
|
||||
if self.filename == None:
|
||||
return
|
||||
#save the current profile so we can put it back latter
|
||||
oldProfile = profile.getGlobalProfileString()
|
||||
|
||||
put = profile.putProfileSetting
|
||||
get = profile.getProfileSetting
|
||||
|
||||
@ -247,8 +250,6 @@ class simpleModeWindow(configBase.configWindowBase):
|
||||
put('enable_raft', 'True')
|
||||
put('skirt_line_count', '0')
|
||||
|
||||
profile.saveGlobalProfile(profile.getDefaultProfilePath())
|
||||
|
||||
#Create a progress panel and add it to the window. The progress panel will start the Skein operation.
|
||||
spp = sliceProgessPanel.sliceProgessPanel(self, self, self.filename)
|
||||
self.sizer.Add(spp, (len(self.progressPanelList)+2,0), span=(1,4), flag=wx.EXPAND)
|
||||
@ -257,6 +258,9 @@ class simpleModeWindow(configBase.configWindowBase):
|
||||
newSize.IncBy(0, spp.GetSize().GetHeight())
|
||||
self.SetSize(newSize)
|
||||
self.progressPanelList.append(spp)
|
||||
|
||||
#Restore the old profile.
|
||||
profile.loadGlobalProfileFromString(oldProfile)
|
||||
|
||||
def OnPrint(self, e):
|
||||
printWindow.printWindow()
|
||||
@ -286,5 +290,4 @@ class simpleModeWindow(configBase.configWindowBase):
|
||||
self.Close()
|
||||
|
||||
def OnClose(self, e):
|
||||
profile.saveGlobalProfile(profile.getDefaultProfilePath())
|
||||
self.Destroy()
|
||||
|
@ -57,7 +57,8 @@ class sliceProgessPanel(wx.Panel):
|
||||
self.prevStep = 'start'
|
||||
self.totalDoneFactor = 0.0
|
||||
self.startTime = time.time()
|
||||
self.thread = WorkerThread(self, filename)
|
||||
p = subprocess.Popen(sliceRun.getSliceCommand(self.filename), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
self.thread = WorkerThread(self, filename, p)
|
||||
|
||||
def OnAbort(self, e):
|
||||
if self.abort:
|
||||
@ -108,14 +109,15 @@ class sliceProgessPanel(wx.Panel):
|
||||
self.statusText.SetLabel(stepName + " [" + str(layer) + "/" + str(maxLayer) + "]")
|
||||
|
||||
class WorkerThread(threading.Thread):
|
||||
def __init__(self, notifyWindow, filename):
|
||||
def __init__(self, notifyWindow, filename, process):
|
||||
threading.Thread.__init__(self)
|
||||
self.filename = filename
|
||||
self.notifyWindow = notifyWindow
|
||||
self.process = process
|
||||
self.start()
|
||||
|
||||
def run(self):
|
||||
p = subprocess.Popen(sliceRun.getSliceCommand(self.filename), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
p = self.process
|
||||
line = p.stdout.readline()
|
||||
maxValue = 1
|
||||
self.progressLog = []
|
||||
|
@ -85,10 +85,23 @@ def saveGlobalProfile(filename):
|
||||
#Save the current profile to an ini file
|
||||
globalProfileParser.write(open(filename, 'w'))
|
||||
|
||||
def resetGlobalProfile():
|
||||
#Create an empty profile with no settings, so everything gets default settings.
|
||||
def loadGlobalProfileFromString(options):
|
||||
global globalProfileParser
|
||||
globalProfileParser = ConfigParser.ConfigParser()
|
||||
globalProfileParser.add_section('profile')
|
||||
for option in options.split('#'):
|
||||
(key, value) = option.split('=', 1)
|
||||
globalProfileParser.set('profile', key, value)
|
||||
|
||||
def getGlobalProfileString():
|
||||
global globalProfileParser
|
||||
if not globals().has_key('globalProfileParser'):
|
||||
loadGlobalProfile(getDefaultProfilePath())
|
||||
|
||||
ret = []
|
||||
for key in globalProfileParser.options('profile'):
|
||||
ret.append(key + "=" + globalProfileParser.get('profile', key))
|
||||
return '#'.join(ret)
|
||||
|
||||
def getProfileSetting(name):
|
||||
if name in profileDefaultSettings:
|
||||
|
@ -58,7 +58,7 @@ def runSlice(fileNames):
|
||||
print "* Failed to find pypy, so sliced with python! *"
|
||||
print "************************************************"
|
||||
else:
|
||||
subprocess.call([pypyExe, os.path.join(sys.path[0], sys.argv[0]), fileName])
|
||||
subprocess.call([pypyExe, os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", os.path.split(sys.argv[0])[1])), '-p', profile.getGlobalProfileString(), fileName])
|
||||
|
||||
def getSliceCommand(filename):
|
||||
if profile.getPreference('slicer').startswith('Slic3r'):
|
||||
@ -116,5 +116,5 @@ def getSliceCommand(filename):
|
||||
pypyExe = getPyPyExe()
|
||||
if pypyExe == False:
|
||||
pypyExe = sys.executable
|
||||
return [pypyExe, os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", os.path.split(sys.argv[0])[1])), filename]
|
||||
return [pypyExe, os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", os.path.split(sys.argv[0])[1])), '-p', profile.getGlobalProfileString(), filename]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user