Exemplo n.º 1
0
 def export(self, event):
     ''' General-purpose export callback.  Decides which export
         command to call based on the menu item text.'''
     
     item = self.frame.GetMenuBar().FindItemById(event.GetId())
     filetype = item.GetLabel()
     
     if filetype in ['.png', '.svg', '.stl']:
         resolution = dialogs.resolution(10)
         if resolution is False:
             return
     
     df = dialogs.save_as(self.directory, extension=filetype)
     if df[1] == '':
         return
     path = os.path.join(*df)
     
     self.exporting = True
     if filetype   == '.math':
         self.start_thread(cmd.export_math, path)
     elif filetype == '.dot':
         self.start_thread(cmd.export_dot, path)
     elif filetype == '.png':
         self.start_thread(cmd.export_png, path,
                           resolution=resolution)
     elif filetype == '.svg':
         self.start_thread(cmd.export_svg, path,
                           resolution=resolution)
     elif filetype == '.stl':
         self.start_thread(cmd.export_stl, path,
                           resolution=resolution)
Exemplo n.º 2
0
 def save(self, event=None):
     """@ brief Saves a generated toolpath file with the appropriate extension.
     """
     dir, file = dialogs.save_as(koko.APP.directory,
                                 extension=self.extension)
     if file == '': return
     path = os.path.join(dir, file)
     shutil.copy(self.file.name, path)
Exemplo n.º 3
0
 def save(self, event=None):
     """@ brief Saves a generated toolpath file with the appropriate extension.
     """
     dir, file = dialogs.save_as(koko.APP.directory,
                                 extension=self.extension)
     if file == '':  return
     path = os.path.join(dir, file)
     shutil.copy(self.file.name, path)
Exemplo n.º 4
0
 def onSaveAs(self, evt=None):
     '''Save As callback from main menu.'''
     
     # Open a file dialog to get target
     df = dialogs.save_as(self.directory, extension='.ko')
     
     if df[1] != '':    
         self.directory, self.filename = df
         self.onSave()
Exemplo n.º 5
0
    def save_as(self, event=None):
        """ @brief Save As callback from main menu.
        """

        # Open a file dialog to get target
        df = dialogs.save_as(self.directory, extension='.cad')

        if df[1] != '':
            self.directory, self.filename = df
            self.save()
Exemplo n.º 6
0
    def save_as(self, event=None):
        """ @brief Save As callback from main menu.
        """

        # Open a file dialog to get target
        df = dialogs.save_as(self.directory, extension='.cad')

        if df[1] != '':
            self.directory, self.filename = df
            self.save()
Exemplo n.º 7
0
    def export_from_asdf(self, filetype):
        asdf = koko.FAB.panels[0].input

        if filetype == '.stl':
            kwargs = {}
        elif filetype == '.png':
            dlg = dialogs.RenderDialog('.png export', asdf)
            if dlg.ShowModal() == wx.ID_OK:
                kwargs = dlg.results
            else:
                kwargs = None
            dlg.Destroy()
        elif filetype == '.asdf':
            kwargs = {}

        if kwargs is None: return

        # Open up a save as dialog to get the export target
        df = dialogs.save_as(self.directory, extension=filetype)
        if df[1] == '': return
        path = os.path.join(*df)

        koko.TASKS.export(asdf, path, **kwargs)
Exemplo n.º 8
0
    def export_from_asdf(self, filetype):
        asdf = koko.FAB.panels[0].input

        if filetype == '.stl':
            kwargs = {}
        elif filetype == '.png':
            dlg = dialogs.RenderDialog('.png export', asdf)
            if dlg.ShowModal() == wx.ID_OK:
                kwargs = dlg.results
            else:
                kwargs = None
            dlg.Destroy()
        elif filetype == '.asdf':
            kwargs = {}

        if kwargs is None:  return

        # Open up a save as dialog to get the export target
        df = dialogs.save_as(self.directory, extension=filetype)
        if df[1] == '':     return
        path = os.path.join(*df)

        koko.TASKS.export(asdf, path, **kwargs)
Exemplo n.º 9
0
    def export_from_cad(self, filetype):
        cad = koko.TASKS.cached_cad

        if 'failed' in koko.FRAME.status:
            dialogs.warning('Design has errors!  Export failed.')
            return
        elif cad is None:
            dialogs.warning(
                'Design needs to be rendered before exporting!  Export failed')
            return
        elif koko.TASKS.export_task:
            dialogs.warning('Export already in progress.')
            return
        elif filetype in ['.png', '.svg'] and any(
                getattr(cad, b) is None
                for b in ['xmin', 'xmax', 'ymin', 'ymax']):
            dialogs.warning('Design needs to be bounded along X and Y axes ' +
                            'to export %s' % filetype)
            return
        elif filetype in ['.stl', '.asdf'] and any(
                getattr(cad, b) is None
                for b in ['xmin', 'xmax', 'ymin', 'ymax', 'zmin', 'zmax']):
            dialogs.warning('Design needs to be bounded on all axes ' +
                            'to export %s' % filetype)
            return
        elif filetype == '.svg' and cad.zmin is not None:
            dialogs.warning('Design must be flat (without z bounds)' +
                            ' to export .svg')
            return

        # Open up a dialog box to get the export resolution or settings
        if filetype == '.asdf':
            dlg = dialogs.ResolutionDialog(10, '.asdf export', cad)
            key = None
        elif filetype == '.stl':
            dlg = dialogs.ResolutionDialog(10, '.stl export', cad,
                                           'Watertight')
            key = 'use_cms'
        elif filetype == '.png':
            dlg = dialogs.ResolutionDialog(10, '.stl export', cad, 'Heightmap')
            key = 'make_heightmap'
        elif filetype in '.svg':
            dlg = dialogs.ResolutionDialog(10, '.svg export', cad)
            key = None
        elif filetype == '.dot':
            dlg = dialogs.CheckDialog('.dot export', 'Packed arrays')
            key = 'dot_arrays'
        else:
            dlg = None

        if dlg:
            if dlg.ShowModal() == wx.ID_OK:
                kwargs = {}
                if isinstance(dlg, dialogs.ResolutionDialog):
                    kwargs.update({'resolution': float(dlg.result)})
                if key:
                    kwargs.update({key: dlg.checked})
            else:
                kwargs = None
            dlg.Destroy()
        else:
            kwargs = {}

        # If we didn't get a valid resolution, then abort
        if kwargs is None: return

        # Open up a save as dialog to get the export target
        df = dialogs.save_as(self.directory, extension=filetype)
        if df[1] == '': return
        path = os.path.join(*df)

        koko.TASKS.export(cad, path, **kwargs)
Exemplo n.º 10
0
    def export_from_cad(self, filetype):
        cad = koko.TASKS.cached_cad

        if 'failed' in koko.FRAME.status:
            dialogs.warning('Design has errors!  Export failed.')
            return
        elif cad is None:
            dialogs.warning('Design needs to be rendered before exporting!  Export failed')
            return
        elif koko.TASKS.export_task:
            dialogs.warning('Export already in progress.')
            return
        elif filetype in ['.png','.svg'] and any(
                getattr(cad,b) is None
                for b in ['xmin','xmax','ymin','ymax']):
            dialogs.warning('Design needs to be bounded along X and Y axes ' +
                            'to export %s' % filetype)
            return
        elif filetype in ['.stl','.asdf'] and any(
                getattr(cad,b) is None
                for b in ['xmin','xmax','ymin','ymax','zmin','zmax']):
            dialogs.warning('Design needs to be bounded on all axes '+
                            'to export %s' % filetype)
            return
        elif filetype == '.svg' and cad.zmin is not None:
            dialogs.warning('Design must be flat (without z bounds)'+
                            ' to export .svg')
            return


        # Open up a dialog box to get the export resolution or settings
        if filetype == '.asdf':
            dlg = dialogs.ResolutionDialog(10, '.asdf export', cad)
            key = None
        elif filetype == '.stl':
            dlg = dialogs.ResolutionDialog(10, '.stl export',
                                   cad, 'Watertight')
            key = 'use_cms'
        elif filetype == '.png':
            dlg = dialogs.ResolutionDialog(
                10, '.stl export', cad, 'Heightmap'
            )
            key = 'make_heightmap'
        elif filetype in '.svg':
            dlg = dialogs.ResolutionDialog(
                10, '.svg export', cad
            )
            key = None
        elif filetype == '.dot':
            dlg = dialogs.CheckDialog('.dot export', 'Packed arrays')
            key = 'dot_arrays'
        else:
            dlg = None

        if dlg:
            if dlg.ShowModal() == wx.ID_OK:
                kwargs = {}
                if isinstance(dlg, dialogs.ResolutionDialog):
                    kwargs.update({'resolution': float(dlg.result)})
                if key:
                    kwargs.update({key: dlg.checked})
            else:
                kwargs = None
            dlg.Destroy()
        else:
                kwargs = {}

        # If we didn't get a valid resolution, then abort
        if kwargs is None:  return

        # Open up a save as dialog to get the export target
        df = dialogs.save_as(self.directory, extension=filetype)
        if df[1] == '':     return
        path = os.path.join(*df)

        koko.TASKS.export(cad, path, **kwargs)
Exemplo n.º 11
0
    def export(self, event):
        ''' General-purpose export callback.  Decides which export
            command to call based on the menu item text.'''

        item = koko.FRAME.GetMenuBar().FindItemById(event.GetId())
        filetype = item.GetLabel()

        cad = koko.TASKS.cached_cad

        if 'failed' in koko.FRAME.status:
            dialogs.warning('Design has errors!  Export failed.')
            return
        elif cad is None:
            dialogs.warning('Design needs to be rendered before exporting!  Export failed')
            return
        elif koko.TASKS.export_task:
            dialogs.warning('Export already in progress.')
            return
        elif filetype in ['.png','.svg'] and any(
                getattr(cad,b) is None
                for b in ['xmin','xmax','ymin','ymax']):
            dialogs.warning('Design needs to be bounded along X and Y axes ' +
                            'to export %s' % filetype)
            return
        elif filetype in ['.stl','.asdf'] and any(
                getattr(cad,b) is None
                for b in ['xmin','xmax','ymin','ymax','zmin','zmax']):
            dialogs.warning('Design needs to be bounded on all axes '+
                            'to export %s' % filetype)
            return
        elif filetype == '.svg' and cad.zmin is not None:
            dialogs.warning('Design must be flat (without z bounds)'+
                            ' to export .svg')
            return


        # Open up a dialog box to get the export resolution or settings
        if filetype == '.asdf':
            dlg = dialogs.ResolutionDialog(10, '.asdf export',
                                   cad, 'Merge leaf cells')
        elif filetype == '.stl':
            dlg = dialogs.ResolutionDialog(10, '.stl export',
                                   cad, 'Watertight')
        elif filetype == '.png':
            dlg = dialogs.ResolutionDialog(10, '.stl export',
                                   cad, 'Heightmap')
        elif filetype in '.svg':
            dlg = dialogs.ResolutionDialog(10, '%s export' % filetype,
                                    cad)
        elif filetype == '.dot':
            dlg = dialogs.CheckDialog('.dot export', 'Packed arrays')
        else:
            dlg = None

        if dlg and dlg.ShowModal() == wx.ID_OK:
            resolution = dlg.result
            checked    = dlg.checked
            success = True
        elif dlg:
            success = False
        else:
            resolution = None
            checked = None
            success = True
        if dlg: dlg.Destroy()

        # If we didn't get a valid resolution, then abort
        if not success:  return

        # Open up a save as dialog to get the export target
        df = dialogs.save_as(self.directory, extension=filetype)
        if df[1] == '':     return
        path = os.path.join(*df)

        koko.TASKS.export(path, resolution, checked)