[IPOL discuss] enabling conditional visualization in demos

eml enric.meinhardt at cmla.ens-cachan.fr
Tue Aug 16 08:54:22 CEST 2011


Juan Cardelino <juan.cardelino at gmail.com>:

> A) TOOLS ALLOWED FOR VISUALIZATION:

> 1) imagemagick's convert:
> *status: installed
> *what do IPOL think about it?: I don't know
> *use: animating gifs for level set evolution for example

While less comfortably than using convert, animated gifs can be
already created using PIL.  See the file gifmaker.py in the PIL
distribution for an example.


> 2)Graphviz (i.e. dot command line option)
> *status: not installed
> *what do IPOL think about it?: I don't know

I think that graphviz is extremely standard and useful, and should be
allowed, at least in the conditional sense that you describe below.

> C) IMPLEMENTATION OF OPTIONAL VISUALIZATION OF GRAPHS

> Regarding the code to implement that, at the moment my app.py looks like this:
>
>        p1 = self.run_proc(['qnm','ms_tree_vec_demo',
> str(a),str(2),self.input_fname, 'output.tr', 'init_part.part'])
>        self.wait_proc(p1)
>
>        p2 = self.run_proc(['qnm','ms_apply_treei_color','output.tr',self.input_fname,
> str(lzero), 'output.png'])
>        self.wait_proc(p2)
>
>        if (self.use_visualization):
>            p3 = self.run_proc(['qnm','partition_to_dot_fancy',
> 'init_part.part',self.input_fname,'init_part.dot'],
> stdout=stdout_file, stderr=stdout_file)
>            self.wait_proc(p3)
>            p4 = self.run_proc([self.tool_neato, '-n2','-Tpng', '-O',
> 'init_part.dot'],stdout=stdout_file, stderr=stdout_file)
>            self.wait_proc(p4)
>        return

Let me propose a possible approach to solve this problem.

The variable "self.use_visualization" should start as true, and then
be set according to the output status of the "neato" command.  If the
command fails (because graphviz is not installed) this variable
becomes false.  Later, this variable is passed to the template to
enable/disable a piece of html:

%if use_visualization
   <!-- html snippet that displays the graph -->
%endif


More information about the discuss mailing list