Exemple #1
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)
Exemple #2
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
Exemple #3
0
 def _checkup_edge_only_leftbottom(self, areas, idx):
     '''
    idx  = 1 : bottom
    idx  = 0 : left
    '''
     fig = self.figure
     f_page = fig.figobj
     f_axes_arr = []
     ac = []
     for f_axes in f_page.walk_axes():
         if f_axes.getp("area") in areas:
             edge_only = f_axes.get_edge_only()
             if f_axes.getp("area") != areas[0]:
                 edge_only[idx] = True
                 ac.append(
                     UndoRedoFigobjMethod(f_axes._artists[0], 'edge_only',
                                          edge_only))
             else:
                 edge_only[idx] = False
                 ac.append(
                     UndoRedoFigobjMethod(f_axes._artists[0], 'edge_only',
                                          edge_only))
             f_axes_arr.append(f_axes)
     f_axes_arr = [
         b[1]
         for b in sorted([(a.getp("area")[idx], a) for a in f_axes_arr])
     ]
     return f_axes_arr, ac
Exemple #4
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')
Exemple #5
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')
Exemple #6
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
Exemple #7
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])
Exemple #8
0
 def make_rangeparam_action0(self, artist, value):
     '''
     this one does call handle_axes_change
     '''
     dprint1('make_rangeparam_action0 is obsolete and should not be used')
     def f(obj = artist.figobj, name = value[0]):
           obj.call_handle_axes_change(name)
     action = UndoRedoFigobjMethod(artist, 
                                   'axrangeparam', value,
                                   finish_action=f)
     action.set_extrainfo(self.name)
     return action
Exemple #9
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
Exemple #10
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
Exemple #11
0
    def make_rangeparam_action0(self, artist, value):
        '''
        this one does call handle_axes_change
        '''
        dprint1('make_rangeparam_action0 is obsolete and should not be used')

        def f(obj=artist.figobj, name=value[0]):
            obj.call_handle_axes_change(name)

        action = UndoRedoFigobjMethod(artist,
                                      'axrangeparam',
                                      value,
                                      finish_action=f)
        action.set_extrainfo(self.name)
        return action
Exemple #12
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
Exemple #13
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()
Exemple #14
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
Exemple #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
Exemple #16
0
    def onMakeSym(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], 1)

        d1 = np.sqrt((p[self._drag_hit][1][0]-p[self._drag_hit-1][1][0])**2 +
                     (p[self._drag_hit][1][1]-p[self._drag_hit-1][1][1])**2)
        d2 = np.sqrt((p[self._drag_hit][1][0]-p[self._drag_hit+1][1][0])**2 +
                     (p[self._drag_hit][1][1]-p[self._drag_hit+1][1][1])**2)
        dx = p[self._drag_hit+1][1][0]-p[self._drag_hit-1][1][0]
        dy = p[self._drag_hit+1][1][1]-p[self._drag_hit-1][1][1]
        dx1 = 1/np.sqrt(dx*dx+dy*dy)*dx*(d1+d2)/2
        dy1 = 1/np.sqrt(dx*dx+dy*dy)*dy*(d1+d2)/2
        p[self._drag_hit-1] = (p[self._drag_hit-1][0],
                               (p[self._drag_hit][1][0]-dx1,
                                p[self._drag_hit][1][1]-dy1),
                               1)
        p[self._drag_hit+1] = (p[self._drag_hit+1][0],
                               (p[self._drag_hit][1][0]+dx1,
                                p[self._drag_hit][1][1]+dy1),
                               1)
        hist = self.get_root_parent().app.history
        hist.start_record()
        hist.add_history(UndoRedoFigobjMethod(self._artists[0],
                                              'pathdata', p))
        hist.stop_record()
Exemple #17
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
Exemple #18
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
Exemple #19
0
    def make_range_actions(self, request):
        actions = []
        for x in request:
            p = self.get_axis_param(x[0])
            if not self.isempty():
                if p is None: continue
                a = self.get_axes_artist_by_name(x[0])[0]
                actions.append(p.make_rangeparam_action(a,  x[1])) 
            else:
                action = UndoRedoFigobjMethod(None, 
                                              'axrangeparam', x[1], figobj=self)
                action.set_extrainfo(x[0])
                actions.append(action)
#        x = request[-1]
#        p = self.get_axis_param(x[0])
#        a = self.get_axes_artist_by_name(x[0])[0]
#        actions.append(p.make_rangeparam_action0(a,  x[1])) 
        return actions
Exemple #20
0
    def onEditPoint(self, evt):
        def add_list(l, name, self, idx):
            value = self.getp(name)
            l.append([name, str(value[idx]), 0, None])

        from ifigure.utils.edit_list import DialogEditList
        l = []
        names = ['x', 'y']
        if self.getp('xerr') is not None:
            names.append('xerr')
        if self.getp('yerr') is not None:
            names.append('yerr')
        for name in names:
            add_list(l, name, self, self._figc_hit)

        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 = _copy(self.getp('x'))
        x[self._figc_hit] = v[names.index('x')]
        y = _copy(self.getp('y'))
        y[self._figc_hit] = v[names.index('y')]
        yerr = _copy(self.getp('yerr'))
        if yerr is not None:
            yerr[self._figc_hit] = v[names.index('yerr')]
        xerr = _copy(self.getp('xerr'))
        if xerr is not None:
            xerr[self._figc_hit] = v[names.index('xerr')]

        actions = [UndoRedoFigobjMethod(self._artists[0],
                                        'data', (x, y)), ]
        if self._mpl_cmd != 'plot':
            actions.append(UndoRedoFigobjMethod(self._artists[0],
                                                'errdata', (xerr, yerr)))
        window = evt.GetEventObject().GetTopLevelParent()
        GlobalHistory().get_history(window).make_entry(actions)
        return 1
Exemple #21
0
 def onAddPoint(self, evt):
     x = self.getp('x').copy()
     y = self.getp('y').copy()
     v = self.getp('enabled_point')[:]
     if self._figc_hit < x.size:
         x = np.insert(x, self._figc_hit + 1, self._drag_backup[0][0])
         v.insert(self._figc_hit + 1, True)
     else:
         y = np.insert(y, self._figc_hit + 1 - x.size,
                       self._drag_backup[1][0])
         v.insert(self._figc_hit + 1, True)
     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,
                                                    menu_name='add point')
     return 1
Exemple #22
0
    def onDelPoint(self, evt):
        x = self.getp('x').copy()
        y = self.getp('y').copy()
        v = self.getp('enabled_point')[:]
        if self._figc_hit < x.size:
            x = np.delete(x, self._figc_hit)
            del v[self._figc_hit]
        else:
            y = np.delete(y, self._figc_hit - x.size)
            del v[self._figc_hit]

        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, menu_name='delete point')
        return 1
Exemple #23
0
    def onResetCommon(self, evt):
        fig = self.parent._figure
        f_page = fig.figobj
        ac = []
        request = []
        for f_axes in f_page.walk_axes():
            ac.append(
                UndoRedoFigobjMethod(f_axes._artists[0], 'edge_only',
                                     [False] * 4))
            ac.append(
                UndoRedoFigobjMethod(f_axes._artists[0], 'extra_margin',
                                     [0, 0, 0, 0]))
            request.append(('m', f_page.get_iaxes(f_axes), f_axes.get_area()))

        ### finish up
        send_area_request(self.parent,
                          request=request,
                          ac=ac,
                          name='reset common axis')
Exemple #24
0
 def move_gp_points(self, index, dx, dy, action=True):
     gp = self.get_gp(index)
     new_x, new_y = gp.calc_new_points(dx, dy)
     if action:
         action1 = UndoRedoFigobjMethod(self._artists[0],
                                        'gppoint' + str(index),
                                        (new_x, new_y))
         return action1
     else:
         m = getattr(self, 'set_' + name1)
         m((new_x, new_y))
Exemple #25
0
    def make_range_actions(self, request):
        actions = []
        for x in request:
            p = self.get_axis_param(x[0])
            if not self.isempty():
                if p is None: continue
                a = self.get_axes_artist_by_name(x[0])[0]
                actions.append(p.make_rangeparam_action(a, x[1]))
            else:
                action = UndoRedoFigobjMethod(None,
                                              'axrangeparam',
                                              x[1],
                                              figobj=self)
                action.set_extrainfo(x[0])
                actions.append(action)
#        x = request[-1]
#        p = self.get_axis_param(x[0])
#        a = self.get_axes_artist_by_name(x[0])[0]
#        actions.append(p.make_rangeparam_action0(a,  x[1]))
        return actions
Exemple #26
0
    def change_figobj_axes(self, figobj, value, direction):
        if len(self.selection) == 0: return
        h = []
        if direction != 'c':
            for a in self.selection:
                h.append(UndoRedoFigobjMethod(a(), 'container_idx', value))
            figmds = get_figmds(a().figobj)
            if figmds is not None:
                if len(figmds._artists) > 0:
                    h.append(
                        UndoRedoFigobjMethod(figmds._artists[0],
                                             'container_idx', value))
        else:
            for a in self.selection:
                h.append(UndoRedoFigobjMethod(a(), 'caxis_idx', value))
        ax = a().axes
        h.append(UndoRedoFigobjMethod(ax, 'adjustrange', None))

        window = self.GetTopLevelParent()
        GlobalHistory().get_history(window).make_entry(h, use_reverse=False)
Exemple #27
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()
Exemple #28
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
Exemple #29
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()
Exemple #30
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
Exemple #31
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()
Exemple #32
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')
Exemple #33
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()
Exemple #34
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
Exemple #35
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')
Exemple #36
0
 def make_rangeparam_action(self, artist, value):
     action = UndoRedoFigobjMethod(artist, 
                                   'axrangeparam', value)
     action.set_extrainfo(self.name)
     return action