From 99f4a01a48bf9bd834f82c9fad18f70f6869e302 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Thu, 12 Dec 2013 16:04:57 +0100 Subject: [PATCH] reporting: fix figure inclusion for windows --- doc/dynare.texi | 6 +++++- matlab/reports/@graph/createGraph.m | 5 ++--- matlab/reports/@graph/graph.m | 6 ++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index 5a51e28ed..8a30d916d 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -10346,7 +10346,7 @@ command. Default: @code{`!'} @end table @end defmethod -@defmethod Report addGraph data, figname, graphSize, showGrid, showLegend, showLegendBox, legendLocation, legendOrientation, legendFontSize, seriesToUse, shade, shadeColor, shadeOpacity, title, xlabel, ylabel, xrange, xTickLabels, yrange, showZeroline +@defmethod Report addGraph data, figname, figDirName, graphSize, showGrid, showLegend, showLegendBox, legendLocation, legendOrientation, legendFontSize, seriesToUse, shade, shadeColor, shadeOpacity, title, xlabel, ylabel, xrange, xTickLabels, yrange, showZeroline Adds a @code{Graph} to a @code{Section}. @optionshead @table @code @@ -10359,6 +10359,10 @@ The @code{dseries} that provides the data for the graph. Default: The name to use when saving this figure. Default: @code{[tempname `.tex']} +@item figDirName, @code{STRING} +The name of the folder in which to store this figure. Default: +@code{tmpFigDir} + @item graphSize, @code{NUMERICAL_VECTOR} The width and height to be passed to the third and fourth elements of the array passed to the @code{`Position'} option of Matlab's diff --git a/matlab/reports/@graph/createGraph.m b/matlab/reports/@graph/createGraph.m index 98543ff0d..49ce04f8d 100644 --- a/matlab/reports/@graph/createGraph.m +++ b/matlab/reports/@graph/createGraph.m @@ -135,12 +135,11 @@ end drawnow; if isempty(o.figname) - tn = tempname; + [junk, tn] = fileparts(tempname); if strcmp(computer, 'PCWIN') || strcmp(computer, 'PCWIN64') - tn = strrep(tn, '\', '/'); tn = strrep(tn, '_', '\_'); end - o.figname = [tn '.tex']; + o.figname = [o.figDirName filesep tn '.tex']; end disp(' converting to tex....'); if isoctave && isempty(regexpi(computer, '.*apple.*', 'once')) diff --git a/matlab/reports/@graph/graph.m b/matlab/reports/@graph/graph.m index c328f823d..812d98992 100644 --- a/matlab/reports/@graph/graph.m +++ b/matlab/reports/@graph/graph.m @@ -39,6 +39,7 @@ o.title = ''; o.ylabel = ''; o.xlabel = ''; +o.figDirName = 'tmpFigDir'; o.figname = ''; o.data = ''; o.seriesToUse = ''; @@ -92,6 +93,7 @@ assert(ischar(o.title), '@graph.graph: title must be a string'); assert(ischar(o.xlabel), '@graph.graph: xlabel file must be a string'); assert(ischar(o.ylabel), '@graph.graph: ylabel file must be a string'); assert(ischar(o.figname), '@graph.graph: figname must be a string'); +assert(ischar(o.figDirName), '@graph.graph: figDirName must be a string'); assert(islogical(o.showGrid), '@graph.graph: showGrid must be either true or false'); assert(islogical(o.showLegend), '@graph.graph: showLegend must be either true or false'); assert(islogical(o.showLegendBox), '@graph.graph: showLegendBox must be either true or false'); @@ -150,6 +152,10 @@ end o = rmfield(o, 'seriesToUse'); o = rmfield(o, 'data'); +if ~exist(o.figDirName, 'file') + mkdir(o.figDirName); +end + % Create graph object o = class(o, 'graph'); end \ No newline at end of file