Commit 665540ee authored by hrchilds's avatar hrchilds

Update from February 26, 2004

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@185 18c085ea-50e0-402c-830e-de6fd14e8384
parent 079a8b33
......@@ -24,11 +24,15 @@ using std::map;
// Brad Whitlock, Tue Sep 2 09:56:54 PDT 2003
// I added materialVars.
//
// Brad Whitlock, Tue Feb 24 15:50:54 PST 2004
// I added cachedDBName and cachedExpressionList.
//
// ****************************************************************************
VariableMenuPopulator::VariableMenuPopulator() : meshVars(), scalarVars(),
materialVars(), vectorVars(), subsetVars(), speciesVars(), curveVars(),
tensorVars(), symmTensorVars()
VariableMenuPopulator::VariableMenuPopulator() :
cachedDBName(), cachedExpressionList(),
meshVars(), scalarVars(), materialVars(), vectorVars(), subsetVars(),
speciesVars(), curveVars(), tensorVars(), symmTensorVars()
{
}
......@@ -49,6 +53,26 @@ VariableMenuPopulator::~VariableMenuPopulator()
{
}
// ****************************************************************************
// Method: VariableMenuPopulator::ClearDatabaseName
//
// Purpose:
// Clears out the database name that is used to determine whether the
// list of variables needs to be regenerated.
//
// Programmer: Brad Whitlock
// Creation: Thu Feb 26 08:43:58 PDT 2004
//
// Modifications:
//
// ****************************************************************************
void
VariableMenuPopulator::ClearDatabaseName()
{
cachedDBName = "";
}
// ****************************************************************************
// Method: VariableMenuPopulator::PopulateVariableLists
//
......@@ -94,14 +118,37 @@ VariableMenuPopulator::~VariableMenuPopulator()
// how expressions are added to the list so that expressions from the
// expression list and expressions from metadata are added separately.
//
// Brad Whitlock, Tue Feb 24 15:49:58 PST 2004
// I added code to check the name of the database that we're using against
// the name of the database that we've used before.
//
// ****************************************************************************
void
VariableMenuPopulator::PopulateVariableLists(const avtDatabaseMetaData *md,
const avtSIL *sil, const ExpressionList *exprList)
bool
VariableMenuPopulator::PopulateVariableLists(const std::string &dbName,
const avtDatabaseMetaData *md, const avtSIL *sil,
const ExpressionList *exprList)
{
if(md == 0 || sil == 0 || exprList == 0)
return;
return false;
//
// If the database name is the same and the expression list is the
// same then return false, indicating that no updates are required.
//
bool expressionsSame = *exprList == cachedExpressionList;
bool variableMetaData = md->GetMustRepopulateOnStateChange();
if(dbName == cachedDBName && expressionsSame && !variableMetaData)
return false;
//
// Save the database name and the expression list so we can check them
// again later so we can get out of this routine early if they are the
// same.
//
cachedDBName = dbName;
if(!expressionsSame)
cachedExpressionList = *exprList;
// Clear out the variable maps.
meshVars.clear();
......@@ -238,6 +285,8 @@ VariableMenuPopulator::PopulateVariableLists(const avtDatabaseMetaData *md,
if(!expr.GetHidden())
AddExpression(expr);
}
return true;
}
// ****************************************************************************
......
#ifndef VARIABLE_MENU_POPULATOR_H
#define VARIABLE_MENU_POPULATOR_H
#include <winutil_exports.h>
#include <ExpressionList.h>
#include <string>
#include <map>
#include <vectortypes.h>
......@@ -8,7 +9,6 @@
class avtDatabaseMetaData;
class avtSIL;
class Expression;
class ExpressionList;
class QvisVariablePopupMenu;
class QObject;
......@@ -38,6 +38,12 @@ class QObject;
// Brad Whitlock, Fri Oct 24 15:41:54 PST 2003
// Added an internal method that helps add expressions to the right list.
//
// Brad Whitlock, Tue Feb 24 15:51:18 PST 2004
// Added cachedDBName and cachedExpressionList so the class can skip
// unnecessary work in PopulateVariableLists. I also made
// PopulateVariableLists return a bool indicating whether or not updates
// are needed.
//
// ****************************************************************************
class WINUTIL_API VariableMenuPopulator
......@@ -47,7 +53,8 @@ public:
VariableMenuPopulator();
virtual ~VariableMenuPopulator();
void PopulateVariableLists(const avtDatabaseMetaData *,
bool PopulateVariableLists(const std::string &,
const avtDatabaseMetaData *,
const avtSIL *,
const ExpressionList *);
......@@ -57,6 +64,7 @@ public:
bool changeVar = false);
bool ItemEnabled(int varType) const;
void ClearDatabaseName();
private:
void UpdateSingleMenu(QvisVariablePopupMenu *, QObject *,
......@@ -65,9 +73,13 @@ private:
void AddVars(StringBoolMap &to, const StringBoolMap &from);
void AddExpression(const Expression &);
// Keep track of the name of the database for which we have variables.
std::string cachedDBName;
// Keep track of the expression list too.
ExpressionList cachedExpressionList;
// Create some lists to keep track of the variable names.
StringBoolMap meshVars, scalarVars, materialVars, vectorVars, subsetVars,
speciesVars, curveVars, tensorVars, symmTensorVars;
StringBoolMap meshVars, scalarVars, materialVars, vectorVars, subsetVars,
speciesVars, curveVars, tensorVars, symmTensorVars;
};
#endif
......@@ -26,4 +26,23 @@ InvalidSetException::InvalidSetException(const char *catName, const char *setNam
msg = str;
}
// ****************************************************************************
// Method: InvalidSetException constructor
//
// Arguments:
// setName The set name.
//
// Programmer: Kathleen Bonnell
// Creation: February 26, 2004
//
// ****************************************************************************
InvalidSetException::InvalidSetException(const char *setName)
{
char str[1024];
sprintf(str, "The set %s has been turned OFF and cannot be used.", setName);
msg = str;
}
......@@ -20,12 +20,17 @@
// Programmer: Kathleen Bonnell
// Creation: August 12, 2002
//
// Modifications:
// Kathleen Bonnell, Thu Feb 26 12:50:38 PST 2004
// Added single-argument constructor. (Gives different message).
//
// ****************************************************************************
class AVTEXCEPTION_API InvalidSetException : public PipelineException
{
public:
InvalidSetException(const char *, const char *);
InvalidSetException(const char *);
virtual ~InvalidSetException() VISIT_THROW_NOTHING {;};
};
......
......@@ -144,11 +144,14 @@ NetworkManager::~NetworkManager(void)
// Don't clear out the vectors, so this can be consistent with how the
// ClearNetworksWithDatabase works.
//
// Brad Whitlock, Thu Feb 26 11:58:58 PDT 2004
// I replaced the commented out cerr with debug3.
//
// ****************************************************************************
void
NetworkManager::ClearAllNetworks(void)
{
//cerr << "NetworkManager::ClearAllNetworks(void)" << endl;
debug3 << "NetworkManager::ClearAllNetworks(void)" << endl;
int i;
for (i = 0; i < databaseCache.size(); i++)
......@@ -183,11 +186,15 @@ NetworkManager::ClearAllNetworks(void)
// Programmer: Hank Childs
// Creation: January 5, 2004
//
// Modifications:
// Brad Whitlock, Thu Feb 26 11:58:58 PDT 2004
// I replaced the commented out cerr with debug3.
//
// ****************************************************************************
void
NetworkManager::ClearNetworksWithDatabase(const std::string &db)
{
//cerr << "NetworkManager::ClearNetworksWithDatabase()" << endl;
debug3 << "NetworkManager::ClearNetworksWithDatabase()" << endl;
int i;
//
......
......@@ -79,6 +79,9 @@ QvisEngineWindow::~QvisEngineWindow()
// Brad Whitlock, Wed Nov 27 13:59:01 PST 2002
// I added widgets to show engine information.
//
// Brad Whitlock, Wed Feb 25 09:25:01 PDT 2004
// I added a button to clear the cache.
//
// ****************************************************************************
void
......@@ -138,17 +141,24 @@ QvisEngineWindow::CreateWindowContents()
stageProgressBar->setTotalSteps(100);
topLayout->addWidget(stageProgressBar);
QHBoxLayout *buttonLayout1 = new QHBoxLayout(topLayout);
QGridLayout *buttonLayout1 = new QGridLayout(topLayout, 2, 3);
buttonLayout1->setSpacing(10);
interruptEngineButton = new QPushButton("Interrupt engine", central, "interruptEngineButton");
connect(interruptEngineButton, SIGNAL(clicked()), this, SLOT(interruptEngine()));
interruptEngineButton->setEnabled(false);
buttonLayout1->addWidget(interruptEngineButton);
buttonLayout1->addStretch(5);
buttonLayout1->addWidget(interruptEngineButton, 0, 0);
buttonLayout1->setColStretch(1, 10);
closeEngineButton = new QPushButton("Close engine", central, "closeEngineButton");
connect(closeEngineButton, SIGNAL(clicked()), this, SLOT(closeEngine()));
closeEngineButton->setEnabled(false);
buttonLayout1->addWidget(closeEngineButton);
buttonLayout1->addWidget(closeEngineButton, 0, 2);
clearCacheButton = new QPushButton("Clear cache", central, "clearCacheButton");
connect(clearCacheButton, SIGNAL(clicked()), this, SLOT(clearCache()));
clearCacheButton->setEnabled(false);
buttonLayout1->addWidget(clearCacheButton, 1, 0);
topLayout->addSpacing(10);
}
......@@ -220,6 +230,9 @@ QvisEngineWindow::SubjectRemoved(Subject *TheRemovedSubject)
// Brad Whitlock, Wed Nov 27 14:00:24 PST 2002
// I added widgets to show engine information.
//
// Brad Whitlock, Wed Feb 25 09:31:17 PDT 2004
// I added code to set the enabled state for the clearCache button.
//
// ****************************************************************************
void
......@@ -274,6 +287,7 @@ QvisEngineWindow::UpdateWindow(bool doAll)
// Set the enabled state of the various widgets.
interruptEngineButton->setEnabled(s.size() > 0);
closeEngineButton->setEnabled(s.size() > 0);
clearCacheButton->setEnabled(s.size() > 0);
engineCombo->setEnabled(s.size() > 0);
}
......@@ -594,6 +608,30 @@ QvisEngineWindow::interruptEngine()
viewer->InterruptComputeEngine(engineCombo->currentText().latin1());
}
// ****************************************************************************
// Method: QvisEngineWindow::clearCache
//
// Purpose:
// This is a Qt slot function that is called to tell the current engine
// to clear its cache.
//
// Programmer: Brad Whitlock
// Creation: Thu Feb 26 14:16:39 PST 2004
//
// Modifications:
//
// ****************************************************************************
void
QvisEngineWindow::clearCache()
{
std::string host(engineCombo->currentText().latin1());
if(viewer->GetLocalHostName() == host)
viewer->ClearCache("localhost");
else
viewer->ClearCache(host);
}
// ****************************************************************************
// Method: QvisEngineWindow::selectEngine
//
......
......@@ -33,6 +33,9 @@ class StatusAttributes;
// Brad Whitlock, Wed Nov 27 13:47:30 PST 2002
// I added widgets to show more engine information.
//
// Brad Whitlock, Wed Feb 25 09:22:29 PDT 2004
// I added a "Clear cache" button.
//
// ****************************************************************************
class GUI_API QvisEngineWindow : public QvisPostableWindowObserver
......@@ -62,6 +65,7 @@ private slots:
void closeEngine();
void interruptEngine();
void selectEngine(int index);
void clearCache();
private:
EngineList *engines;
StatusAttributes *statusAtts;
......@@ -80,6 +84,7 @@ private:
QProgressBar *stageProgressBar;
QPushButton *interruptEngineButton;
QPushButton *closeEngineButton;
QPushButton *clearCacheButton;
};
#endif
......@@ -2704,6 +2704,9 @@ FileTree::Add(const QualifiedFilename &fileName, char separator_)
// Brad Whitlock, Mon Aug 26 16:47:24 PST 2002
// I changed the code so it can use different separators.
//
// Brad Whitlock, Tue Feb 24 15:43:28 PST 2004
// I fixed the code so single filenames are again shown without the path.
//
// ****************************************************************************
void
......@@ -2721,9 +2724,10 @@ FileTree::Reduce()
// Try and reduce the root to see if we can get rid of a single top-level
// directory. Do not reduce the root if it only has one child in it since
// it has to be a file.
if(root->Size() > 2)
int rootSize = root->Size();
if(rootSize > 2)
root->Reduce();
else if(root->Size() == 1)
else if(rootSize <= 2)
{
// The root has only one child and it must be a file. Since it has
// been reduced, strip the path from it so it will match what happens
......
......@@ -2398,7 +2398,9 @@ QvisGUIApplication::RestoreSession()
// Creation: Mon Nov 10 15:07:37 PST 2003
//
// Modifications:
//
// Brad Whitlock, Thu Feb 26 13:30:49 PST 2004
// Added code to tell the viewer to clear the caches on all engines.
//
// ****************************************************************************
void
......@@ -2437,6 +2439,15 @@ QvisGUIApplication::RestoreSessionFile(const QString &s)
DataNode *plotDatabases = guiNode->GetNode("plotDatabases");
if(plotDatabases)
{
//
// If we're going to be opening up files, have the
// viewer tell all engines to clear their caches.
//
viewer->ClearCacheForAllEngines();
//
// Open each of the files that we'll need.
//
const stringVector &db = plotDatabases->AsStringVector();
for(int i = 0; i < db.size(); ++i)
{
......
......@@ -36,6 +36,8 @@
#define REMOVE_LAST_OPERATOR_ID 1000
#define REMOVE_ALL_OPERATORS_ID 1001
#define VARIABLE_CUTOFF 100
using std::string;
using std::vector;
......@@ -91,13 +93,20 @@ using std::vector;
// Brad Whitlock, Fri Aug 15 15:07:59 PST 2003
// I added a QMenuBar argument to the constructor.
//
// Brad Whitlock, Tue Feb 24 16:27:15 PST 2004
// I added varMenuPopulator and a few other new members.
//
// ****************************************************************************
QvisPlotManagerWidget::QvisPlotManagerWidget(QMenuBar *menuBar,
QWidget *parent, const char *name) : QWidget(parent, name), GUIBase(),
SimpleObserver(), menuPopulator(), plotPlugins()
SimpleObserver(), menuPopulator(), varMenuPopulator(), plotPlugins()
{
pluginsLoaded = false;
updatePlotVariableMenuEnabledState = false;
updateOperatorMenuEnabledState = false;
updateVariableMenuEnabledState = false;
maxVarCount = 0;
topLayout = new QGridLayout(this, 4, 4);
topLayout->setSpacing(5);
......@@ -388,14 +397,13 @@ QvisPlotManagerWidget::Update(Subject *TheChangedSubject)
// Get whether or not we are allowed to modify things.
bool canChange = !globalAtts->GetExecuting();
// Enable the plot and operator attributes menus.
bool havePlots = plotAttsMenu->count() > 0;
plotMenuBar->setItemEnabled(plotAttsMenuId, pluginsLoaded && canChange &&
havePlots);
bool haveOperators = operatorAttsMenu->count() > 0;
plotMenuBar->setItemEnabled(operatorAttsMenuId, pluginsLoaded &&
canChange && haveOperators);
plotMenuBar->update();
//
// Initialize the class members that are used in various methods to tell
// us whether updating the menu enabled state is required.
//
this->updatePlotVariableMenuEnabledState = false;
this->updateOperatorMenuEnabledState = false;
this->updateVariableMenuEnabledState = false;
if(TheChangedSubject == plotList)
{
......@@ -436,12 +444,29 @@ QvisPlotManagerWidget::Update(Subject *TheChangedSubject)
fileServer->CloseFile();
fileServer->Notify();
// We closed the file but we don't want to notify this object
// so we need to clear out the menu populators.
menuPopulator.ClearDatabaseName();
varMenuPopulator.ClearDatabaseName();
UpdatePlotVariableMenu();
UpdateVariableMenu();
}
}
else if(fileServer->FileChanged())
{
//
// If the file changed and we closed it, we probably did a reopen
// so we should clear the cached database name so the next time
// that the menu populators are asked to populate their variables
// they will do it instead of returning early.
//
if(fileServer->ClosedFile())
{
menuPopulator.ClearDatabaseName();
varMenuPopulator.ClearDatabaseName();
}
UpdatePlotVariableMenu();
}
}
......@@ -465,20 +490,21 @@ QvisPlotManagerWidget::Update(Subject *TheChangedSubject)
UpdateHideDeleteDrawButtonsEnabledState();
applyOperatorToggle->setEnabled(canChange);
bool havePlots = (plotAttsMenu->count() > 0);
bool haveOperators = (operatorAttsMenu->count() > 0);
plotMenuBar->setItemEnabled(plotAttsMenuId, canChange && havePlots);
plotMenuBar->setItemEnabled(operatorAttsMenuId, canChange && haveOperators);
plotMenuBar->setItemEnabled(varMenuId, (varMenu->count() > 0) && canChange);
// Update the first two menu items' enabled state.
UpdatePlotAndOperatorMenuEnabledState();
//
// When the globalAtts change, we might have to update the
// enabled state for the entire plot and operator menu bar.
//
this->updatePlotVariableMenuEnabledState = true;
this->updateOperatorMenuEnabledState = true;
this->updateVariableMenuEnabledState = true;
}
else if(TheChangedSubject == pluginAtts)
{
// do nothing yet -- JSM 9/5/01
}
// Update the enabled state for the menu bar.
UpdatePlotAndOperatorMenuEnabledState();
}
// ****************************************************************************
......@@ -512,6 +538,9 @@ QvisPlotManagerWidget::Update(Subject *TheChangedSubject)
// I separated the logic to regenerate the plot list and just change its
// selections so it's not so hard to select multiple items
//
// Brad Whitlock, Thu Feb 26 11:17:22 PDT 2004
// I changed how the plot and operator menu's enabled state is set.
//
// ****************************************************************************
void
......@@ -567,6 +596,17 @@ QvisPlotManagerWidget::UpdatePlotList()
plotListBox->blockSignals(false);
}
// If there are no variables, clear out the variable menu.
if(plotList->GetNumPlots() == 0 && varMenu->count() > 0)
varMenu->clear();
//
// The operator menu can be disabled if there are no plots. Same with
// the variable list so we check them both.
//
this->updateOperatorMenuEnabledState = true;
this->updateVariableMenuEnabledState = true;
// Set the enabled states for the hide, delete, and draw buttons.
UpdateHideDeleteDrawButtonsEnabledState();
......@@ -782,7 +822,10 @@ QvisPlotManagerWidget::EnablePluginMenus()
// fileServer and puts the results in some class variables.
//
// Arguments:
// filename : The file for which to get metadata.
// populator : The menu populator that we want to update.
// filename : The file for which to get metadata.
//
// Returns: True if an updates is needed; false otherwise.
//
// Programmer: Brad Whitlock
// Creation: Thu Sep 14 14:28:43 PST 2000
......@@ -791,16 +834,21 @@ QvisPlotManagerWidget::EnablePluginMenus()
// Brad Whitlock, Mon Mar 17 15:44:44 PST 2003
// I made it use a menu populator.
//
// Brad Whitlock, Tue Feb 24 16:25:25 PST 2004
// I added the populator argument and I made the method return bool.
//
// ****************************************************************************
void
QvisPlotManagerWidget::PopulateVariableLists(const QualifiedFilename &filename)
bool
QvisPlotManagerWidget::PopulateVariableLists(VariableMenuPopulator &populator,
const QualifiedFilename &filename)
{
// Get a pointer to the specified file's metadata object.
const avtDatabaseMetaData *md = fileServer->GetMetaData(filename);
const avtSIL *sil = fileServer->GetSIL(filename);
menuPopulator.PopulateVariableLists(md, sil, exprList);
return populator.PopulateVariableLists(filename.FullName(),
md, sil, exprList);
}
// ****************************************************************************
......@@ -850,26 +898,42 @@ QvisPlotManagerWidget::PopulateVariableLists(const QualifiedFilename &filename)
// Hank Childs, Fri Aug 1 21:30:30 PDT 2003
// Re-enable Curve plots, since they now require Curve variables.
//
// Brad Whitlock, Tue Feb 24 16:06:46 PST 2004
// I improved the code to it does not update the variable menus each time.
//
// ****************************************************************************
void
QvisPlotManagerWidget::UpdatePlotVariableMenu()
{
// Update the metadata to use the current file.
PopulateVariableLists(fileServer->GetOpenFile());
//
// Update the menu populator so it uses the current file. If it changed
// then needsUpdate will be true and we need to update the variable menu.
//
bool needsUpdate = PopulateVariableLists(menuPopulator,
fileServer->GetOpenFile());
// Update the various menus
for(int i = 0; i < plotPlugins.size(); ++i)
if(needsUpdate)
{
int varCount = menuPopulator.UpdateSingleVariableMenu(
plotPlugins[i].varMenu, this, plotPlugins[i].varTypes, false);
bool hasEntries = (varCount > 0);
this->maxVarCount = 0;
for(int i = 0; i < plotPlugins.size(); ++i)
{
int varCount = menuPopulator.UpdateSingleVariableMenu(
plotPlugins[i].varMenu, this, plotPlugins[i].varTypes, false);
this->maxVarCount = (varCount > this->maxVarCount) ? varCount : this->maxVarCount;
bool hasEntries = (varCount > 0);
// If the menu has a different enabled state, set it now.
if(hasEntries != plotMenu->isItemEnabled(i))
plotMenu->setItemEnabled(i, hasEntries);
}
plotMenu->setItemEnabled(i, hasEntries);
//
// Set the flag to indicate that we need to update the enabled
// state for the plot variable menu.
//
this->updatePlotVariableMenuEnabledState = true;
}
// Set the enabled state of the Plot and Operator menus.
UpdatePlotAndOperatorMenuEnabledState();
}