예제 #1
0
 def func(evt, value=a0[k], i0=i, h=holder, gp = self):
     id = h._gp_points.index(gp)
     action1 = UndoRedoFigobjMethod(h._artists[0],
                                    'gp_trans', value)
     action1.set_extrainfo((id, i0))
     window = evt.GetEventObject().GetTopLevelParent()
     hist = GlobalHistory().get_history(window)
     hist.make_entry([action1], menu_name = 'change trans')
예제 #2
0
 def func(evt, value=a0[k], i0=i, h=holder, gp=self):
     id = h._gp_points.index(gp)
     action1 = UndoRedoFigobjMethod(h._artists[0], 'gp_trans',
                                    value)
     action1.set_extrainfo((id, i0))
     window = evt.GetEventObject().GetTopLevelParent()
     hist = GlobalHistory().get_history(window)
     hist.make_entry([action1], menu_name='change trans')
예제 #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
예제 #4
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
예제 #5
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
예제 #6
0
    def SetCanvasValue2(self, artist=None):
        a = self.h_slider.GetValue()
        b = self.v_slider.GetValue()
        c = self.use_def.IsChecked()

        se = self.GetParent().GetParent().GetParent()
        pe = se.GetParent()
        canvas = pe.get_canvas()

        f_page = (canvas.get_figure()).figobj
        if se.area_hit in se.area:
            idx = se.area.index(se.area_hit)
        else:
            se.area_hit = se.area[0]
            idx = 0

        f_axes = f_page.get_child(idx)
        if f_axes is None: return
        ac = [
            UndoRedoFigobjProperty(f_axes._artists[0], 'use_def_margin', c),
        ]
        window = self.GetTopLevelParent()
        GlobalHistory().get_history(window).make_entry(
            ac, menu_name='use default margin')
        wx.CallAfter(self.GetParent().GetParent().GetParent().SetEditorValue)
        return
        f_axes.setp("use_def_margin", c)
        f_page.realize()
        canvas.draw()
        self.GetParent().GetParent().GetParent().SetEditorValue()
예제 #7
0
 def onEditPoint(self, evt):
     x, y = self._eval_xy()
     if self._figc_hit < x.size:
         l = [
             ['x', str(x[self._figc_hit]), 0, None],
         ]
     else:
         l = [
             ['y', str(y[self._figc_hit - x.size]), 0, None],
         ]
     window = evt.GetEventObject().GetTopLevelParent()
     value = DialogEditList(l,
                            modal=True,
                            style=wx.DEFAULT_DIALOG_STYLE
                            | wx.RESIZE_BORDER,
                            tip=None,
                            parent=window)
     if value[0]:
         v = value[1]
     else:
         return
     x = self.getp('x').copy()
     y = self.getp('y').copy()
     if self._figc_hit < x.size:
         x[self._figc_hit] = float(v[0])
     else:
         y[self._figc_hit - x.size] = v[0]
     action = UndoRedoFigobjMethod(self._artists[0], 'data', (x, y))
     window = evt.GetEventObject().GetTopLevelParent()
     GlobalHistory().get_history(window).make_entry([action])
     return 1
예제 #8
0
    def dragdone(self, a, evt):
        axes = a.axes
        x, y = self._eval_xy()
        dxd, dyd = self._drag_delta

        if (evt.xdata is not None and evt.ydata is not None):
            i = 0
            xdata = []
            ydata = []
            for x0 in nd_iter(x):
                xd, void = transform_point(axes.transData, x0, evt.ydata)
                x1, void = transform_point(axes.transData.inverted(), xd + dxd,
                                           void)
                xdata.append(x1)
                i = i + 1
            for y0 in nd_iter(y):
                void, yd = transform_point(axes.transData, evt.xdata, y0)
                void, y1 = transform_point(axes.transData.inverted(), void,
                                           yd + dyd)
                ydata.append(y1)

                i = i + 1
        else:
            xdata = x
            ydata = y

        action = UndoRedoFigobjMethod(self._artists[0], 'data',
                                      (np.array(xdata), np.array(ydata)))
        window = evt.guiEvent.GetEventObject().GetTopLevelParent()
        GlobalHistory().get_history(window).make_entry([action])
        return 1
예제 #9
0
 def onDelPoint(self, evt):
     v = self.getp('enabled_point')[:]
     x = self.getp('x').copy()
     y = self.getp('y').copy()
     del v[self._figc_hit]
     vm = self.getp('marked_point')[:]
     del vm[self._figc_hit]
     x = np.delete(x, self._figc_hit)
     y = np.delete(y, self._figc_hit)
     actions = [UndoRedoFigobjMethod(self._artists[0],
                                     'data', (x, y)), ]
     if self._mpl_cmd != 'plot':
         xerr = _copy(self.getp('xerr'))
         yerr = _copy(self.getp('yerr'))
         if xerr is not None:
             xerr = np.delete(xerr, self._figc_hit)
         if yerr is not None:
             yerr = np.delete(yerr, self._figc_hit)
         actions.append(UndoRedoFigobjMethod(self._artists[0],
                                             'errdata', (xerr, yerr)))
     actions.append(UndoRedoFigobjMethod(self._artists[0],
                                         'enabled_point', v))
     actions.append(UndoRedoFigobjMethod(self._artists[0],
                                         'marked_point', vm))
     window = evt.GetEventObject().GetTopLevelParent()
     GlobalHistory().get_history(window).make_entry(actions)
     return 1
예제 #10
0
    def SetCanvasValue(self, artist=None):
        a = self.h_slider.GetValue()
        b = self.v_slider.GetValue()
        c = self.use_def.IsChecked()

        se = self.GetParent().GetParent().GetParent()
        pe = se.GetParent()
        canvas = pe.get_canvas()

        f_page = (canvas.get_figure()).figobj
        idx = se.area.index(se.area_hit)
        f_axes = f_page.get_child(idx)

        ac = []
        if c:
            ac.append(
                UndoRedoFigobjMethod(canvas.get_figure(), 'def_margin',
                                     [a[0], 1. - a[1], b[0], 1. - b[1]]))
        else:
            ac.append(
                UndoRedoFigobjMethod(f_axes._artists[0], 'margin',
                                     [a[0], 1. - a[1], b[0], 1. - b[1]]))
        window = self.GetTopLevelParent()
        GlobalHistory().get_history(window).make_entry(ac, menu_name='margin')
        wx.CallAfter(self.GetParent().GetParent().GetParent().SetEditorValue)
예제 #11
0
    def SetCanvasValue(self, axes=None, request=None, ac=None, name='area'):
        ifig_canvas = self.parent.get_canvas()
        if request is None:
            ifig_canvas.set_area(self.area)
        else:
            fig_page = ifig_canvas._figure.figobj
            if ac is None: ac = []
            for mode, idx, value in request:
                if mode == 'm':  #modify
                    fig_axes = fig_page.get_axes(idx)
                    ac.append(
                        UndoRedoFigobjMethod(fig_axes._artists[0], 'area',
                                             value))
                elif mode == 'a':  # add
                    iax = fig_page.add_axes(area=value)
                    ax = fig_page.get_axes(iax)
                    ax.realize()
                    sel = [weakref.ref(ax._artists[0])]
                    ac.append(UndoRedoAddRemoveArtists(artists=sel, mode=0))
                elif mode == 'd':  # delete
                    fig_axes = fig_page.get_axes(idx)
                    sel = [weakref.ref(a) for a in fig_axes._artists]
                    ac.append(UndoRedoAddRemoveArtists(artists=sel, mode=1))

            window = self.GetTopLevelParent()
            GlobalHistory().get_history(window).make_entry(ac, menu_name=name)

        ifig_canvas.draw()
예제 #12
0
            def func(evt, value=a0[k], holder=self):
                ac = []
                for i in range(holder.num_gp()):
                    action1 = UndoRedoFigobjMethod(self._artists[0],
                                                   'gp_trans', value)
                    action1.set_extrainfo((i, 0))
                    action2 = UndoRedoFigobjMethod(self._artists[0],
                                                   'gp_trans', value)
                    action2.set_extrainfo((i, 1))
                    ac.append(action1)
                    ac.append(action2)
#                    gp = holder.get_gp(i)
#                    holder.change_gp_trans(gp, 0, value)
#                    holder.change_gp_trans(gp, 1, value)
                window = evt.GetEventObject().GetTopLevelParent()
                hist = GlobalHistory().get_history(window)
                hist.make_entry(ac, menu_name='change trans')
예제 #13
0
            def func(evt, value=a0[k], holder=self):
                ac = []
                for i in range(holder.num_gp()):
                    action1 = UndoRedoFigobjMethod(self._artists[0],
                                                  'gp_trans', value)
                    action1.set_extrainfo((i, 0))
                    action2 = UndoRedoFigobjMethod(self._artists[0],
                                                  'gp_trans', value)
                    action2.set_extrainfo((i, 1))
                    ac.append(action1)
                    ac.append(action2)
#                    gp = holder.get_gp(i)
#                    holder.change_gp_trans(gp, 0, value)
#                    holder.change_gp_trans(gp, 1, value) 
                window = evt.GetEventObject().GetTopLevelParent()
                hist = GlobalHistory().get_history(window)
                hist.make_entry(ac, menu_name = 'change trans')
예제 #14
0
    def dragdone(self, a, evt, idx = 'all'):
        axes = a.axes
        x, y = self._eval_xy()
        x = x.copy()
        y = y.copy()
        dxd, dyd = self._drag_delta

        if (evt.xdata is not  None and
            evt.ydata is not None):
            i = 0
            xdata = []
            ydata = []
            for x0 in x:
                x1 = x0[:]
                if idx == 'all' or idx == i: 
                    if (self._drag_mode==1 or 
                       self._drag_mode==2):
                       xd, void= transform_point(axes.transData,
                                              x0[0], evt.ydata)
                       x1[0], void= transform_point(axes.transData.inverted(),
                                              xd+dxd, void)
                    if (self._drag_mode==1 or 
                       self._drag_mode==3):
                       xd, void= transform_point(axes.transData,
                                              x0[1], evt.ydata)
                       x1[1], void= transform_point(axes.transData.inverted(),
                                              xd+dxd, void)
                xdata.append(x1)
                i = i + 1        
            for y0 in y:
                y1 = y0[:]
                if idx == 'all' or idx == i: 
                    if (self._drag_mode==1 or 
                        self._drag_mode==4):
                        void, yd= transform_point(axes.transData,
                                          evt.xdata, y0[0])
                        void, y1[0]= transform_point(axes.transData.inverted(),
                                          void, yd+dyd)
                    if (self._drag_mode==1 or 
                        self._drag_mode==5):
                        void, yd= transform_point(axes.transData,
                                          evt.xdata, y0[1])
                        void, y1[1]= transform_point(axes.transData.inverted(),
                                          void, yd+dyd)
                ydata.append(y1)
                i = i + 1        
        else:
            xdata = x
            ydata = y

        xdata = np.array(xdata)
        ydata = np.array(ydata)
        action = UndoRedoFigobjMethod(self._artists[0], 
                                     'data', (xdata,ydata))

        window = evt.guiEvent.GetEventObject().GetTopLevelParent()
        GlobalHistory().get_history(window).make_entry([action])
        return 1
예제 #15
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
예제 #16
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()
예제 #17
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()
예제 #18
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
예제 #19
0
    def onAddPoint(self, evt):
        axes = self._artists[0].axes
        if axes is None:
            return
        x = self.getp('x').copy()
        y = self.getp('y').copy()
        xed, yed = axes.transData.transform(self._figc_hit_pos)

        for k in range(x.size-1):
            x0 = x[k]
            y0 = y[k]
            x1 = x[k+1]
            y1 = y[k+1]
            x0d, y0d = axes.transData.transform([x0, y0])
            x1d, y1d = axes.transData.transform([x1, y1])
            d = np.sqrt((x0d-x1d)**2 + (y0d-y1d)**2)
            m1 = ((x1d-xed)*(x1d-x0d) + (y1d-yed)*(y1d-y0d))/d/d
            if (m1 < 0 or m1 > 1):
                continue
            m2 = ((x1d-xed)*(y1d-y0d) - (y1d-yed)*(x1d-x0d))/d
            if (m2 > 5 or m2 < -5):
                continue
            break
        else:
            return 1

        v = self.getp('enabled_point')[:]
        x = self.getp('x').copy()
        y = self.getp('y').copy()
        v.insert(k+1, True)
        vm = self.getp('marked_point')[:]
        vm.insert(k+1, True)

        x = np.insert(x, k+1, self._figc_hit_pos[0])
        y = np.insert(y, k+1, self._figc_hit_pos[1])
        actions = [UndoRedoFigobjMethod(self._artists[0],
                                        'data', (x, y)), ]
        if self._mpl_cmd != 'plot':
            xerr = _copy(self.getp('xerr'))
            yerr = _copy(self.getp('yerr'))
            if xerr is not None:
                xerr = np.insert(xerr, k+1, xerr[k])
            if yerr is not None:
                yerr = np.insert(yerr, k+1, yerr[k])
            actions.append(UndoRedoFigobjMethod(self._artists[0],
                                                'errdata', (xerr, yerr)))
        actions.append(UndoRedoFigobjMethod(self._artists[0],
                                            'enabled_point', v))
        actions.append(UndoRedoFigobjMethod(self._artists[0],
                                            'marked_point', vm))

        window = evt.GetEventObject().GetTopLevelParent()
        GlobalHistory().get_history(window).make_entry(actions)
        return 1
예제 #20
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()
예제 #21
0
 def onDelSpan(self, evt):
     x, y = self._eval_xy()
     x = x.copy()
     y = y.copy()
     if self._figc_hit < x.size:
         x = np.array([xx for i, xx in enumerate(x) if i != self._figc_hit])
     else:
         y = np.array(
             [xx for i, xx in enumerate(y) if i != self._figc_hit - len(x)])
     action = UndoRedoFigobjMethod(self._artists[0], 'data', (x, y))
     window = evt.GetEventObject().GetTopLevelParent()
     GlobalHistory().get_history(window).make_entry([action])
     return 1
예제 #22
0
    def onEnablePoint(self, evt):
        v = self.getp('enabled_point')[:]
        v[self._figc_hit] = True
        x = self.getp('x').copy()
        y = self.getp('y').copy()

        actions = [
            UndoRedoFigobjMethod(self._artists[0], 'enabled_point', v),
            UndoRedoFigobjMethod(self._artists[0], 'data', (x, y))
        ]
        window = evt.GetEventObject().GetTopLevelParent()
        GlobalHistory().get_history(window).make_entry(actions)
        return 1
예제 #23
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()
예제 #24
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
예제 #25
0
    def onDisablePoint(self, evt):
        v = self.getp('enabled_point')[:]
        v[self._figc_hit] = False

        # x, y is the same, this triggers control_changed_callback
        x = self.getp('x').copy()
        y = self.getp('y').copy()
        actions = [UndoRedoFigobjMethod(self._artists[0],
                                        'data', (x, y)),
                   UndoRedoFigobjMethod(self._artists[0],
                                        'enabled_point', v)]
        window = evt.GetEventObject().GetTopLevelParent()
        GlobalHistory().get_history(window).make_entry(actions)
        return 1
예제 #26
0
 def finish_text_edit(x,
                      y,
                      txt,
                      target_artist=self._artists[0],
                      obj=canvas,
                      tab=str(idx + 1)):
     self = obj
     if tab != '0':
         a1 = UndoRedoFigobjMethod(target_artist, 'legendlabel', txt)
         a1.set_extrainfo(tab)
     else:
         a1 = UndoRedoFigobjMethod(target_artist, 'title', txt)
     window = self.GetTopLevelParent()
     GlobalHistory().get_history(window).make_entry([a1])
예제 #27
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
예제 #28
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()            
예제 #29
0
    def send_range_action(self, requests, menu_name='edit'):
        a = []
        f = []
        for key in requests:
            if len(requests[key]) > 0:
                a.extend(key.make_range_actions(requests[key]))
                name = requests[key][0][0]
                f.append(
                    (weakref.ref(key), 'call_handle_axes_change', (name, )))
#            f.append((ifigure.events, 'SendRangeChangedEvent', (key,)))
        if len(a) == 0: return
        window = self.GetTopLevelParent()
        GlobalHistory().get_history(window).make_entry(a,
                                                       finish_action=f,
                                                       menu_name=menu_name)
예제 #30
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()
예제 #31
0
    def dragdone(self, a, evt):
        if evt.xdata is None: return

        x = self._artists[0].get_xdata()
        y = self._artists[0].get_ydata()
        x[self._figc_hit] = self._drag_backup[0]
        y[self._figc_hit] = self._drag_backup[1]

        x = self._artists[0].get_xdata().copy()
        y = self._artists[0].get_ydata().copy()
        x[self._figc_hit] = evt.xdata
        y[self._figc_hit] = evt.ydata
        action = UndoRedoFigobjMethod(self._artists[0], 'data', (x, y))
        window = evt.guiEvent.GetEventObject().GetTopLevelParent()
        GlobalHistory().get_history(window).make_entry([action])
        return 1
예제 #32
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()
예제 #33
0
    def dragdone_a(self, a, evt, sfift=None, scale=None):
        if self._picker_a_type == 'area':
            shift = evt.guiEvent.ShiftDown()
        else:
            shift = True
        redraw, scale0 = super(FigText, self).dragdone_a(a,
                                                         evt,
                                                         shift=shift,
                                                         scale=scale)

        window = evt.guiEvent.GetEventObject().GetTopLevelParent()

        #        hist = self.get_root_parent().app.history
        h = self.scale_artist(scale0, action=True)
        GlobalHistory().get_history(window).make_entry(h)
        return 0, scale0
예제 #34
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()
예제 #35
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
예제 #36
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()            
예제 #37
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()
예제 #38
0
    def SetCanvasValue(self, artist=None):
        a = self.h_slider.GetValue()
        b = self.v_slider.GetValue()

        se = self.GetParent().GetParent().GetParent()
        pe = se.GetParent()
        canvas = pe.get_canvas()

        f_page = (canvas.get_figure()).figobj
        ac = []
        ac.append(
            UndoRedoFigobjMethod(canvas.get_figure(), 'page_margin',
                                 [a[0], 1. - a[1], b[0], 1. - b[1]]))
        window = self.GetTopLevelParent()
        GlobalHistory().get_history(window).make_entry(ac,
                                                       menu_name='page margin')
        wx.CallAfter(self.GetParent().GetParent().GetParent().SetEditorValue)
예제 #39
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()
예제 #40
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()
예제 #41
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()            
예제 #42
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()            
예제 #43
0
파일: fig_grp.py 프로젝트: piScope/piScope
    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
예제 #44
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
예제 #45
0
 def onClipTextByAxes(evt, figobj=self):
     action1 = UndoRedoFigobjProperty(figobj._artists[0],
                                      'clip', not self.getp('clip'))
     window = evt.GetEventObject().GetTopLevelParent()
     hist = GlobalHistory().get_history(window)
     hist.make_entry([action1], menu_name = 'clipping')