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()
def onCopyPath(self, event): from ifigure.mto.fig_plot import FigPlot from ifigure.mto.fig_fill import FigFill if self._hit_path is not None: canvas = event.GetEventObject() v = self._hit_path.vertices if self.getp('FillMode'): obj = FigFill(v[:, 0], v[:, 1]) else: obj = FigPlot(v[:, 0], v[:, 1], 'k') ax = self.get_figaxes() name = ax.get_next_name('Contour_path') ax.add_child(name, obj) obj.realize() ax.set_bmp_update(False) canvas.draw() artists = [weakref.ref(obj._artists[0])] h = [UndoRedoAddRemoveArtists(artists=artists, mode=0)] window = canvas.GetTopLevelParent() GlobalHistory().get_history(window).make_entry( h, menu_name='add path plot')
def onGeneratePatch(self, event): from ifigure.mto.fig_fill import FigFill if self._hit_a is not None: canvas = event.GetEventObject() x, y = self._hit_a.get_xy() w = self._hit_a.get_width() h = self._hit_a.get_height() x = [x, x + w, x + w, x, x] y = [y, y, y + h, y + h, y] obj = FigFill(x, y, color=self.getvar('color')) ax = self.get_figaxes() name = ax.get_next_name('HistBin') ax.add_child(name, obj) obj.realize() ax.set_bmp_update(False) canvas.draw() artists = [weakref.ref(obj._artists[0])] h = [UndoRedoAddRemoveArtists(artists=artists, mode=0)] window = canvas.GetTopLevelParent() GlobalHistory().get_history(window).make_entry( h, menu_name='add histbin')