except Exception, e:
                debug('Import failed due to %s' % (str(e)))

    @log_call
    def OnExportButton(self, evt):
        """Called on Export... button
        """
        dlg = wx.FileDialog(self,
                            message="Save file as ...",
                            defaultDir=os.getcwd(),
                            defaultFile="camera_params.json",
                            wildcard="Json (*.json)|*.json|",
                            style=wx.SAVE)
        ret = dlg.ShowModal()
        if ret == wx.ID_OK:
            path = dlg.GetPath()
            try:
                camera = self.target.renderer.GetActiveCamera()
                data = dict(position=tuple(camera.GetPosition()),
                            focal_point=tuple(camera.GetFocalPoint()),
                            view_up=tuple(camera.GetViewUp()),
                            parallel_scale=camera.GetParallelScale())
                ofile = open(path, 'w')
                ofile.write(json.dumps(data))
                ofile.close()
            except Exception, e:
                debug('Export failed due to %s' % (str(e)))


register_inspector_page('ParticleVisualizerNode', ParticleVisualizerInspector)
            except Exception, e:
                debug('Import failed due to %s' %(str(e)))
            self.target.propagate_down(UpdateEvent(None))

    @log_call
    def OnExportButton(self, evt):
        """Called on Export... button
        """
        dlg = wx.FileDialog(
            self, message="Save file as ...", defaultDir=os.getcwd(),
            defaultFile="camera_params.json", wildcard="Json (*.json)|*.json|",
            style=wx.SAVE)
        ret = dlg.ShowModal()
        if ret==wx.ID_OK:
            path = dlg.GetPath()
            try:
                camera = self.target.renderer.GetActiveCamera()
                data = dict(
                    position=tuple(camera.GetPosition()),
                    focal_point=tuple(camera.GetFocalPoint()),
                    view_up=tuple(camera.GetViewUp()),
                    parallel_scale=camera.GetParallelScale())
                ofile = open(path, 'w')
                ofile.write(json.dumps(data))
                ofile.close()
            except Exception, e:
                debug('Export failed due to %s' %(str(e)))


register_inspector_page('ParticleSpaceVisualizerNode', ParticleSpaceVisualizerInspector)
            sid = self.listbox.GetString(idx)
            if self.listbox.IsChecked(idx):
                if sid in self.target.ignore_list:
                    self.target.ignore_list.remove(sid)
            else:
                if sid not in self.target.ignore_list:
                    self.target.ignore_list.append(sid)

            self.target.internal_update()
            for child in self.target.children:
                child.propagate_down(UpdateEvent(None))

    @log_call
    def update(self):
        """Update UI.
        """
        self.target.update_list(**self.target.kwargs_cache)
        if self.target.sid_list is not None:
            self.listbox.SetItems(self.target.sid_list)
            for i, sid in enumerate(self.target.sid_list):
                if sid not in self.target.ignore_list:
                    self.listbox.Check(i, True)

register_inspector_page('ParticleSpaceFilterNode', ParticleSpaceFilterInspector)


if __name__=='__main__':
    # TBD
    from doctest import testmod, ELLIPSIS
    testmod(optionflags = ELLIPSIS)
Exemple #4
0
    """Datasource inspector page.
    """
    def __init__(self, *args, **kwargs):
        """Initializer.
        """
        InspectorPage.__init__(self, *args, **kwargs)
        label = wx.StaticText(self, -1, 'URI')
        text = wx.TextCtrl(self, -1, '', style=wx.TE_READONLY)
        self.uri_text = text
        h_sizer = wx.BoxSizer(wx.HORIZONTAL)
        h_sizer.Add(label, 0, wx.EXPAND | wx.ALL, 0)
        h_sizer.Add(text, 1, wx.EXPAND | wx.ALL, 0)
        # self.sizer comes from parent.
        self.sizer.Add(h_sizer, 0, wx.EXPAND | wx.ALL, 10)

    def update(self):
        """Update UI.
        """
        if (self.target and hasattr(self.target, 'datasource')
                and self.target.datasource.uri):
            self.uri_text.SetValue(self.target.datasource.uri)
        else:
            self.uri_text.SetValue('')


register_inspector_page('RootPipelineNode', DatasourceInspectorPage)

if __name__ == '__main__':
    # TBD
    pass
        node = hdf5_data.get(current_path)
        debug('selected node: %s' %node)
        # for node having attrs, populate attrs grid.
        if hasattr(node, 'attrs'):
            n_attrs = len(node.attrs.items())
            grid = self.attr_grid
            grid.InsertRows(0, n_attrs)
            for row_idx, (key, value) in enumerate(node.attrs.items()):
                grid.SetCellValue(row_idx, 0, key)
                grid.SetCellValue(row_idx, 1, "%s" %value)
        # for node having value (implies dataset), populate values grid.
        if hasattr(node, 'value'):
            grid = self.vals_grid
            labels = node.dtype.names
            n_labels = len(labels)
            grid.InsertCols(0, n_labels)
            grid.InsertRows(0, node.len())
            for i, label in enumerate(labels):
                grid.SetColLabelValue(i, label)
            for row_idx, row_data in enumerate(node.value):
                for col_idx in range(n_labels):
                    grid.SetCellValue(row_idx, col_idx, "%s" %row_data[col_idx])
            
register_inspector_page('SimpleHdf5TreeVisualizerNode', SimpleHdf5TreeInspector)


if __name__=='__main__':
    # TBD
    from doctest import testmod, ELLIPSIS
    testmod(optionflags=ELLIPSIS)
        # for node having attrs, populate attrs grid.
        if hasattr(node, 'attrs'):
            n_attrs = len(node.attrs.items())
            grid = self.attr_grid
            grid.InsertRows(0, n_attrs)
            for row_idx, (key, value) in enumerate(node.attrs.items()):
                grid.SetCellValue(row_idx, 0, key)
                grid.SetCellValue(row_idx, 1, "%s" % value)
        # for node having value (implies dataset), populate values grid.
        if hasattr(node, 'value'):
            grid = self.vals_grid
            labels = node.dtype.names
            n_labels = len(labels)
            grid.InsertCols(0, n_labels)
            grid.InsertRows(0, node.len())
            for i, label in enumerate(labels):
                grid.SetColLabelValue(i, label)
            for row_idx, row_data in enumerate(node.value):
                for col_idx in range(n_labels):
                    grid.SetCellValue(row_idx, col_idx,
                                      "%s" % row_data[col_idx])


register_inspector_page('SimpleHdf5TreeVisualizerNode',
                        SimpleHdf5TreeInspector)

if __name__ == '__main__':
    # TBD
    from doctest import testmod, ELLIPSIS
    testmod(optionflags=ELLIPSIS)
        self.sizer.Add(n_data_label, 0, wx.ALL|wx.EXPAND, 5)
        self.sizer.Add(n_data, 0, wx.ALL|wx.EXPAND, 5)
        self.sizer.Add(cursor_label, 0, wx.ALL|wx.EXPAND, 5)
        self.sizer.Add(cursor_spin, 0, wx.ALL|wx.EXPAND, 5)
        self.sizer.Add(data_label, 0, wx.ALL|wx.EXPAND, 5)
        self.sizer.Add(data_text, 0, wx.ALL|wx.EXPAND, 5)
        self.n_data = n_data
        self.cursor_spin = cursor_spin
        self.data_text = data_text

    @log_call
    def OnCursorSpin(self, event):
        if self.target:
            self.target.index_cursor = self.cursor_spin.GetValue()
        self.target.propagate_down(UpdateEvent(None))

    def update(self):
        self.n_data.SetValue("%s" %self.target.n_data)
        self.cursor_spin.SetRange(0, self.target.n_data)
        self.cursor_spin.SetValue(self.target.index_cursor)
        self.data_text.SetValue("%s" %self.target.selected_data)


register_inspector_page('SequentialHdf5SelectorNode', SequentialHdf5SelectorInspector)


if __name__=='__main__':
    # TBD
    from doctest import testmod, ELLIPSIS
    testmod(optionflags=ELLIPSIS)
    @log_call
    def update(self):
        """Update UI.
        """
        if self.target and hasattr(self.target, 'hdf5_data'):
            hdf5_data = self.target.hdf5_data
            debug('hdf5_data at %s' % (hdf5_data))
            if hdf5_data:
                # glob attributes from the hdf5 data.
                for prop_name in self.PROP_NAMES:
                    widget = getattr(self, prop_name, None)
                    prop_value = getattr(hdf5_data, prop_name, None)
                    if widget and prop_value:
                        widget.SetValue(str(prop_value))
                return
        # else fallback
        debug('**** not found: %s, %s' % (self.target, self.target.hdf5_data))
        for prop_name in self.PROP_NAMES:
            widget = getattr(self, prop_name, None)
            if widget:
                widget.SetValue('')


register_inspector_page('SimpleHdf5LoaderNode', SimpleHdf5LoaderInspector)

if __name__ == '__main__':
    # TBD
    from doctest import testmod, ELLIPSIS
    testmod(optionflags=ELLIPSIS)
    @log_call
    def update(self):
        """Update UI.
        """
        if self.target and hasattr(self.target, 'hdf5_data'):
            hdf5_data = self.target.hdf5_data
            debug('hdf5_data at %s' %(hdf5_data))
            if hdf5_data:
                # glob attributes from the hdf5 data.
                for prop_name in self.PROP_NAMES:
                    widget = getattr(self, prop_name, None)
                    prop_value = getattr(hdf5_data, prop_name, None)
                    if widget and prop_value:
                        widget.SetValue(str(prop_value))
                return
        # else fallback
        debug('**** not found: %s, %s' %(self.target, self.target.hdf5_data))
        for prop_name in self.PROP_NAMES:
            widget = getattr(self, prop_name, None)
            if widget:
                widget.SetValue('')


register_inspector_page('SimpleHdf5LoaderNode', SimpleHdf5LoaderInspector)


if __name__=='__main__':
    # TBD
    from doctest import testmod, ELLIPSIS
    testmod(optionflags=ELLIPSIS)
Exemple #10
0
            if self.listbox.IsChecked(idx):
                if sid in self.target.ignore_list:
                    self.target.ignore_list.remove(sid)
            else:
                if sid not in self.target.ignore_list:
                    self.target.ignore_list.append(sid)

            self.target.internal_update()
            for child in self.target.children:
                child.propagate_down(UpdateEvent(None))

    @log_call
    def update(self):
        """Update UI.
        """
        self.target.update_list(**self.target.kwargs_cache)
        if self.target.sid_list is not None:
            self.listbox.SetItems(self.target.sid_list)
            for i, sid in enumerate(self.target.sid_list):
                if sid not in self.target.ignore_list:
                    self.listbox.Check(i, True)


register_inspector_page('ParticleSpaceFilterNode',
                        ParticleSpaceFilterInspector)

if __name__ == '__main__':
    # TBD
    from doctest import testmod, ELLIPSIS
    testmod(optionflags=ELLIPSIS)
        self.sizer.Add(n_data_label, 0, wx.ALL | wx.EXPAND, 5)
        self.sizer.Add(n_data, 0, wx.ALL | wx.EXPAND, 5)
        self.sizer.Add(cursor_label, 0, wx.ALL | wx.EXPAND, 5)
        self.sizer.Add(cursor_spin, 0, wx.ALL | wx.EXPAND, 5)
        self.sizer.Add(data_label, 0, wx.ALL | wx.EXPAND, 5)
        self.sizer.Add(data_text, 0, wx.ALL | wx.EXPAND, 5)
        self.n_data = n_data
        self.cursor_spin = cursor_spin
        self.data_text = data_text

    @log_call
    def OnCursorSpin(self, event):
        if self.target:
            self.target.index_cursor = self.cursor_spin.GetValue()
        self.target.propagate_down(UpdateEvent(None))

    def update(self):
        self.n_data.SetValue("%s" % self.target.n_data)
        self.cursor_spin.SetRange(0, self.target.n_data)
        self.cursor_spin.SetValue(self.target.index_cursor)
        self.data_text.SetValue("%s" % self.target.selected_data)


register_inspector_page('SequentialHdf5SelectorNode',
                        SequentialHdf5SelectorInspector)

if __name__ == '__main__':
    # TBD
    from doctest import testmod, ELLIPSIS
    testmod(optionflags=ELLIPSIS)
    def __init__(self, *args, **kwargs):
        """Initializer.
        """
        InspectorPage.__init__(self, *args, **kwargs)
        glob_pattern_label = wx.StaticText(self, -1, 'Glob pattern')
        glob_pattern = wx.TextCtrl(self, -1, "%s" % self.target.glob_pattern)
        self.Bind(wx.EVT_TEXT, self.OnGlobPatternText, glob_pattern)
        self.sizer.Add(glob_pattern_label, 0, wx.ALL | wx.EXPAND, 5)
        self.sizer.Add(glob_pattern, 0, wx.ALL | wx.EXPAND, 5)
        self.glob_pattern = glob_pattern

    @log_call
    def OnGlobPatternText(self, event):
        pattern = self.glob_pattern.GetValue()
        if pattern:
            self.target.glob_pattern = pattern
            self.target.internal_update()
            for child in self.target.children:
                child.propagate_down(UpdateEvent(None))

    def update(self):
        self.glob_pattern.SetValue("%s" % self.target.glob_pattern)


register_inspector_page('Hdf5BundleLoaderNode', Hdf5BundleLoaderInspector)

if __name__ == '__main__':
    # TBD
    from doctest import testmod, ELLIPSIS
    testmod(optionflags=ELLIPSIS)
Exemple #13
0
    def __init__(self, *args, **kwargs):
        """Initializer.
        """
        InspectorPage.__init__(self, *args, **kwargs)
        label = wx.StaticText(self, -1, 'URI')
        text = wx.TextCtrl(self, -1, '', style=wx.TE_READONLY)
        self.uri_text = text
        h_sizer = wx.BoxSizer(wx.HORIZONTAL)
        h_sizer.Add(label, 0, wx.EXPAND|wx.ALL, 0)
        h_sizer.Add(text, 1, wx.EXPAND|wx.ALL, 0)
        # self.sizer comes from parent.
        self.sizer.Add(h_sizer, 0, wx.EXPAND|wx.ALL, 10)

    def update(self):
        """Update UI.
        """
        if (self.target and hasattr(self.target, 'datasource')
            and self.target.datasource.uri):
            self.uri_text.SetValue(self.target.datasource.uri)
        else:
            self.uri_text.SetValue('')
        

register_inspector_page('RootPipelineNode', DatasourceInspectorPage)
    

if __name__=='__main__':
    # TBD
    pass

        """Initializer.
        """
        InspectorPage.__init__(self, *args, **kwargs)
        glob_pattern_label = wx.StaticText(self, -1, 'Glob pattern')
        glob_pattern = wx.TextCtrl(self, -1, "%s" %self.target.glob_pattern)
        self.Bind(wx.EVT_TEXT, self.OnGlobPatternText, glob_pattern)
        self.sizer.Add(glob_pattern_label, 0, wx.ALL|wx.EXPAND, 5)
        self.sizer.Add(glob_pattern, 0, wx.ALL|wx.EXPAND, 5)
        self.glob_pattern = glob_pattern

    @log_call
    def OnGlobPatternText(self, event):
        pattern = self.glob_pattern.GetValue()
        if pattern:
            self.target.glob_pattern = pattern
            self.target.internal_update()
            for child in self.target.children:
                child.propagate_down(UpdateEvent(None))
            
    def update(self):
        self.glob_pattern.SetValue("%s" %self.target.glob_pattern)


register_inspector_page('Hdf5BundleLoaderNode', Hdf5BundleLoaderInspector)


if __name__=='__main__':
    # TBD
    from doctest import testmod, ELLIPSIS
    testmod(optionflags=ELLIPSIS)