Hello,
I patched vrml_browse.m so that it also considers whitedune as a vrml browser,
and so that it gives a more useful message if it does not find a working
browser. I also added a set_vrml_browser_name.m function. Both work on Debian
etch w/ octave 3.0.1 and octave-forge packages.
I did not commit them on svn because I haven't set up svn yet on my
replacement machine. So I send here vrml_browse.m and
set_vrml_browser_name.m in attachment. If someone could double-check and
check these in octave-forge, that'd be great; otherwise, I will check them
in myself anytime starting October 23 (I'll be too busy until then).
Hth,
Etienne
On Wed, September 24, 2008 08:22, [EMAIL PROTECTED] wrote:
#
# Hello,
#
# thanks for bringing my attention to this thread.
#
# On Wed, September 24, 2008 01:34, Thomas Weber wrote:
# # Am Mittwoch, den 24.09.2008, 10:00 +0200 schrieb David Bateman:
# #> Thomas Weber wrote:
# #> > Hi,
# #> >
# #> > vrml uses nze (in the the demos, at least), but doesn't declare a
# #> > dependency on the miscellaneous package.
# #> >
# #> > Same with nanstd and statistics package.
# #> >
# #> > And tars and struct package.
# #> >
# #> > Patch attached.
# #> >
# #> >
# #> Ok I applied it..
# #
# # Thanks,
# #
# #>
# #> > I still receive an error about a missing structure element:
# #> > vmesh example 1: failed
# #> > error: structure has no member `normalize'
# #> > but this might be due to my change from "freewrl" to "whitedune", which
# #> > is the actual reason for this mail:
# #> >
# #> > freewrl is not available in Debian. Is whitedune a suitable
#
# No freewrl package anymore? Uh oh. As a workaround, it seems the freewrl
# homepage http://freewrl.sourceforge.net/download.html gives instructions on
# how to add a repository that'll provide freewrl.
#
# Supporting whitedune seems a good idea. Unfortunately my debian system w/
# octave on it croaked for good on Sunday. I will try to install octave+debian
# on a new system, but I am time limited, so I don't know how far I will get.
# More news soon.
#
# Cheers,
#
# Etienne
#
# #> > replacement?
# #> I'm sorry I can't respond to that question as I have no idea.
# #
# # CC'ing Etienne, to get his opinion.
# #
# # Etienne, do you know if whitedune is a suitable replacement for freewrl?
# # The former is packaged in Debian, while the latter is not.
# #
# # Thanks
# # Thomas
# #
# #
# # -------------------------------------------------------------------------
# # This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
# # Build the coolest Linux based applications with Moblin SDK & win great
# prizes
# # Grand prize is a trip for two to an Open Source event anywhere in the world
# # http://moblin-contest.org/redirect.php?banner_id=100&url=/
# # _______________________________________________
# # Octave-dev mailing list
# # Octave-dev@lists.sourceforge.net
# # https://lists.sourceforge.net/lists/listinfo/octave-dev
# #
#
#
# --
# http://www.isr.ist.utl.pt/~etienne
#
#
--
http://www.isr.ist.utl.pt/~etienne
## Copyright (C) 2002 Etienne Grossmann. All rights reserved.
##
## This program is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by the
## Free Software Foundation; either version 2, or (at your option) any
## later version.
##
## This is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
## for more details.
##
## p = vrml_browse ([s]) - View vrml code s with FreeWRL
## vrml_browse ("-kill") - Kill the browser
##
## s : string : VRML code, as returned by the vrml_XYZ functions.
## If s is not specified, a sombrero is showed
##
## p : int : pid of the current browser. If freewrl has not been started
## or has died, a new one is started. p is zero or negative in
## case of failure to start freewrl.
##
## Some keystrokes for FreeWRL (more in the freewrl manpage) :
##
## 'e' : Examine : mouse 1 and drag rotates the scene
## mouse 3 and drag moves closer/farther
## 'w' : Walk : mouse 1 and drag moves for/backward, turns
## mouse 3 and drag translates parallel to the screen
## 's' : Save a snapshot in files 'octave.snapshot.NNNN.ppm'
## 'q' : Quit
##
## WARNING : FreeWRL >0.25 (http://www.crc.ca/FreeWRL/) must be installed.
##
## BUG : The vrml browser is not killed when octave exits. Sometimes the
## vrml browser does not get raised or gets raised improperly
## (shows the contents of the topmost window above it). Use
## "-kill".
##
## Author : Etienne Grossmann <[EMAIL PROTECTED]>
function p = vrml_browse (varargin)
verbose = 0;
best_option = " ";
# Allow scripting and specify where
# browser's output goes
##out_option = "--ps --psout /tmp/octave_browser_out.txt " ;
out_option = " " ;
geo_option = " " ;
global vrml_b_pid = 0;
global vrml_b_name = [];
p = vrml_b_pid ;
bop = "";
go_to_bg = 0;
if nargin<1
s = "";
else
i = 1;
while i <= length (varargin)
o = varargin{i++};
if strcmp (o, "-kill")
vrml_kill(); return;
elseif strcmp (o, "-bop") # Browser options
bop = [bop," ",varargin{i++}," "];
elseif strcmp (o, "-bg") # Browser options
go_to_bg = 1;
elseif strcmp (o, "-geometry") # Browser options
geo_option = varargin{i++};
if !ischar (geo_option)
assert (length (geo_option) == 2)
geo_option = sprintf ("--geometry %ix%i",geo_option);
else
geo_option = sprintf ("--geometry %s",geo_option);
end
end
end
s = varargin{length (varargin)};
end
if isempty (vrml_b_name)
if system ("which freewrl",1) == 0
vrml_b_name = "freewrl";
elseif system ("which whitedune",1) == 0
vrml_b_name = "whitedune";
else
printf (["\nvrml_browse: Can't find vrml browser. Please call\n",\
"\n\tset_vrml_browser_name (BROWSER_NAME)\n",\
"\nwith the name of an installed vrml browser.\n"]);
printf (["\n If your favorite browser is neither 'freewrl' nor 'whitedune'\n",\
"(the current defaults) write to [EMAIL PROTECTED]",\
"the name of your favorite browser so we can add it to the list of\n",\
"supported defaults\n\n"]);
return;
end
end
##vrml_b_name = "/home/etienne/bin/my_freewrl.sh";
##b_opt = [out_option," ",bop," ",best_option," --server --snapb octave.snap "]
##;
##b_opt = [out_option," ",bop," ",best_option," --server "] ;
##b_opt = [out_option," ",bop," ",best_option," --snapb octave_freewrl_snapshots "] ;
b_opt = [out_option," ",bop," ",best_option, " ",geo_option] ;
b_temp = "/tmp/octave_vrml_output.wrl" ;
b_log = " &> /tmp/octave_vrml_browser.log";
new_browser = 0 ;
# ####################################
if vrml_b_pid > 0 # There's already a browser ##########
# Check that browser is really alive
[status, dum] = system (sprintf ("kill -CONT %d &> /dev/null",vrml_b_pid));
if ! status
if verbose
printf ( "vrml_browse : browser pid=%d is still alive\n",vrml_b_pid);
end
else
if verbose
printf ( ["vrml_browse : ",\
"browser pid=%d died. I'll spawn another\n"], vrml_b_pid);
end
vrml_b_pid = -1 ;
end
end # End of check if old browser's alive
# ####################################
# ####################################
# Check that temp file exists ########
[status, dum] = system (["test -e ",b_temp]);
if !length (s)
if verbose
printf( "vrml_browse : Trying to create temp file\n");
end
# Do a sombrero
n = 30 ;
x = y = linspace (-8, 8, n)';
[xx, yy] = meshgrid (x, y);
r = sqrt (xx .^ 2 + yy .^ 2) + eps;
z = 3*sin (r) ./ (2*r);
x /= 4 ; y /= 4 ;
## pix = ones (n) ;
## tmp = [1 0 0 1 1 1 0 0 1 1 0 0 0 0 0 1 1 0 0 1 1 1 0 1 0 1 1 0 0 0 ;\
## 0 1 1 0 1 0 1 1 0 1 1 1 0 1 1 1 0 1 1 0 1 1 0 1 0 1 1 0 1 1 ;\
## 0 1 1 0 1 0 1 1 1 1 1 1 0 1 1 1 0 1 1 0 1 1 0 1 0 1 1 0 0 0 ;\
## 0 1 1 0 1 0 1 1 0 1 1 1 0 1 1 1 0 0 0 0 1 1 0 1 0 1 1 0 1 1 ;\
## 1 0 0 1 1 1 0 0 1 1 1 1 0 1 1 1 0 1 1 0 1 1 1 0 1 1 1 0 0 0 ];
## rtmp = rows(tmp)+2;
## for i=1:rtmp:n-rtmp,
## pix(i+[1:rows(tmp)],1:columns(tmp)) = tmp ;
## end
## pix = flipud (pix);
## col = [1;1;1]*pix(:)' ;
## keyboard
rmat = [0.90000 -0.38730 0.20000;
0.38730 0.50000 -0.77460;
0.20000 0.77460 0.60000];
## s = vrml_points ([x(:),y(:),z(:)],"balls");
## s = vrml_transfo (vrml_thick_surf (x,y,z, "col",col), [0.25,0,0],rmat);
s = vrml_transfo (vrml_thick_surf (x,y,z), [0.25,0,0],rmat );
end
save_vrml (b_temp, s); # "nobg", s) ;
# End of preparing temp file #########
# ####################################
# ####################################
# Eventually start browser ###########
if vrml_b_pid <= 0
new_browser = 1 ;
if verbose,
printf( "vrml_browse : spawning browser ...\n");
end
## keyboard
# Starting a background browser :
#
# popen2 seems broken.
# popen had some problem, can't recall what
# system "async" does not give me pid of
# browser, but pid of shell
# system "sync" only returns when child
# process has exited
#
# So my solution is : "system" a process that
# forks. Its child is a browser. The parent
# prints the child's pid (given by fork())
# and exits. Octave reads the output of the
# system call, which is the browser's pid.
# Phew!
if 1
cmd = [vrml_b_name," ",b_opt," ",b_temp," "]
## [status, out] = system (cmd = [vrml_b_name," ",b_opt," \"file:",b_temp,"\""], 1);
[status, out] = system (cmd = [vrml_b_name," ",b_opt," ",b_temp], 1);
## cmd
if status,
printf("vrml_browse : Can't start browser '%s'. Is it installed?\n",\
vrml_b_name);
p = vrml_b_pid ;
return ;
else
vrml_b_pid = -1;
server_works = 0;
end
if server_works
vrml_b_pid = str2num (out);
end
if verbose, printf( "vrml_browse : OK\n"); end
end
end # End of starting new browser ########
# ####################################
if (!new_browser) && (vrml_b_pid > 1)
# ####################################
# Send USR1 signal to browser to tell it to
# raise itself.
[status, dum] = system (sprintf ("kill -USR1 %d &> /dev/null",vrml_b_pid));
if status,
printf ("vrml_browse : browser pid=%d can't be signaled\n",vrml_b_pid);
else
if verbose,
printf( ["vrml_browse : USR1 sent to browser pid=%d\n"], vrml_b_pid);
end
end
end # End of signaling browser ##########
# ####################################
p = vrml_b_pid ;
endfunction
## Copyright (C) 2002 Etienne Grossmann. All rights reserved.
##
## This program is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by the
## Free Software Foundation; either version 2, or (at your option) any
## later version.
##
## This is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
## for more details.
##
## set_vrml_browser_name (n) - Set the name of the vrml browser
##
## set_vrml_browser_name (n) sets the name of the vrml browser used by
## vrml_browse() and vmesh(). Any vrml browser that can be called with
##
## BROWSER_NAME VRML_FILE.wrl can be used.
##
function set_vrml_browser_name (n)
global vrml_b_name;
vrml_b_name = n;
## Should do a better check, since vrml_b_name may be a file in path
##if ! exist (vrml_b_name, "file")
## printf (["set_vrml_browser_name: Warning! ",\
## "Setting vrml browser name to '%s' which is not a file\n"],\
## vrml_b_name);
##end
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev