[Scilab-users] ?==?utf-8?q? Exporting graphic figure and its calcs

Alexis Cros Alexis.Cros at promes.cnrs.fr
Tue Jun 6 10:25:26 CEST 2017


Hi. IrfanView does the job (under Windows)! It's a nice command line 
based graphic editor.

Grand thank you your all your responses.

Have a nice week

Alexis



Le 31/05/2017 à 18:09, Philipp Mühlmann a écrit :
> Hallo,
> I understand you want to export a GUI-surface with all entities 
> (buttons, etc) as an image.
>
> For windows machines one can use the dos() command, connected with 
> irfanView to create screen shots and save them as an image.
>
> Have a look at the irfanView i_options.txt to see what can be done by 
> calling irfanView.
>
> Here an example:
> you might exchange the path-variables to your needs
>
>
> h  =  figure('position',  [50  50  400  400],  'backgroundcolor',  [0.7  0.9  1],  ..
> "figure_name",  'WHAT DAY WERE YOU BORN?');
>
> T1  =  uicontrol(h,  'style',  'text',  'string',  'Type year:',  ..
> 'position',  [20  340  200  50],  'backgroundcolor',  [0.7  0.9  1]);
>
> E1  =  uicontrol(h,  'style',  'edit',  'string',  '2000',  ..
> 'position',  [150  350  70  30],  'fontsize',  15,  'backgroundcolor',  [1  1  1]);
>
> T2  =  uicontrol(h,  'style',  'text',  'string',  'Select month:',  ..
> 'position',  [20  260  200  50],  'backgroundcolor',  [0.7  0.9  1]);
>
> L1  =  uicontrol(h,  'style',  'listbox',  'position',  [150  130  120  170],  ..
>   'fontsize',  15,  'backgroundcolor',  [1  1  1]);
> set(L1,  'string',  'January | February | March | April | May | June | ..
> July | August | September | October | November | December');  
> set(L1,  'value',  [1:12]);
>
> T3  =  uicontrol(h,  'style',  'text',  'string',  'Type date:',  ..
> 'position',  [20  60  200  50],  'backgroundcolor',  [0.7  0.9  1]);
>
> E2  =  uicontrol(h,  'style',  'edit',  'string',  '15',  ..
> 'position',  [150  70  70  30],  'fontsize',  15,  'backgroundcolor',  [1  1  1]);
>
> function  birthday(guientries)
>         y  =  eval(get(E1,  'string'))
>         m  =  get(L1,  'value')
>         d  =  eval(get(E2,  'string'))
>      num  =  datenum(y,  m,  d);
>      [n,  s]  =  weekday(num);  
>      disp('You were born on '+s)
> endfunction
>
> P1  =  uicontrol(h,  'position',  [300  70  80  30],  'style',  'pushbutton',  ..
> 'string',  'Submit',  'callback',  'birthday',  'backgroundcolor',  [1  1  0]);
>
> // access IrfanView and try to make a screen shot of the GUI
> IV_PATH  =  'C:\Program Files (x86)\IrfanView';
>
> OUT_PATH  =  'E:\Scilab_Uebungen\031_call_software'
>
> // capture the GUI crop it, so that figure borders are not visible 
> anymore and save it as a png file
> dos('i_view32.exe /capture=3 /crop=(0,47,0,420,0) 
> /convert='+OUT_PATH+'\test.png ');
>
>
> Good luck,
> Philipp
>
>
>
>
>
> 2017-05-31 14:54 GMT+02:00 Alexis Cros <Alexis.Cros at promes.cnrs.fr 
> <mailto:Alexis.Cros at promes.cnrs.fr>>:
>
>     Hi,
>
>     nice trick. May be interesting to transcode it to other OSs and to
>     integrate into the Scilab built-in functions.
>
>     Thank you for the tip
>
>     A.
>
>
>
>     Le 31/05/2017 à 10:47, Antoine Monmayrant a écrit :
>
>         Hello again,
>
>         To add more details to my previous answer, here is the
>         function I hastily hacked together to workaround the bug that
>         prevent exporting uicontrols:
>
>
>         function exportHack()
>             // Export figure with uicontrols to png using X server &
>         import (imagemagick)
>             // Horrible hack that should only work on my machine
>         (linux 64bits)
>             // get around bug
>         http://bugzilla.scilab.org/show_bug.cgi?id=14836
>         <http://bugzilla.scilab.org/show_bug.cgi?id=14836>
>         https://bugzilla.scilab.org/show_bug.cgi?id=14502
>         <https://bugzilla.scilab.org/show_bug.cgi?id=14502>
>              h=gcbo;
>              //current figure name
>              figname=h.parent.parent.figure_name;
>              //getting X server id for current window
>              ret=unix_g("xwininfo -int -name " +""""+figname+"""");
>              //hackish, depends directly on the syntax of xwininfo outputs
>              tok=tokens(ret(2),':');
>             tok=tokens(tok(3)," ")
>             winid=tok(1);//X server windows id, as a string
>                 // File save dialog parameters
>             file_mask=["*.png"];
>             boxTitle="Export";
>             //If previous filename is present, use it to start in the
>         corresponding directory
>             if h.userdata~="" then
>                dir=h.userdata;
>             else
>                dir=pwd();
>             end
>             dir
>             PathFileName=uiputfile(file_mask,dir,boxTitle);
>             // LD_LIBRARY_PATH required to get around bug:
>         http://bugzilla.scilab.org/show_bug.cgi?id=14143
>         <http://bugzilla.scilab.org/show_bug.cgi?id=14143>
>            
>         unix_s("LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH
>         ; import -window "+winid +" "+PathFileName)
>            //   keep savec filename for future reference.
>             h.userdata=PathFileName;
>         endfunction
>
>         It only works on a linux system with X server and imagemagick.
>         It will not run out of the box on your system, but it might
>         inspire you to find your own workaround.
>
>         Hope it helps,
>
>         Antoine
>
>
>
>         Le Mardi, Mai 30, 2017 15:58 CEST, Alexis Cros
>         <Alexis.Cros at promes.cnrs.fr
>         <mailto:Alexis.Cros at promes.cnrs.fr>> a écrit:
>
>             Hello,
>
>             I have created a graphic figure which contains several
>             things :
>
>                       - uicontrol frames which contain axes
>             (polarplot, plot2d...)
>
>                       - uicontrol texts
>
>             gui_sumup  =  figure(55,        'Position',  [0  0
>             my_screen_size(1)-H_BORDERS_THICK
>             my_screen_size(2)-START_BAR_THICK],..                    
>                                  // Position x, y and size x, y
>                 'BackgroundColor',  BLUE,..
>                 'Figure_name',  'Emissivity compute utility')
>
>             I would like to export the full figure containing all
>             entities. When I
>             execute the folowing instruction, only the background
>             figure is exported :
>
>             xs2png(gui_sumup,  computed_folder_path  +
>             '\Graphs\SUM_UP-'  +  csv_main_header_edit.String +  '.png')
>
>             or
>
>             xs2png(55 ,  computed_folder_path  + '\Graphs\SUM_UP-'  + 
>             csv_main_header_edit.String +  '.png')
>
>             Is there a way to encapsulate all entities into the
>             general figure (like
>             merging?) to export it ?
>
>             Thanks
>
>             Alexis
>
>         _______________________________________________
>         users mailing list
>         users at lists.scilab.org <mailto:users at lists.scilab.org>
>         http://lists.scilab.org/mailman/listinfo/users
>         <http://lists.scilab.org/mailman/listinfo/users>
>
>
>     _______________________________________________
>     users mailing list
>     users at lists.scilab.org <mailto:users at lists.scilab.org>
>     http://lists.scilab.org/mailman/listinfo/users
>     <http://lists.scilab.org/mailman/listinfo/users>
>
>
>
>
> -- 
> In Kanada is' ka' na' da. Sonst wär' Kanada Jemanda.
>
> There we have the salad.
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20170606/4d6c2d45/attachment.htm>


More information about the users mailing list