Commit e88c709b authored by miller86's avatar miller86

adding zip wrapper plugin; moved some stuff from CommonPluginInfo to General...

adding zip wrapper plugin; moved some stuff from CommonPluginInfo to General in all databases; fixed some problems in visit -diff

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@1817 18c085ea-50e0-402c-830e-de6fd14e8384
parent 4ff7772e
......@@ -251,7 +251,7 @@ def GetVarType(metadata, varname):
# Date: Wed Jul 18 18:12:28 PDT 2007
#
###############################################################################
def MeshForVar(metadata, varname):
def MeshForVar(metadata, varname, dontCheckExpressions=0):
meshName = "Unknown"
vInfo = GetVarInfo(metadata, varname)
if vInfo != 0 and hasattr(vInfo, "meshName"):
......@@ -259,9 +259,45 @@ def MeshForVar(metadata, varname):
if tmpMeshName != None:
meshName = tmpMeshName.group(1)
else:
# look at meshes themselves
for i in range(metadata.GetNumMeshes()):
if metadata.GetMeshes(i).name == varname:
meshName = varname
break
ttab = string.maketrans("()<>,:","@@@@@@")
# if we don't yet have an answer, look at current expressions
if meshName == "Unknown" and dontCheckExpressions == 0:
exprList = Expressions()
i = 0;
while i < len(exprList) and meshName == "Unknown":
theExpr = exprList[i]
if theExpr[0] == varname:
defnTmp = string.translate(theExpr[1],ttab)
defnFields = defnTmp.split('@')
for f in defnFields:
meshNameTmp = MeshForVar(metadata, f, 1)
if meshNameTmp != "Unknown":
meshName = meshNameTmp
break
i = i + 1
# if we don't yet have an answer, look at expressions from database
if meshName == "Unknown" and dontCheckExpressions == 0:
exprList = metadata.GetExprList()
i = 0;
while i < exprList.GetNumExpressions() and meshName == "Unknown":
theExpr = exprList.GetExpressions(i)
if theExpr.name == varname:
defnTmp = string.translate(theExpr.definition,ttab)
defnFields = defnTmp.split('@')
for f in defnFields:
meshNameTmp = MeshForVar(metadata, f, 1)
if meshNameTmp != "Unknown":
meshName = meshNameTmp
break
i = i + 1
return meshName
###############################################################################
......@@ -367,8 +403,14 @@ def SyncTimeStates(srcWin):
print "Updating time state to state 0"
currentTimeState = 0
mdl = GetMetaData(dbl, currentTimeState)
mdr = GetMetaData(dbr, currentTimeState)
TimeSliderSetState(currentTimeState)
# There is a bug with correlations when time arg is used to GetMetaData.
# Without it, it turns out we always get state zero.
# mdl = GetMetaData(dbl, currentTimeState)
# mdr = GetMetaData(dbr, currentTimeState)
mdl = GetMetaData(dbl)
mdr = GetMetaData(dbr)
if mdl.numStates != mdr.numStates:
print "Database \"%s\" has %d states"%(dbl, mdl.numStates)
......@@ -378,17 +420,6 @@ def SyncTimeStates(srcWin):
UpdateExpressions(mdl, mdr)
for win in (1,2,3,4):
if win == 2 and cmfeMode == 0:
continue
if win == srcWin:
continue
SetActiveWindow(win)
wi = GetWindowInformation()
if wi.activeTimeSlider != -1:
TimeSliderSetState(currentTimeState)
SetActiveWindow(1)
###############################################################################
# Function: SyncTime...
......@@ -503,6 +534,9 @@ def UpdateThisExpression(exprName, expr, currentExpressions, addedExpressions,
# changes in timesteps along with adding new expressions for new variables,
# deleting old expressions and leaving unchanged expressions alone.
#
# Mark C. Miller, Thu Jul 19 21:36:47 PDT 2007
# Inverted loops to identify pre-defined expressions coming from md.
#
###############################################################################
def UpdateExpressions(mdl, mdr):
global forcePosCMFE
......@@ -522,25 +556,26 @@ def UpdateExpressions(mdl, mdr):
# remove any pre-defined expressions in currentExpressions
# coming from the metadata
for expr_i in range(mdl.GetExprList().GetNumExpressions()):
for expr_i in range(len(currentExpressionsTmp)):
foundIt = 0
for expr_j in range(len(currentExpressionsTmp)):
if currentExpressionsTmp[expr_j][0] == \
mdl.GetExprList().GetExpressions(expr_i).name:
# Look for it in the left db's metadata
for expr_j in range(mdl.GetExprList().GetNumExpressions()):
if currentExpressionsTmp[expr_i][0] == \
mdl.GetExprList().GetExpressions(expr_j).name:
foundIt = 1
break
if foundIt == 0:
currentExpressionsList.append(currentExpressionsTmp[expr_j])
for expr_i in range(mdr.GetExprList().GetNumExpressions()):
foundIt = 0
for expr_j in range(len(currentExpressionsTmp)):
if currentExpressionsTmp[expr_j][0] == \
mdr.GetExprList().GetExpressions(expr_i).name:
foundIt = 1
break
# Look for it in the right db's metadata
for expr_j in range(mdr.GetExprList().GetNumExpressions()):
if currentExpressionsTmp[expr_i][0] == \
mdr.GetExprList().GetExpressions(expr_j).name:
foundIt = 1
break
# If we didn't find it in either left or right dbs md, it is
# NOT a pre-defined expression. So, we can keep it.
if foundIt == 0:
currentExpressionsList.append(currentExpressionsTmp[expr_j])
currentExpressions = tuple(currentExpressionsList)
# Iterate over all the scalar variables in metadata.
......@@ -685,20 +720,20 @@ def UpdateExpressions(mdl, mdr):
# Print out some information about what we did
if len(addedExpressions) > 0:
print " Added %d expressions..."%len(addedExpressions)
# for expr_i in range(len(addedExpressions)):
# print " %s"%addedExpressions[expr_i]
for expr_i in range(len(addedExpressions)):
print " %s"%addedExpressions[expr_i]
if len(unchangedExpressions) > 0:
print " Unchanged %d expressioons..."%len(unchangedExpressions)
# for expr_i in range(len(unchangedExpressions)):
# print " %s"%unchangedExpressions[expr_i]
for expr_i in range(len(unchangedExpressions)):
print " %s"%unchangedExpressions[expr_i]
if len(updatedExpressions) > 0:
print " Updated %d expressions..."%len(updatedExpressions)
# for expr_i in range(len(updatedExpressions)):
# print " %s"%updatedExpressions[expr_i]
for expr_i in range(len(updatedExpressions)):
print " %s"%updatedExpressions[expr_i]
if len(deletedExpressions) > 0:
print " Deleted %d expressions"%len(deletedExpressions)
# for expr_i in range(len(deletedExpressions)):
# print " %s"%deletedExpressions[expr_i]
for expr_i in range(len(deletedExpressions)):
print " %s"%deletedExpressions[expr_i]
print "Finished defining expressions"
......@@ -718,36 +753,41 @@ def UpdateExpressions(mdl, mdr):
def Initialize():
global winDbMap
global cmfeMode
global oldw
#
# Open left and right database operands
#
if OpenDatabase(dbl) == 0:
print "VisIt could not open ", dbl
sys.exit(3)
if OpenDatabase(dbr) == 0:
print "VisIt could not open ", dbr
sys.exit(3)
#
# Make a 2x2 window layout as follows
# 1: L-CMFE(R) 2: R-CMFE(L) -- only when cmfeMode==1
# 3: L 4: R
SetWindowLayout(4)
# Lock in time so other windows will inherit time lock.
SetCloneWindowOnFirstRef(1)
ToggleLockTime()
ToggleLockViewMode()
# Open a database in each window.
winDbMap = {1 : dbl, 2 : dbr, 3 : dbl, 4 : dbr}
for win in (1,2,3,4):
SetActiveWindow(win)
if OpenDatabase(winDbMap[win]) == 0:
print "VisIt could not open ", winDbMap[win]
sys.exit(3)
SetWindowLayout(4)
SyncTimeStates(0)
# If we were able to create any expressions, let's set up some plots based on the
# first one. That way, we can also set up some annotations.
winDbMap = {1 : dbl, 2 : dbr, 3 : dbl, 4 : dbr}
if len(diffVars) > 0:
theVar = GetDiffVarNames(diffVars[0])
windowsToVars = {1 : theVar[1], 2 : theVar[1], 3 : theVar[0], 4 : theVar[0]}
for win in (1,2,3,4):
SetActiveWindow(win)
DeleteAllPlots()
ActivateDatabase(winDbMap[win])
if win == 2 and cmfeMode == 0:
continue
SetActiveWindow(win)
AddPlot("Pseudocolor", windowsToVars[win])
else:
print "No plots are being set up by default since the databases did not have any scalars in common."
......@@ -769,17 +809,17 @@ def Initialize():
annot.textColor = (255,0,0,255)
annot.fontBold = 1
SetActiveWindow(1)
CreateDatabaseCorrelation("DIFF", (dbl, dbr), 0)
# Open the GUI
OpenGUI()
# Move the viewer's window area closer to the GUI.
SetWindowArea(410,0,1100,1100)
# Draw the plots in the windows.
for win in (1,2,3,4):
SetActiveWindow(win)
DrawPlots()
# Register macro only seems to work from window 1
SetActiveWindow(1)
RegisterMacro("DiffSummary", DiffSummary)
RegisterMacro("ToggleMesh", ToggleMesh)
RegisterMacro("ToggleBoundary", ToggleBoundary)
......@@ -801,7 +841,9 @@ def Initialize():
RegisterMacro("ToggleHidePlot4", ToggleHidePlot4)
RegisterMacro("ToggleHidePlot5", ToggleHidePlot5)
# Back to window 1
for win in (1,2,3,4):
SetActiveWindow(win)
DrawPlots()
SetActiveWindow(1)
print "Type 'help()' to get more information on using 'visit -diff'"
......@@ -1228,8 +1270,10 @@ def SyncWindows(srcWin):
else:
ChangeActivePlotsVar(theVar[0])
DrawPlots()
SetActivePlots(tuple(hiddenPlotsList))
HideActivePlots()
hiddenPlotsTmp = tuple(hiddenPlotsList)
if len(hiddenPlotsTmp) > 0:
SetActivePlots(tuple(hiddenPlotsList))
HideActivePlots()
SetActivePlots(tuple(activePlotsList))
SetActiveWindow(srcWin)
......
......@@ -94,6 +94,11 @@ class DBOptionsAttributes;
// Hank Childs, Mon May 23 16:31:36 PDT 2005
// Add DBOptions.
//
// Mark C. Miller, Mon Aug 6 13:36:16 PDT 2007
// Added GetDfltExtsFromGen and GetFilenamesFromGen as newer ways to
// obtain this information instead of GetDefaultExtensions and GetFilenames
// on CommonDatabasePluginInfo. Note, however, we will leave the older
// methods around for backward compatibility for plugins VisIt does not own.
// ****************************************************************************
class PLUGIN_API GeneralDatabasePluginInfo
......@@ -105,6 +110,10 @@ class PLUGIN_API GeneralDatabasePluginInfo
virtual char *GetID() const = 0;
virtual bool EnabledByDefault() const { return true; }
virtual bool HasWriter() const { return false; }
virtual std::vector<std::string> GetDfltExtsFromGen() const
{ std::vector<std::string> rv; return rv; };
virtual std::vector<std::string> GetFilenamesFromGen() const
{ std::vector<std::string> rv; return rv; };
};
class PLUGIN_API CommonDatabasePluginInfo : public virtual GeneralDatabasePluginInfo
......
......@@ -44,6 +44,7 @@
#include <DebugStream.h>
#include <InvalidPluginException.h>
#include <visitstream.h>
#include <visit-config.h>
#include <string>
#include <vector>
......@@ -161,11 +162,17 @@ DatabasePluginManager::Instance()
//
// Modifications:
//
// Mark C. Miller, Mon Aug 6 13:36:16 PDT 2007
// Fixed problem where calling this method in a situation where the given
// plugin had not already been loaded would result in defining it in
// loadedindexmap with an index of 0.
// ****************************************************************************
EngineDatabasePluginInfo *
DatabasePluginManager::GetEnginePluginInfo(const string &id)
{
if (!PluginLoaded(id))
return 0;
return enginePluginInfo[loadedindexmap[id]];
}
......@@ -186,11 +193,17 @@ DatabasePluginManager::GetEnginePluginInfo(const string &id)
//
// Modifications:
//
// Mark C. Miller, Mon Aug 6 13:36:16 PDT 2007
// Fixed problem where calling this method in a situation where the given
// plugin had not already been loaded would result in defining it in
// loadedindexmap with an index of 0.
// ****************************************************************************
CommonDatabasePluginInfo *
DatabasePluginManager::GetCommonPluginInfo(const string &id)
{
if (!PluginLoaded(id))
return 0;
return commonPluginInfo[loadedindexmap[id]];
}
......@@ -213,6 +226,8 @@ DatabasePluginManager::GetCommonPluginInfo(const string &id)
// Hank Childs, Tue Mar 22 16:06:15 PST 2005
// Fix memory leak.
//
// Mark C. Miller, Mon Aug 6 13:36:16 PDT 2007
// Added code to update extensions and filenames.
// ****************************************************************************
bool
......@@ -244,11 +259,13 @@ DatabasePluginManager::LoadGeneralPluginInfo()
// Success! Add it to the list.
allindexmap[info->GetID()] = ids.size();
ids .push_back(info->GetID());
names .push_back(info->GetName());
versions .push_back(info->GetVersion());
enabled .push_back(info->EnabledByDefault());
haswriter.push_back(info->HasWriter());
ids .push_back(info->GetID());
names .push_back(info->GetName());
versions .push_back(info->GetVersion());
enabled .push_back(info->EnabledByDefault());
haswriter .push_back(info->HasWriter());
extensions.push_back(info->GetDfltExtsFromGen());
filenames .push_back(info->GetFilenamesFromGen());
delete info;
return true;
}
......@@ -408,3 +425,184 @@ DatabasePluginManager::PluginHasWriter(const string &id)
return retval;
}
// ****************************************************************************
// Method: DatabasePluginManager::PluginDefaultExtensions
//
// Purpose: Returns file extensions for a plugin
//
// Arguments:
// id the plugin id
//
// Programmer: Mark C. Miller
// Creation: August 3, 2007
//
// ****************************************************************************
vector<string>
DatabasePluginManager::PluginFileExtensions(const string &id)
{
vector<string> retval;
if(allindexmap.find(id) != allindexmap.end())
{
int index = allindexmap[id];
if(index < names.size())
retval = extensions[index];
}
return retval;
}
// ****************************************************************************
// Method: DatabasePluginManager::PluginDefaultFilenames
//
// Purpose: Returns filenames for a plugin
//
// Arguments:
// id the plugin id
//
// Programmer: Mark C. Miller
// Creation: August 3, 2007
//
// ****************************************************************************
vector<string>
DatabasePluginManager::PluginFilenames(const string &id)
{
vector<string> retval;
if(allindexmap.find(id) != allindexmap.end())
{
int index = allindexmap[id];
if(index < names.size())
retval = filenames[index];
}
return retval;
}
// ****************************************************************************
// Method: DatabasePluginManager::GetMatchingPluginId
//
// Purpose: Returns database plugin id matching extensions with given filename
//
// Arguments:
// id the filename to match with
//
// Programmer: Mark C. Miller
// Creation: July 31, 2007
//
// ****************************************************************************
string
DatabasePluginManager::GetMatchingPluginId(const char *filename, bool searchAll)
{
int i;
string rv = "";
//
// Parse out the path and get just the filename.
//
string file_and_path = filename;
const char *fap = file_and_path.c_str();
int len = strlen(fap);
int lastSlash = -1;
for (i = len-1 ; i >= 0 ; i--)
{
if (fap[i] == SLASH_CHAR)
{
lastSlash = i;
break;
}
}
int start = lastSlash+1;
string file(fap + start);
//
// Try each database type looking for a match to the given extensions
//
int iMax = searchAll ? GetNAllPlugins() : GetNEnabledPlugins();
for (i=0; i<iMax && rv == ""; i++)
{
string id = searchAll ? GetAllID(i) : GetEnabledID(i);
CommonDatabasePluginInfo *info = GetCommonPluginInfo(id);
bool foundMatch = false;
//
// Check to see if there is an extension that matches.
// Look first using GeneralPluginInfo via PluginFileExtensions
// call (the newer way). If that yields nothing, then try the
// CommonPluginInfo via the GetDefaultExtensions (the old way).
//
int j;
vector<string> extensions = PluginFileExtensions(id);
int nextensions = extensions.size();
bool shouldIssueObsoletePluginWarning = false;
if (nextensions == 0)
{
if (info)
extensions = info->GetDefaultExtensions();
nextensions = extensions.size();
shouldIssueObsoletePluginWarning = nextensions > 0;
}
for (j=0; j<nextensions && !foundMatch; j++)
{
string ext = extensions[j];
if (ext[0] != '.')
{
ext = string(".") + extensions[j];
}
#if defined(_WIN32)
if (file.length() >= ext.length())
{
string fileExt(file.substr(file.length() - ext.length()));
foundMatch = (_stricmp(fileExt.c_str(), ext.c_str()) == 0);
}
#else
if (file.length() >= ext.length() &&
file.substr(file.length() - ext.length()) == ext)
{
foundMatch = true;
}
#endif
}
//
// Check to see if there is an exact name that matches.
// Again, get filenames first from GeneralPluginInfo and,
// failing that, then the older way (from CommonPluginInfo).
//
vector<string> filenames = PluginFilenames(id);
int nfiles = filenames.size();
if (nfiles == 0)
{
if (info)
filenames = info->GetFilenames();
nfiles = filenames.size();
shouldIssueObsoletePluginWarning |= nfiles > 0;
}
for (j=0; j<nfiles && !foundMatch; j++)
{
if (filenames[j] == file)
{
foundMatch = true;
}
}
if (foundMatch)
rv = id;
if (foundMatch and shouldIssueObsoletePluginWarning)
{
static bool issuedWarning = false;
if (!issuedWarning)
{
cerr << "Warning: For plugin id = \"" << id
<< "\", default file extensions/names found in" << endl;
cerr << "CommonPluginInfo indicating obsolete plugin code." << endl;
cerr << "Please re-generate the plugin info files using xml2info." << endl;
cerr << "This message will continue to appear, once per session," << endl;
cerr << "until the problem has been addressed." << endl;
issuedWarning = true;
}
}
}
return rv;
}
......@@ -70,6 +70,9 @@ class EngineDatabasePluginInfo;
// Jeremy Meredith, Tue Feb 22 15:20:03 PST 2005
// Added way to determine directly if a plugin has a writer.
//
// Mark C. Miller, Mon Aug 6 13:36:16 PDT 2007
// Added PluginFileExtensions, PluginFilenames and GetMatchingPluginId
// add supporting data members, extensions, filenames.
// ****************************************************************************
class PLUGIN_API DatabasePluginManager : public PluginManager
......@@ -85,6 +88,11 @@ class PLUGIN_API DatabasePluginManager : public PluginManager
CommonDatabasePluginInfo *GetCommonPluginInfo(const std::string&);
EngineDatabasePluginInfo *GetEnginePluginInfo(const std::string&);
bool PluginHasWriter(const std::string&);
std::vector<std::string> PluginFileExtensions(const std::string&);
std::vector<std::string> PluginFilenames(const std::string&);
std::string GetMatchingPluginId(const char *fname,
bool searchAll = false);
private:
DatabasePluginManager();
......@@ -100,6 +108,8 @@ class PLUGIN_API DatabasePluginManager : public PluginManager
// arrays containing all plugins (appends the ones in PluginManager.C)
std::vector<bool> haswriter;
std::vector<std::vector<std::string> > extensions;
std::vector<std::vector<std::string> > filenames;
// arrays containing enabled plugins
std::vector<CommonDatabasePluginInfo*> commonPluginInfo;
......
......@@ -770,6 +770,23 @@ PluginManager::LoadPluginsNow()
}
}
// ****************************************************************************
// Method: PluginManager::LoadSinglePluginNow
//
// Purpose: Load a specific plugin
//
// Programmer: Mark C. Miller
// Creation: August 5, 2007
//
// ****************************************************************************
bool
PluginManager::LoadSinglePluginNow(const std::string& id)
{
int index = GetAllIndex(id);
return LoadSinglePlugin(index);
}
// ****************************************************************************
// Method: PluginManager::LoadSinglePlugin
//
......@@ -794,9 +811,12 @@ PluginManager::LoadPluginsNow()
// Hank Childs, Fri Jan 28 13:19:33 PST 2005
// Use catch return.
//
// Mark C. Miller, Mon Aug 6 13:36:16 PDT 2007
// Changed return value to bool to indicate if it actually loaded
// the plugin.
// ****************************************************************************
void
bool
PluginManager::LoadSinglePlugin(int index)
{
if (!enabled[index])
......@@ -804,7 +824,7 @@ PluginManager::LoadSinglePlugin(int index)
debug1 << "Skipping disabled "<<managerName.c_str()<<" plugin "
<<