import os import ifigure.widgets.canvas.custom_picker as cpicker import numpy as np import weakref import logging from ifigure.utils.cbook import ProcessKeywords, LoadImageFile, isdynamic, isiterable from ifigure.utils.args_parser import ArgsParser from matplotlib.path import Path from matplotlib.transforms import Bbox, TransformedPath from matplotlib.colors import Colormap from ifigure.matplotlib_mod.cz_linecollection import CZLineCollection from ifigure.matplotlib_mod.art3d_gl import Line3DCollectionGL, LineGL import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('FigPlot') _decimate_limit = 2500 _decimate_limit_switch = 3 class FigPlot(FigObj, XUser, YUser, ZUser, CUser): ''' FigPlot: an object to handle line and errorbar plot. See help(plot), help(errorbar) for more detail of generating this object from ifigure.interactive ''' def __new__(cls, *args, **kywds): def set_hidden_vars(obj):
# # # History : 0.5 sometime around Apr. 2012 # 0.6 stop() command # 0.7 8/30/12 keyborad interupt # import collections, weakref, os, logging, wx, threading, types, shutil, multiprocessing, sys, traceback import cPickle as pickle from ifigure.mto.py_code import PyCode import ifigure.utils.cbook as cbook import ifigure, ifigure.events import ifigure.widgets.dialog as dialog from ifigure.mto.fileholder import FileHolder import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('PyScript') txt1 = '(job involving GUI access, such as graphics generation,\nshould not use this option.)' class ScriptStop(Exception): def __init__(self, message = ''): super(Exception, self).__init__() self.message = message def __str__(self): return repr(self.messge) class ExitScript(Exception): def __init__(self, message = ''): super(Exception, self).__init__() self.message = message def __str__(self): return repr(self.message)
from matplotlib.lines import Line2D from matplotlib.path import Path from matplotlib.collections import PathCollection import matplotlib import re import os from os.path import expanduser import traceback from distutils.version import LooseVersion from matplotlib.artist import ArtistInspector from ifigure.utils.setting_parser import iFigureSettingParser as SP import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('ifiure_config') isMPL2 = LooseVersion(matplotlib.__version__) >= LooseVersion("2.0") isMPL33 = LooseVersion(matplotlib.__version__) >= LooseVersion("3.3") if isMPL2: # let's use classic for now. import matplotlib.pyplot matplotlib.pyplot.style.use('classic') pickle_protocol = 2 def artist_property_checker(obj, prop, values=None): #print('inspecting', obj, prop) if values is None:
import ifigure.events from matplotlib.lines import Line2D from matplotlib.patches import Rectangle from ifigure.mdsplus.filed_ndarray import FiledNDArray, FiledNDArrayAutoDel from ifigure.mdsplus.mds_job import MDSjob import wx # # debug setting # import ifigure.utils.debug as debug from .utils import parse_server_string debug.debug_default_level = 1 dprint1, dprint2, dprint3 = debug.init_dprints('FigMds') import traceback script_file_name = 'mdsscript.py' panel_text = { 'timetrace': 'required y\noptional x \n(x should monotonically increase)', 'stepplot': 'required y\noptional x \n(x should monotonically increase)', 'plot': 'required y\noptional x, xerr, yerr', 'contour': 'required z\noptional x, y', 'image': 'required z\noptional x, y', 'axline': 'required either x or y', 'axspan': 'required either x or y', 'text': 'required s\noptional x, y', 'surface': 'required z\noptional x, y', 'noplot': ''
from ifigure.utils.cbook import isiterable, isndarray, isdynamic, issequence, isnumber import ifigure import ifigure.events from ifigure.mto.fig_obj import FigObj, mask_negative from ifigure.mto.axis_user import XUser, YUser, ZUser, CUser from ifigure.widgets.canvas.file_structure import * import ifigure.utils.cbook as cbook import ifigure.widgets.canvas.custom_picker as cpicker from ifigure.utils.args_parser import ArgsParser from ifigure.widgets.undo_redo_history import UndoRedoAddRemoveArtists, GlobalHistory from ifigure.utils.triangulation_wrapper import tri_args import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('FigContour') def_clabel_param = { 'use_clabel' : False, 'fontsize': 10, 'fixed_color':False, 'colors' : 'k', 'inline': True, 'inline_spacing': 5, 'fmt': '%1.3f', 'skip':0} default_kargs = {'use_tri': False, 'FillMode': False, 'interp' : 'nearest',
# History : # #******************************************* # Copyright(c) 2012- PSFC, MIT #******************************************* from ifigure.matplotlib_mod.figure_mod import FigureMod as Figure from ifigure.mto.fig_obj import FigObj from ifigure.mto.fig_axes import FigAxes from ifigure.widgets.canvas.file_structure import * import ifigure, os, wx, weakref import ifigure.utils.cbook as cbook import ifigure.events import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('FigPage') frameart_zbase = -100000 # a big number so that it is draw first. class FigPage(FigObj): def __init__(self, figsize=(0.15, 0.1), dpi=72, src=None, *args, **kywds): ###list of page obj ### this is for text, suptitle, and legend ### placed in figure self.figobj = [] super(FigPage, self).__init__() ##left, righ, top, bottom (fraction of rect) self.setp("def_margin", [0.15, 0.1, 0.15, 0.15]) self.setp("figsize", figsize) self.setp("dpi", dpi)
from ifigure.mto.fig_obj import FigObj, mask_negative from ifigure.widgets.canvas.file_structure import * from ifigure.mto.axis_user import XUser, YUser from ifigure.ifigure_config import pick_r import ifigure, os import ifigure.utils.cbook as cbook import ifigure.widgets.canvas.custom_picker as cpicker import numpy as np import weakref from ifigure.widgets.undo_redo_history import UndoRedoArtistProperty,UndoRedoFigobjProperty,UndoRedoFigobjMethod from ifigure.widgets.undo_redo_history import GlobalHistory from ifigure.utils.args_parser import ArgsParser import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('FigSpline') def bs_basis(t): at=abs(t) if t > -1. and t < 1.: return (3*at*at*at-6*at*at+4)/6 if t > -2. and t < 2.: return -(at-2)*(at-2)*(at-2)/6 return 0. def calc_xy(xp, yp, mesh=10, mode=1): if mode == 0: return [p for p in xp], [p for p in yp] xp1 = np.concatenate(([xp[0], xp[0]],xp,[xp[-1], xp[-1]])) yp1 = np.concatenate(([yp[0], yp[0]],yp,[yp[-1], yp[-1]])) ks = range(len(xp)+2)
# # Author : # Syun'ichi Shiraiwa # E-mail : # [email protected] #******************************************* # Copyright(c) 2012- S.Shiraiwa #******************************************* import weakref, os import ifigure.events from ifigure.mto.treedict import TreeDict from ifigure.utils.cbook import isiterable from ifigure.utils.weak_callback import WeakCallback import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('UndoRedoHistory') def weakref_method(meth, callback): weak_obj = weakref.ref(meth.im_self, callback) weak_func = weakref.ref(meth.im_func, callback) return weak_obj, weak_func def weakref_deref(meth_ref): obj = meth_ref[0]() func = meth_ref[1]() meth = getattr(obj, func.__name__) return meth class History(object): def __init__(self): self.old_value = None self.new_value = None
# History : # #******************************************* # Copyright(c) 2012- PSFC, MIT #******************************************* from ifigure.matplotlib_mod.figure_mod import FigureMod as Figure from ifigure.mto.fig_obj import FigObj from ifigure.mto.fig_axes import FigAxes from ifigure.widgets.canvas.file_structure import * import ifigure, os, wx, weakref import ifigure.utils.cbook as cbook import ifigure.events import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('FigPage') frameart_zbase = -100000 # a big number so that it is draw first. class FigPage(FigObj): def __init__(self, figsize=(0.15,0.1), dpi=72, src=None, *args, **kywds): ###list of page obj ### this is for text, suptitle, and legend ### placed in figure self.figobj=[] super(FigPage,self).__init__() ##left, righ, top, bottom (fraction of rect) self.setp("def_margin",[0.15, 0.1, 0.15, 0.15]) self.setp("figsize", figsize) self.setp("dpi",dpi)
from ifigure.widgets.canvas.file_structure import * import ifigure, os import ifigure.widgets.canvas.custom_picker as cpicker import numpy as np import weakref, logging from ifigure.utils.cbook import ProcessKeywords, LoadImageFile, isdynamic from matplotlib.tri import Triangulation from ifigure.matplotlib_mod.triplot_mod import triplot from ifigure.utils.args_parser import ArgsParser from matplotlib import cm from matplotlib.colors import Normalize, colorConverter, LightSource from matplotlib.cm import ScalarMappable from matplotlib.colors import ColorConverter cc = ColorConverter() import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('FigSolid') #from mpl_toolkits.axes_grid1.inset_locator import inset_axes from .gl_compound import GLCompound class FigSolid(GLCompound, FigObj, XUser, YUser, ZUser, CUser): def __new__(cls, *args, **kywds): def set_hidden_vars(obj): obj._objs=[] ## for debug.... obj._data_extent=None return obj if kywds.has_key('src'): obj = FigObj.__new__(cls, *args, **kywds) obj = set_hidden_vars(obj) return obj
instead of pushing the data into pipe, it creates files with two resolutions. main process will open coarse resolution file first. FileNDArray : used in sub process FileNDArrayAutoDel : used in main process, allowing automatic delete of file ''' import tempfile, numpy import numpy, os, time import ifigure.utils.debug as debug debug.debug_default_level = 1 dprint1, dprint2, dprint3 = debug.init_dprints('FigNDArray') import traceback def random_tmp_name(seed='1'): ### generate a random string for an initial work dir from datetime import datetime import hashlib strtime= datetime.now().strftime("%Y-%m-%d %H:%M:%S. %f") #print strtime m=hashlib.md5() m.update(strtime+str(seed)) txt=m.hexdigest() return txt class FiledNDArray(object): def __init__(self, array):
import multiprocessing as mp import threading, Queue, traceback import time, tempfile, wx, select from weakref import WeakKeyDictionary import ifigure.utils.debug as debug debug.debug_default_level = 1 dprint1, dprint2, dprint3 = debug.init_dprints('event_listener') from numpy import ndarray MDSEventReceived = wx.NewEventType() MDSSCOPE_EVT_MDSEVENT = wx.PyEventBinder(MDSEventReceived, 1) mds_event_listener_lock = threading.Lock() listener_thread = None from .event_listener_proc_fake import EventListenerProc, use_event_listener class EventListener(threading.Thread): def __init__(self, *args, **kargs): super(EventListener, self).__init__(*args, **kargs) self.queue = mp.Queue() ## queue to receive message self.task_queue = mp.JoinableQueue() self.listener_proc = EventListenerProc(self.task_queue, self.queue) wx.CallAfter(self.listener_proc.start) self.viewers = WeakKeyDictionary() def run(self, *args, **kargs): while True: # try: event_name = self.queue.get(True) if event_name == 'stop':
from ifigure.mto.axis_user import XUser, YUser from ifigure.mto.fig_obj import set_mpl_all, get_mpl_first import ifigure, os import ifigure.utils.cbook as cbook from ifigure.utils.geom import transform_point import ifigure.widgets.canvas.custom_picker as cpicker from ifigure.widgets.undo_redo_history import GlobalHistory from ifigure.widgets.undo_redo_history import UndoRedoArtistProperty from ifigure.widgets.undo_redo_history import UndoRedoFigobjProperty from ifigure.widgets.undo_redo_history import UndoRedoFigobjMethod import numpy as np import weakref from ifigure.utils.args_parser import ArgsParser import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('FigAxspan') def _special_xy_check(v): ### special check for x and y try: if (len(v) == 2): x0 = v[0] x1 = v[1] if ((isinstance(x0, float) or isinstance(x0, int)) and (isinstance(x1, float) or isinstance(x1, int))): return [[x0, x1]], True for item in v: if len(item) != 2: flag = False except: flag = False return [], flag
# # MDS worker pool for threaded worker and multiprocessing worker. # import multiprocessing as mp import time, weakref, threading, Queue import ifigure.utils.debug as debug debug.debug_default_level = 1 dprint1, dprint2, dprint3 = debug.init_dprints('MDSMPWorkerPool') from ifigure.mdsplus.mds_mpth_proxyworker import MDSMPProxyWorker, MDSTHProxyWorker from ifigure.mdsplus.mds_mpth_directworker import MDSMPDirectWorker, MDSTHDirectWorker jllock = threading.Lock() class MDSWorkerPoolBase(object): job_id = 0 job_list = {} def submit_ana_group(self, ana_group): job_id = MDSWorkerPoolBase.job_id # if hasattr(ana_group[0],'fig_mds'): # print 'submit', ana_group[0].fig_mds() jllock.acquire() MDSWorkerPoolBase.job_list[job_id] = [len(ana_group), weakref.ref(ana_group)] self.tasks.put((job_id, [(a.jobs, a.jobnames) for a in ana_group], ana_group.global_tdi)) jllock.release() MDSWorkerPoolBase.job_id = job_id + 1 def check_ana_group_done(self): from ifigure.mdsplus.mdsscope import GlobalCounter
from ifigure.utils.cbook import isiterable, isndarray, isdynamic, issequence, isnumber import ifigure import ifigure.events from ifigure.mto.fig_obj import FigObj, mask_negative from ifigure.mto.axis_user import XUser, YUser, ZUser, CUser from ifigure.widgets.canvas.file_structure import * import ifigure.utils.cbook as cbook import ifigure.widgets.canvas.custom_picker as cpicker from ifigure.utils.args_parser import ArgsParser from ifigure.widgets.undo_redo_history import UndoRedoAddRemoveArtists, GlobalHistory from ifigure.utils.triangulation_wrapper import tri_args import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('FigContour') def_clabel_param = { 'use_clabel': False, 'fontsize': 10, 'fixed_color': False, 'colors': 'k', 'inline': True, 'inline_spacing': 5, 'fmt': '%1.3f', 'skip': 0 } default_kargs = { 'use_tri': False, 'FillMode': False,
import weakref from sets import Set from matplotlib.cm import ScalarMappable, get_cmap from matplotlib.colors import LogNorm, Normalize, Colormap, SymLogNorm import ifigure from ifigure.widgets.undo_redo_history import UndoRedoFigobjMethod import matplotlib.ticker as mticker from ifigure.utils.cbook import isiterable import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('AxisParam') class Memberholder(object): def __init__(self): self._member = [] self._ax_idx = [] def add_ax_idx(self,v): if not v in self._ax_idx: self._ax_idx.append(v) def rm_ax_idx(self,v): self._ax_idx=[x for x in self._ax_idx if x != v] def get_member(self): return self._member def walk_member(self): for m in self._member: if m() is not None: yield(m()) def add_member(self, obj):
import ifigure.server import numpy as np import ifigure.utils.debug as debug from ifigure.mto.treedict import TreeDict from ifigure.utils.cbook import text_repr # shell_variable EvtShellEnter = wx.NewEventType() EVT_SHELL_ENTER = wx.PyEventBinder(EvtShellEnter, 1) try: from ifigure.version import ifig_version except: ifig_version = 'dev' dprint1, dprint2, dprint3 = debug.init_dprints('SimpleShell') from six.moves.queue import Queue, Empty ON_POSIX = 'posix' in sys.builtin_module_names sx_print_to_consol = False def enqueue_output(p, queue): while True: line = p.stdout.readline() queue.put(line) if p.poll() is not None: queue.put(p.stdout.read()) break
from ifigure.utils.cbook import ProcessKeywords from ifigure.utils.triangulation_wrapper import tri_args from matplotlib.cm import ScalarMappable from matplotlib.patches import Rectangle from matplotlib.transforms import Bbox from ifigure.utils.args_parser import ArgsParser from matplotlib.colors import Colormap from matplotlib.patches import Rectangle from ifigure.widgets.undo_redo_history import UndoRedoAddRemoveArtists, GlobalHistory # # debug setting # import ifigure.utils.debug as debug debug.debug_default_level = 1 dprint1, dprint2, dprint3 = debug.init_dprints('FigHist') default_kargs = {} class FigHist(FigObj, XUser, YUser, ZUser): def __new__(cls, *args, **kywds): def set_hidden_vars(obj): obj._tri = None for key in default_kargs: if not obj.hasp(key): obj.setp(key, default_kargs[key]) if not obj.hasvar(key): obj.setvar(key, default_kargs[key]) return obj if kywds.has_key('src'): obj = FigObj.__new__(cls, *args, **kywds)
import os, sys, weakref, logging, threading import cPickle as pickle from ifigure.mto.treedict import TopTreeDict, TreeDict from ifigure.mto.py_code import PyParam, AbsModuleContainer, AbsScriptContainer, AbsFileContainer from ifigure.mto.py_code import PyModel from ifigure.mto.py_solver import PySolver from ifigure.mto.py_code import PySol from ifigure.mto.fig_book import FigBook import ifigure.widgets.dialog as dialog import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('ProjectTop') import ifigure import ifigure.utils.cbook as cbook lock = threading.Lock() class PySetting(TreeDict, AbsModuleContainer, AbsScriptContainer): @classmethod def load_classimage(self): from ifigure.ifigure_config import icondir as path idx=cbook.LoadImageFile(path, 'setting.png') return [idx] @classmethod def get_namebase(self): return 'setting' @classmethod def isPySetting(self): return True def tree_viewer_menu(self):
import re import os from os.path import expanduser import traceback from distutils.version import LooseVersion from matplotlib.artist import ArtistInspector from ifigure.utils.setting_parser import iFigureSettingParser as SP import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('ifiure_config') import matplotlib isMPL2 = LooseVersion(matplotlib.__version__) >= LooseVersion("2.0") if isMPL2: # let's use classic for now. import matplotlib.pyplot matplotlib.pyplot.style.use('classic') def artist_property_checker(obj, prop, values=None): # print 'inspecting', obj, prop if values is None: values = ArtistInspector(obj).get_valid_values(prop) matches=re.findall(r"\'(.+?)\'",values) # print 'inspector returns ', values # print 'checking ...', matches setter = getattr(obj, 'set_'+prop) getter = getattr(obj, 'get_'+prop)
from ifigure.mto.fig_obj import set_mpl_all, get_mpl_first import ifigure, os from ifigure.utils.cbook import nd_iter, LoadImageFile from ifigure.utils.geom import transform_point from ifigure.widgets.undo_redo_history import GlobalHistory from ifigure.widgets.undo_redo_history import UndoRedoArtistProperty from ifigure.widgets.undo_redo_history import UndoRedoFigobjProperty from ifigure.widgets.undo_redo_history import UndoRedoFigobjMethod import numpy as np import weakref from ifigure.utils.args_parser import ArgsParser import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('FigAxline') class FigAxline(FigObj, XUser, YUser): def __new__(cls, *args, **kywds): """ FigAxline([x1,x2,x3...], [y1,y2,...]) x is for vertical line y is for horizontal line """ def set_hidden_vars(obj): obj._objs = [] ## for debug.... obj._drag_backup = None obj._drag_delta = None obj._data_extent = None return obj
import wx import os import weakref import ifigure from ifigure.utils.edit_list import DialogEditListTab import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('dlg_preference') class PrefComponent(object): def __init__(self, cname='Sample'): self.name = cname def get_dialoglist(self): list1 = [ ["Sample", 'preferred setting', 0, None], ] hint1 = [None] return list1, hint1 def set_dialog_result(self, data): dprint1('set_dialog_result should be overwritten') def save_setting(self): dprint1('save_setting should be overwritten') def dlg_preference(components, parent): lists = [] hints = []
import subprocess as sp import numpy as np import ifigure.utils.cbook as cbook import ifigure.widgets.canvas.custom_picker as cpicker from scipy.interpolate import griddata from ifigure.utils.cbook import ProcessKeywords import matplotlib from matplotlib.tri import Triangulation from matplotlib.cm import ScalarMappable import matplotlib.image as mpimage from ifigure.utils.args_parser import ArgsParser from ifigure.mto.fig_box import FigBox from matplotlib.image import FigureImage import ifigure.utils.debug as debug debug.debug_default_level = 1 dprint1, dprint2, dprint3 = debug.init_dprints('FigEPS') def calc_newpos_from_anchor(p1, p2, dp, mode): if mode == 0: return (p1, p1+dp) elif mode == 1: m = (p1+p2)/2. return (m-dp/2., m+dp/2.) else: return (p2-dp, p2) from matplotlib.backends.backend_pdf import RendererPdf, PdfFile, Name, Op, pdfRepr from matplotlib.backends.backend_ps import RendererPS import matplotlib.backends.backend_ps unicode_file = 'unicode_literals' in dir(matplotlib.backends.backend_ps)
import weakref import array from scipy.misc import imresize from ctypes import sizeof, c_float, c_void_p, c_uint, string_at import matplotlib from functools import wraps from matplotlib.backends.backend_wx import FigureCanvasWx as Canvas from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as CanvasAgg from matplotlib.backends.backend_wx import RendererWx from ifigure.utils.cbook import EraseBitMap from operator import itemgetter import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('BackendWXAggGL') from distutils.version import LooseVersion from ifigure.matplotlib_mod.backend_wxagg_mod import FigureCanvasWxAggMod isMPL_before_1_2 = LooseVersion(matplotlib.__version__) < LooseVersion("1.2") use_gl_12 = True def load_glcanvas(debug = False): if wx.__version__[0] == '4' and not use_gl_12: from glcanvas_15 import MyGLCanvas if debug: dprint1('loading glcanvas15') else: from glcanvas_12 import MyGLCanvas if debug: dprint1('loading glcanvas12') return MyGLCanvas
import os, ifigure import numpy as np import ifigure.utils.cbook as cbook from ifigure.mto.py_code import PyData from ifigure.mdsplus.fig_mds import FigMds from ifigure.mto.figobj_param import FigobjParam, FigobjData import ifigure.utils.debug as debug debug.debug_default_level = 1 dprint1, dprint2, dprint3 = debug.init_dprints('FigMdsData') import traceback class FigMdsData(FigMds): def __init__(self, *args, **kargs): FigMds.__init__(self, *args, **kargs) self._plot_type = 'noplot' @classmethod def load_classimage(self): from ifigure.ifigure_config import icondir as path idx=cbook.LoadImageFile(path, 'data.png') return [idx] @classmethod def property_in_palette(self): return ["mdssource"] def get_artist_extent(self, a=None): return [None]*4 def generate_artist(self, *args, **kargs): pass def del_artist(self, *args, **kargs): pass def postprocess_data(self, ana, viewer,
import ifigure.server import numpy as np import ifigure.utils.debug as debug from ifigure.mto.treedict import TreeDict from ifigure.utils.cbook import text_repr ## shell_variable EvtShellEnter= wx.NewEventType() EVT_SHELL_ENTER = wx.PyEventBinder(EvtShellEnter, 1) try: from ifigure.version import ifig_version except: ifig_version = 'dev' dprint1, dprint2, dprint3 = debug.init_dprints('SimpleShell') import wx.py.shell #(wx4 removed this) wx.lib.shell from os.path import expanduser, abspath from ifigure.utils.wx3to4 import isWX3 import time import thread from threading import Timer, Thread try: from Queue import Queue, Empty except ImportError: from queue import Queue, Empty # python 3.x ON_POSIX = 'posix' in sys.builtin_module_names
from ifigure.widgets.dlg_preference import PrefComponent from ifigure.utils.setting_parser import iFigureSettingParser as SP import wx import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('HelperApp') def config_name(): if wx.Platform == '__WXMAC__': return 'pref.helperapp_mac_config' else: return 'pref.helperapp_config' class HelperApp(PrefComponent): def __init__(self): PrefComponent.__init__(self, 'HelperApp') p = SP() self.setting = p.read_setting(config_name()) def save_setting(self): p = SP() p.write_setting(config_name(), self.setting) def get_dialoglist(self): txt = 'yes' if self.setting["use_editor"] else 'no' list1 = [["Pdf", str(self.setting["pdf"]), 200, None], ["PostScript", str(self.setting["ps"]), 200, None], ["Editor", str(self.setting["editor"]), 200, None], ["ghostscript", str(self.setting["gs"]), 200, None], ["ps2pdf", str(self.setting["ps2pdf"]), 200, None], ["convert", str(self.setting["convert"]), 200, None],
from ifigure.mto.fig_obj import FigObj, mask_negative from ifigure.mto.axis_user import XUser, YUser, ZUser from ifigure.widgets.canvas.file_structure import * import ifigure, os import ifigure.widgets.canvas.custom_picker as cpicker import numpy as np import weakref, logging from ifigure.utils.cbook import isiterable,ProcessKeywords,LoadImageFile import matplotlib from matplotlib.collections import PolyCollection from matplotlib.patches import Polygon from ifigure.utils.args_parser import ArgsParser import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('FigFill') def _arg_names(mpl_cmd): if mpl_cmd == 'fill': return ("x", "y", "s") elif mpl_cmd == 'fill_between': return ("x", "y", "y2", "where") elif mpl_cmd == 'fill_betweenx': return ("y", "x", "x2", "where") class FigFill(FigObj, XUser, YUser, ZUser): def __new__(cls, *args, **kywds): def set_hidden_vars(obj):
# load image file # this could be widget toolkit dependent import wx, os, string, weakref, matplotlib, threading, traceback, ifigure import numpy as np import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('cbook') try: import Image except ImportError: from PIL import Image from ifigure.utils.wx3to4 import image_GetAlpha, image_SetAlpha, image_SetOptionInt, wxEmptyImage from ifigure.utils.wx3to4 import menu_Append, wxBitmapFromImage, wxCursorFromImage, menu_AppendItem def is_safename(txt): try: exec txt + '= 3' in {}, {} except: return False return True def text_repr(val): if isinstance(val, list): if (len(val) >10): text = (val[:10].__repr__())[:-1]+'...' else: text = val.__repr__() elif isinstance(val, tuple):
import numpy as np import time import wx import weakref import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('canvas_common') # # OpenGL extention # try: from wx import glcanvas except ImportError: pass try: # The Python OpenGL package can be found at # http://PyOpenGL.sourceforge.net/ from OpenGL.GL import * from OpenGL.GLUT import * from OpenGL.GLU import * from OpenGL.GL import shaders from OpenGL.arrays import vbo class myvbo(vbo.VBO): pass haveOpenGL = True except ImportError: haveOpenGL = False
commit revert : discard all changes in tree and files clone : make clone outside the project directory ''' import os, wx, shutil, ifigure.events, traceback, time, subprocess, shlex from fnmatch import fnmatch import ifigure.widgets.dialog as dialog from ifigure.mto.treedict import TreeDict from ifigure.utils.edit_list import DialogEditList from ifigure.utils.cbook import isBinary from ifigure.utils.wx3to4 import PyDeadObjectError, deref_proxy import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('HGSupport') r_vname = 'mercurial_root' p_vname = 'mercurial_path' diffwindow = None from ifigure.utils.get_username import get_username usr = get_username() try: import hgapi has_hg = True def has_repo(obj): if not isinstance(obj, HGSupport): return False if not obj.has_owndir(): return False return os.path.exists(os.path.join(obj.owndir(), '.hg'))
import threading import types import shutil import multiprocessing import sys import traceback import ifigure.utils.pickle_wrapper as pickle from ifigure.mto.py_code import PyCode import ifigure.utils.cbook as cbook import ifigure import ifigure.events import ifigure.widgets.dialog as dialog from ifigure.mto.fileholder import FileHolder import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('PyScript') txt1 = '(job involving GUI access, such as graphics generation,\nshould not use this option.)' class ScriptStop(Exception): def __init__(self, message=''): super(Exception, self).__init__() self.message = message def __str__(self): return repr(self.messge) class ExitScript(Exception): def __init__(self, message=''):
import ifigure.widgets.canvas.custom_picker as cpicker from scipy.interpolate import griddata, bisplrep, bisplev, interp2d from ifigure.utils.cbook import ProcessKeywords from ifigure.utils.triangulation_wrapper import tri_args from matplotlib.cm import ScalarMappable from matplotlib.patches import Rectangle from matplotlib.transforms import Bbox from ifigure.utils.args_parser import ArgsParser from matplotlib.colors import Colormap # # debug setting # import ifigure.utils.debug as debug debug.debug_default_level = 1 dprint1, dprint2, dprint3 = debug.init_dprints('FigScatter') default_kargs = {} class FigScatter(FigObj, XUser, YUser, ZUser, CUser): def __new__(cls, *args, **kywds): def set_hidden_vars(obj): obj._tri = None for key in default_kargs: if not obj.hasp(key): obj.setp(key, default_kargs[key]) if not obj.hasvar(key): obj.setvar(key, default_kargs[key]) return obj if kywds.has_key('src'): obj = FigObj.__new__(cls, *args, **kywds) obj = set_hidden_vars(obj)
from __future__ import print_function # # MDS worker pool for threaded worker and multiprocessing worker. # from ifigure.mdsplus.mds_mpth_directworker import MDSMPDirectWorker, MDSTHDirectWorker from ifigure.mdsplus.mds_mpth_proxyworker import MDSMPProxyWorker, MDSTHProxyWorker import multiprocessing as mp import time import weakref import threading from six.moves import queue as Queue import ifigure.utils.debug as debug debug.debug_default_level = 1 dprint1, dprint2, dprint3 = debug.init_dprints('MDSMPWorkerPool') jllock = threading.Lock() class MDSWorkerPoolBase(object): job_id = 0 job_list = {} def submit_ana_group(self, ana_group): job_id = MDSWorkerPoolBase.job_id # if hasattr(ana_group[0],'fig_mds'): # print 'submit', ana_group[0].fig_mds() jllock.acquire() MDSWorkerPoolBase.job_list[job_id] = [ len(ana_group), weakref.ref(ana_group) ] self.tasks.put((job_id, [(a.jobs, a.jobnames)
import os import ifigure.widgets.canvas.custom_picker as cpicker import numpy as np import weakref import logging from ifigure.utils.cbook import ProcessKeywords, LoadImageFile, isdynamic from matplotlib.tri import Triangulation from ifigure.matplotlib_mod.triplot_mod import triplot from ifigure.utils.args_parser import ArgsParser from matplotlib import cm from matplotlib.colors import Normalize, colorConverter, LightSource, Colormap from matplotlib.cm import ScalarMappable from matplotlib.colors import ColorConverter cc = ColorConverter() dprint1, dprint2, dprint3 = debug.init_dprints('FigSurface') def _reduce_size(X, Y, Z, rstride, cstride): rows, cols = Z.shape # Force X and Y to take the same shape. # If they can not be fitted to that shape, # then an exception is automatically thrown. X.shape = (rows, cols) Y.shape = (rows, cols) # We want two sets of lines, one running along the "rows" of # Z and another set of lines running along the "columns" of Z. # This transpose will make it easy to obtain the columns. rii = range(0, rows, rstride) cii = range(0, cols, cstride)
import ifigure.widgets.canvas.custom_picker as cpicker import numpy as np import weakref, logging from ifigure.utils.cbook import ProcessKeywords, LoadImageFile, isdynamic from matplotlib.tri import Triangulation from ifigure.matplotlib_mod.triplot_mod import triplot from ifigure.utils.args_parser import ArgsParser from matplotlib import cm from matplotlib.colors import Normalize, colorConverter, LightSource, Colormap from matplotlib.cm import ScalarMappable from matplotlib.colors import ColorConverter cc = ColorConverter() import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('FigSurface') def _reduce_size(X, Y, Z, rstride, cstride): rows, cols = Z.shape # Force X and Y to take the same shape. # If they can not be fitted to that shape, # then an exception is automatically thrown. X.shape = (rows, cols) Y.shape = (rows, cols) # We want two sets of lines, one running along the "rows" of # Z and another set of lines running along the "columns" of Z. # This transpose will make it easy to obtain the columns. rii = range(0, rows, rstride) cii = range(0, cols, cstride)
from matplotlib.artist import allow_rasterization from ifigure.mto.fig_obj import FigObj from ifigure.mto.axis_user import XUser, YUser, ZUser, CUser from ifigure.widgets.canvas.file_structure import * import ifigure, os import ifigure.widgets.canvas.custom_picker as cpicker import numpy as np import weakref, logging from ifigure.utils.cbook import ProcessKeywords, LoadImageFile, isdynamic, isiterable from ifigure.utils.triangulation_wrapper import tri_args from ifigure.matplotlib_mod.triplot_mod import triplot from ifigure.utils.args_parser import ArgsParser from matplotlib.path import Path from matplotlib.transforms import Bbox, TransformedPath import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('FigPlot') from ifigure.mto.triangle_plots import TrianglePlots class FigTriplot(FigObj, XUser, YUser, TrianglePlots): ''' triplot(x, y) triplot(tri, x, y) ''' def __new__(cls, *args, **kywds): if len(args) == 3: tri = args[0] args = args[1:] else: tri = None
from matplotlib.figure import Figure from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas from ifigure.utils.edit_list import ScrolledEditListPanel, EditListPanel, EDITLIST_CHANGED from wx import ScrolledWindow as SP from numpy.linalg import inv from ifigure.widgets.undo_redo_history import GlobalHistory from ifigure.widgets.undo_redo_history import UndoRedoArtistProperty from ifigure.widgets.undo_redo_history import UndoRedoFigobjProperty from ifigure.widgets.undo_redo_history import UndoRedoFigobjMethod from ifigure.widgets.undo_redo_history import UndoRedoGroupUngroupFigobj from ifigure.widgets.undo_redo_history import UndoRedoAddRemoveArtists import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('SectionEditor') class section_editor(wx.Panel): def __init__(self, parent): super(section_editor, self).__init__(parent) self.area = [] self.rect = [] self.use_def_margin = [] self.area_hit = None self.page_margin = [0, 0, 0, 0] self.nomargin = False notebook = wx.Notebook(self)
import numpy as np import ifigure import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('GL_COMPOUND') class GLCompound(object): def isCompound(self): return self.hasvar('array_idx') @property def hidden_component(self): if not hasattr(self, '_hidden_component'): self._hidden_component = [] return self._hidden_component @property def shown_component(self): h = self._hidden_component array_idx = list(np.unique(self.getvar('array_idx'))) for x in h: if x in array_idx: array_idx.remove(x) return array_idx def hide_component(self, idx, inverse = False): ''' idx = list ''' if not self.isCompound(): return if inverse:
import sys, wx, time import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('import_dw') replace_shot = True def interpret_globals(com, var, globals): globals[com] = var.strip() return globals def interpret_globals_int(com, var, globals): globals[com] = int(var) return globals def interpret_plots(com1, com2, var, plots, use_int=False): a = com1.split('_') c = int(a[2]) - 1 r = int(a[1]) - 1 if len(plots) <= c: return plots if len(plots[c]) <= r: return plots if use_int: plots[c][r][com2] = int(var) else: plots[c][r][com2] = var.strip() # print c, r, com2, var return plots
from ifigure.mto.fig_obj import set_mpl_all, get_mpl_first import ifigure import os import ifigure.utils.cbook as cbook from ifigure.utils.geom import transform_point import ifigure.widgets.canvas.custom_picker as cpicker from ifigure.widgets.undo_redo_history import GlobalHistory from ifigure.widgets.undo_redo_history import UndoRedoArtistProperty from ifigure.widgets.undo_redo_history import UndoRedoFigobjProperty from ifigure.widgets.undo_redo_history import UndoRedoFigobjMethod import numpy as np import weakref from ifigure.utils.args_parser import ArgsParser import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('FigAxspan') def _special_xy_check(v): # special check for x and y try: if (len(v) == 2): x0 = v[0] x1 = v[1] if ((isinstance(x0, float) or isinstance(x0, int)) and (isinstance(x1, float) or isinstance(x1, int))): return [[x0, x1]], True for item in v: if len(item) != 2: flag = False except:
import weakref from matplotlib.cm import ScalarMappable, get_cmap from matplotlib.colors import LogNorm, Normalize, Colormap, SymLogNorm import ifigure from ifigure.widgets.undo_redo_history import UndoRedoFigobjMethod import matplotlib.ticker as mticker from ifigure.utils.cbook import isiterable from ifigure.ifigure_config import isMPL33 import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('AxisParam') class Memberholder(object): def __init__(self): self._member = [] self._ax_idx = [] def add_ax_idx(self, v): if not v in self._ax_idx: self._ax_idx.append(v) def rm_ax_idx(self, v): self._ax_idx = [x for x in self._ax_idx if x != v] def get_member(self): return self._member def walk_member(self): for m in self._member: if m() is not None: yield (m())
from ifigure.utils.cbook import ProcessKeywords from ifigure.utils.triangulation_wrapper import tri_args from matplotlib.cm import ScalarMappable from matplotlib.patches import Rectangle from matplotlib.transforms import Bbox from ifigure.utils.args_parser import ArgsParser from matplotlib.colors import Colormap from matplotlib.patches import Rectangle from ifigure.widgets.undo_redo_history import UndoRedoAddRemoveArtists, GlobalHistory # # debug setting # import ifigure.utils.debug as debug debug.debug_default_level = 1 dprint1, dprint2, dprint3 = debug.init_dprints('FigHist') default_kargs = {} class FigHist(FigObj, XUser, YUser, ZUser): def __new__(cls, *args, **kywds): def set_hidden_vars(obj): obj._tri = None for key in default_kargs: if not obj.hasp(key): obj.setp(key, default_kargs[key]) if not obj.hasvar(key): obj.setvar(key, default_kargs[key]) return obj if kywds.has_key('src'): obj = FigObj.__new__(cls, *args, **kywds) obj = set_hidden_vars(obj)
from ifigure.utils.setting_parser import iFigureSettingParser as SettingParser from ifigure.mdsplus.mds_sp_worker_pool import MDSSPWorkerPool from ifigure.mdsplus.mds_mpth_worker_pool import MDSMPWorkerPool, MDSTHWorkerPool #from ifigure.mdsplus.fig_mds import build_init_local_global_session from ifigure.mdsplus.fig_mds import build_current_shot_session from ifigure.mdsplus.fig_mds import add_connect_session from ifigure.mdsplus.event_listener import MDSSCOPE_EVT_MDSEVENT from ifigure.mdsplus.mdsscope import ScopeEngine, message, set_call_after_queue # # debug setting # import ifigure.utils.debug as debug debug.debug_default_level = 1 dprint1, dprint2, dprint3 = debug.init_dprints('MDSScope') class FakeTextCtrl(object): def __init__(self, *args, **kargs): self._value = '' def SetValue(self, value): self._value = value def GetValue(self): return self._value class FakeBookViewerFrame(object): def __init__(self, *args, **kargs): self._title = '' self._parent = '' self._status_txt = ['']*10
from __future__ import print_function import ifigure import os import sys import time import subprocess import random from ifigure.utils.pickled_pipe import PickledPipe # # debug setting # import ifigure.utils.debug as debug debug.debug_default_level = 1 dprint1, dprint2, dprint3 = debug.init_dprints('MDSSPWokerPool') class MDSSPWorkerPool(object): def __init__(self, num, *args): self.num = num self.pch = [None]*num dirname = os.path.dirname(ifigure.__file__) type = args[0] if len(args) > 1: host = args[1] port = args[2] else: host = None port = None
# check can be list and conncted by '|' # ['float', 'int'] : # True if it is number ( = same as ['real']) # ['iter|nonstr', 'dynamic'] : # True if it is either 'dynamic' or 'iterable and not string' # # v, kywds, flag = p.process(*args, **kywds) # # v is a dict v[name] = value # kywds is remaining keywords which is not processed # flag is True if rule is successfully applied # from ifigure.utils.cbook import isiterable, isndarray, isdynamic, issequence, isnumber import numpy as np import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('ArgsParser') def bit(n, l): if n == 0: return [0]*l v = [0]*l k = 0 while n >= 2**k: v[k] = int((n & 2**k) != 0) k = k+1 return v def convert_ndarray(v, name): if not v.has_key(name): return v if v[name] is None: return v if isdynamic(v[name]): return v if isiterable(v[name]) and not isndarray(v[name]):
import os, wx, logging, shutil, weakref import ifigure, ifigure.events import ifigure.utils.cbook as cbook import ifigure.mto.abs_module as abs_module import ifigure.mto.py_code as py_code import ifigure.add_on import ifigure.widgets.dialog as dialog from ifigure.mto.fileholder import FileHolder import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('PyModule') # # the same as PyCode but different default icon # active_module = {} class PyModule(py_code.PyCode, FileHolder): def __init__(self, *args, **kargs): self._obj = None self._can_have_child = False self._has_private_owndir = False self._first_load = True self._args = args self._kargs = kargs super(PyModule, self).__init__(*args, **kargs) @classmethod def isPyModule(self): return True @classmethod def get_namebase(self):
instead of pushing the data into pipe, it creates files with two resolutions. main process will open coarse resolution file first. FileNDArray : used in sub process FileNDArrayAutoDel : used in main process, allowing automatic delete of file ''' import tempfile, numpy import numpy, os, time import ifigure.utils.debug as debug debug.debug_default_level = 1 dprint1, dprint2, dprint3 = debug.init_dprints('FigNDArray') import traceback def random_tmp_name(seed='1'): ### generate a random string for an initial work dir from datetime import datetime import hashlib strtime = datetime.now().strftime("%Y-%m-%d %H:%M:%S. %f") #print strtime m = hashlib.md5() m.update(strtime + str(seed)) txt = m.hexdigest() return txt
from .event_listener_proc_fake import EventListenerProc, use_event_listener from numpy import ndarray import multiprocessing as mp import threading from six.moves import queue as Queue import traceback import time import tempfile import wx import select from weakref import WeakKeyDictionary import ifigure.utils.debug as debug debug.debug_default_level = 1 dprint1, dprint2, dprint3 = debug.init_dprints('event_listener') MDSEventReceived = wx.NewEventType() MDSSCOPE_EVT_MDSEVENT = wx.PyEventBinder(MDSEventReceived, 1) mds_event_listener_lock = threading.Lock() listener_thread = None class EventListener(threading.Thread): def __init__(self, *args, **kargs): super(EventListener, self).__init__(*args, **kargs) self.queue = mp.Queue() # queue to receive message self.task_queue = mp.JoinableQueue() self.listener_proc = EventListenerProc(self.task_queue, self.queue) wx.CallAfter(self.listener_proc.start) self.viewers = WeakKeyDictionary()
from ifigure.utils.setting_parser import iFigureSettingParser as SettingParser from ifigure.mdsplus.mds_sp_worker_pool import MDSSPWorkerPool from ifigure.mdsplus.mds_mpth_worker_pool import MDSMPWorkerPool, MDSTHWorkerPool #from ifigure.mdsplus.fig_mds import build_init_local_global_session from ifigure.mdsplus.fig_mds import build_current_shot_session from ifigure.mdsplus.fig_mds import add_connect_session from ifigure.mdsplus.event_listener import MDSSCOPE_EVT_MDSEVENT from ifigure.mdsplus.mdsscope import ScopeEngine, message, set_call_after_queue # # debug setting # import ifigure.utils.debug as debug debug.debug_default_level = 1 dprint1, dprint2, dprint3 = debug.init_dprints('MDSScope') class FakeTextCtrl(object): def __init__(self, *args, **kargs): self._value = '' def SetValue(self, value): self._value = value def GetValue(self): return self._value class FakeBookViewerFrame(object): def __init__(self, *args, **kargs):
import wx, weakref import numpy as np from ifigure.mto.fig_axes import FigAxes #from ifigure.widgets.primitive_widgets import margin_widget, marginp_widget from ifigure.widgets.margin_widget import MarginWidget, MarginpWidget from ifigure.utils import geom as geom_util import ifigure.events #from matplotlib.figure import Figure #from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas from ifigure.utils.edit_list import EditListPanel, EDITLIST_CHANGED from numpy.linalg import inv import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('LayoutEditor') from ifigure.widgets.undo_redo_history import GlobalHistory from ifigure.widgets.undo_redo_history import UndoRedoFigobjMethod from ifigure.widgets.undo_redo_history import UndoRedoGroupUngroupFigobj from ifigure.widgets.undo_redo_history import UndoRedoAddRemoveArtists from ifigure.utils.wx3to4 import menu_AppendItem def _fix_event_data(w, h, event): event.xdata = float(event.x) / w event.ydata = float(event.y) / h if (event.xdata < 0) | (event.xdata > 1): event.xdata = None if (event.ydata < 0) | (event.ydata > 1): event.ydata = None return event
import weakref import array from scipy.misc import imresize from ctypes import sizeof, c_float, c_void_p, c_uint, string_at import matplotlib from functools import wraps from matplotlib.backends.backend_wx import FigureCanvasWx as Canvas from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as CanvasAgg from matplotlib.backends.backend_wx import RendererWx from ifigure.utils.cbook import EraseBitMap from operator import itemgetter import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('BackendWXAggGL') isMPL_before_1_2 = LooseVersion(matplotlib.__version__) < LooseVersion("1.2") # # OpenGL extention # try: from wx import glcanvas except ImportError: pass try: # The Python OpenGL package can be found at # http://PyOpenGL.sourceforge.net/ from OpenGL.GL import * from OpenGL.GLUT import *
from __future__ import print_function ''' PostOffice simple postoffice to send a file ''' import wx import binascii #import sys, socket, shlex, threading, os, binascii, subprocess, time, tempfile from ifigure.widgets.passwd_dialog import PasswordDialog, UsernamePasswordDialog from ifigure.utils.setting_parser import iFigureSettingParser as SP from ifigure.utils.edit_list import DialogEditList from ifigure.utils.mailfile import checkPasswd, sendMail from ifigure.widgets.dlg_preference import PrefComponent import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('PostOffice') coding = 'utf-8' class PostOffice(PrefComponent): def __init__(self): PrefComponent.__init__(self, 'PostOffice') p = SP() self.setting = p.read_setting('pref.postoffice_config') self.passwd = None self.username = None self.parent = None def save_setting(self): p = SP()
import subprocess as sp import numpy as np import ifigure.utils.cbook as cbook import ifigure.widgets.canvas.custom_picker as cpicker from scipy.interpolate import griddata from ifigure.utils.cbook import ProcessKeywords import matplotlib from matplotlib.tri import Triangulation from matplotlib.cm import ScalarMappable import matplotlib.image as mpimage from ifigure.utils.args_parser import ArgsParser from ifigure.mto.fig_box import FigBox from matplotlib.image import FigureImage import ifigure.utils.debug as debug debug.debug_default_level = 1 dprint1, dprint2, dprint3 = debug.init_dprints('FigEPS') def calc_newpos_from_anchor(p1, p2, dp, mode): if mode == 0: return (p1, p1 + dp) elif mode == 1: m = (p1 + p2) / 2. return (m - dp / 2., m + dp / 2.) else: return (p2 - dp, p2) from matplotlib.backends.backend_pdf import RendererPdf, PdfFile, Name, Op, pdfRepr from matplotlib.backends.backend_ps import RendererPS
import ifigure import ifigure.utils.cbook as cbook import ifigure.widgets.canvas.custom_picker as cpicker import ifigure.utils.geom as geom from ifigure.widgets.undo_redo_history import GlobalHistory from ifigure.widgets.undo_redo_history import UndoRedoArtistProperty from ifigure.widgets.undo_redo_history import UndoRedoFigobjProperty from ifigure.widgets.undo_redo_history import UndoRedoFigobjMethod from ifigure.mto.generic_points import GenericPoint, GenericPointsHolder from ifigure.mto.figobj_gpholder import FigObjGPHolder from ifigure.utils.args_parser import ArgsParser import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('FigText') num_gp = 1 class FigText(FigObjGPHolder): def __new__(cls, *args, **kywds): def set_hidden_vars(obj): obj._objs = [] # for debug.... obj._drag_backup = None obj._drag_mode = 1 # 1 transpose 2 expand 3 rotate obj._drag_start = None return obj if 'src' in kywds: obj = FigObjGPHolder.__new__(cls, *args, **kywds) obj = set_hidden_vars(obj)
from ifigure.widgets.dlg_preference import PrefComponent from ifigure.utils.setting_parser import iFigureSettingParser as SP import wx import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('HelperApp') def config_name(): if wx.Platform == '__WXMAC__': return 'pref.helperapp_mac_config' else: return 'pref.helperapp_config' class HelperApp(PrefComponent): def __init__(self): PrefComponent.__init__(self, 'HelperApp') p = SP() self.setting = p.read_setting(config_name()) def save_setting(self): p = SP() p.write_setting(config_name(), self.setting) def get_dialoglist(self): txt = 'yes' if self.setting["use_editor"] else 'no' list1 = [ ["Pdf", str(self.setting["pdf"]), 200, None],
import sys, wx, time import ifigure.utils.debug as debug dprint1, dprint2, dprint3 = debug.init_dprints('import_dw') replace_shot = True def interpret_globals(com, var, globals): globals[com]=var.strip() return globals def interpret_globals_int(com, var, globals): globals[com]=int(var) return globals def interpret_plots(com1, com2, var, plots, use_int = False): a=com1.split('_') c = int(a[2])-1 r = int(a[1])-1 if len(plots) <= c: return plots if len(plots[c]) <= r: return plots if use_int: plots[c][r][com2]=int(var) else: plots[c][r][com2]=var.strip() # print c, r, com2, var return plots def import_dw(file=''): if file == '': open_dlg = wx.FileDialog ( None, message="Select DWscope to open", wildcard='*.dat',style=wx.FD_OPEN) if open_dlg.ShowModal() == wx.ID_OK: file = open_dlg.GetPath()