Commit 9467f942 authored by Yori Fournier's avatar Yori Fournier
Browse files

rename files and change init from main module

parent 3261e6f8
Pipeline #496 failed with stage
in 5 minutes and 41 seconds
......@@ -44,7 +44,6 @@ from mpl_unpickler import MplUnpickler
np.set_printoptions(threshold='nan')
# matplotlib import for client/local -----------------------------------
if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):
......@@ -114,29 +113,23 @@ if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):
if D_HIERARCHY in ('CLIENT', 'client'):
# MyAxes: Overlay on matplotlib.Axes class
from .myAxes_client import MyAxesClient as MyAxes
# MplAxes: Overlay on matplotlib.Axes class
from .mpl_axes_client import MplAxesClient as MplAxes
# MyFig: Overlay on matplotlib.Figure class
from .myFig_client import MyFigClient as MyFig
# MplFig: Overlay on matplotlib.Figure class
from .mpl_fig_client import MplFigClient as MplFig
from .progressbar import ProgressBar
from .mplClient2 import MplClient2
from .mpl_client import MplClient
elif(D_HIERARCHY in ('SERVER', 'server')):
# MyAxes: Overlay on matplotlib.Axes class
from .myAxes_server import MyAxesServer as MyAxes
# MyFig: Overlay on matplotlib.Figure class
from .myFig_server import MyFigServer as MyFig
# from .test import FigTestServer
# from .test import FigTest
# MplAxes: Overlay on matplotlib.Axes class
from .mpl_axes_server import MplAxesServer as MplAxes
# for testing purpose
# from .test import readStupidData, readStupidData2
# MplFig: Overlay on matplotlib.Figure class
from .mpl_fig_server import MplFigServer as MplFig
SERVER_IOFUNCTIONS = {
# 'readStupidData': readStupidData,
......@@ -146,14 +139,14 @@ elif(D_HIERARCHY in ('SERVER', 'server')):
#'FigTest': FigTest
}
from .mplServer2 import MplServer2, MplHandler
from .mpl_server import MplServer, MplHandler
elif D_HIERARCHY in ('LOCAL', 'local'):
# MyAxes: Overlay on matplotlib.Axes class
# MplAxes: Overlay on matplotlib.Axes class
from .mpl_axes import MplAxes
# MyFig: Overlay on matplotlib.Figure class
# MplFig: Overlay on matplotlib.Figure class
from .mpl_grid import Grid, VerticalGrid, HorizontalGrid
from .mpl_fig import MplFig
from .empty_fig import EmptyFig
......@@ -183,23 +176,3 @@ if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):
else:
print(SEVR + """The backend you choosed is not
supported interactive mode not available""")
# mpl_tool_box.*: interface functions to use myplotlib interactively
# from .mpl_tool_box import print2file # need to make tools for server ?? or just put them in client/local
#from .mpl_tool_box import FigOneAxes
# if D_HIERARCHY in ('CLIENT', 'client', 'LOCAL', 'local'):
# from .mpl_tool_box import print2file # need to make tools for server ?? or just put them in client/local
# from .mpl_tool_box import FigOneAxes
# from .mpl_tool_box import window_exists, getCurrentWindowIDs
# from .mpl_tool_box import print2file, print2screen, printListCurrentWindows
# from .mpl_tool_box import getWindow, getFigOnWindow, drawFigOnWindow, giveDataToWindow
# from .mpl_tool_box import closeWindow, closeAllWindows
# TESTS ----------------------------------------------------------------
# from .test import myTest
# from .test import testList
# from .test import FigTest
# usage
#
# <in class MySuperFig>
# def addAxes(self):
#
# self.layout = MyGrid()
# self.layout.addAxes(MySuperAxes(self, 6./8, [0.15, 0.15, 0.7, 0.7]), 'superAxes1'))
#
# This is creating an object MyGrid which overwrite the computeRect function
# from MySuperAxes depending on the parameters given to MyGrid.
#
# The example of a equidistant Grid
#
# self.layout = MySuperGrid()
# self.layout.addAxes(MySuperAxes(self, 6./8, [0.15, 0.15, 0.7, 0.7]), 'superAxes1', (0, 0)))
# self.layout.addAxes(MySuperAxes(self, 6./8, [0.15, 0.15, 0.7, 0.7]), 'superAxes2', (0, 1)))
#
# Depending on the last argument the gridOffsetY is going to be computed and the
# computeRect function altered for both Axes. The ratio and frame are still the one within the gridCell.
#
# For the vertical grid I realisez that We may need to fit the layout at the
# end of fig.addAxes when all axes are present.
# Another point is that layout can not be dynamic, because the frame of an Axes
# is static (changing the frame requires to destroy the Axes, because of the canvas and the dpi)
# Therefore we should not allow the user to dynamically use grid.
#
# Maybe at the end of fig._initialize we may call self.grid.fitLayout()
# This suggests that all figure have a grid.
# This suggests that grids are not optional but a must and therefore
# any combinaison are required and that grid containing grid should be
# possible.
class MyGrid():
def __init__(self, fig):
self.fig = fig
def addAxes(self, ax, name, *args, **kwargs):
ax.computeRect = self.generateComputeRect(args, kwargs)
self.fig.add_axes(self, ax, name)
def generateComputeRect(self, *args, **kwargs):
gridOffsetX = 0
gridOffsetY = 0
gridWidth = self.fig.get_figwidth()
gridHeight = self.fig.get_figheight()
def computeRect(self, ratio, frameRect, *args, **kwargs):
# Get the optional keyword
forceRatioOnWidth = kwargs.pop('forceRatioOnWidth', None)
forceRatioOnHeight = kwargs.pop('forceRatioOnHeight', None)
# get the frame allowed
framePosX, framePosY, frameWidth, frameHeight = frameRect
if(forceRatioOnWidth):
frameWidth = ratio * gridWidth / (frameHeight * gridHeight)
elif(forceRatioOnHeight):
frameHeight = ratio * (frameWidth * gridWidth) / gridHeight
rect = [framePosX + gridOffsetX,
framePosY + gridOffsetY,
frameWidth,
frameHeight]
return(rect)
return(computeRect)
class MyVGrid(MyGrid):
def __init__(self, fig):
self.lastOffsetY = 0
MyGrid.__init__(self, fig)
def generateComputeRect(self, *args, **kwargs):
self.axesCount = self.axesCount + 1
gridOffsetX = 0
gridOffsetY =
gridWidth = self.fig.get_figwidth()
gridHeight = self.fig.get_figheight()
def computeRect(self, ratio, frameRect, *args, **kwargs):
# Get the optional keyword
forceRatioOnWidth = kwargs.pop('forceRatioOnWidth', None)
forceRatioOnHeight = kwargs.pop('forceRatioOnHeight', None)
# get the frame allowed
framePosX, framePosY, frameWidth, frameHeight = frameRect
if(forceRatioOnWidth):
frameWidth = ratio * gridWidth / (frameHeight * gridHeight)
elif(forceRatioOnHeight):
frameHeight = ratio * (frameWidth * gridWidth) / gridHeight
rect = [framePosX + gridOffsetX,
framePosY + gridOffsetY,
frameWidth,
frameHeight]
return(rect)
return(computeRect)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment