Пример #1
0
 def undo_remove(self, data):
     ind, pos = data
     print 'undoing removal of dataset, index %d, position %d' % (ind, pos)
     dataset = Dataset(self, ind)
     dataset.id = dataset.id[1:]
     self.on_dataset_modified(dataset)
     self.datasets.insert(pos, dataset)
     dataset.connect('modified', self.on_dataset_modified)
     self.emit('add-dataset', dataset)
     self.redraw(True)
Пример #2
0
 def undo_remove(self, data):
     ind, pos = data
     print 'undoing removal of dataset, index %d, position %d' % (ind, pos)
     dataset = Dataset(self, ind)
     dataset.id = dataset.id[1:]
     self.on_dataset_modified(dataset)
     self.datasets.insert(pos, dataset)
     dataset.connect('modified', self.on_dataset_modified)
     self.emit('add-dataset', dataset)
     self.redraw(True)
Пример #3
0
    def add(self, state, x, y):
        ind = self.data.datasets.append(worksheet=x.worksheet.id, id=create_id(), 
                                        x=x.name.encode('utf-8'), y=y.name.encode('utf-8'))

        d = Dataset(self, ind)
        self.datasets.append(d)
        pos = len(self.datasets)-1
#        print 'added dataset, index %d, position %d' % (ind, pos)

        d.connect('modified', self.on_dataset_modified)
        d.connect_signals()

        self.on_dataset_modified(d)
        self.emit('add-dataset', d)

        state['obj'] = d

        return pos
Пример #4
0
    def add(self, state, x, y):
        ind = self.data.datasets.append(worksheet=x.worksheet.id,
                                        id=create_id(),
                                        x=x.name.encode('utf-8'),
                                        y=y.name.encode('utf-8'))

        d = Dataset(self, ind)
        self.datasets.append(d)
        pos = len(self.datasets) - 1
        #        print 'added dataset, index %d, position %d' % (ind, pos)

        d.connect('modified', self.on_dataset_modified)
        d.connect_signals()

        self.on_dataset_modified(d)
        self.emit('add-dataset', d)

        state['obj'] = d

        return pos
Пример #5
0
    def __init__(self, project, name=None, parent=None, location=None):
        Item.__init__(self, project, name, parent, location)

        self.paint_xor_objects = False
        self.selected_datasets = []

        self.mode = 'arrow'

        self.graph_objects = []
        self.dragobj = None

        self.selected_object = None

        self.plot_height = 100
        self.plot_width = 100

        self.datasets = []
        if location is not None:
            for i, l in enumerate(self.data.datasets):
                if not l.id.startswith('-'):
                    self.datasets.append(Dataset(self, i))
                    self.datasets[-1].connect('modified',
                                              self.on_dataset_modified)
            for l in self.data.lines:
                if not l.id.startswith('-'):
                    self.graph_objects.append(Line(self, l))
            for l in self.data.text:
                if not l.id.startswith('-'):
                    self.graph_objects.append(Text(self, l))

        self.functions = []
        #        if location is not None:
        #            for i in range(len(self.data.functions)):
        #                if not self.data.functions[i].id.startswith('-'):
        #                    f = Function(self, i)
        #                    self.functions.append(f)
        #                    f.connect('modified', self.on_dataset_modified)
        #                    f.func.connect('modified', self.on_dataset_modified)

        self.ps = False

        self.axis_top = Axis('top', self)
        self.axis_bottom = Axis('bottom', self)
        self.axis_right = Axis('right', self)
        self.axis_left = Axis('left', self)

        self.axes = [
            self.axis_top, self.axis_right, self.axis_bottom, self.axis_left
        ]

        self.grid_h = Grid('horizontal', self)
        self.grid_v = Grid('vertical', self)

        self.set_range(0.0, 100.5)
        if location is None:
            self.xmin, self.ymin = 0, 0
            self.ymax, self.xmax = 10, 10
        self.newf()

        if self.xtype == '':
            self._xtype = 'linear'
        if self.ytype == '':
            self._ytype = 'linear'
        self.selected_function = None

        self.rubberband = Rubberband(self)
        self.cross = Cross(self)
        self.rangehandle = Rangehandle(self)

        self.objects = [self.rubberband, self.cross, self.rangehandle]
        self.textpainter = TextPainter(self)

        self.axis_title_font_size = 12.
        self.background_color = (1., 1., 1., 1.)
        self.pwidth = 120.
        self.pheight = 100.

        self.recalc = True