__init__.py 5.26 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
np.set_printoptions(threshold='nan')

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

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

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

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

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

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

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

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

Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
100
# myplotlib
101
from .mpl_data import MplData
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
102

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

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

112
    from .rconfig import rcParams
113

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

116
117
    # MplAxes: Overlay on matplotlib.Axes class
    from .mpl_axes_client import MplAxesClient as MplAxes
118

119
    from .mpl_grid import Grid, VerticalGrid, HorizontalGrid
120

121
122
    # MplFig: Overlay on matplotlib.Figure class
    from .mpl_fig_client import MplFigClient as MplFig
Yori 'AGy' Fournier's avatar
Yori 'AGy' Fournier committed
123

124
    from .progressbar import ProgressBar
125

126
    from .mpl_client import MplClient
127
128

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

130
    # MplAxes: Overlay on matplotlib.Axes class
131
    from .mpl_axes_server import MplAxesServer as MplAxes
132

133
    from .mpl_grid import Grid, VerticalGrid, HorizontalGrid
134

135
136
    # MplFig: Overlay on matplotlib.Figure class
    from .mpl_fig_server import MplFigServer as MplFig
137

Yori Fournier's avatar
Yori Fournier committed
138
    SERVER_IOFUNCTIONS = {
139
140
        #        'readStupidData': readStupidData,
        #        'readStupidData2': readStupidData2
Yori Fournier's avatar
Yori Fournier committed
141
142
    }
    SERVER_FIGURES = {
143
        # 'FigTest': FigTest
144
    }
145

146
    from .mpl_server import MplServer, MplHandler
147

148
elif D_HIERARCHY in ('LOCAL', 'local'):
149

150
    # MplAxes: Overlay on matplotlib.Axes class
151
    from .mpl_axes import MplAxes
152

153
    # MplFig: Overlay on matplotlib.Figure class
154
155
    from .mpl_grid import Grid, VerticalGrid, HorizontalGrid
    from .mpl_fig import MplFig
156
157
158
    from .empty_fig import EmptyFig
    from .empty_axes import EmptyAxes

159
else:
160

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

164
165

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

167
    _G_WINDOWS = []
168

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