Exemplo n.º 1
0
def setup():
    languages = ['en']

    locale_path = getResourcePath('locale')
    locale_path = os.path.normpath(locale_path)
    translation = gettext.translation('Cura', locale_path, languages, fallback=True)
    translation.install(unicode=True)
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
def setup():
    languages = ['en']

    locale_path = getResourcePath('locale')
    locale_path = os.path.normpath(locale_path)
    translation = gettext.translation('Cura',
                                      locale_path,
                                      languages,
                                      fallback=True)
    translation.install(unicode=True)
Exemplo n.º 4
0
 def _loadFromFile(self, filename):
     self._filename = filename
     self._filetime = os.stat(
         os.path.join(getResourcePath('shaders'), filename)).st_mtime
     vertexProgram = ''
     fragmentProgram = ''
     type = 'BOTH'
     for line in open(os.path.join(getResourcePath('shaders'), filename),
                      "r"):
         if line.startswith('--'):
             type = line[2:].strip()
             continue
         if type == 'BOTH':
             vertexProgram += line
             fragmentProgram += line
         elif type == 'VERTEX':
             vertexProgram += line
         elif type == 'FRAGMENT':
             fragmentProgram += line
     self._vertexString = vertexProgram
     self._fragmentString = fragmentProgram
Exemplo n.º 5
0
 def _loadFromFile(self, filename):
     vertexProgram = ''
     fragmentProgram = ''
     type = 'BOTH'
     for line in open(os.path.join(getResourcePath('shaders'), filename), "r"):
         if line.startswith('--'):
             type = line[2:].strip()
             continue
         if type == 'BOTH':
             vertexProgram += line
             fragmentProgram += line
         elif type == 'VERTEX':
             vertexProgram += line
         elif type == 'FRAGMENT':
             fragmentProgram += line
     self._vertexString = vertexProgram
     self._fragmentString = fragmentProgram
Exemplo n.º 6
0
    def bind(self):
        if self._filename is not None:
            if self._filetime != os.stat(
                    os.path.join(getResourcePath('shaders'),
                                 self._filename)).st_mtime:
                self.release()
                self._loadFromFile(self._filename)

        if self._program is None and self._vertexString is not None:
            global contextSource
            self._contextSource = contextSource
            vertexString = self._vertexString
            fragmentString = self._fragmentString
            self._vertexString = None
            try:
                vertexShader = shaders.compileShader(vertexString,
                                                     GL_VERTEX_SHADER)
                fragmentShader = shaders.compileShader(fragmentString,
                                                       GL_FRAGMENT_SHADER)

                #shader.compileProgram tries to return the shader program as a overloaded int. But the return value of a shader does not always fit in a int (needs to be a long). So we do raw OpenGL calls.
                # This is to ensure that this works on intel GPU's
                # self._program = shaders.compileProgram(self._vertexProgram, self._fragmentProgram)
                self._program = glCreateProgram()
                glAttachShader(self._program, vertexShader)
                glAttachShader(self._program, fragmentShader)
                glLinkProgram(self._program)
                # Validation has to occur *after* linking
                glValidateProgram(self._program)
                if glGetProgramiv(self._program,
                                  GL_VALIDATE_STATUS) == GL_FALSE:
                    raise RuntimeError("Validation failure: %s" %
                                       (glGetProgramInfoLog(self._program)))
                if glGetProgramiv(self._program, GL_LINK_STATUS) == GL_FALSE:
                    raise RuntimeError("Link failure: %s" %
                                       (glGetProgramInfoLog(self._program)))
                glDeleteShader(vertexShader)
                glDeleteShader(fragmentShader)
            except RuntimeError, e:
                print str(e)
                self._program = None
Exemplo n.º 7
0
    def OnInit(self):
        self._settings_view_presets = [SettingsViewPreset()]
        self._active_setting_view = self._settings_view_presets[0]
        self._active_setting_view.setName('Normal')
        self._active_setting_view.importFromFile(getResourcePath('view_presets/normal_view.ini'))

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

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

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

        self._machine.loadSettings(getDefaultPreferenceStoragePath('settings.ini'))
        self.setActiveSettingsView(self._active_setting_view)
        return True
Exemplo n.º 8
0
    def OnInit(self):
        self._settings_view_presets = [SettingsViewPreset()]
        self._active_setting_view = self._settings_view_presets[0]
        self._active_setting_view.setName('Normal')
        self._active_setting_view.importFromFile(
            getResourcePath('view_presets/normal_view.ini'))

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

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

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

        self._machine.loadSettings(
            getDefaultPreferenceStoragePath('settings.ini'))
        self.setActiveSettingsView(self._active_setting_view)
        return True