Commit 599b5c7e authored by Yori 'AGy' Fournier's avatar Yori 'AGy' Fournier
Browse files

FEATURE: as seen

now you can create a figure interactively,
modify it and save it into a file thanks to

fig.print2file(<file-name>, as_seen = True)

without as_seen keyword the print2file function
will recall fig.plot and by this mean clean the axes
and redraw them as defined in the FigClass
parent 87001341
......@@ -156,7 +156,7 @@ class MyFig_base(Figure):
if (self.debug and rest != {}) :
print(DBUG + "These keywords have not been updated: " + str(rest))
return(True)
......@@ -167,6 +167,7 @@ class MyFig_base(Figure):
debug = kwargs.get('debug', D_DEBUG)
oformat = kwargs.get('oformat', D_OFORMAT)
opath = kwargs.get('opath', D_OPATH)
as_seen = kwargs.get('as_seen', False)
# set the dpi
if(oformat == 'png'):
......@@ -187,7 +188,8 @@ class MyFig_base(Figure):
canvas = FigureCanvas(self) # the canvas of the figure changed
# Plot the figure
self.plot()
if not as_seen:
self.plot()
# draw the figure on the new canvas
canvas.draw() # not really needed (savefig does that)
......@@ -244,7 +246,7 @@ class MyFig(MyFig_base):
# define user keywords before
# __init__ to erase them from kwargs
self.defineKeywords()
self.declareKeywords()
MyFig_base.__init__(self, rawdata, *args, **kwargs)
......@@ -262,8 +264,8 @@ class MyFig(MyFig_base):
# need to be done for the first init
self.set_rawdata(self.rawdata) # This function can be overwriten
# DEFINE KEYWORDS --------------------------------------------------
def defineKeywords(self):
# DECLARE KEYWORDS -------------------------------------------------
def declareKeywords(self):
pass
# ADD AXES ---------------------------------------------------------
......@@ -293,11 +295,14 @@ class MyFig(MyFig_base):
for ax, rawdata in zip(self.get_axes(), self.rawdata):
try:
if(self.debug):
ax.formatRawData(rawdata)
except:
print(SEVR + "The " + str(ax.__class__.__name__) + " with index " + str(self.get_axes().index(ax)) + " could not format the rawdata.")
return(False)
else:
try:
ax.formatRawData(rawdata)
except:
print(SEVR + "The " + str(ax.__class__.__name__) + " with index " + str(self.get_axes().index(ax)) + " could not format the rawdata.")
return(False)
if self.formatted is False:
self.formatted = True
......@@ -334,6 +339,6 @@ class MyFig(MyFig_base):
# RESET ------------------------------------------------------------
def reset(self, *args, **kwargs):
self.clf()
self.defineKeywords()
self.declareKeywords()
self._initialize(*args, **kwargs)
self.plot()
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