__init__.py 5.73 KB
Newer Older
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
1
2
3
4
5
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# ================= FILE HEADER ========================================
#
Philipp Gast's avatar
Philipp Gast committed
6
#   myplotlib v3.0.1,
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#
#   @file      __init__.py
#   @author    Yori 'AGy' Fournier
#   @licence   CC-BY-SA
#
#   Import and Configuration file for myplotlib
#
#   @section Import
#
#   myplotlib is base on matplotlib therefore it requires
#   Figure and Axes as main classes and a few further functions.
#
#   @section Config
#
#   Default value for user parameters
#   and configuration for the default plotting
#
#   @section Module Import
#
#   Import of myplotlib classes and function
#
#   @section History
#
#   v 0.0.0 - __init__.py file for the myplotlib module
#
# ======================================================================
#
#
# IMPORT ---------------------------------------------------------------
Yori Fournier's avatar
Yori Fournier committed
36
from .config import INFO, WARN, SEVR, DBUG, SPCE
37
from .config import D_HIERARCHY
Yori Fournier's avatar
Yori Fournier committed
38

Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
39
40
import os as os
import numpy as np
41
np.set_printoptions(threshold='nan')
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
42

43
44
# matplotlib import for client/local -----------------------------------
if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):
Yori Fournier's avatar
Yori Fournier committed
45

46
    if D_HIERARCHY in ('CLIENT', 'client'):
47
        print(INFO+'Import '+__package__+' as a client.')
48
    else:
49
        print(INFO+'Import '+__package__+' for local use.')
50
51
52
    
    # Test mpl version:
    from matplotlib import __version__ as mplvers
Yori Fournier's avatar
Yori Fournier committed
53

54
55
    if int(mplvers.replace('.','')[:3]) < 143 :
        print('\n\n' + WARN + 72*'=' + '\n' + SPCE + 'The matplotlib version you are using is not supported.\n' + SPCE + 'Most of myplotlib should work, but some stuff may not.\n' + SPCE + 'ex: expect an error with test203\n' + SPCE + 72*'=' + '\n\n')
56

57
58
59
60
61
62
63
64
65
66
    # matplotlib
    from matplotlib.pyplot import figure
    from matplotlib.pyplot import rc
    from matplotlib.pyplot import show, draw, ion, ioff, clf
    from matplotlib.pyplot import close as mpclose
    from matplotlib.pyplot import fignum_exists, savefig
    from matplotlib.axes import Axes
    from matplotlib.figure import Figure
    from matplotlib import is_interactive
    from matplotlib import use
67
68
69

    from .config import D_HOST, D_PORT
    from socket import socket, AF_INET, SOCK_STREAM
70
71
    
elif D_HIERARCHY in ('SERVER', 'server'):
72
    print(INFO+'Import '+__package__+' as a server.')
73
    from .config import D_HOST, D_PORT
74
    from socket import socket, AF_INET, SOCK_STREAM, SOL_SOCKET, SO_REUSEADDR
75
76
77
78
79

else:    
    print(SEVR+'the value of D_HIERARCHY has to be SERVER or CLIENT')
    raise ImportError
    
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
80
# myplotlib
81
from .myData import MyData
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
82

83
84
85
86
87
88
# CONFIGURATION --------------------------------------------------------
from .config import D_FIGNUM, D_FIGSIZE, D_REFORMAT, D_FORMATTED
from .config import D_RAWDATA, D_INPUTARG
from .config import D_IPATH
from .config import D_OPATH, D_OFORMAT
from .config import D_DEBUG
89
90

if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):
91
    
92
93
    from .rconfig import rcParams
    
94
95
96
if D_HIERARCHY in ('CLIENT', 'client'):
    
    # MyAxes: Overlay on matplotlib.Axes class
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
97
    from .myAxes_client import MyAxes_client as MyAxes
98
99

    # MyFig: Overlay on matplotlib.Figure class
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
100
101
    from .myFig_client import MyFig_client as MyFig

102
103
    from .progressbar import ProgressBar
    
104
    from .mplClient import MplClient
105
    from .mplClient2 import MplClient2
106
107

elif(D_HIERARCHY in ('SERVER', 'server')):
108

109
110
111
112
113
     # MyAxes: Overlay on matplotlib.Axes class
    from .myAxes_server import MyAxes_server as MyAxes

    # MyFig: Overlay on matplotlib.Figure class
    from .myFig_server import MyFig_server as MyFig
114
115
116

#    from .test import FigTestServer
    from .test import FigTest
117
118

# for testing purpose
119
    from .test import readStupidData, readStupidData2
120

121
122
123
    SERVER_IOFUNCTIONS = {'readStupidData': readStupidData,
                          'readStupidData2': readStupidData2
    }
124
    SERVER_FIGURES = {'FigTest': FigTest}
125

126
    from .mplServer import MplServer
127
    from .mplServer2 import MplServer2, MplHandler
128
129
130
    
elif D_HIERARCHY in ('LOCAL', 'local'):
    
131
132
    # MyAxes: Overlay on matplotlib.Axes class
    from .myAxes import MyAxes
133

134
135
    # MyFig: Overlay on matplotlib.Figure class
    from .myFig import MyFig
136
137
138
139
140
141
142
143

else:
    
    print(SEVR+'the value of D_HIERARCHY has to be SERVER, CLIENT or LOCAL')
    raise ImportError        
    

if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):
144
    
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
    _G_WINDOWS = []
    
    # MyWin: Overlay on matplotlib.FigureManager class
    if rcParams['backend'] == u'TkAgg':
        from .myWin_TkAgg import MyWin_TkAgg as MyWin
    elif rcParams['backend'] == u'GTKAgg':
        from .myWin_GTKAgg import MyWin_GTKAgg as MyWin
    elif rcParams['backend'] == u'WXAgg':
        from .myWin_WXAgg import MyWin_WXAgg as MyWin
    elif rcParams['backend'] == u'Qt4Agg':
        from .myWin_Qt4Agg import MyWin_Qt4Agg as MyWin
    elif rcParams['backend'] == u'MacOSX':
        from .myWin_MacOSx import MyWin_MacOSx as MyWin
    else:
        print(SEVR + "The backend you choosed is not supported interactive mode not available")
160

Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
161
# myTool.*: interface functions to use myplotlib interactively
162
163
164
165
166
#from .mytool import print2file  # need to make tools for server ?? or just put them in client/local
#from .mytool import FigOneAxes 

if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):

167
168
    from .mytool import print2file  # need to make tools for server ?? or just put them in client/local
    from .mytool import FigOneAxes 
169
170
171
172
    from .mytool import window_exists, getCurrentWindowIDs
    from .mytool import print2file, print2screen, printListCurrentWindows
    from .mytool import getWindow, getFigOnWindow, drawFigOnWindow, giveDataToWindow
    from .mytool import closeWindow, closeAllWindows
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
173

174
# TESTS ----------------------------------------------------------------
175

176
177
178
#    from .test import myTest
#    from .test import testList
    from .test import FigTest
179

180