コード例 #1
0
ファイル: app.py プロジェクト: hanxiaomax/Cura2
    def OnInit(self):
        self._settings_view_presets = []
        self._active_setting_view = None

        self._scene = Printer3DScene()
        self._view = PrinterView3D()
        self._translator = FDMPrinterTranslator()

        machine_storage = ConfigParser()
        machine_storage.read(getDefaultPreferenceStoragePath('machines.ini'))
        n = 0
        while machine_storage.has_section('machine_%d' % n):
            machine = None
            if machine_storage.has_option('machine_%d' % n, 'machine_class'):
                try:
                    class_name = machine_storage.get('machine_%d' % n, 'machine_class')
                    module_name, class_name = class_name.rsplit('.', 1)
                    __import__(module_name)
                    module = sys.modules[module_name]
                    machine = getattr(module, class_name)()
                except:
                    import traceback
                    traceback.print_exc()
                    machine = None
            if machine is None:
                machine = FDMPrinter()
            machine.loadSettingsFromConfigParser(machine_storage, 'machine_%d' % n)
            self.addMachine(machine)
            n += 1

        if len(self._machine_list) < 1:
            wizard = NewDFMPrinterWizard()
            machine = wizard.run()
            if machine is not None:
                self.addMachine(machine)

        if len(self._machine_list) < 1:
            return False

        self._toolbox.append(RotateTool(self))
        self._toolbox.append(ScaleTool(self))
        self._toolbox.append(MirrorTool(self))
        self._toolbox.append(SelectAndMoveTool(self))

        svp = SettingsViewPreset()
        svp.setName('Normal')
        svp.importFromFile(getResourcePath('view_presets/normal_view.ini'))
        svp.setBuildIn()
        self.addSettingsViewPreset(svp)

        for svp in loadSettingViewPresets(getDefaultPreferenceStoragePath('view_presets.ini')):
            self.addSettingsViewPreset(svp)

        self.setActiveSettingsView(self._settings_view_presets[int(getPreference('active_view_preset', 0))])
        self.setMachine(self._machine_list[int(getPreference('active_machine', 0))])

        wx.CallAfter(self._scene.loadFile, 'C:/Models/D&D/Box.stl')

        return True
コード例 #2
0
ファイル: fileBrowser.py プロジェクト: MiniRalis/Cura2
 def _watchPathsThread(self):
     supported_extensions = self._app.getScene().getSupportedLoadExtensions()
     while True:
         path = getPreference('last_file_path', '')
         fileList = []
         try:
             for file in os.listdir(path):
                 _, ext = os.path.splitext(file)
                 if ext.lower() not in supported_extensions:
                     continue
                 try:
                     info = os.stat(os.path.join(path, file))
                     fileList.append((info.st_mtime, os.path.join(path, file)))
                 except:
                     pass
         except:
             pass
         fileList.sort(reverse=True)
         wx.CallAfter(self._updateFileList, map(lambda n: n[1], fileList[:20]))
         self._timeout = 50
         while self._timeout > 0:
             sleep(0.1)
             if not self:
                 return
             self._timeout -= 1
コード例 #3
0
ファイル: profilePanel.py プロジェクト: daid/Cura2
    def __init__(self, parent, app):
        super(ProfilePanel, self).__init__(parent)

        self._app = app
        self._buttons = []
        self._panels = []

        sizer = wx.BoxSizer(wx.VERTICAL)
        self._titleBar = InnerTitleBar(self, 'Profile')
        self._titleBar.Bind(wx.EVT_LEFT_DOWN, self.onSmallToggle)
        sizer.Add(self._titleBar, flag=wx.EXPAND)

        n = 0
        for c in self._app.getMachine().getSettingCategories():
            if not c.isVisible():
                continue
            # Filter out categories that do not have visible settings.
            if len(filter(lambda s: s.isVisible(), c.getSettings())) < 1:
                continue
            b = ProfileCategoryButton(self, c.getLabel(), c.getIcon())
            b.category = c
            b.Bind(wx.EVT_BUTTON, self.onCategoryButton)
            self._buttons.append(b)
            p = SettingPanel(self, self._app, c)
            self._panels.append(p)

            # n += 1
            # if n % 4 == 0:
            #     sizer.Add(wx.StaticLine(self), flag=wx.EXPAND)

        self._pluginsButton = ProfileCategoryButton(self, 'Plugins', 'icon_plugin.png')
        self._pluginsButton.Hide()
        self._loadProfileButton = ProfileCategoryButton(self, 'Load profile', 'icon_load_profile.png')
        self._loadProfileButton.Hide()
        self._saveButton = PrintSaveButton(self, app)
        self._pluginsButton.Bind(wx.EVT_BUTTON, self.onPluginButton)
        self._loadProfileButton.Bind(wx.EVT_BUTTON, self.onLoadProfileButton)

        sizer.Add(self._pluginsButton, flag=wx.EXPAND)
        sizer.Add(self._loadProfileButton, flag=wx.EXPAND)
        sizer.Add(self._saveButton, flag=wx.EXPAND)
        self.SetSizer(sizer)
        self.setSmall(preferences.getPreference('profile_small', 'False') == 'True')
        self._updateSizer()
コード例 #4
0
ファイル: cutApp.py プロジェクト: dotBits/Cura2
    def OnInit(self):
        self._scene = CutScene()
        self._view = CutView3D()
        self._translator = CutTranslator()

        machine_storage = ConfigParser()
        machine_storage.read(getDefaultPreferenceStoragePath('cut_machines.ini'))
        n = 0
        while machine_storage.has_section('machine_%d' % n):
            machine = None
            if machine_storage.has_option('machine_%d' % n, 'machine_class'):
                try:
                    class_name = machine_storage.get('machine_%d' % n, 'machine_class')
                    module_name, class_name = class_name.rsplit('.', 1)
                    __import__(module_name)
                    module = sys.modules[module_name]
                    machine = getattr(module, class_name)()
                except:
                    import traceback
                    traceback.print_exc()
                    machine = None
            if machine is None:
                machine = CutMachine()
            machine.loadSettingsFromConfigParser(machine_storage, 'machine_%d' % n)
            self.addMachine(machine)
            n += 1

        if len(self._machine_list) < 1:
            from Cura.machine.cutMachine import CutMachine
            self.addMachine(CutMachine())

        if len(self._machine_list) < 1:
            return False

        self._toolbox.append(RotateTool(self))
        self._toolbox.append(MirrorTool(self))
        self._toolbox.append(SelectAndMoveTool(self))

        idx = min(int(getPreference('active_machine', 0)), len(self._machine_list) - 1)
        self.setMachine(self._machine_list[idx])

        return True
コード例 #5
0
ファイル: profilePanel.py プロジェクト: sanyaade-iot/Cura2
    def __init__(self, parent, app):
        super(ProfilePanel, self).__init__(parent)

        self._app = app
        self._categoryButtons = []

        sizer = wx.BoxSizer(wx.VERTICAL)
        self._titleBar = InnerTitleBar(self, 'Profile')
        self._titleBar.Bind(wx.EVT_LEFT_DOWN, self.onSmallToggle)
        sizer.Add(self._titleBar, flag=wx.EXPAND)

        n = 0
        for c in self._app.getMachine().getSettingCategories():
            if not c.isVisible():
                continue
            # Filter out categories that do not have visible settings.
            if len(filter(lambda s: s.isVisible(), c.getSettings())) < 1:
                continue
            b = ProfileCategoryButton(self, c.getLabel(), c.getIcon())
            b.category = c
            sizer.Add(b, flag=wx.EXPAND)
            b.Bind(wx.EVT_BUTTON, self.onCategoryButton)
            self._categoryButtons.append(b)

            n += 1
            if n % 4 == 0:
                sizer.Add(wx.StaticLine(self), flag=wx.EXPAND)

        self._pluginsButton = ProfileCategoryButton(self, 'Plugins',
                                                    'icon_plugin.png')
        self._pluginsButton.Hide()
        self._loadProfileButton = ProfileCategoryButton(
            self, 'Load profile', 'icon_load_profile.png')
        self._saveButton = PrintSaveButton(self, app)
        self._pluginsButton.Bind(wx.EVT_BUTTON, self.onPluginButton)
        self._loadProfileButton.Bind(wx.EVT_BUTTON, self.onLoadProfileButton)
        sizer.Add(self._pluginsButton, flag=wx.EXPAND)
        sizer.Add(self._loadProfileButton, flag=wx.EXPAND)
        sizer.Add(self._saveButton, flag=wx.EXPAND)
        self.SetSizer(sizer)
        self.setSmall(
            preferences.getPreference('profile_small', 'False') == 'True')
コード例 #6
0
ファイル: preferencesDialog.py プロジェクト: daid/Cura2
    def __init__(self, app):
        self._app = app
        super(PreferencesDialog, self).__init__(app.getMainWindow(), title='Settings')
        self._main_panel = wx.Panel(self)
        self._bottom_panel = wx.Panel(self)
        self.SetSizer(wx.BoxSizer(wx.VERTICAL))
        self.GetSizer().Add(self._main_panel, 1, wx.EXPAND)
        self.GetSizer().Add(wx.StaticLine(self), 0, wx.EXPAND)
        self.GetSizer().Add(self._bottom_panel, 0, wx.EXPAND)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self._bottom_panel.SetSizer(sizer)
        self._close_button = wx.Button(self._bottom_panel, -1, 'Ok')
        sizer.Add(wx.Panel(self._bottom_panel), 1)
        sizer.Add(self._close_button, 0, border=5, flag=wx.ALL)
        self.Bind(wx.EVT_BUTTON, self.onCloseButton, self._close_button)

        sizer = wx.GridBagSizer(2, 2)
        self._main_panel.SetSizer(sizer)
        setting_view_options = map(lambda svp: svp.getName(), self._app.getSettingsViewPresets())
        setting_view_options.append('+Add custom')
        self._setting_view_selection = wx.ComboBox(self._main_panel, choices=setting_view_options, style=wx.CB_DROPDOWN | wx.CB_READONLY)
        self._setting_view_selection.SetSelection(self._app.getSettingsViewPresets().index(self._app.getActiveSettingsViewPreset()))
        self._setting_view_customize = wx.Button(self._main_panel, label=_('Customize'))
        self._legacy_rendering = wx.CheckBox(self._main_panel)
        self._legacy_rendering.SetValue(getPreference('legacy_rendering', 'False') == 'True')
        sizer.Add(wx.StaticText(self._main_panel, -1, 'Settings view preset'), pos=(0, 0), border=5, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL)
        sizer.Add(self._setting_view_selection, pos=(0, 1), border=5, flag=wx.ALL | wx.EXPAND)
        sizer.Add(self._setting_view_customize, pos=(0, 2), border=5, flag=wx.ALL)
        sizer.Add(wx.StaticText(self._main_panel, -1, 'Safemode 3D rendering'), pos=(1, 0), border=5, flag=wx.LEFT | wx.RIGHT | wx.ALIGN_CENTER_VERTICAL)
        sizer.Add(self._legacy_rendering, pos=(1, 1), border=5, flag=wx.ALL | wx.EXPAND)
        sizer.AddGrowableCol(1)

        self._main_panel.Layout()

        self.Bind(wx.EVT_BUTTON, self.onCustomizeButton, self._setting_view_customize)
        self._setting_view_selection.Bind(wx.EVT_COMBOBOX, self.onSettingsViewChange)
        self.Bind(wx.EVT_CLOSE, self.onClose)
コード例 #7
0
ファイル: openGLUtils.py プロジェクト: daid/Cura2
import wx
import numpy
import os
import atexit

from OpenGL.GL import *
from OpenGL.GL import shaders
from ctypes import c_void_p
from Cura.preferences import getPreference
from Cura.resources import getResourcePath
from Cura.resources import getBitmap

legacyMode = getPreference('legacy_rendering', 'False') == 'True'
shuttingDown = False
contextSource = None


#Register an at-exit function so we do not try to cleanup the OpenGL context on exit. (Window that needs to handle the cleanup could already be destroyed)
def _death():
    global shuttingDown
    shuttingDown = True
atexit.register(_death)


class GLShader(object):
    def __init__(self, vertexProgram=None, fragmentProgram=None, filename=None):
        super(GLShader, self).__init__()

        if filename is not None:
            self._loadFromFile(filename)
        else:
コード例 #8
0
ファイル: preferencesDialog.py プロジェクト: daid/Cura2
 def onClose(self, e):
     if (getPreference('legacy_rendering', 'False') == 'True') != self._legacy_rendering.GetValue():
         setPreference('legacy_rendering', self._legacy_rendering.GetValue())
         wx.MessageBox('When changing [Safemode 3D rendering] a restart of Cura is required.', 'Safemode 3D rendering')
     self.Destroy()