__init__.py 6.08 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
41
import os as os
import numpy as np

Yori Fournier's avatar
Yori Fournier committed
42
43
44
from signal import Signal, Query, Status, Answer
from mpl_unpickler import MplUnpickler

45
46
47
np.set_printoptions(threshold='nan')


48
49
# matplotlib import for client/local -----------------------------------
if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):
Yori Fournier's avatar
Yori Fournier committed
50

51
    if D_HIERARCHY in ('CLIENT', 'client'):
52
        print(INFO + 'Import ' + __package__ + ' as a client.')
53
    else:
54
        print(INFO + 'Import ' + __package__ + ' for local use.')
55

56
57
    # Test mpl version:
    from matplotlib import __version__ as mplvers
Yori Fournier's avatar
Yori Fournier committed
58

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
    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')
76

77
78
79
80
81
82
83
    # 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
84
    from matplotlib.figure import Figure
85
86
    from matplotlib import is_interactive
    from matplotlib import use
87
88
89

    from .config import D_HOST, D_PORT
    from socket import socket, AF_INET, SOCK_STREAM
90

91
elif D_HIERARCHY in ('SERVER', 'server'):
92
93
    if DBUG:
        print(INFO + 'Import ' + __package__ + ' as a server.')
94
    from .config import D_HOST, D_PORT
95
    from socket import socket, AF_INET, SOCK_STREAM, SOL_SOCKET, SO_REUSEADDR
96

97
else:
98
    print(SEVR + 'the value of D_HIERARCHY has to be SERVER or CLIENT')
99
    raise ImportError
100

Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
101
# myplotlib
102
from .myData import MyData
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
103

104
105
106
107
108
109
# 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
110
111

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

113
    from .rconfig import rcParams
114

115
if D_HIERARCHY in ('CLIENT', 'client'):
116

117
    # MyAxes: Overlay on matplotlib.Axes class
118
    from .myAxes_client import MyAxesClient as MyAxes
119
120

    # MyFig: Overlay on matplotlib.Figure class
121
    from .myFig_client import MyFigClient as MyFig
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
122

123
    from .progressbar import ProgressBar
124

125
    from .mplClient2 import MplClient2
126
127

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

129
     # MyAxes: Overlay on matplotlib.Axes class
130
    from .myAxes_server import MyAxesServer as MyAxes
131
132

    # MyFig: Overlay on matplotlib.Figure class
133
    from .myFig_server import MyFigServer as MyFig
134
135

#    from .test import FigTestServer
Yori Fournier's avatar
Yori Fournier committed
136
#    from .test import FigTest
137
138

# for testing purpose
Yori Fournier's avatar
Yori Fournier committed
139
#    from .test import readStupidData, readStupidData2
140

Yori Fournier's avatar
Yori Fournier committed
141
    SERVER_IOFUNCTIONS = {
142
143
        #        'readStupidData': readStupidData,
        #        'readStupidData2': readStupidData2
Yori Fournier's avatar
Yori Fournier committed
144
145
146
    }
    SERVER_FIGURES = {
        #'FigTest': FigTest
147
    }
148

149
    from .mplServer2 import MplServer2, MplHandler
150

151
elif D_HIERARCHY in ('LOCAL', 'local'):
152

153
154
    # MyAxes: Overlay on matplotlib.Axes class
    from .myAxes import MyAxes
155

156
    # MyFig: Overlay on matplotlib.Figure class
157
    from .mplGrid import Grid, VerticalGrid, HorizontalGrid
158
    from .myFig import MyFig
159
160
161
    from .empty_fig import EmptyFig
    from .empty_axes import EmptyAxes

162
else:
163

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

167
168

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

170
    _G_WINDOWS = []
171

172
173
174
175
176
177
178
179
180
181
182
183
    # 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:
184
        print(SEVR + """The backend you choosed is not
185
                supported interactive mode not available""")
186

Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
187
188
# myTool.*: interface functions to use myplotlib interactively

189
190
# from .mytool import print2file  # need to make tools for server ?? or just put them in client/local
#from .mytool import FigOneAxes
191

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

Yori Fournier's avatar
Yori Fournier committed
194
#    from .mytool import print2file  # need to make tools for server ?? or just put them in client/local
195
#    from .mytool import FigOneAxes
Yori Fournier's avatar
Yori Fournier committed
196
197
198
199
#    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
200

201
# TESTS ----------------------------------------------------------------
202

203
204
#    from .test import myTest
#    from .test import testList
Yori Fournier's avatar
Yori Fournier committed
205
#    from .test import FigTest