コード例 #1
0
    def setpickregion(self, canvas, tag):
        obj = canvas.getObjectByTag(tag)
        if obj.kind != 'rectangle':
            return True
        canvas.deleteObjectByTag(tag, redraw=False)

        if self.picktag:
            try:
                canvas.deleteObjectByTag(self.picktag, redraw=False)
            except:
                pass

        # determine center of rectangle
        x = obj.x1 + (obj.x2 - obj.x1) // 2
        y = obj.y1 + (obj.y2 - obj.y1) // 2

        tag = canvas.add(CanvasTypes.CompoundObject(
            CanvasTypes.Rectangle(obj.x1,
                                  obj.y1,
                                  obj.x2,
                                  obj.y2,
                                  color=self.pickcolor),
            CanvasTypes.Point(x, y, 10, color='red'),
            CanvasTypes.Text(obj.x1,
                             obj.y2 + 4,
                             "Pick: calc",
                             color=self.pickcolor)),
                         redraw=False)
        self.picktag = tag

        #self.fv.raise_tab("detail")
        return self.redo()
コード例 #2
0
ファイル: PixTable.py プロジェクト: astrofrog/ginga
    def add_mark(self, data_x, data_y, radius=None, color=None, style=None):
        if not radius:
            radius = self.mark_radius
        if not color:
            color = self.mark_color
        if not style:
            style = self.mark_style

        self.logger.debug("Setting mark at %d,%d" % (data_x, data_y))
        self.mark_index += 1
        tag = 'mark%d' % (self.mark_index)
        tag = self.canvas.add(CanvasTypes.CompoundObject(
            CanvasTypes.Point(data_x,
                              data_y,
                              self.mark_radius,
                              style=style,
                              color=color,
                              linestyle='solid'),
            CanvasTypes.Text(data_x + 10,
                             data_y,
                             "%d" % (self.mark_index),
                             color=color)),
                              tag=tag)
        self.marks.append(tag)
        self.w.marks.append_text(tag)
        self.select_mark(tag, pan=False)
コード例 #3
0
ファイル: Histogram.py プロジェクト: astrofrog/ginga
    def draw_cb(self, canvas, tag):
        obj = canvas.getObjectByTag(tag)
        if obj.kind != 'rectangle':
            return True
        canvas.deleteObjectByTag(tag, redraw=False)

        if self.histtag:
            try:
                canvas.deleteObjectByTag(self.histtag, redraw=False)
            except:
                pass

        tag = canvas.add(CanvasTypes.CompoundObject(
            CanvasTypes.Rectangle(obj.x1, obj.y1, obj.x2, obj.y2,
                                  color=self.histcolor),
            CanvasTypes.Text(obj.x1, obj.y2+4, "Histogram",
                             color=self.histcolor)))
        self.histtag = tag

        return self.redo()
コード例 #4
0
ファイル: Cuts.py プロジェクト: astrofrog/ginga
    def draw_cb(self, canvas, tag):
        obj = canvas.getObjectByTag(tag)
        if obj.kind != 'line':
            return True
        canvas.deleteObjectByTag(tag, redraw=False)

        # calculate center of line
        wd = obj.x2 - obj.x1
        dw = wd // 2
        ht = obj.y2 - obj.y1
        dh = ht // 2
        x, y = obj.x1 + dw + 4, obj.y1 + dh + 4

        if self.cutstag:
            # Replacing a cut
            print "replacing cut position"
            cutobj = canvas.getObjectByTag(self.cutstag)
            line = cutobj.objects[0]
            line.x1, line.y1, line.x2, line.y2 = obj.x1, obj.y1, obj.x2, obj.y2
            text = cutobj.objects[1]
            text.x, text.y = x, y

        else:
            # Adding new cut
            print "adding cut position"
            self.count += 1
            tag = "cuts%d" % (self.count)
            canvas.add(CanvasTypes.CompoundObject(
                CanvasTypes.Line(obj.x1,
                                 obj.y1,
                                 obj.x2,
                                 obj.y2,
                                 color='cyan',
                                 cap='ball'),
                CanvasTypes.Text(x, y, "cuts%d" % self.count, color='cyan')),
                       tag=tag)

            self.addCutsTag(tag, select=True)

        print "redoing cut plots"
        return self.redo()