Commit c018389a authored by hrchilds's avatar hrchilds

Update from October 6, 2003

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@92 18c085ea-50e0-402c-830e-de6fd14e8384
parent 0469af87
......@@ -109,15 +109,14 @@ def applyFunctionToFrames(func, nframes, conversionargs):
# Programmer: Brad Whitlock
# Date: Wed Dec 18 11:33:22 PDT 2002
#
# Modifications:
# Brad Whitlock, Fri Oct 3 13:12:54 PST 2003
# Changed so it uses unlink to remove files.
#
###############################################################################
def RemoveFile(fileName):
command = "rm "
if(sys.platform == "win32"):
command = "del "
command = command + " " + fileName
# Remove the files.
os.system(command)
os.unlink(fileName)
def removeFilesHelper(threadID, start, end, conversionargs):
# Get the arguments out of the tuple.
......@@ -183,6 +182,20 @@ def EncodeQuickTimeMovieHelper(threadID, start, end, conversionargs):
subMovieName = "%s.%d" % (moviename, threadID)
createQuickTimeFile(subMovieName, baseFormat, start, end, xres, yres)
###############################################################################
# Function: MovieClassSaveWindow
#
# Purpose: This function is called from the mangled Python script when it
# wants to save an image.
#
# Programmer: Brad Whitlock
# Date: Fri Oct 3 12:47:32 PDT 2003
#
###############################################################################
classSaveWindowObj = 0
def MovieClassSaveWindow():
return classSaveWindowObj.SaveImage2()
###############################################################################
# Class: MakeMovie
#
......@@ -192,6 +205,8 @@ def EncodeQuickTimeMovieHelper(threadID, start, end, conversionargs):
# Date: Mon Jul 28 12:45:45 PDT 2003
#
# Modifications:
# Brad Whitlock, Fri Oct 3 11:14:59 PDT 2003
# Added support for processing Python files.
#
###############################################################################
......@@ -204,6 +219,10 @@ class MakeMovie:
# Programmer: Brad Whitlock
# Date: Mon Jul 28 13:58:06 PST 2003
#
# Modifications:
# Brad Whitlock, Fri Oct 3 11:14:50 PDT 2003
# Added support for processing Python files.
#
###########################################################################
def __init__(self):
......@@ -222,6 +241,8 @@ class MakeMovie:
# Movie properties.
self.stateFile = ""
self.scriptFile = ""
self.usingStateFile = 1
self.frameBase = "frame"
self.movieBase = "movie"
self.movieFormat = self.MPEG_MOVIE
......@@ -250,10 +271,14 @@ class MakeMovie:
# Brad Whitlock, Tue Aug 12 09:57:05 PDT 2003
# Added a note about Windows.
#
# Brad Whitlock, Fri Oct 3 11:16:12 PDT 2003
# Added -scriptfile.
#
###########################################################################
def PrintUsage(self):
print "Usage: visit -movie [-format fmt] [-geometry size] -sessionfile name"
print " -sessionfile name | -scriptfile name "
print " [-output moviename] [-framestep step]"
print ""
print "OPTIONS"
......@@ -297,6 +322,10 @@ class MakeMovie:
print " when you save your session from within VisIt's "
print " GUI after you set up your plots how you want them."
print ""
print " -scriptfile name The scriptfile option lets you pick the name"
print " of a VisIt Python script to use as input for your"
print " movie."
print ""
print " -framestep step The number of frames to advance when going to "
print " the next frame."
print ""
......@@ -330,6 +359,9 @@ class MakeMovie:
# Brad Whitlock, Tue Aug 12 09:57:31 PDT 2003
# Prevented use of mpeg, qt, and sm on Windows.
#
# Brad Whitlock, Fri Oct 3 11:25:33 PDT 2003
# Added support for -scriptfile.
#
###########################################################################
def ProcessArguments(self):
......@@ -384,6 +416,15 @@ class MakeMovie:
elif(sys.argv[i] == "-sessionfile"):
if((i+1) < len(sys.argv)):
self.stateFile = sys.argv[i+1]
self.usesStateFile = 1
i = i + 1
else:
self.PrintUsage()
sys.exit(-1)
elif(sys.argv[i] == "-scriptfile"):
if((i+1) < len(sys.argv)):
self.scriptFile = sys.argv[i+1]
self.usesStateFile = 0
i = i + 1
else:
self.PrintUsage()
......@@ -424,9 +465,9 @@ class MakeMovie:
# Make sure that the user provided the -sessionfile option or we can't
# make a movie!
if(self.stateFile == ""):
if(self.stateFile == "" and self.scriptFile == ""):
self.PrintUsage()
print "You must provide the -sessionfile option!"
print "You must provide the -sessionfile or the -scriptfile option!"
sys.exit(-1)
# If the movie is just a set of frames, make sure that we use the
......@@ -491,6 +532,26 @@ class MakeMovie:
SetSaveWindowAttributes(s)
return SaveWindow()
###########################################################################
# Method: SaveImage2
#
# Purpose: This method tells VisIt to save an image.
#
# Notes: This method is called when we save an image from a Python
# script.
#
# Programmer: Brad Whitlock
# Date: Fri Oct 3 12:45:30 PDT 2003
#
###########################################################################
def SaveImage2(self):
# Figure out the extension for the output files.
ext = self.LookupImageExtension(self.outputFormat)
retval = self.SaveImage(self.numFrames, ext)
self.numFrames = self.numFrames + 1
return retval
###########################################################################
# Method: LookupImageExtension
#
......@@ -514,6 +575,47 @@ class MakeMovie:
retval = "rgb"
return retval
###########################################################################
# Method: CreateMangledSource
#
# Purpose: This method reads in the Python file that we want to execute
# and creates an alternate version in which all of the
# SaveWindow method calls have been replaced with
# MovieClassSaveWindow.
#
# Programmer: Brad Whitlock
# Date: Mon Jul 28 13:58:06 PST 2003
#
###########################################################################
def CreateMangledSource(self, name):
import string
# Read in the Python file that we want to source.
f = open(name, "r")
lines = f.readlines()
f.close()
#
# Create a new Python file and save modified source where every call
# to VisIt's SaveWindow() method gets replaced by MovieClassSaveWindow()
# which causes the script to save the image using the name and format
# prescribed by this movie framework.
#
newname = "%s.mangled" % name
f = open(newname, "w")
for line in lines:
index = string.find(line, "SaveWindow()")
if index == -1:
f.write(line)
else:
before = line[:index]
after = line[index+len("SaveWindow()")]
f.write(before + "MovieClassSaveWindow()" + after)
f.close()
return newname
###########################################################################
# Method: GenerateFrames
#
......@@ -522,6 +624,12 @@ class MakeMovie:
# Programmer: Brad Whitlock
# Date: Mon Jul 28 13:58:06 PST 2003
#
# Modifications:
# Brad Whitlock, Fri Oct 3 11:27:50 PDT 2003
# Changed to allow scripts to save images. I also forced camera view
# mode to be enabled so keyframe animations that change the view actually
# save images that have a keyframed view.
#
###########################################################################
def GenerateFrames(self):
......@@ -533,21 +641,36 @@ class MakeMovie:
# Figure out the extension for the output files.
ext = self.LookupImageExtension(self.outputFormat)
# Make the viewer try and restore its session using the file that
# was passed in.
RestoreSession(self.stateFile, 0)
# Make sure that plots are all drawn.
DrawPlots()
# Save an image for each frame in the animation.
self.numFrames = 0
i = 0
while(i < AnimationGetNFrames()):
AnimationSetFrame(i)
self.SaveImage(self.numFrames, ext)
self.numFrames = self.numFrames + 1
i = i + self.frameStep
if(self.usesStateFile):
# Make the viewer try and restore its session using the file that
# was passed in.
RestoreSession(self.stateFile, 0)
# Make sure that plots are all drawn.
DrawPlots()
# Make sure that camera view mode is on so that if we have a
# saved keyframe animation, we really get the keyframed view.
if(GetWindowInformation().cameraViewMode == 0):
ToggleCameraViewMode()
# Save an image for each frame in the animation.
self.numFrames = 0
i = 0
while(i < AnimationGetNFrames()):
AnimationSetFrame(i)
self.SaveImage(self.numFrames, ext)
self.numFrames = self.numFrames + 1
i = i + self.frameStep
else:
# Save the callback data so we can call methods on this object.
globals()['classSaveWindowObj'] = self
# Create a modified version of the user's script.
name = self.CreateMangledSource(self.scriptFile)
# Try executing the modified version of the user's script.
Source(name)
# Remove the modified script.
RemoveFile(name);
###########################################################################
# Method: EncodeMPEGMovie
......
......@@ -261,6 +261,9 @@ $0 = shift @ARGV;
# Jeremy Meredith, Mon Sep 29 11:26:47 PDT 2003
# Added help for the "-o" and "-launchengine" flags.
#
# Brad Whitlock, Fri Oct 3 12:59:49 PDT 2003
# I made the -s argument become -scriptfile when -movie is specified.
#
###############################################################################
......@@ -370,7 +373,7 @@ USAGE: visit [arguments]
Scripting arguments:
-s <scriptname> Runs the specified VisIt script. Note that
this argument only takes effect with -cli.
this argument only takes effect with -cli or -movie.
-verbose Prints status information during pipeline
execution.
......@@ -459,6 +462,7 @@ while (scalar(@ARGV) > 0) {
elsif ($arg eq "-time_annotation" ) { $exe_name = "time_annotation"; }
elsif ($arg eq "-mpeg_encode" ) { $exe_name = "mpeg_encode"; }
elsif ($arg eq "-movie" ) { $exe_name = "cli"; $add_movie_args = 1; }
elsif ($arg eq "-s") { if($add_movie_args) { $sfile = shift; push @visitargs, "-scriptfile", $sfile;} else { push @visitargs, $arg;}}
elsif ($arg eq "-publicpluginsonly"){ $publiconly = 1; push @visitargs, $arg; }
elsif ($arg eq "-version") { $want_version = 1; }
elsif ($arg eq "-help") { print STDERR "$usage\n"; exit(0); }
......@@ -1113,7 +1117,6 @@ else
print GDBFILE "directory $ENV{VISITHOME}/components/Database/Database\n";
print GDBFILE "directory $ENV{VISITHOME}/components/Database/Formats\n";
print GDBFILE "directory $ENV{VISITHOME}/components/Database/Ghost\n";
print GDBFILE "directory $ENV{VISITHOME}/components/Database/MIR\n";
print GDBFILE "directory $ENV{VISITHOME}/components/Exceptions/Database\n";
print GDBFILE "directory $ENV{VISITHOME}/components/Exceptions/Pipeline\n";
print GDBFILE "directory $ENV{VISITHOME}/components/Exceptions/VisWindow\n";
......@@ -1123,6 +1126,9 @@ else
print GDBFILE "directory $ENV{VISITHOME}/components/Expressions/Math\n";
print GDBFILE "directory $ENV{VISITHOME}/components/Expressions/MeshQuality\n";
print GDBFILE "directory $ENV{VISITHOME}/components/Math\n";
print GDBFILE "directory $ENV{VISITHOME}/components/MIR/Base\n";
print GDBFILE "directory $ENV{VISITHOME}/components/MIR/Tet\n";
print GDBFILE "directory $ENV{VISITHOME}/components/MIR/Zoo\n";
print GDBFILE "directory $ENV{VISITHOME}/components/Pipeline/Data\n";
print GDBFILE "directory $ENV{VISITHOME}/components/Pipeline/Pipeline\n";
print GDBFILE "directory $ENV{VISITHOME}/components/Pipeline/PrivateFilters\n";
......
......@@ -10,7 +10,7 @@
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Wed Jul 23 11:29:38 PDT 2003
// Creation: Fri Oct 3 10:16:08 PDT 2003
//
// Modifications:
//
......@@ -33,7 +33,7 @@ ColorAttribute::ColorAttribute() : AttributeSubject("U")
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Wed Jul 23 11:29:38 PDT 2003
// Creation: Fri Oct 3 10:16:08 PDT 2003
//
// Modifications:
//
......@@ -59,7 +59,7 @@ ColorAttribute::ColorAttribute(const ColorAttribute &obj) : AttributeSubject("U"
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Wed Jul 23 11:29:38 PDT 2003
// Creation: Fri Oct 3 10:16:08 PDT 2003
//
// Modifications:
//
......@@ -79,7 +79,7 @@ ColorAttribute::~ColorAttribute()
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Wed Jul 23 11:29:38 PDT 2003
// Creation: Fri Oct 3 10:16:08 PDT 2003
//
// Modifications:
//
......@@ -106,7 +106,7 @@ ColorAttribute::operator = (const ColorAttribute &obj)
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Wed Jul 23 11:29:38 PDT 2003
// Creation: Fri Oct 3 10:16:08 PDT 2003
//
// Modifications:
//
......@@ -135,7 +135,7 @@ ColorAttribute::operator == (const ColorAttribute &obj) const
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Wed Jul 23 11:29:38 PDT 2003
// Creation: Fri Oct 3 10:16:08 PDT 2003
//
// Modifications:
//
......@@ -156,7 +156,7 @@ ColorAttribute::operator != (const ColorAttribute &obj) const
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Wed Jul 23 11:29:38 PDT 2003
// Creation: Fri Oct 3 10:16:08 PDT 2003
//
// Modifications:
//
......@@ -177,7 +177,7 @@ ColorAttribute::TypeName() const
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Wed Jul 23 11:29:38 PDT 2003
// Creation: Fri Oct 3 10:16:08 PDT 2003
//
// Modifications:
//
......@@ -205,7 +205,7 @@ ColorAttribute::CopyAttributes(const AttributeGroup *atts)
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Wed Jul 23 11:29:38 PDT 2003
// Creation: Fri Oct 3 10:16:08 PDT 2003
//
// Modifications:
//
......@@ -231,7 +231,7 @@ ColorAttribute::CreateCompatible(const std::string &tname) const
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Wed Jul 23 11:29:38 PDT 2003
// Creation: Fri Oct 3 10:16:08 PDT 2003
//
// Modifications:
//
......@@ -258,7 +258,7 @@ ColorAttribute::NewInstance(bool copy) const
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Wed Jul 23 11:29:38 PDT 2003
// Creation: Fri Oct 3 10:16:08 PDT 2003
//
// Modifications:
//
......@@ -286,7 +286,9 @@ ColorAttribute::SelectAll()
// Creation: Wed Jul 23 11:29:38 PDT 2003
//
// Modifications:
//
// Brad Whitlock, Fri Oct 3 10:13:43 PDT 2003
// I made it always save to the parentNode.
//
// ****************************************************************************
bool
......@@ -295,27 +297,13 @@ ColorAttribute::CreateNode(DataNode *parentNode, bool forceAdd)
if(parentNode == 0)
return false;
ColorAttribute defaultObject;
bool addToParent = false;
// Create a node for ColorAttribute.
DataNode *node = new DataNode("ColorAttribute");
node->AddNode(new DataNode("color", color, 4));
parentNode->AddNode(node);
if(!FieldsEqual(0, &defaultObject))
{
addToParent = true;
node->AddNode(new DataNode("color", color, 4));
}
// Add the node to the parent node.
if(addToParent || forceAdd)
parentNode->AddNode(node);
else
delete node;
return (addToParent || forceAdd);
return true;
}
// ****************************************************************************
// Method: ColorAttribute::SetFromNode
//
......@@ -325,7 +313,7 @@ ColorAttribute::CreateNode(DataNode *parentNode, bool forceAdd)
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Wed Jul 23 11:29:38 PDT 2003
// Creation: Fri Oct 3 10:16:08 PDT 2003
//
// Modifications:
//
......@@ -334,6 +322,7 @@ ColorAttribute::CreateNode(DataNode *parentNode, bool forceAdd)
void
ColorAttribute::SetFromNode(DataNode *parentNode)
{
int i;
if(parentNode == 0)
return;
......@@ -389,7 +378,7 @@ ColorAttribute::GetColor()
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Wed Jul 23 11:29:38 PDT 2003
// Creation: Fri Oct 3 10:16:08 PDT 2003
//
// Modifications:
//
......@@ -414,7 +403,7 @@ ColorAttribute::GetFieldName(int index) const
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Wed Jul 23 11:29:38 PDT 2003
// Creation: Fri Oct 3 10:16:08 PDT 2003
//
// Modifications:
//
......@@ -439,7 +428,7 @@ ColorAttribute::GetFieldType(int index) const
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Wed Jul 23 11:29:38 PDT 2003
// Creation: Fri Oct 3 10:16:08 PDT 2003
//
// Modifications:
//
......@@ -464,7 +453,7 @@ ColorAttribute::GetFieldTypeName(int index) const
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Wed Jul 23 11:29:38 PDT 2003
// Creation: Fri Oct 3 10:16:08 PDT 2003
//
// Modifications:
//
......
......@@ -133,3 +133,36 @@ ColorAttribute::Alpha() const
return (int)color[3];
}
Function: CreateNode
Declaration: bool CreateNode(DataNode *, bool);
Definition:
// ****************************************************************************
// Method: ColorAttribute::CreateNode
//
// Purpose:
// This method creates a DataNode representation of the object so it can be saved to a config file.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Wed Jul 23 11:29:38 PDT 2003
//
// Modifications:
// Brad Whitlock, Fri Oct 3 10:13:43 PDT 2003
// I made it always save to the parentNode.
//
// ****************************************************************************
bool
ColorAttribute::CreateNode(DataNode *parentNode, bool forceAdd)
{
if(parentNode == 0)
return false;
// Create a node for ColorAttribute.
DataNode *node = new DataNode("ColorAttribute");
node->AddNode(new DataNode("color", color, 4));
parentNode->AddNode(node);
return true;
}
......@@ -12,7 +12,7 @@
// Notes: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Wed Jul 23 11:29:38 PDT 2003
// Creation: Fri Oct 3 10:16:08 PDT 2003
//
// Modifications:
//
......
......@@ -13,4 +13,5 @@
<Function name="Green" user="true"></Function>
<Function name="Blue" user="true"></Function>
<Function name="Alpha" user="true"></Function>
<Function name="CreateNode" user="false"></Function>
</Attribute>
......@@ -105,6 +105,43 @@ ConfigManager::WriteIndent(int indentLevel)
fprintf(fp, " ");
}
// ****************************************************************************
// Method: ConfigManager::WriteQuotedStringData
//
// Purpose:
// Writes the string to the file surrounded by quotes and and quotes that
// the string had in it are escaped.
//
// Arguments:
// str : The string to write to the file.
//
// Programmer: Brad Whitlock
// Creation: Fri Oct 3 16:18:10 PST 2003
//
// Modifications:
//
// ****************************************************************************
void
ConfigManager::WriteQuotedStringData(const std::string &str)
{
fputc('"', fp);
if(str.size() > 0)
{
const char *cptr = str.c_str();
for(int i = 0; i < str.size(); ++i)
{
// Add escape characters.
if(cptr[i] == '"' || cptr[i] == '\\')
fputc('\\', fp);
fputc(cptr[i], fp);
}
}
fputc('"', fp);
fputc(' ', fp);
}
// ****************************************************************************
// Method: ConfigManager::WriteData
//
......@@ -122,6 +159,10 @@ ConfigManager::WriteIndent(int indentLevel)
// Brad Whitlock, Fri Mar 30 14:37:21 PST 2001
// Added unsigned char cases.
//
// Brad Whitlock, Fri Oct 3 16:00:21 PST 2003
// I made string vectors and arrays quote their strings so they read in
// correctly if the strings contain spaces.
//
// ****************************************************************************
void
......@@ -203,8 +244,8 @@ ConfigManager::WriteData(DataNode *node)
case STRING_ARRAY_NODE:
{ // new scope
const std::string *sptr = node->AsStringArray();
for(i = 0; i < node->GetLength(); ++i, ++sptr)
fprintf(fp, "%s ", sptr->c_str());
for(i = 0; i < node->GetLength(); ++i)
WriteQuotedStringData(*sptr++);
}
break;
case BOOL_ARRAY_NODE:
......@@ -265,7 +306,7 @@ ConfigManager::WriteData(DataNode *node)
{ // new scope
const stringVector &svec = node->AsStringVector();
for(i = 0; i < svec.size(); ++i)
fprintf(fp, "%s ", svec[i].c_str());
WriteQuotedStringData(svec[i]);