Example #1
0
    def dragdone_a(self, a, evt, shift=None, scale=None):
        shift = evt.guiEvent.ShiftDown()
        redraw, scale0 = super(FigCurve, self).dragdone_a(a, evt, 
                                     shift = shift, scale=scale)
        if self._drag_mode == 3:
            self._drag_mode = 2

        h = []

        if self._drag_hit != -1:
           figure = self.get_containter()
           if figure.patches.count(self._drag_artist)!=0:
              figure.patches.remove(self._drag_artist)
              self._drag_artist = None
           p=[item for item in self.get_path()]
           dx = evt.x - self._st_p[0]
           dy = evt.y - self._st_p[1]
           p = self.move_path(p, self._drag_hit, dx, dy)

           self._drag_hit = -1
           h = h + [UndoRedoFigobjMethod(self._artists[0], 
                                      'pathdata', p)]
           scale0 = [1, 0, 0, 1, 0, 0]
        else:
           h = h + self.scale_artist(scale0, action = True)

#        hist = self.get_root_parent().app.history
        window = evt.guiEvent.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
        hist.start_record()         
        for item in h: hist.add_history(item)  
        hist.stop_record()            
        return 0, scale0
Example #2
0
    def dragdone_a(self, a, evt, shift=None, scale=None):

        shift = evt.guiEvent.ShiftDown()
        redraw, scale0 = super(FigArrow, self).dragdone_a(a, evt, 
                                     shift = shift, scale=scale)

        dx1=0
        dx2=0
        dy1=0
        dy2=0

        h = []
        if scale is None:
            dx = evt.x - self._st_p[0] 
            dy = evt.y - self._st_p[1]
            if self._drag_mode & 1 != 0:
               dx1=dx
               dy1=dy
            if self._drag_mode & 2 != 0:
               dx2=dx
               dy2=dy
            a1=  self.move_gp_points(0, dx1, dy1, action=True)
            a2=  self.move_gp_points(1, dx2, dy2, action=True)
            h.append(a1)
            h.append(a2)
        else:
            h = h + self.scale_artist(scale, action = True)

        window = evt.guiEvent.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)

        hist.start_record()         
        for item in h: hist.add_history(item)  
        hist.stop_record()            
        return 0, scale0
Example #3
0
    def dragdone_a(self, a, evt, shift=None, scale=None):
        shift = evt.guiEvent.ShiftDown()
        redraw, scale0 = super(FigCurve, self).dragdone_a(a, evt,
                                                          shift=shift, scale=scale)
        if self._drag_mode == 3:
            self._drag_mode = 2

        h = []

        if self._drag_hit != -1:
            figure = self.get_containter()
            if figure.patches.count(self._drag_artist) != 0:
                figure.patches.remove(self._drag_artist)
                self._drag_artist = None
            p = [item for item in self.get_path()]
            dx = evt.x - self._st_p[0]
            dy = evt.y - self._st_p[1]
            p = self.move_path(p, self._drag_hit, dx, dy)

            self._drag_hit = -1
            h = h + [UndoRedoFigobjMethod(self._artists[0],
                                          'pathdata', p)]
            scale0 = [1, 0, 0, 1, 0, 0]
        else:
            h = h + self.scale_artist(scale0, action=True)

#        hist = self.get_root_parent().app.history
        window = evt.guiEvent.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
        hist.start_record()
        for item in h:
            hist.add_history(item)
        hist.stop_record()
        return 0, scale0
Example #4
0
    def dragdone_a(self, a, evt, shift=None, scale=None):
        shift = evt.guiEvent.ShiftDown()
        redraw, scale0 = super(FigLegend, self).dragdone_a(a,
                                                           evt,
                                                           shift=shift,
                                                           scale=scale)
        x = min(self._drag_rec[:2])
        y = min(self._drag_rec[2:])

        bbx = a.get_bbox_to_anchor()
        pos = mpltransforms.BboxTransformFrom(bbx).transform_point((x, y))

        h = [
            UndoRedoFigobjMethod(a, 'legendloc',
                                 (True, self.getp('legendloc'), pos))
        ]

        window = evt.guiEvent.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
        self._hit_a = None
        self._picker_a_mode = 0
        #        h = h + self.scale_artist(scale0, action = True)

        if len(h) != 0:
            hist.start_record()
            for item in h:
                hist.add_history(item)
            hist.stop_record()
        return 0, scale0
Example #5
0
    def onRmNode(self, evt):
        p = self.get_path()
        p = cbook.BezierRmnode(p, self._drag_hit)
        if p is None:
            pass

        window = evt.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
        #       hist = self.get_root_parent().app.history
        hist.start_record()
        hist.add_history(UndoRedoFigobjMethod(self._artists[0], 'pathdata', p))
        hist.stop_record()
Example #6
0
    def onRmNode(self, evt):
        p = self.get_path()
        p = cbook.BezierRmnode(p, self._drag_hit)
        if p is None: 
            pass

        window = evt.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
 #       hist = self.get_root_parent().app.history
        hist.start_record()         
        hist.add_history(UndoRedoFigobjMethod(self._artists[0], 
                         'pathdata', p))
        hist.stop_record()            
Example #7
0
    def dragdone(self, a, evt):
        if evt.inaxes is None: return 0

        x, y = self.get_dragged_node(evt)
        #        app = evt.guiEvent.GetEventObject().GetTopLevelParent()
        #        hist = app.history
        window = evt.guiEvent.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
        hist.start_record()
        action1 = UndoRedoFigobjMethod(a, 'splinenode', (x, y))
        hist.add_history(action1)
        hist.stop_record()
        return 1
Example #8
0
    def dragdone(self, a, evt):
        if evt.inaxes is None: return 0 

        x, y = self.get_dragged_node(evt)
#        app = evt.guiEvent.GetEventObject().GetTopLevelParent()
#        hist = app.history
        window = evt.guiEvent.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
        hist.start_record()            
        action1 = UndoRedoFigobjMethod(a, 'splinenode', (x, y))
        hist.add_history(action1)
        hist.stop_record()            
        return 1
Example #9
0
    def onConvLine(self, evt):
        segpath = cbook.BezierSplit(self.get_path())
        p = segpath[self._hit_seg_i]
        segpath[self._hit_seg_i] = [p[0], (mpath.Path.LINETO, p[-1][1], 0)]
        path = cbook.BezierJoin(segpath)

        window = evt.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
        #        hist = self.get_root_parent().app.history
        hist.start_record()
        hist.add_history(
            UndoRedoFigobjMethod(self._artists[0], 'pathdata', path))
        hist.stop_record()
Example #10
0
    def onAddNode(self, evt):
        fig_page = self.get_figpage()
        xy = self._artists[0].get_verts()
        path = self.get_path()
        hit, idx = cbook.BezierHitTest(path, self._st_p[0], self._st_p[1])
        if hit:
            path = cbook.BezierInsert(path, idx, self._st_p[0], self._st_p[1])
            window = evt.GetEventObject().GetTopLevelParent()
            hist = GlobalHistory().get_history(window)
#            hist = self.get_root_parent().app.history
            hist.start_record()         
            hist.add_history(UndoRedoFigobjMethod(self._artists[0], 
                             'pathdata', path))
            hist.stop_record()
Example #11
0
    def onAddNode(self, evt):
        fig_page = self.get_figpage()
        xy = self._artists[0].get_verts()
        path = self.get_path()
        hit, idx = cbook.BezierHitTest(path, self._st_p[0], self._st_p[1])
        if hit:
            path = cbook.BezierInsert(path, idx, self._st_p[0], self._st_p[1])
            window = evt.GetEventObject().GetTopLevelParent()
            hist = GlobalHistory().get_history(window)
#            hist = self.get_root_parent().app.history
            hist.start_record()
            hist.add_history(UndoRedoFigobjMethod(self._artists[0],
                                                  'pathdata', path))
            hist.stop_record()
Example #12
0
    def dragdone_a(self, a, evt, shift=None, scale=None):
        shift = evt.guiEvent.ShiftDown()
        redraw, scale0 = super(FigCircle, self).dragdone_a(a, evt, 
                                     shift = shift, scale=scale)
        window = evt.guiEvent.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
#        hist = selfget_root_parent().app.history
        h = []
        h = h + self.scale_artist(scale0, action = True)

        hist.start_record()         
        for item in h: hist.add_history(item)  
        hist.stop_record()            
        return 0, scale0
Example #13
0
    def onConvLine(self, evt):
        segpath=cbook.BezierSplit(self.get_path())
        p = segpath[self._hit_seg_i]
        segpath[self._hit_seg_i] = [p[0], 
                                    (mpath.Path.LINETO, p[-1][1], 0)]
        path = cbook.BezierJoin(segpath)

        window = evt.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
#        hist = self.get_root_parent().app.history
        hist.start_record()         
        hist.add_history(UndoRedoFigobjMethod(self._artists[0], 
                             'pathdata', path))
        hist.stop_record()
Example #14
0
    def onMakeAsym(self, evt):
        p = self.get_path()
        p = [p[i] for i in range(len(p))]
        p[self._drag_hit]=(p[self._drag_hit][0],p[self._drag_hit][1],3)
        p[self._drag_hit-1]=(p[self._drag_hit-1][0],p[self._drag_hit-1][1],3)
        p[self._drag_hit+1]=(p[self._drag_hit+1][0],p[self._drag_hit+1][1],3)

        window = evt.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
#        hist = self.get_root_parent().app.history
        hist.start_record()         
        hist.add_history(UndoRedoFigobjMethod(self._artists[0], 
                         'pathdata', p))
        hist.stop_record()            
Example #15
0
    def dragdone_a(self, a, evt, shift=None, scale=None):
        shift = evt.guiEvent.ShiftDown()
        redraw, scale0 = super(FigCircle, self).dragdone_a(a, evt,
                                                           shift=shift, scale=scale)
        window = evt.guiEvent.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
#        hist = selfget_root_parent().app.history
        h = []
        h = h + self.scale_artist(scale0, action=True)

        hist.start_record()
        for item in h:
            hist.add_history(item)
        hist.stop_record()
        return 0, scale0
Example #16
0
    def onMakeAsym(self, evt):
        p = self.get_path()
        p = [p[i] for i in range(len(p))]
        p[self._drag_hit] = (p[self._drag_hit][0], p[self._drag_hit][1], 3)
        p[self._drag_hit - 1] = (p[self._drag_hit - 1][0],
                                 p[self._drag_hit - 1][1], 3)
        p[self._drag_hit + 1] = (p[self._drag_hit + 1][0],
                                 p[self._drag_hit + 1][1], 3)

        window = evt.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
        #        hist = self.get_root_parent().app.history
        hist.start_record()
        hist.add_history(UndoRedoFigobjMethod(self._artists[0], 'pathdata', p))
        hist.stop_record()
Example #17
0
    def onConvCurve(self, evt):
        segpath=cbook.BezierSplit(self.get_path())
        p = segpath[self._hit_seg_i]
        x0, y0 = p[0][1]
        x1, y1 = p[-1][1]
        segpath[self._hit_seg_i] = [p[0], 
               (mpath.Path.CURVE4, (x0*0.7+x1*0.3, y0*0.7+y1*0.3), p[0][2]),
               (mpath.Path.CURVE4, (x0*0.3+x1*0.7, y0*0.3+y1*0.7), 2),
               (mpath.Path.CURVE4, p[-1][1], 2)]
        path = cbook.BezierJoin(segpath)

        window = evt.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
        hist.start_record()         
        hist.add_history(UndoRedoFigobjMethod(self._artists[0], 
                             'pathdata', path))
        hist.stop_record()
Example #18
0
    def onRmNode(self, evt):
        if self._hit_artist == -1: return
        if self._hit_idx == -1: return

        x = self.getp("x")
        y = self.getp("y")
        xn = [x[i] for i in range(len(x)) if i != self._hit_idx]
        yn = [y[i] for i in range(len(y)) if i != self._hit_idx]

        #        app = evt.GetEventObject().GetTopLevelParent()
        window = evt.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
        hist.start_record()
        a = self._artists[self._hit_artist[0]]
        action1 = UndoRedoFigobjMethod(a, 'splinenode', (xn, yn))
        hist.add_history(action1)
        hist.stop_record()
Example #19
0
    def onRmNode(self, evt):
        if self._hit_artist == -1: return
        if self._hit_idx    == -1: return

        x = self.getp("x")
        y = self.getp("y")
        xn = [x[i] for i in range(len(x)) if i != self._hit_idx]
        yn = [y[i] for i in range(len(y)) if i != self._hit_idx]

#        app = evt.GetEventObject().GetTopLevelParent()
        window = evt.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
        hist.start_record()            
        a = self._artists[self._hit_artist[0]]
        action1 = UndoRedoFigobjMethod(a,
                                       'splinenode', (xn, yn))
        hist.add_history(action1)
        hist.stop_record()            
Example #20
0
    def onAddNode(self, evt):
        if self._hit_artist == -1: return
        if self._hit_seg == -1: return

        #_hit_artist = (artist index, mpl event)
        idx = long(self._hit_seg / self._mesh)
        x = [p for p in self.getp("x")]
        y = [p for p in self.getp("y")]
        x.insert(idx, self._hit_artist[1].xdata)
        y.insert(idx, self._hit_artist[1].ydata)

        window = evt.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
        hist.start_record()
        a = self._artists[self._hit_artist[0]]
        action1 = UndoRedoFigobjMethod(a, 'splinenode', (x, y))
        hist.add_history(action1)
        hist.stop_record()
Example #21
0
    def onConvCurve(self, evt):
        segpath = cbook.BezierSplit(self.get_path())
        p = segpath[self._hit_seg_i]
        x0, y0 = p[0][1]
        x1, y1 = p[-1][1]
        segpath[self._hit_seg_i] = [p[0],
                                    (mpath.Path.CURVE4,
                                     (x0*0.7+x1*0.3, y0*0.7+y1*0.3), p[0][2]),
                                    (mpath.Path.CURVE4,
                                     (x0*0.3+x1*0.7, y0*0.3+y1*0.7), 2),
                                    (mpath.Path.CURVE4, p[-1][1], 2)]
        path = cbook.BezierJoin(segpath)

        window = evt.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
        hist.start_record()
        hist.add_history(UndoRedoFigobjMethod(self._artists[0],
                                              'pathdata', path))
        hist.stop_record()
Example #22
0
    def onAddNode(self, evt):
        if self._hit_artist == -1: return
        if self._hit_seg    == -1: return

        #_hit_artist = (artist index, mpl event)
        idx = long(self._hit_seg/self._mesh)
        x = [p for p in self.getp("x")]
        y = [p for p in self.getp("y")]
        x.insert(idx, self._hit_artist[1].xdata)
        y.insert(idx, self._hit_artist[1].ydata)

        window = evt.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
        hist.start_record()            
        a = self._artists[self._hit_artist[0]]
        action1 = UndoRedoFigobjMethod(a,
                                       'splinenode', (x, y))
        hist.add_history(action1)
        hist.stop_record()            
Example #23
0
    def dragdone_a(self, a, evt, shift = None, scale=None):
        shift = evt.guiEvent.ShiftDown()
        redraw, scale0 = super(FigGrp, self).dragdone_a(a, evt, 
                                     shift = shift, scale=scale)

                
        window = evt.guiEvent.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
#        hist = self.get_root_parent().app.history
        h = self.scale_artist(scale0, action = True)
        if len(h) != 0:
           hist.start_record()         
           for item in h: hist.add_history(item)  
           hist.stop_record()            
        for name, child in self.get_children():
            for a1 in child.walk_artists():
                child.dragdone_a_clean(a1)
                child.highlight_artist(False, artist=[a1])       
        self.highlight_artist(False, artist=[a])       
#        self.highlight_artist(True, artist=[a])       
        return 0, scale0
Example #24
0
    def dragdone_a(self, a, evt, shift=None, scale=None):
        shift = evt.guiEvent.ShiftDown()
        redraw, scale0 = super(FigGrp, self).dragdone_a(a,
                                                        evt,
                                                        shift=shift,
                                                        scale=scale)

        window = evt.guiEvent.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
        #        hist = self.get_root_parent().app.history
        h = self.scale_artist(scale0, action=True)
        if len(h) != 0:
            hist.start_record()
            for item in h:
                hist.add_history(item)
            hist.stop_record()
        for name, child in self.get_children():
            for a1 in child.walk_artists():
                child.dragdone_a_clean(a1)
                child.highlight_artist(False, artist=[a1])
        self.highlight_artist(False, artist=[a])
        #        self.highlight_artist(True, artist=[a])
        return 0, scale0
Example #25
0
    def dragdone_a(self, a, evt, shift=None, scale=None):
        shift = evt.guiEvent.ShiftDown()
        redraw, scale0 = super(FigLegend, self).dragdone_a(a, evt, 
                                     shift = shift, scale=scale)
        x = min(self._drag_rec[:2])
        y = min(self._drag_rec[2:])

        bbx = a.get_bbox_to_anchor()
        pos =  mpltransforms.BboxTransformFrom(bbx).transform_point((x,y))

        h = [UndoRedoFigobjMethod(a, 'legendloc', 
                                  (True, self.getp('legendloc'), pos))]

        window = evt.guiEvent.GetEventObject().GetTopLevelParent()
        hist = GlobalHistory().get_history(window)
        self._hit_a = None
        self._picker_a_mode = 0
#        h = h + self.scale_artist(scale0, action = True)

        if len(h) != 0:
           hist.start_record()         
           for item in h: hist.add_history(item)  
           hist.stop_record()            
        return 0, scale0