def onCopyProfileClipboard(self, e): try: if not wx.TheClipboard.IsOpened(): wx.TheClipboard.Open() clipData = wx.TextDataObject() self.lastTriedClipboard = profile.getProfileString() profileString = profile.insertNewlines("CURA_PROFILE_STRING:" + self.lastTriedClipboard) clipData.SetText(profileString) wx.TheClipboard.SetData(clipData) wx.TheClipboard.Close() except: print "Could not write to clipboard, unable to get ownership. Another program is using the clipboard."
def __init__(self): self._engineLog = [] self._gcodeData = StringIO.StringIO() self._polygons = [] self._replaceInfo = {} self._success = False self._printTimeSeconds = None self._filamentMM = [0.0] * 4 self._modelHash = None self._profileString = profile.getProfileString() self._preferencesString = profile.getPreferencesString() self._gcodeInterpreter = gcodeInterpreter.gcode() self._gcodeLoadThread = None self._finished = False
def _load_profile_from_data(self, gcodeFile): for line in gcodeFile: if type(line) is tuple: line = line[0] if ';' in line: comment = line[line.find(';')+1:].strip() if comment.startswith('CURA_PROFILE_STRING:'): original_profile = profile.getProfileString() profile_string=comment[len('CURA_PROFILE_STRING:'):] profile.setProfileFromString(profile_string) self._load_profile_settings() profile.setProfileFromString(original_profile) break
def _load_profile_from_data(self, gcodeFile): for line in gcodeFile: if type(line) is tuple: line = line[0] if ';' in line: comment = line[line.find(';') + 1:].strip() if comment.startswith('CURA_PROFILE_STRING:'): original_profile = profile.getProfileString() profile_string = comment[len('CURA_PROFILE_STRING:'):] profile.setProfileFromString(profile_string) self._load_profile_settings() profile.setProfileFromString(original_profile) break
def submitSliceInfoOnline(self): if profile.getPreference('submit_slice_information') != 'True': return if version.isDevVersion(): return data = { 'processor': platform.processor(), 'machine': platform.machine(), 'platform': platform.platform(), 'profile': profile.getProfileString(), 'preferences': profile.getPreferencesString(), 'modelhash': self._modelHash, 'version': version.getVersion(), } try: f = urllib2.urlopen("http://www.youmagine.com/curastats/", data = urllib.urlencode(data), timeout = 1) f.read() f.close() except: pass
def submitSliceInfoOnline(self): if profile.getPreference("submit_slice_information") != "True": return if version.isDevVersion(): return data = { "processor": platform.processor(), "machine": platform.machine(), "platform": platform.platform(), "profile": profile.getProfileString(), "preferences": profile.getPreferencesString(), "modelhash": self._modelHash, "version": version.getVersion(), } try: f = urllib2.urlopen("http://www.youmagine.com/curastats/", data=urllib.urlencode(data), timeout=1) f.read() f.close() except: pass
def submitSliceInfoOnline(self): if profile.getPreference('submit_slice_information') != 'True': return # if version.isDevVersion(): # return data = { 'processor': platform.processor(), 'machine': platform.machine(), 'platform': platform.platform(), 'profile': profile.getProfileString(), 'preferences': profile.getPreferencesString(), 'modelhash': self._modelHash, 'version': version.getVersion(), } try: f = urllib2.urlopen("http://www.youmagine.com/curastats/", data=urllib.urlencode(data), timeout=1) f.read() f.close() except: pass
def __init__(self): super(mainWindow, self).__init__(None, title='Cura - ' + version.getVersion()) wx.EVT_CLOSE(self, self.OnClose) # allow dropping any file, restrict later self.SetDropTarget(dropTarget.FileDropTarget(self.OnDropFiles)) # TODO: wxWidgets 2.9.4 has a bug when NSView does not register for dragged types when wx drop target is set. It was fixed in 2.9.5 if sys.platform.startswith('darwin'): try: import objc nswindow = objc.objc_object( c_void_p=self.MacGetTopLevelWindowRef()) view = nswindow.contentView() view.registerForDraggedTypes_([u'NSFilenamesPboardType']) except: pass self.normalModeOnlyItems = [] mruFile = os.path.join(profile.getBasePath(), 'mru_filelist.ini') self.config = wx.FileConfig(appName="Cura", localFilename=mruFile, style=wx.CONFIG_USE_LOCAL_FILE) self.ID_MRU_MODEL1, self.ID_MRU_MODEL2, self.ID_MRU_MODEL3, self.ID_MRU_MODEL4, self.ID_MRU_MODEL5, self.ID_MRU_MODEL6, self.ID_MRU_MODEL7, self.ID_MRU_MODEL8, self.ID_MRU_MODEL9, self.ID_MRU_MODEL10 = [ wx.NewId() for line in xrange(10) ] self.modelFileHistory = wx.FileHistory(10, self.ID_MRU_MODEL1) self.config.SetPath("/ModelMRU") self.modelFileHistory.Load(self.config) self.ID_MRU_PROFILE1, self.ID_MRU_PROFILE2, self.ID_MRU_PROFILE3, self.ID_MRU_PROFILE4, self.ID_MRU_PROFILE5, self.ID_MRU_PROFILE6, self.ID_MRU_PROFILE7, self.ID_MRU_PROFILE8, self.ID_MRU_PROFILE9, self.ID_MRU_PROFILE10 = [ wx.NewId() for line in xrange(10) ] self.profileFileHistory = wx.FileHistory(10, self.ID_MRU_PROFILE1) self.config.SetPath("/ProfileMRU") self.profileFileHistory.Load(self.config) self.menubar = wx.MenuBar() self.fileMenu = wx.Menu() i = self.fileMenu.Append(-1, _("Load model file...\tCTRL+L")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showLoadModel(), i) i = self.fileMenu.Append(-1, _("Save model...\tCTRL+S")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveModel(), i) i = self.fileMenu.Append(-1, _("Reload platform\tF5")) self.Bind(wx.EVT_MENU, lambda e: self.scene.reloadScene(e), i) i = self.fileMenu.Append(-1, _("Clear platform")) self.Bind(wx.EVT_MENU, lambda e: self.scene.OnDeleteAll(e), i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _("Print...\tCTRL+P")) self.Bind(wx.EVT_MENU, lambda e: self.scene.OnPrintButton(1), i) i = self.fileMenu.Append(-1, _("Save GCode...")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveGCode(), i) i = self.fileMenu.Append(-1, _("Show slice engine log...")) self.Bind(wx.EVT_MENU, lambda e: self.scene._showEngineLog(), i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _("Open Profile...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnLoadProfile, i) i = self.fileMenu.Append(-1, _("Save Profile...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnSaveProfile, i) i = self.fileMenu.Append(-1, _("Load Profile from GCode...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnLoadProfileFromGcode, i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _("Reset Profile to default")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnResetProfile, i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _("Preferences...\tCTRL+,")) self.Bind(wx.EVT_MENU, self.OnPreferences, i) i = self.fileMenu.Append(-1, _("Machine settings...")) self.Bind(wx.EVT_MENU, self.OnMachineSettings, i) self.fileMenu.AppendSeparator() # Model MRU list modelHistoryMenu = wx.Menu() self.fileMenu.AppendMenu(wx.NewId(), '&' + _("Recent Model Files"), modelHistoryMenu) self.modelFileHistory.UseMenu(modelHistoryMenu) self.modelFileHistory.AddFilesToMenu() self.Bind(wx.EVT_MENU_RANGE, self.OnModelMRU, id=self.ID_MRU_MODEL1, id2=self.ID_MRU_MODEL10) # Profle MRU list profileHistoryMenu = wx.Menu() self.fileMenu.AppendMenu(wx.NewId(), _("Recent Profile Files"), profileHistoryMenu) self.profileFileHistory.UseMenu(profileHistoryMenu) self.profileFileHistory.AddFilesToMenu() self.Bind(wx.EVT_MENU_RANGE, self.OnProfileMRU, id=self.ID_MRU_PROFILE1, id2=self.ID_MRU_PROFILE10) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(wx.ID_EXIT, _("Quit")) self.Bind(wx.EVT_MENU, self.OnQuit, i) self.menubar.Append(self.fileMenu, '&' + _("File")) toolsMenu = wx.Menu() #i = toolsMenu.Append(-1, 'Batch run...') #self.Bind(wx.EVT_MENU, self.OnBatchRun, i) #self.normalModeOnlyItems.append(i) if minecraftImport.hasMinecraft(): i = toolsMenu.Append(-1, _("Minecraft map import...")) self.Bind(wx.EVT_MENU, self.OnMinecraftImport, i) if version.isDevVersion(): i = toolsMenu.Append(-1, _("PID Debugger...")) self.Bind(wx.EVT_MENU, self.OnPIDDebugger, i) i = toolsMenu.Append(-1, _("Copy profile to clipboard")) self.Bind(wx.EVT_MENU, self.onCopyProfileClipboard, i) toolsMenu.AppendSeparator() self.allAtOnceItem = toolsMenu.Append(-1, _("Print all at once"), kind=wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.onOneAtATimeSwitch, self.allAtOnceItem) self.oneAtATime = toolsMenu.Append(-1, _("Print one at a time"), kind=wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.onOneAtATimeSwitch, self.oneAtATime) if profile.getPreference('oneAtATime') == 'True': self.oneAtATime.Check(True) else: self.allAtOnceItem.Check(True) self.menubar.Append(toolsMenu, _("Tools")) #Machine menu for machine configuration/tooling self.machineMenu = wx.Menu() self.updateMachineMenu() self.menubar.Append(self.machineMenu, _("Machine")) expertMenu = wx.Menu() i = expertMenu.Append(-1, _("Switch to quickprint..."), kind=wx.ITEM_RADIO) self.switchToQuickprintMenuItem = i self.Bind(wx.EVT_MENU, self.OnSimpleSwitch, i) i = expertMenu.Append(-1, _("Switch to full settings..."), kind=wx.ITEM_RADIO) self.switchToNormalMenuItem = i self.Bind(wx.EVT_MENU, self.OnNormalSwitch, i) expertMenu.AppendSeparator() i = expertMenu.Append(-1, _("Open expert settings...\tCTRL+E")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnExpertOpen, i) expertMenu.AppendSeparator() i = expertMenu.Append(-1, _("Run first run wizard...")) self.Bind(wx.EVT_MENU, self.OnFirstRunWizard, i) self.bedLevelWizardMenuItem = expertMenu.Append( -1, _("Run bed leveling wizard...")) self.Bind(wx.EVT_MENU, self.OnBedLevelWizard, self.bedLevelWizardMenuItem) self.headOffsetWizardMenuItem = expertMenu.Append( -1, _("Run head offset wizard...")) self.Bind(wx.EVT_MENU, self.OnHeadOffsetWizard, self.headOffsetWizardMenuItem) self.menubar.Append(expertMenu, _("Expert")) helpMenu = wx.Menu() i = helpMenu.Append(-1, _("Online documentation...")) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('http://daid.github.com/Cura'), i) i = helpMenu.Append(-1, _("Report a problem...")) self.Bind( wx.EVT_MENU, lambda e: webbrowser.open('https://github.com/daid/Cura/issues'), i) i = helpMenu.Append(-1, _("Check for update...")) self.Bind(wx.EVT_MENU, self.OnCheckForUpdate, i) if profile.getPreference('use_youmagine') == 'True': i = helpMenu.Append(-1, _("Open YouMagine website...")) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://www.youmagine.com/'), i) i = helpMenu.Append(-1, _("About Cura...")) self.Bind(wx.EVT_MENU, self.OnAbout, i) self.menubar.Append(helpMenu, _("Help")) self.SetMenuBar(self.menubar) self.splitter = wx.SplitterWindow(self, style=wx.SP_3D | wx.SP_LIVE_UPDATE) self.leftPane = wx.Panel(self.splitter, style=wx.BORDER_NONE) self.rightPane = wx.Panel(self.splitter, style=wx.BORDER_NONE) self.splitter.Bind(wx.EVT_SPLITTER_DCLICK, lambda evt: evt.Veto()) ##Gui components## self.simpleSettingsPanel = simpleMode.simpleModePanel( self.leftPane, lambda: self.scene.sceneUpdated()) self.normalSettingsPanel = normalSettingsPanel( self.leftPane, lambda: self.scene.sceneUpdated()) self.leftSizer = wx.BoxSizer(wx.VERTICAL) self.leftSizer.Add(self.simpleSettingsPanel, 1) self.leftSizer.Add(self.normalSettingsPanel, 1, wx.EXPAND) self.leftPane.SetSizer(self.leftSizer) #Preview window self.scene = sceneView.SceneView(self.rightPane) #Main sizer, to position the preview window, buttons and tab control sizer = wx.BoxSizer() self.rightPane.SetSizer(sizer) sizer.Add(self.scene, 1, flag=wx.EXPAND) # Main window sizer sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(sizer) sizer.Add(self.splitter, 1, wx.EXPAND) sizer.Layout() self.sizer = sizer self.updateProfileToAllControls() self.SetBackgroundColour( self.normalSettingsPanel.GetBackgroundColour()) self.simpleSettingsPanel.Show(False) self.normalSettingsPanel.Show(False) # Set default window size & position self.SetSize((wx.Display().GetClientArea().GetWidth() / 2, wx.Display().GetClientArea().GetHeight() / 2)) self.Centre() #Timer set; used to check if profile is on the clipboard self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.onTimer) self.timer.Start(1000) self.lastTriedClipboard = profile.getProfileString() # Restore the window position, size & state from the preferences file try: if profile.getPreference('window_maximized') == 'True': self.Maximize(True) else: posx = int(profile.getPreference('window_pos_x')) posy = int(profile.getPreference('window_pos_y')) width = int(profile.getPreference('window_width')) height = int(profile.getPreference('window_height')) if posx > 0 or posy > 0: self.SetPosition((posx, posy)) if width > 0 and height > 0: self.SetSize((width, height)) self.normalSashPos = int( profile.getPreference('window_normal_sash')) except: self.normalSashPos = 0 self.Maximize(True) if self.normalSashPos < self.normalSettingsPanel.printPanel.GetBestSize( )[0] + 5: self.normalSashPos = self.normalSettingsPanel.printPanel.GetBestSize( )[0] + 5 self.splitter.SplitVertically(self.leftPane, self.rightPane, self.normalSashPos) if wx.Display.GetFromPoint(self.GetPosition()) < 0: self.Centre() if wx.Display.GetFromPoint( (self.GetPositionTuple()[0] + self.GetSizeTuple()[1], self.GetPositionTuple()[1] + self.GetSizeTuple()[1])) < 0: self.Centre() if wx.Display.GetFromPoint(self.GetPosition()) < 0: self.SetSize((800, 600)) self.Centre() self.updateSliceMode() self.scene.SetFocus()
def __init__(self): super(mainWindow, self).__init__(None, title='SawersPrinter3D - ' + version.getVersion()) wx.EVT_CLOSE(self, self.OnClose) # allow dropping any file, restrict later self.SetDropTarget(dropTarget.FileDropTarget(self.OnDropFiles)) self.normalModeOnlyItems = [] mruFile = os.path.join(profile.getBasePath(), 'mru_filelist.ini') self.config = wx.FileConfig(appName="Cura", localFilename=mruFile, style=wx.CONFIG_USE_LOCAL_FILE) self.ID_MRU_MODEL1, self.ID_MRU_MODEL2, self.ID_MRU_MODEL3, self.ID_MRU_MODEL4, self.ID_MRU_MODEL5, self.ID_MRU_MODEL6, self.ID_MRU_MODEL7, self.ID_MRU_MODEL8, self.ID_MRU_MODEL9, self.ID_MRU_MODEL10 = [wx.NewId() for line in xrange(10)] self.modelFileHistory = wx.FileHistory(10, self.ID_MRU_MODEL1) self.config.SetPath("/ModelMRU") self.modelFileHistory.Load(self.config) self.ID_MRU_PROFILE1, self.ID_MRU_PROFILE2, self.ID_MRU_PROFILE3, self.ID_MRU_PROFILE4, self.ID_MRU_PROFILE5, self.ID_MRU_PROFILE6, self.ID_MRU_PROFILE7, self.ID_MRU_PROFILE8, self.ID_MRU_PROFILE9, self.ID_MRU_PROFILE10 = [wx.NewId() for line in xrange(10)] self.profileFileHistory = wx.FileHistory(10, self.ID_MRU_PROFILE1) self.config.SetPath("/ProfileMRU") self.profileFileHistory.Load(self.config) self.menubar = wx.MenuBar() self.fileMenu = wx.Menu() i = self.fileMenu.Append(-1, _("Load model file...\tCTRL+L")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showLoadModel(), i) i = self.fileMenu.Append(-1, _("Save model...\tCTRL+S")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveModel(), i) i = self.fileMenu.Append(-1, _("Clear platform")) self.Bind(wx.EVT_MENU, lambda e: self.scene.OnDeleteAll(e), i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _("Print...\tCTRL+P")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showPrintWindow(), i) i = self.fileMenu.Append(-1, _("Save GCode...")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveGCode(), i) i = self.fileMenu.Append(-1, _("Show slice engine log...")) self.Bind(wx.EVT_MENU, lambda e: self.scene._showSliceLog(), i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _("Open Profile...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnLoadProfile, i) i = self.fileMenu.Append(-1, _("Save Profile...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnSaveProfile, i) i = self.fileMenu.Append(-1, _("Load Profile from GCode...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnLoadProfileFromGcode, i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _("Reset Profile to default")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnResetProfile, i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _("Preferences...\tCTRL+,")) self.Bind(wx.EVT_MENU, self.OnPreferences, i) i = self.fileMenu.Append(-1, _("Machine settings...")) self.Bind(wx.EVT_MENU, self.OnMachineSettings, i) self.fileMenu.AppendSeparator() # Model MRU list modelHistoryMenu = wx.Menu() self.fileMenu.AppendMenu(wx.NewId(), '&' + _("Recent Model Files"), modelHistoryMenu) self.modelFileHistory.UseMenu(modelHistoryMenu) self.modelFileHistory.AddFilesToMenu() self.Bind(wx.EVT_MENU_RANGE, self.OnModelMRU, id=self.ID_MRU_MODEL1, id2=self.ID_MRU_MODEL10) # Profle MRU list profileHistoryMenu = wx.Menu() self.fileMenu.AppendMenu(wx.NewId(), _("Recent Profile Files"), profileHistoryMenu) self.profileFileHistory.UseMenu(profileHistoryMenu) self.profileFileHistory.AddFilesToMenu() self.Bind(wx.EVT_MENU_RANGE, self.OnProfileMRU, id=self.ID_MRU_PROFILE1, id2=self.ID_MRU_PROFILE10) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(wx.ID_EXIT, _("Quit")) self.Bind(wx.EVT_MENU, self.OnQuit, i) self.menubar.Append(self.fileMenu, '&' + _("File")) toolsMenu = wx.Menu() #i = toolsMenu.Append(-1, 'Batch run...') #self.Bind(wx.EVT_MENU, self.OnBatchRun, i) #self.normalModeOnlyItems.append(i) if minecraftImport.hasMinecraft(): i = toolsMenu.Append(-1, _("Minecraft map import...")) self.Bind(wx.EVT_MENU, self.OnMinecraftImport, i) if version.isDevVersion(): i = toolsMenu.Append(-1, _("PID Debugger...")) self.Bind(wx.EVT_MENU, self.OnPIDDebugger, i) i = toolsMenu.Append(-1, _("Copy profile to clipboard")) self.Bind(wx.EVT_MENU, self.onCopyProfileClipboard,i) self.menubar.Append(toolsMenu, _("Tools")) #Machine menu for machine configuration/tooling self.machineMenu = wx.Menu() self.updateMachineMenu() self.menubar.Append(self.machineMenu, _("Machine")) expertMenu = wx.Menu() i = expertMenu.Append(-1, _("Switch to quickprint..."), kind=wx.ITEM_RADIO) self.switchToQuickprintMenuItem = i self.Bind(wx.EVT_MENU, self.OnSimpleSwitch, i) i = expertMenu.Append(-1, _("Switch to full settings..."), kind=wx.ITEM_RADIO) self.switchToNormalMenuItem = i self.Bind(wx.EVT_MENU, self.OnNormalSwitch, i) expertMenu.AppendSeparator() i = expertMenu.Append(-1, _("Open expert settings...\tCTRL+E")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnExpertOpen, i) expertMenu.AppendSeparator() i = expertMenu.Append(-1, _("Run first run wizard...")) self.Bind(wx.EVT_MENU, self.OnFirstRunWizard, i) self.bedLevelWizardMenuItem = expertMenu.Append(-1, _("Run bed leveling wizard...")) self.Bind(wx.EVT_MENU, self.OnBedLevelWizard, self.bedLevelWizardMenuItem) self.headOffsetWizardMenuItem = expertMenu.Append(-1, _("Run head offset wizard...")) self.Bind(wx.EVT_MENU, self.OnHeadOffsetWizard, self.headOffsetWizardMenuItem) self.menubar.Append(expertMenu, _("Expert")) helpMenu = wx.Menu() i = helpMenu.Append(-1, _("Online documentation...")) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('http://daid.github.com/Cura'), i) i = helpMenu.Append(-1, _("Report a problem...")) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://github.com/daid/Cura/issues'), i) i = helpMenu.Append(-1, _("Check for update...")) self.Bind(wx.EVT_MENU, self.OnCheckForUpdate, i) i = helpMenu.Append(-1, _("Open YouMagine website...")) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://www.youmagine.com/'), i) i = helpMenu.Append(-1, _("About Cura...")) self.Bind(wx.EVT_MENU, self.OnAbout, i) self.menubar.Append(helpMenu, _("Help")) self.SetMenuBar(self.menubar) self.splitter = wx.SplitterWindow(self, style = wx.SP_3D | wx.SP_LIVE_UPDATE) self.leftPane = wx.Panel(self.splitter, style=wx.BORDER_NONE) self.rightPane = wx.Panel(self.splitter, style=wx.BORDER_NONE) self.splitter.Bind(wx.EVT_SPLITTER_DCLICK, lambda evt: evt.Veto()) ##Gui components## self.simpleSettingsPanel = simpleMode.simpleModePanel(self.leftPane, lambda : self.scene.sceneUpdated()) self.normalSettingsPanel = normalSettingsPanel(self.leftPane, lambda : self.scene.sceneUpdated()) self.leftSizer = wx.BoxSizer(wx.VERTICAL) self.leftSizer.Add(self.simpleSettingsPanel, 1) self.leftSizer.Add(self.normalSettingsPanel, 1, wx.EXPAND) self.leftPane.SetSizer(self.leftSizer) #Preview window self.scene = sceneView.SceneView(self.rightPane) #Main sizer, to position the preview window, buttons and tab control sizer = wx.BoxSizer() self.rightPane.SetSizer(sizer) sizer.Add(self.scene, 1, flag=wx.EXPAND) # Main window sizer sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(sizer) sizer.Add(self.splitter, 1, wx.EXPAND) sizer.Layout() self.sizer = sizer self.updateProfileToAllControls() self.SetBackgroundColour(self.normalSettingsPanel.GetBackgroundColour()) self.simpleSettingsPanel.Show(False) self.normalSettingsPanel.Show(False) # Set default window size & position self.SetSize((wx.Display().GetClientArea().GetWidth()/2,wx.Display().GetClientArea().GetHeight()/2)) self.Centre() #Timer set; used to check if profile is on the clipboard self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.onTimer) self.timer.Start(1000) self.lastTriedClipboard = profile.getProfileString() # Restore the window position, size & state from the preferences file try: if profile.getPreference('window_maximized') == 'True': self.Maximize(True) else: posx = int(profile.getPreference('window_pos_x')) posy = int(profile.getPreference('window_pos_y')) width = int(profile.getPreference('window_width')) height = int(profile.getPreference('window_height')) if posx > 0 or posy > 0: self.SetPosition((posx,posy)) if width > 0 and height > 0: self.SetSize((width,height)) self.normalSashPos = int(profile.getPreference('window_normal_sash')) except: self.normalSashPos = 0 self.Maximize(True) if self.normalSashPos < self.normalSettingsPanel.printPanel.GetBestSize()[0] + 5: self.normalSashPos = self.normalSettingsPanel.printPanel.GetBestSize()[0] + 5 self.splitter.SplitVertically(self.leftPane, self.rightPane, self.normalSashPos) if wx.Display.GetFromPoint(self.GetPosition()) < 0: self.Centre() if wx.Display.GetFromPoint((self.GetPositionTuple()[0] + self.GetSizeTuple()[1], self.GetPositionTuple()[1] + self.GetSizeTuple()[1])) < 0: self.Centre() if wx.Display.GetFromPoint(self.GetPosition()) < 0: self.SetSize((800,600)) self.Centre() self.updateSliceMode()
def __init__(self): super(mainWindow, self).__init__(None, title='Cura - ' + version.getVersion()) wx.EVT_CLOSE(self, self.OnClose) # allow dropping any file, restrict later self.SetDropTarget(dropTarget.FileDropTarget(self.OnDropFiles)) # TODO: wxWidgets 2.9.4 has a bug when NSView does not register for dragged types when wx drop target is set. It was fixed in 2.9.5 if sys.platform.startswith('darwin'): try: import objc nswindow = objc.objc_object(c_void_p=self.MacGetTopLevelWindowRef()) view = nswindow.contentView() view.registerForDraggedTypes_([u'NSFilenamesPboardType']) except: pass self.normalModeOnlyItems = [] mruFile = os.path.join(profile.getBasePath(), 'mru_filelist.ini') self.config = wx.FileConfig(appName="Cura", localFilename=mruFile, style=wx.CONFIG_USE_LOCAL_FILE) self.ID_MRU_MODEL1, self.ID_MRU_MODEL2, self.ID_MRU_MODEL3, self.ID_MRU_MODEL4, self.ID_MRU_MODEL5, self.ID_MRU_MODEL6, self.ID_MRU_MODEL7, self.ID_MRU_MODEL8, self.ID_MRU_MODEL9, self.ID_MRU_MODEL10 = [wx.NewId() for line in xrange(10)] self.modelFileHistory = wx.FileHistory(10, self.ID_MRU_MODEL1) self.config.SetPath("/ModelMRU") self.modelFileHistory.Load(self.config) self.ID_MRU_PROFILE1, self.ID_MRU_PROFILE2, self.ID_MRU_PROFILE3, self.ID_MRU_PROFILE4, self.ID_MRU_PROFILE5, self.ID_MRU_PROFILE6, self.ID_MRU_PROFILE7, self.ID_MRU_PROFILE8, self.ID_MRU_PROFILE9, self.ID_MRU_PROFILE10 = [wx.NewId() for line in xrange(10)] self.profileFileHistory = wx.FileHistory(10, self.ID_MRU_PROFILE1) self.config.SetPath("/ProfileMRU") self.profileFileHistory.Load(self.config) self.menubar = wx.MenuBar() self.fileMenu = wx.Menu() i = self.fileMenu.Append(-1, _("Load model file...\tCTRL+L")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showLoadModel(), i) i = self.fileMenu.Append(-1, _("Save model...\tCTRL+S")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveModel(), i) i = self.fileMenu.Append(-1, _("Reload platform\tF5")) self.Bind(wx.EVT_MENU, lambda e: self.scene.reloadScene(e), i) i = self.fileMenu.Append(-1, _("Clear platform")) self.Bind(wx.EVT_MENU, lambda e: self.scene.OnDeleteAll(e), i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _("Print...\tCTRL+P")) self.Bind(wx.EVT_MENU, lambda e: self.scene.OnPrintButton(1), i) i = self.fileMenu.Append(-1, _("Save GCode...")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveGCode(), i) i = self.fileMenu.Append(-1, _("Show slice engine log...")) self.Bind(wx.EVT_MENU, lambda e: self.scene._showEngineLog(), i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _("Open Profile...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnLoadProfile, i) i = self.fileMenu.Append(-1, _("Save Profile...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnSaveProfile, i) if version.isDevVersion(): i = self.fileMenu.Append(-1, "Save difference from default...") self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnSaveDifferences, i) i = self.fileMenu.Append(-1, _("Load Profile from GCode...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnLoadProfileFromGcode, i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _("Reset Profile to default")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnResetProfile, i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _("Preferences...\tCTRL+,")) self.Bind(wx.EVT_MENU, self.OnPreferences, i) i = self.fileMenu.Append(-1, _("Machine settings...")) self.Bind(wx.EVT_MENU, self.OnMachineSettings, i) self.fileMenu.AppendSeparator() # Model MRU list modelHistoryMenu = wx.Menu() self.fileMenu.AppendMenu(wx.NewId(), '&' + _("Recent Model Files"), modelHistoryMenu) self.modelFileHistory.UseMenu(modelHistoryMenu) self.modelFileHistory.AddFilesToMenu() self.Bind(wx.EVT_MENU_RANGE, self.OnModelMRU, id=self.ID_MRU_MODEL1, id2=self.ID_MRU_MODEL10) # Profle MRU list profileHistoryMenu = wx.Menu() self.fileMenu.AppendMenu(wx.NewId(), _("Recent Profile Files"), profileHistoryMenu) self.profileFileHistory.UseMenu(profileHistoryMenu) self.profileFileHistory.AddFilesToMenu() self.Bind(wx.EVT_MENU_RANGE, self.OnProfileMRU, id=self.ID_MRU_PROFILE1, id2=self.ID_MRU_PROFILE10) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(wx.ID_EXIT, _("Quit")) self.Bind(wx.EVT_MENU, self.OnQuit, i) self.menubar.Append(self.fileMenu, '&' + _("File")) toolsMenu = wx.Menu() #i = toolsMenu.Append(-1, 'Batch run...') #self.Bind(wx.EVT_MENU, self.OnBatchRun, i) #self.normalModeOnlyItems.append(i) if minecraftImport.hasMinecraft(): i = toolsMenu.Append(-1, _("Minecraft map import...")) self.Bind(wx.EVT_MENU, self.OnMinecraftImport, i) if version.isDevVersion(): i = toolsMenu.Append(-1, _("PID Debugger...")) self.Bind(wx.EVT_MENU, self.OnPIDDebugger, i) i = toolsMenu.Append(-1, _("Auto Firmware Update...")) self.Bind(wx.EVT_MENU, self.OnAutoFirmwareUpdate, i) #i = toolsMenu.Append(-1, _("Copy profile to clipboard")) #self.Bind(wx.EVT_MENU, self.onCopyProfileClipboard,i) toolsMenu.AppendSeparator() self.allAtOnceItem = toolsMenu.Append(-1, _("Print all at once"), kind=wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.onOneAtATimeSwitch, self.allAtOnceItem) self.oneAtATime = toolsMenu.Append(-1, _("Print one at a time"), kind=wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.onOneAtATimeSwitch, self.oneAtATime) if profile.getPreference('oneAtATime') == 'True': self.oneAtATime.Check(True) else: self.allAtOnceItem.Check(True) self.menubar.Append(toolsMenu, _("Tools")) #Machine menu for machine configuration/tooling self.machineMenu = wx.Menu() self.updateMachineMenu() self.menubar.Append(self.machineMenu, _("Machine")) expertMenu = wx.Menu() i = expertMenu.Append(-1, _("Switch to quickprint..."), kind=wx.ITEM_RADIO) self.switchToQuickprintMenuItem = i self.Bind(wx.EVT_MENU, self.OnSimpleSwitch, i) i = expertMenu.Append(-1, _("Switch to full settings..."), kind=wx.ITEM_RADIO) self.switchToNormalMenuItem = i self.Bind(wx.EVT_MENU, self.OnNormalSwitch, i) expertMenu.AppendSeparator() i = expertMenu.Append(-1, _("Open expert settings...\tCTRL+E")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnExpertOpen, i) # expertMenu.AppendSeparator() # self.bedLevelWizardMenuItem = expertMenu.Append(-1, _("Run bed leveling wizard...")) # self.Bind(wx.EVT_MENU, self.OnBedLevelWizard, self.bedLevelWizardMenuItem) # self.headOffsetWizardMenuItem = expertMenu.Append(-1, _("Run head offset wizard...")) # self.Bind(wx.EVT_MENU, self.OnHeadOffsetWizard, self.headOffsetWizardMenuItem) self.menubar.Append(expertMenu, _("Expert")) helpMenu = wx.Menu() i = helpMenu.Append(-1, _("Online documentation...")) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('http://creatablelabs.com/support'), i) i = helpMenu.Append(-1, _("Report a problem...")) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://github.com/AteamVentures/Creatable_D2/issues'), i) # i = helpMenu.Append(-1, _("Check for update...")) # self.Bind(wx.EVT_MENU, self.OnCheckForUpdate, i) # i = helpMenu.Append(-1, _("Open YouMagine website...")) # self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://www.youmagine.com/'), i) i = helpMenu.Append(-1, _("About Cura...")) self.Bind(wx.EVT_MENU, self.OnAbout, i) self.menubar.Append(helpMenu, _("Help")) self.SetMenuBar(self.menubar) self.splitter = wx.SplitterWindow(self, style = wx.SP_3D | wx.SP_LIVE_UPDATE) self.leftPane = wx.Panel(self.splitter, style=wx.BORDER_NONE) self.rightPane = wx.Panel(self.splitter, style=wx.BORDER_NONE) self.splitter.Bind(wx.EVT_SPLITTER_DCLICK, lambda evt: evt.Veto()) #Preview window self.scene = sceneView.SceneView(self.rightPane) ##Gui components## self.simpleSettingsPanel = simpleMode.simpleModePanel(self.leftPane, self.scene.sceneUpdated) self.normalSettingsPanel = normalSettingsPanel(self.leftPane, self.scene.sceneUpdated) self.leftSizer = wx.BoxSizer(wx.VERTICAL) self.leftSizer.Add(self.simpleSettingsPanel, 1) self.leftSizer.Add(self.normalSettingsPanel, 1, wx.EXPAND) self.leftPane.SetSizer(self.leftSizer) #Main sizer, to position the preview window, buttons and tab control sizer = wx.BoxSizer() self.rightPane.SetSizer(sizer) sizer.Add(self.scene, 1, flag=wx.EXPAND) # Main window sizer sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(sizer) sizer.Add(self.splitter, 1, wx.EXPAND) sizer.Layout() self.sizer = sizer self.updateProfileToAllControls() self.SetBackgroundColour(self.normalSettingsPanel.GetBackgroundColour()) self.simpleSettingsPanel.Show(False) self.normalSettingsPanel.Show(False) # Set default window size & position self.SetSize((wx.Display().GetClientArea().GetWidth()/2,wx.Display().GetClientArea().GetHeight()/2)) self.Centre() #Timer set; used to check if profile is on the clipboard self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.onTimer) #self.timer.Start(1000) self.lastTriedClipboard = profile.getProfileString() # Restore the window position, size & state from the preferences file try: if profile.getPreference('window_maximized') == 'True': self.Maximize(True) else: posx = int(profile.getPreference('window_pos_x')) posy = int(profile.getPreference('window_pos_y')) width = int(profile.getPreference('window_width')) height = int(profile.getPreference('window_height')) if posx > 0 or posy > 0: self.SetPosition((posx,posy)) if width > 0 and height > 0: self.SetSize((width,height)) self.normalSashPos = int(profile.getPreference('window_normal_sash')) except: self.normalSashPos = 0 self.Maximize(True) if self.normalSashPos < self.normalSettingsPanel.printPanel.GetBestSize()[0] + 5: self.normalSashPos = self.normalSettingsPanel.printPanel.GetBestSize()[0] + 5 self.splitter.SplitVertically(self.leftPane, self.rightPane, self.normalSashPos) if wx.Display.GetFromPoint(self.GetPosition()) < 0: self.Centre() if wx.Display.GetFromPoint((self.GetPositionTuple()[0] + self.GetSizeTuple()[1], self.GetPositionTuple()[1] + self.GetSizeTuple()[1])) < 0: self.Centre() if wx.Display.GetFromPoint(self.GetPosition()) < 0: self.SetSize((800,600)) self.Centre() self.updateSliceMode() self.scene.SetFocus() self.dialogframe = None if Publisher is not None: Publisher().subscribe(self.onPluginUpdate, "pluginupdate") pluginCount = self.normalSettingsPanel.pluginPanel.GetActivePluginCount() if pluginCount == 1: self.scene.notification.message("Warning: 1 plugin from the previous session is still active.") if pluginCount > 1: self.scene.notification.message("Warning: %i plugins from the previous session are still active." % pluginCount)
def __init__(self): super(mainWindow, self).__init__(None, title='Cura - ' + version.getVersion()) wx.EVT_CLOSE(self, self.OnClose) # allow dropping any file, restrict later self.SetDropTarget(dropTarget.FileDropTarget(self.OnDropFiles)) # TODO: wxWidgets 2.9.4 has a bug when NSView does not register for dragged types when wx drop target is set. It was fixed in 2.9.5 if sys.platform.startswith('darwin'): try: import objc nswindow = objc.objc_object(c_void_p=self.MacGetTopLevelWindowRef()) view = nswindow.contentView() view.registerForDraggedTypes_([u'NSFilenamesPboardType']) except: pass self.normalModeOnlyItems = [] mruFile = os.path.join(profile.getBasePath(), 'mru_filelist.ini') self.config = wx.FileConfig(appName="Cura", localFilename=mruFile, style=wx.CONFIG_USE_LOCAL_FILE) self.ID_MRU_MODEL1, self.ID_MRU_MODEL2, self.ID_MRU_MODEL3, self.ID_MRU_MODEL4, self.ID_MRU_MODEL5, self.ID_MRU_MODEL6, self.ID_MRU_MODEL7, self.ID_MRU_MODEL8, self.ID_MRU_MODEL9, self.ID_MRU_MODEL10 = [wx.NewId() for line in xrange(10)] self.modelFileHistory = wx.FileHistory(10, self.ID_MRU_MODEL1) self.config.SetPath("/ModelMRU") self.modelFileHistory.Load(self.config) self.ID_MRU_PROFILE1, self.ID_MRU_PROFILE2, self.ID_MRU_PROFILE3, self.ID_MRU_PROFILE4, self.ID_MRU_PROFILE5, self.ID_MRU_PROFILE6, self.ID_MRU_PROFILE7, self.ID_MRU_PROFILE8, self.ID_MRU_PROFILE9, self.ID_MRU_PROFILE10 = [wx.NewId() for line in xrange(10)] self.profileFileHistory = wx.FileHistory(10, self.ID_MRU_PROFILE1) self.config.SetPath("/ProfileMRU") self.profileFileHistory.Load(self.config) self.menubar = wx.MenuBar() self.fileMenu = wx.Menu() i = self.fileMenu.Append(-1, _(u"모델 불러오기...\tCTRL+L")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showLoadModel(), i) i = self.fileMenu.Append(-1, _(u"모델 저장하기...\tCTRL+S")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveModel(), i) i = self.fileMenu.Append(-1, _(u"새로고침\tF5")) self.Bind(wx.EVT_MENU, lambda e: self.scene.reloadScene(e), i) i = self.fileMenu.Append(-1, _(u"모델링 지우기")) self.Bind(wx.EVT_MENU, lambda e: self.scene.OnDeleteAll(e), i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _(u"출력하기...\tCTRL+P")) self.Bind(wx.EVT_MENU, lambda e: self.scene.OnPrintButton(1), i) i = self.fileMenu.Append(-1, _(u"G코드 저장하기...")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveGCode(), i) i = self.fileMenu.Append(-1, _(u"슬라이스 엔진 로그 보기...")) self.Bind(wx.EVT_MENU, lambda e: self.scene._showEngineLog(), i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _(u"설정 불러오기...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnLoadProfile, i) i = self.fileMenu.Append(-1, _(u"설정 저장하기...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnSaveProfile, i) i = self.fileMenu.Append(-1, _(u"G코드의 설정값 불러오기...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnLoadProfileFromGcode, i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _(u"설정값 초기화")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnResetProfile, i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _(u"환경설정...\tCTRL+,")) self.Bind(wx.EVT_MENU, self.OnPreferences, i) i = self.fileMenu.Append(-1, _(u"기기 세팅...")) self.Bind(wx.EVT_MENU, self.OnMachineSettings, i) self.fileMenu.AppendSeparator() # Model MRU list modelHistoryMenu = wx.Menu() self.fileMenu.AppendMenu(wx.NewId(), '&' + _(u"최근 모델파일"), modelHistoryMenu) self.modelFileHistory.UseMenu(modelHistoryMenu) self.modelFileHistory.AddFilesToMenu() self.Bind(wx.EVT_MENU_RANGE, self.OnModelMRU, id=self.ID_MRU_MODEL1, id2=self.ID_MRU_MODEL10) # Profle MRU list profileHistoryMenu = wx.Menu() self.fileMenu.AppendMenu(wx.NewId(), _(u"최근 설정파일"), profileHistoryMenu) self.profileFileHistory.UseMenu(profileHistoryMenu) self.profileFileHistory.AddFilesToMenu() self.Bind(wx.EVT_MENU_RANGE, self.OnProfileMRU, id=self.ID_MRU_PROFILE1, id2=self.ID_MRU_PROFILE10) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(wx.ID_EXIT, _(u"종료")) self.Bind(wx.EVT_MENU, self.OnQuit, i) self.menubar.Append(self.fileMenu, '&' + _(u"파일(File)")) toolsMenu = wx.Menu() #i = toolsMenu.Append(-1, 'Batch run...') #self.Bind(wx.EVT_MENU, self.OnBatchRun, i) #self.normalModeOnlyItems.append(i) if minecraftImport.hasMinecraft(): i = toolsMenu.Append(-1, _("Minecraft map import...")) self.Bind(wx.EVT_MENU, self.OnMinecraftImport, i) if version.isDevVersion(): i = toolsMenu.Append(-1, _("PID Debugger...")) self.Bind(wx.EVT_MENU, self.OnPIDDebugger, i) i = toolsMenu.Append(-1, _(u"클립보드에 설정 복사하기")) self.Bind(wx.EVT_MENU, self.onCopyProfileClipboard,i) toolsMenu.AppendSeparator() self.allAtOnceItem = toolsMenu.Append(-1, _(u"한 번에 모두 출력"), kind=wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.onOneAtATimeSwitch, self.allAtOnceItem) self.oneAtATime = toolsMenu.Append(-1, _(u"차례로 하나씩 출력"), kind=wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.onOneAtATimeSwitch, self.oneAtATime) if profile.getPreference('oneAtATime') == 'True': self.oneAtATime.Check(True) else: self.allAtOnceItem.Check(True) self.menubar.Append(toolsMenu, _(u"도구(Tools)")) #Machine menu for machine configuration/tooling self.machineMenu = wx.Menu() self.updateMachineMenu() self.menubar.Append(self.machineMenu, _(u"기기(Machine)")) expertMenu = wx.Menu() i = expertMenu.Append(-1, _(u"간편 출력모드로 전환..."), kind=wx.ITEM_RADIO) self.switchToQuickprintMenuItem = i self.Bind(wx.EVT_MENU, self.OnSimpleSwitch, i) i = expertMenu.Append(-1, _(u"상세 설정모드로 전환..."), kind=wx.ITEM_RADIO) self.switchToNormalMenuItem = i self.Bind(wx.EVT_MENU, self.OnNormalSwitch, i) expertMenu.AppendSeparator() i = expertMenu.Append(-1, _(u"전문가설정...\tCTRL+E")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnExpertOpen, i) expertMenu.AppendSeparator() i = expertMenu.Append(-1, _(u"초기설정 마법사...")) self.Bind(wx.EVT_MENU, self.OnFirstRunWizard, i) self.bedLevelWizardMenuItem = expertMenu.Append(-1, _(u"베드수평 마법사...")) self.Bind(wx.EVT_MENU, self.OnBedLevelWizard, self.bedLevelWizardMenuItem) self.headOffsetWizardMenuItem = expertMenu.Append(-1, _(u"head offset 마법사...")) self.Bind(wx.EVT_MENU, self.OnHeadOffsetWizard, self.headOffsetWizardMenuItem) self.menubar.Append(expertMenu, _(u"전문가(Expert)")) helpMenu = wx.Menu() i = helpMenu.Append(-1, _(u"온라인 문서...")) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('http://daid.github.com/Cura'), i) i = helpMenu.Append(-1, _(u"오류 보고...")) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://github.com/daid/Cura/issues'), i) i = helpMenu.Append(-1, _(u"업데이트 확인...")) self.Bind(wx.EVT_MENU, self.OnCheckForUpdate, i) i = helpMenu.Append(-1, _(u"YouMagine website 열기...")) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://www.youmagine.com/'), i) i = helpMenu.Append(-1, _(u"소프트웨어 정보...")) self.Bind(wx.EVT_MENU, self.OnAbout, i) self.menubar.Append(helpMenu, _(u"도움말(Help)")) self.SetMenuBar(self.menubar) self.splitter = wx.SplitterWindow(self, style = wx.SP_3D | wx.SP_LIVE_UPDATE) self.leftPane = wx.Panel(self.splitter, style=wx.BORDER_NONE) self.rightPane = wx.Panel(self.splitter, style=wx.BORDER_NONE) self.splitter.Bind(wx.EVT_SPLITTER_DCLICK, lambda evt: evt.Veto()) ##Gui components## self.simpleSettingsPanel = simpleMode.simpleModePanel(self.leftPane, lambda : self.scene.sceneUpdated()) self.normalSettingsPanel = normalSettingsPanel(self.leftPane, lambda : self.scene.sceneUpdated()) self.leftSizer = wx.BoxSizer(wx.VERTICAL) self.leftSizer.Add(self.simpleSettingsPanel, 1) self.leftSizer.Add(self.normalSettingsPanel, 1, wx.EXPAND) self.leftPane.SetSizer(self.leftSizer) #Preview window self.scene = sceneView.SceneView(self.rightPane) #Main sizer, to position the preview window, buttons and tab control sizer = wx.BoxSizer() self.rightPane.SetSizer(sizer) sizer.Add(self.scene, 1, flag=wx.EXPAND) # Main window sizer sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(sizer) sizer.Add(self.splitter, 1, wx.EXPAND) sizer.Layout() self.sizer = sizer self.updateProfileToAllControls() self.SetBackgroundColour(self.normalSettingsPanel.GetBackgroundColour()) self.simpleSettingsPanel.Show(False) self.normalSettingsPanel.Show(False) # Set default window size & position self.SetSize((wx.Display().GetClientArea().GetWidth()/2,wx.Display().GetClientArea().GetHeight()/2)) self.Centre() #Timer set; used to check if profile is on the clipboard self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.onTimer) self.timer.Start(1000) self.lastTriedClipboard = profile.getProfileString() # Restore the window position, size & state from the preferences file try: if profile.getPreference('window_maximized') == 'True': self.Maximize(True) else: posx = int(profile.getPreference('window_pos_x')) posy = int(profile.getPreference('window_pos_y')) width = int(profile.getPreference('window_width')) height = int(profile.getPreference('window_height')) if posx > 0 or posy > 0: self.SetPosition((posx,posy)) if width > 0 and height > 0: self.SetSize((width,height)) self.normalSashPos = int(profile.getPreference('window_normal_sash')) except: self.normalSashPos = 0 self.Maximize(True) if self.normalSashPos < self.normalSettingsPanel.printPanel.GetBestSize()[0] + 5: self.normalSashPos = self.normalSettingsPanel.printPanel.GetBestSize()[0] + 5 self.splitter.SplitVertically(self.leftPane, self.rightPane, self.normalSashPos) if wx.Display.GetFromPoint(self.GetPosition()) < 0: self.Centre() if wx.Display.GetFromPoint((self.GetPositionTuple()[0] + self.GetSizeTuple()[1], self.GetPositionTuple()[1] + self.GetSizeTuple()[1])) < 0: self.Centre() if wx.Display.GetFromPoint(self.GetPosition()) < 0: self.SetSize((800,600)) self.Centre() self.updateSliceMode() self.scene.SetFocus()
def __init__(self): super(mainWindow, self).__init__(None, title='Cura-BCN3D-' + version.getVersion() + '-beta2') wx.EVT_CLOSE(self, self.OnClose) # allow dropping any file, restrict later self.SetDropTarget(dropTarget.FileDropTarget(self.OnDropFiles)) # TODO: wxWidgets 2.9.4 has a bug when NSView does not register for dragged types when wx drop target is set. It was fixed in 2.9.5 if sys.platform.startswith('darwin'): try: import objc nswindow = objc.objc_object( c_void_p=self.MacGetTopLevelWindowRef()) view = nswindow.contentView() view.registerForDraggedTypes_([u'NSFilenamesPboardType']) except: pass self.normalModeOnlyItems = [] mruFile = os.path.join(profile.getBasePath(), 'mru_filelist.ini') self.config = wx.FileConfig(appName="Cura", localFilename=mruFile, style=wx.CONFIG_USE_LOCAL_FILE) self.ID_MRU_MODEL1, self.ID_MRU_MODEL2, self.ID_MRU_MODEL3, self.ID_MRU_MODEL4, self.ID_MRU_MODEL5, self.ID_MRU_MODEL6, self.ID_MRU_MODEL7, self.ID_MRU_MODEL8, self.ID_MRU_MODEL9, self.ID_MRU_MODEL10 = [ wx.NewId() for line in xrange(10) ] self.modelFileHistory = wx.FileHistory(10, self.ID_MRU_MODEL1) self.config.SetPath("/ModelMRU") self.modelFileHistory.Load(self.config) self.ID_MRU_PROFILE1, self.ID_MRU_PROFILE2, self.ID_MRU_PROFILE3, self.ID_MRU_PROFILE4, self.ID_MRU_PROFILE5, self.ID_MRU_PROFILE6, self.ID_MRU_PROFILE7, self.ID_MRU_PROFILE8, self.ID_MRU_PROFILE9, self.ID_MRU_PROFILE10 = [ wx.NewId() for line in xrange(10) ] self.profileFileHistory = wx.FileHistory(10, self.ID_MRU_PROFILE1) self.config.SetPath("/ProfileMRU") self.profileFileHistory.Load(self.config) #Now we create the different menu options, the first one is the options displayed by the 'File' button self.menubar = wx.MenuBar() self.fileMenu = wx.Menu() i = self.fileMenu.Append(-1, _("Load model file...\tCTRL+L")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showLoadModel(), i) i = self.fileMenu.Append(-1, _("Load Draudi file...\tCTRL+D")) self.Bind(wx.EVT_MENU, self.OnLoadDraudiModel, i) i = self.fileMenu.Append(-1, _("Save model...\tCTRL+S")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveModel(), i) i = self.fileMenu.Append(-1, _("Reload platform\tF5")) self.Bind(wx.EVT_MENU, lambda e: self.scene.reloadScene(e), i) i = self.fileMenu.Append(-1, _("Clear platform\tCTRL+Q")) self.Bind(wx.EVT_MENU, lambda e: self.scene.OnDeleteAll(e), i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _("Print...\tCTRL+P")) self.Bind(wx.EVT_MENU, lambda e: self.scene.OnPrintButton(1), i) i = self.fileMenu.Append(-1, _("Save GCode...\tCTRL+G")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveGCode(), i) i = self.fileMenu.Append(-1, _("Show slice engine log...")) self.Bind(wx.EVT_MENU, lambda e: self.scene._showEngineLog(), i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _("Open Profile...\tCTRL+C")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, lambda e: self.scene.OnLoadConfigurations(), i) i = self.fileMenu.Append(-1, _("Save Profile...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnSaveProfile, i) if version.isDevVersion(): i = self.fileMenu.Append(-1, "Save difference from default...") self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnSaveDifferences, i) i = self.fileMenu.Append(-1, _("Load Profile from GCode...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnLoadProfileFromGcode, i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _("Preferences...\tCTRL+,")) self.Bind(wx.EVT_MENU, self.OnPreferences, i) i = self.fileMenu.Append(-1, _("Machine settings...")) self.Bind(wx.EVT_MENU, self.OnMachineSettings, i) self.fileMenu.AppendSeparator() # Model MRU list modelHistoryMenu = wx.Menu() self.fileMenu.AppendMenu(wx.NewId(), '&' + _("Recent Model Files"), modelHistoryMenu) self.modelFileHistory.UseMenu(modelHistoryMenu) self.modelFileHistory.AddFilesToMenu() self.Bind(wx.EVT_MENU_RANGE, self.OnModelMRU, id=self.ID_MRU_MODEL1, id2=self.ID_MRU_MODEL10) # Profle MRU list profileHistoryMenu = wx.Menu() self.fileMenu.AppendMenu(wx.NewId(), _("Recent Profile Files"), profileHistoryMenu) self.profileFileHistory.UseMenu(profileHistoryMenu) self.profileFileHistory.AddFilesToMenu() self.Bind(wx.EVT_MENU_RANGE, self.OnProfileMRU, id=self.ID_MRU_PROFILE1, id2=self.ID_MRU_PROFILE10) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(wx.ID_EXIT, _("Quit")) self.Bind(wx.EVT_MENU, self.OnQuit, i) #Here we set the name of the menubar, which in this case is 'File' self.menubar.Append(self.fileMenu, '&' + _("File")) #The next menu option is 'Tools' toolsMenu = wx.Menu() #At BCN3D we do not recommend printing one at a time and we have set a message to come up #in case a user does choose that option. self.allAtOnceItem = toolsMenu.Append(-1, _("Print all at once"), kind=wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.onOneAtATimeSwitch, self.allAtOnceItem) self.oneAtATime = toolsMenu.Append(-1, _("Print one at a time"), kind=wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.onOneAtATimeSwitch, self.oneAtATime) if profile.getPreference('oneAtATime') == 'True': self.oneAtATime.Check(True) else: self.allAtOnceItem.Check(True) #We name this menu option self.menubar.Append(toolsMenu, _("Tools")) #Machine menu for machine configuration/tooling self.machineMenu = wx.Menu() self.updateMachineMenu() self.menubar.Append(self.machineMenu, _("Machine")) #we switch between panels expertMenu = wx.Menu() i = expertMenu.Append(-1, _("Switch to quickprint..."), kind=wx.ITEM_RADIO) self.switchToQuickprintMenuItem = i self.Bind(wx.EVT_MENU, self.OnSimpleSwitch, i) i = expertMenu.Append(-1, _("Switch to full settings..."), kind=wx.ITEM_RADIO) self.switchToNormalMenuItem = i self.Bind(wx.EVT_MENU, self.OnNormalSwitch, i) expertMenu.AppendSeparator() #Open a series of settings that you are not normally able to see i = expertMenu.Append(-1, _("Open expert settings...\tCTRL+E")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnExpertOpen, i) expertMenu.AppendSeparator() self.bedLevelWizardMenuItem = expertMenu.Append( -1, _("Run bed leveling wizard...")) self.Bind(wx.EVT_MENU, self.OnBedLevelWizard, self.bedLevelWizardMenuItem) self.headOffsetWizardMenuItem = expertMenu.Append( -1, _("Run head offset wizard...")) self.Bind(wx.EVT_MENU, self.OnHeadOffsetWizard, self.headOffsetWizardMenuItem) #give the menu bar a name, in this case 'Expert' self.menubar.Append(expertMenu, _("Expert")) helpMenu = wx.Menu() i = helpMenu.Append(-1, _("Online documentation...")) self.Bind( wx.EVT_MENU, lambda e: webbrowser.open( 'http://www.bcn3dtechnologies.com/es/forum'), i) if sys.platform.startswith('win'): i = helpMenu.Append(-1, _("Report a problem...")) self.Bind( wx.EVT_MENU, lambda e: webbrowser.open( 'https://github.com/BCN3D/BCN3D-Cura-Windows/issues'), i) elif sys.platform.startswith('darwin'): i = helpMenu.Append(-1, _("Report a problem...")) self.Bind( wx.EVT_MENU, lambda e: webbrowser.open( 'https://github.com/BCN3D/BCN3D-Cura-Mac/issues'), i) i = helpMenu.Append(-1, _("Check for update...")) self.Bind(wx.EVT_MENU, self.OnCheckForUpdate, i) i = helpMenu.Append(-1, _("About Cura...")) self.Bind(wx.EVT_MENU, self.OnAbout, i) self.menubar.Append(helpMenu, _("Help")) self.SetMenuBar(self.menubar) self.splitter = wx.SplitterWindow(self, style=wx.SP_3D | wx.SP_LIVE_UPDATE) self.leftPane = wx.Panel(self.splitter, style=wx.BORDER_NONE) self.rightPane = wx.Panel(self.splitter, style=wx.BORDER_NONE) self.splitter.Bind(wx.EVT_SPLITTER_DCLICK, lambda evt: evt.Veto()) #Preview window self.scene = sceneView.SceneView(self.rightPane) ##Gui components## #We want two different simple modes, one for BCN3D users and the default cura one for other machines #Currently working on this, will be available soon #machine_type = profile.getMachineSetting('machine_type') #if machine_type == 'BCN3DSigma': # self.simpleSettingsPanel = simpleModeSigma(self.leftPane, self.scene.sceneUpdated) #else: #call to the different panels self.simpleSettingsPanel = simpleMode.simpleModePanel( self.leftPane, self.scene.sceneUpdated) self.normalSettingsPanel = normalSettingsPanel(self.leftPane, self.scene.sceneUpdated) #Simple panel will be fix while you can change the size for advanced panel self.leftSizer = wx.BoxSizer(wx.VERTICAL) self.leftSizer.Add(self.simpleSettingsPanel, 1) self.leftSizer.Add(self.normalSettingsPanel, 1, wx.EXPAND) self.leftPane.SetSizer(self.leftSizer) #Main sizer, to position the preview window, buttons and tab control sizer = wx.BoxSizer() self.rightPane.SetSizer(sizer) sizer.Add(self.scene, 1, flag=wx.EXPAND) # Main window sizer sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(sizer) sizer.Add(self.splitter, 1, wx.EXPAND) sizer.Layout() self.sizer = sizer self.updateProfileToAllControls() self.SetBackgroundColour( self.normalSettingsPanel.GetBackgroundColour()) self.simpleSettingsPanel.Show(False) self.normalSettingsPanel.Show(False) # Set default window size & position self.SetSize((wx.Display().GetClientArea().GetWidth() / 2, wx.Display().GetClientArea().GetHeight() / 2)) self.Centre() #Timer set; used to check if profile is on the clipboard self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.onTimer) #self.timer.Start(1000) self.lastTriedClipboard = profile.getProfileString() # Restore the window position, size & state from the preferences file try: if profile.getPreference('window_maximized') == 'True': self.Maximize(True) else: posx = int(profile.getPreference('window_pos_x')) posy = int(profile.getPreference('window_pos_y')) width = int(profile.getPreference('window_width')) height = int(profile.getPreference('window_height')) if posx > 0 or posy > 0: self.SetPosition((posx, posy)) if width > 0 and height > 0: self.SetSize((width, height)) self.normalSashPos = int( profile.getPreference('window_normal_sash')) except: self.normalSashPos = 0 self.Maximize(True) if self.normalSashPos < self.normalSettingsPanel.printPanel.GetBestSize( )[0] + 5: self.normalSashPos = self.normalSettingsPanel.printPanel.GetBestSize( )[0] + 5 self.splitter.SplitVertically(self.leftPane, self.rightPane, self.normalSashPos) if wx.Display.GetFromPoint(self.GetPosition()) < 0: self.Centre() if wx.Display.GetFromPoint( (self.GetPositionTuple()[0] + self.GetSizeTuple()[1], self.GetPositionTuple()[1] + self.GetSizeTuple()[1])) < 0: self.Centre() if wx.Display.GetFromPoint(self.GetPosition()) < 0: self.SetSize((800, 600)) self.Centre() self.updateSliceMode() self.scene.SetFocus() self.dialogframe = None if Publisher is not None: Publisher().subscribe(self.onPluginUpdate, "pluginupdate") pluginCount = self.normalSettingsPanel.pluginPanel.GetActivePluginCount( ) if pluginCount == 1: self.scene.notification.message( "Warning: 1 plugin from the previous session is still active.") if pluginCount > 1: self.scene.notification.message( "Warning: %i plugins from the previous session are still active." % pluginCount)
def __init__(self): # 软件标题 super(mainWindow, self).__init__(None, title='Tianjin DaGe Technology Co.Ltd') wx.EVT_CLOSE(self, self.OnClose) # allow dropping any file, restrict later self.SetDropTarget(dropTarget.FileDropTarget(self.OnDropFiles)) # TODO: wxWidgets 2.9.4 has a bug when NSView does not register for dragged types when wx drop target is set. It was fixed in 2.9.5 if sys.platform.startswith('darwin'): try: import objc nswindow = objc.objc_object(c_void_p=self.MacGetTopLevelWindowRef()) view = nswindow.contentView() view.registerForDraggedTypes_([u'NSFilenamesPboardType']) except: pass self.normalModeOnlyItems = [] mruFile = os.path.join(profile.getBasePath(), 'mru_filelist.ini') self.config = wx.FileConfig(appName="Cura", localFilename=mruFile, style=wx.CONFIG_USE_LOCAL_FILE) self.ID_MRU_MODEL1, self.ID_MRU_MODEL2, self.ID_MRU_MODEL3, self.ID_MRU_MODEL4, self.ID_MRU_MODEL5, self.ID_MRU_MODEL6, self.ID_MRU_MODEL7, self.ID_MRU_MODEL8, self.ID_MRU_MODEL9, self.ID_MRU_MODEL10 = [wx.NewId() for line in xrange(10)] self.modelFileHistory = wx.FileHistory(10, self.ID_MRU_MODEL1) self.config.SetPath("/ModelMRU") self.modelFileHistory.Load(self.config) self.ID_MRU_PROFILE1, self.ID_MRU_PROFILE2, self.ID_MRU_PROFILE3, self.ID_MRU_PROFILE4, self.ID_MRU_PROFILE5, self.ID_MRU_PROFILE6, self.ID_MRU_PROFILE7, self.ID_MRU_PROFILE8, self.ID_MRU_PROFILE9, self.ID_MRU_PROFILE10 = [wx.NewId() for line in xrange(10)] self.profileFileHistory = wx.FileHistory(10, self.ID_MRU_PROFILE1) self.config.SetPath("/ProfileMRU") self.profileFileHistory.Load(self.config) self.menubar = wx.MenuBar() # 添加菜单栏 #file的菜单,第一个 self.fileMenu = wx.Menu() i = self.fileMenu.Append(-1, _("Load model file...\tCTRL+L")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showLoadModel(), i) i = self.fileMenu.Append(-1, _("Save model...\tCTRL+S")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveModel(), i) i = self.fileMenu.Append(-1, _("Reload platform\tF5")) self.Bind(wx.EVT_MENU, lambda e: self.scene.reloadScene(e), i) i = self.fileMenu.Append(-1, _("Clear platform\tCTRL+D")) self.Bind(wx.EVT_MENU, lambda e: self.scene.OnDeleteAll(e), i) self.fileMenu.AppendSeparator() #分割线 i = self.fileMenu.Append(-1, _("Print...\tCTRL+P")) self.Bind(wx.EVT_MENU, lambda e: self.scene.OnPrintButton(1), i) i = self.fileMenu.Append(-1, _("Save GCode...\tCTRL+G")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveGCode(), i) i = self.fileMenu.Append(-1, _("Show slice engine log...")) self.Bind(wx.EVT_MENU, lambda e: self.scene._showEngineLog(), i) self.fileMenu.AppendSeparator() #分割线 i = self.fileMenu.Append(-1, _("Open Profile...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnLoadProfile, i) i = self.fileMenu.Append(-1, _("Save Profile...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnSaveProfile, i) if version.isDevVersion(): i = self.fileMenu.Append(-1, "Save difference from default...") self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnSaveDifferences, i) i = self.fileMenu.Append(-1, _("Load Profile from GCode...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnLoadProfileFromGcode, i) # self.fileMenu.AppendSeparator() ## Disabled the reset profile option, as it resets to global defaults, not machine defaults. # i = self.fileMenu.Append(-1, _("Reset Profile to default")) # self.normalModeOnlyItems.append(i) # self.Bind(wx.EVT_MENU, self.OnResetProfile, i) self.fileMenu.AppendSeparator() #分割线 i = self.fileMenu.Append(-1, _("Preferences...\tCTRL+,")) self.Bind(wx.EVT_MENU, self.OnPreferences, i) i = self.fileMenu.Append(-1, _("Machine settings...")) self.Bind(wx.EVT_MENU, self.OnMachineSettings, i) self.fileMenu.AppendSeparator() # Model MRU list 模型历史记录 modelHistoryMenu = wx.Menu() self.fileMenu.AppendMenu(wx.NewId(), '&' + _("Recent Model Files"), modelHistoryMenu) self.modelFileHistory.UseMenu(modelHistoryMenu) self.modelFileHistory.AddFilesToMenu() self.Bind(wx.EVT_MENU_RANGE, self.OnModelMRU, id=self.ID_MRU_MODEL1, id2=self.ID_MRU_MODEL10) # Profile MRU list 轮廓历史记录 profileHistoryMenu = wx.Menu() self.fileMenu.AppendMenu(wx.NewId(), _("Recent Profile Files"), profileHistoryMenu) self.profileFileHistory.UseMenu(profileHistoryMenu) self.profileFileHistory.AddFilesToMenu() self.Bind(wx.EVT_MENU_RANGE, self.OnProfileMRU, id=self.ID_MRU_PROFILE1, id2=self.ID_MRU_PROFILE10) self.fileMenu.AppendSeparator() #分割线 i = self.fileMenu.Append(wx.ID_EXIT, _("Quit")) self.Bind(wx.EVT_MENU, self.OnQuit, i) self.menubar.Append(self.fileMenu, '&' + _("File")) # Tools菜单,第二个 toolsMenu = wx.Menu() #i = toolsMenu.Append(-1, 'Batch run...') #self.Bind(wx.EVT_MENU, self.OnBatchRun, i) #self.normalModeOnlyItems.append(i) # 不懂这两个判断语句的作用 if minecraftImport.hasMinecraft(): i = toolsMenu.Append(-1, _("Minecraft map import...")) self.Bind(wx.EVT_MENU, self.OnMinecraftImport, i) if version.isDevVersion(): i = toolsMenu.Append(-1, _("PID Debugger...")) self.Bind(wx.EVT_MENU, self.OnPIDDebugger, i) i = toolsMenu.Append(-1, _("Auto Firmware Update...")) self.Bind(wx.EVT_MENU, self.OnAutoFirmwareUpdate, i) #i = toolsMenu.Append(-1, _("Copy profile to clipboard")) #self.Bind(wx.EVT_MENU, self.onCopyProfileClipboard,i) toolsMenu.AppendSeparator() #分割线 self.allAtOnceItem = toolsMenu.Append(-1, _("Print all at once"), kind=wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.onOneAtATimeSwitch, self.allAtOnceItem) self.oneAtATime = toolsMenu.Append(-1, _("Print one at a time"), kind=wx.ITEM_RADIO) self.Bind(wx.EVT_MENU, self.onOneAtATimeSwitch, self.oneAtATime) if profile.getPreference('oneAtATime') == 'True': self.oneAtATime.Check(True) else: self.allAtOnceItem.Check(True) self.menubar.Append(toolsMenu, _("Tools")) #Machine menu for machine configuration/tooling # 机器配置和工具 机器菜单。第三个 self.machineMenu = wx.Menu() self.updateMachineMenu() self.menubar.Append(self.machineMenu, _("Machine")) # Expert菜单 第四个 expertMenu = wx.Menu() i = expertMenu.Append(-1, _("Switch to quickprint..."), kind=wx.ITEM_RADIO) self.switchToQuickprintMenuItem = i self.Bind(wx.EVT_MENU, self.OnSimpleSwitch, i) i = expertMenu.Append(-1, _("Switch to full settings..."), kind=wx.ITEM_RADIO) self.switchToNormalMenuItem = i self.Bind(wx.EVT_MENU, self.OnNormalSwitch, i) expertMenu.AppendSeparator() i = expertMenu.Append(-1, _("Open expert settings...\tCTRL+E")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnExpertOpen, i) expertMenu.AppendSeparator() self.bedLevelWizardMenuItem = expertMenu.Append(-1, _("Run bed leveling wizard...")) self.Bind(wx.EVT_MENU, self.OnBedLevelWizard, self.bedLevelWizardMenuItem) self.headOffsetWizardMenuItem = expertMenu.Append(-1, _("Run head offset wizard...")) self.Bind(wx.EVT_MENU, self.OnHeadOffsetWizard, self.headOffsetWizardMenuItem) self.menubar.Append(expertMenu, _("Expert")) # help菜单 第五个 helpMenu = wx.Menu() i = helpMenu.Append(-1, _("Online documentation...")) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('http://daid.github.com/Cura'), i) i = helpMenu.Append(-1, _("Report a problem...")) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://github.com/daid/Cura/issues'), i) i = helpMenu.Append(-1, _("Check for update...")) self.Bind(wx.EVT_MENU, self.OnCheckForUpdate, i) i = helpMenu.Append(-1, _("Open YouMagine website...")) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://www.youmagine.com/'), i) i = helpMenu.Append(-1, _("About Software...")) self.Bind(wx.EVT_MENU, self.OnAbout, i) self.menubar.Append(helpMenu, _("Help")) self.SetMenuBar(self.menubar) ##################################以上5个菜单,全部结束########################### self.splitter = wx.SplitterWindow(self, style = wx.SP_3D | wx.SP_LIVE_UPDATE) # 将界面划分为两个子界面,一个是3D效果的 self.leftPane = wx.Panel(self.splitter, style=wx.BORDER_NONE) self.rightPane = wx.Panel(self.splitter, style=wx.BORDER_NONE) self.splitter.Bind(wx.EVT_SPLITTER_DCLICK, lambda evt: evt.Veto()) #Preview window # 第一次调用该模块 # 该函数还有关于OpenGL的知识,需要学习掌握 self.scene = sceneView.SceneView(self.rightPane) # 将右边的界面传到该函数,实现预览功能 ##Gui components## # 第一次调用simpleMode # 将左边的界面传入,实现相关的功能 self.simpleSettingsPanel = simpleMode.simpleModePanel(self.leftPane, self.scene.sceneUpdated) # 调用simpleMode.py的功能 self.normalSettingsPanel = normalSettingsPanel(self.leftPane, self.scene.sceneUpdated) # BoxSizer # Google翻译一个框分级机背后的基本想法是,窗口将最多以相当简单的基本几何形状布置,通常在一排或一列或任几个层次结构。 self.leftSizer = wx.BoxSizer(wx.VERTICAL) self.leftSizer.Add(self.simpleSettingsPanel, 1) self.leftSizer.Add(self.normalSettingsPanel, 1, wx.EXPAND) self.leftPane.SetSizer(self.leftSizer) #Main sizer, to position the preview window, buttons and tab control # 主要的大小选择器,定位预览窗口,按钮,标签管理 sizer = wx.BoxSizer() self.rightPane.SetSizer(sizer) sizer.Add(self.scene, 1, flag=wx.EXPAND) # Main window sizer # 主要窗口的大小选择器 sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(sizer) sizer.Add(self.splitter, 1, wx.EXPAND) sizer.Layout() self.sizer = sizer self.updateProfileToAllControls() self.SetBackgroundColour(self.normalSettingsPanel.GetBackgroundColour()) self.simpleSettingsPanel.Show(False) self.normalSettingsPanel.Show(False) # Set default window size & position # 设置默认的窗口大小和坐标 self.SetSize((wx.Display().GetClientArea().GetWidth()/2,wx.Display().GetClientArea().GetHeight()/2)) self.Centre() #Timer set; used to check if profile is on the clipboard # Timer 设置,用来检查轮廓图是否在剪贴板上 self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.onTimer) #self.timer.Start(1000) self.lastTriedClipboard = profile.getProfileString() # Restore the window position, size & state from the preferences file # 从参数选择文件中,还原窗口位置,大小,状态, try: if profile.getPreference('window_maximized') == 'True': # 最大 self.Maximize(True) else: posx = int(profile.getPreference('window_pos_x')) posy = int(profile.getPreference('window_pos_y')) width = int(profile.getPreference('window_width')) height = int(profile.getPreference('window_height')) if posx > 0 or posy > 0: self.SetPosition((posx,posy)) # 设置x,y坐标 if width > 0 and height > 0: self.SetSize((width,height)) # 设置宽,高 self.normalSashPos = int(profile.getPreference('window_normal_sash')) # 设置正常 except: self.normalSashPos = 0 self.Maximize(True) if self.normalSashPos < self.normalSettingsPanel.printPanel.GetBestSize()[0] + 5: self.normalSashPos = self.normalSettingsPanel.printPanel.GetBestSize()[0] + 5 self.splitter.SplitVertically(self.leftPane, self.rightPane, self.normalSashPos) if wx.Display.GetFromPoint(self.GetPosition()) < 0: self.Centre() if wx.Display.GetFromPoint((self.GetPositionTuple()[0] + self.GetSizeTuple()[1], self.GetPositionTuple()[1] + self.GetSizeTuple()[1])) < 0: self.Centre() if wx.Display.GetFromPoint(self.GetPosition()) < 0: self.SetSize((800,600)) self.Centre() self.updateSliceMode() self.scene.SetFocus() self.dialogframe = None if Publisher is not None: Publisher().subscribe(self.onPluginUpdate, "pluginupdate") pluginCount = self.normalSettingsPanel.pluginPanel.GetActivePluginCount() if pluginCount == 1: self.scene.notification.message("Warning: 1 plugin from the previous session is still active.") if pluginCount > 1: self.scene.notification.message("Warning: %i plugins from the previous session are still active." % pluginCount)