Commit c157736f authored by Yori 'AGy' Fournier's avatar Yori 'AGy' Fournier
Browse files

Changed the position of computeFitRect because of import ussues

Now I put computeFitRect Back tp myAxes, because it is a required function,
and also because in mytool It won't work becuase myTool requires to import
myFig, which can not be done before myAxes.

Therefore computeFitRect is still imported as a tool in __init__ but
from myAxes.
parent 5ca25d9c
......@@ -97,7 +97,8 @@ from .mytool import window_exists, getCurrentWindowIDs
from .mytool import print2file, print2screen, printListCurrentWindows
from .mytool import getWindow, getFigOnWindow, drawFigOnWindow, giveDataToWindow
from .mytool import closeWindow, closeAllWindows
from .mytool import FigOneAxes, computeFitRect
from .mytool import FigOneAxes
from .myAxes import computeFitRect
from .test import myTest
......
......@@ -46,10 +46,50 @@
# IMPORT ---------------------------------------------------------------
from . import SEVR, DBUG
from . import Axes
from .mytool import computeFitRect
from . import rcParams
# COMPUTE SMART FRAME -----------------------------------------------
def computeFitRect(fig, ratio, frameRect):
# get the frame allowed
framePosX, framePosY, frameWidth, frameHeight = frameRect
# get the size of the figure
figWidth = fig.get_figwidth()
figHeight = fig.get_figheight()
figDpi = fig.get_dpi()
# get the font size in inches
fontsize = rcParams['font.size'] / figDpi
# the largest width and height allowed in inches
maxWidth = figWidth * frameWidth - 8. * (figDpi / 75.) * fontsize
maxHeight = figHeight * frameHeight - 4. * (figDpi / 75.) * fontsize
# the hypothetical width and height in inches
# for a given aspect ratio
hypoWidth = maxHeight / ratio
hypoHeight = maxWidth * ratio
# if the hypothetical width is larger that the
# maximum allowed width (in inches) then chose
# the hypothetical Height
if (hypoWidth > maxWidth):
height = hypoHeight / figHeight # height in percent
width = maxWidth / figWidth # width in percent
posX = framePosX + 4. * (figDpi / 75.) * fontsize / figWidth # posX
posY = framePosY + 3. * (figDpi / 75.) * fontsize / figHeight # posY
else:
height = maxHeight / figHeight
width = hypoWidth / figWidth
posX = framePosX + (frameWidth - width) / 2.
posY = framePosY + 3. * (figDpi / 75.) * fontsize / figHeight
rect = [posX, posY, width, height]
return(rect)
# Class MyAxes Overwriting Matplotlib.figure.Axes
class MyAxes(Axes):
......
......@@ -11,7 +11,6 @@ from .myTool import giveDataToWindow
from .myTool import drawFigOnWindow
from .myTool import closeAllWindows
from .myTool import closeWindow
from .myTool import computeFitRect
from .figOneAxes import FigOneAxes
from .axPlot2D import AxPlot2D
......
......@@ -371,44 +371,3 @@ def print2file(ClassName, inputArg, filename, *args, **kwargs):
# end
return(True)
# COMPUTE SMART FRAME -----------------------------------------------
def computeFitRect(fig, ratio, frameRect):
# get the frame allowed
framePosX, framePosY, frameWidth, frameHeight = frameRect
# get the size of the figure
figWidth = fig.get_figwidth()
figHeight = fig.get_figheight()
figDpi = fig.get_dpi()
# get the font size in inches
fontsize = rcParams['font.size'] / figDpi
# the largest width and height allowed in inches
maxWidth = figWidth * frameWidth - 8. * (figDpi / 75.) * fontsize
maxHeight = figHeight * frameHeight - 4. * (figDpi / 75.) * fontsize
# the hypothetical width and height in inches
# for a given aspect ratio
hypoWidth = maxHeight / ratio
hypoHeight = maxWidth * ratio
# if the hypothetical width is larger that the
# maximum allowed width (in inches) then chose
# the hypothetical Height
if (hypoWidth > maxWidth):
height = hypoHeight / figHeight # height in percent
width = maxWidth / figWidth # width in percent
posX = framePosX + 4. * (figDpi / 75.) * fontsize / figWidth # posX
posY = framePosY + 3. * (figDpi / 75.) * fontsize / figHeight # posY
else:
height = maxHeight / figHeight
width = hypoWidth / figWidth
posX = framePosX + (frameWidth - width) / 2.
posY = framePosY + 3. * (figDpi / 75.) * fontsize / figHeight
rect = [posX, posY, width, height]
return(rect)
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