Updates will be applied April 15th at 12pm EDT (UTC-0400). GitLab could be a little slow between 12 - 12:45pm EDT.

Commit 1ff99c01 authored by hrchilds's avatar hrchilds

Update from December 14, 2004

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@378 18c085ea-50e0-402c-830e-de6fd14e8384
parent b321b9b7
......@@ -5,6 +5,12 @@
#include <ExprNode.h>
#include <ExprNodeFactory.h>
#include <ExprParser.h>
#include <string>
#include <set>
#include <ImproperUseException.h>
#include <RecursiveExpressionException.h>
using std::set;
using std::string;
ParsingExprList * ParsingExprList::instance = 0;
......@@ -276,3 +282,59 @@ ParsingExprList::GetExpressionTree(Expression *expr)
ParseTreeNode *t = Instance()->GetParser()->Parse(expr->GetDefinition());
return (ExprNode*)t;
}
// ****************************************************************************
// Method: ParsingExprList::GetRealVariable
//
// Purpose:
// Determine the first true database variable for any given
// expression. Throw an ImproperUseException if there were
// no real variables in an expression, throw a
// RecursiveExpressionException if the expression is recursive,
// and return the empty string if an unknown error occurred
// during parsing.
//
// Arguments:
// var the original variable name
//
// Note: refactored this from my original implementation in ViewerPlotList.
//
// Programmer: Jeremy Meredith
// Creation: December 14, 2004
//
// ****************************************************************************
string
ParsingExprList::GetRealVariable(const string &var)
{
string realvar = var;
set<string> expandedVars;
expandedVars.insert(realvar);
Expression *expr = GetExpression(realvar);
while (expr)
{
ExprNode *tree = GetExpressionTree(expr);
if (!tree)
{
// We won't normally get here because error
// conditions will usually throw exceptions.
return "";
}
const set<string> &varLeaves = tree->GetVarLeaves();
if (varLeaves.empty())
{
EXCEPTION1(ImproperUseException,
"After parsing, expression has no real variables.");
}
realvar = *varLeaves.begin();
if (expandedVars.count(realvar))
{
EXCEPTION1(RecursiveExpressionException, realvar);
}
expandedVars.insert(realvar);
expr = ParsingExprList::GetExpression(realvar);
}
return realvar;
}
......@@ -29,6 +29,10 @@ class ExprNode;
// Jeremy Meredith, Wed Nov 24 12:27:15 PST 2004
// Refactored and changed parse tree classes around.
//
// Jeremy Meredith, Tue Dec 14 14:09:51 PST 2004
// I added code to get the first real (database, non-expression) variable
// for a given variable (which may or may not be an expression).
//
// ****************************************************************************
class EXPR_API ParsingExprList : public SimpleObserver
......@@ -53,6 +57,8 @@ public:
static ExprNode *GetExpressionTree(std::string varname)
{ return GetExpressionTree(varname.c_str()); }
static std::string GetRealVariable(const std::string &var);
protected:
Parser* GetParser() { return parser; }
......
......@@ -11,6 +11,8 @@
class AttributeSubject;
class QvisNotepadArea;
class QvisPostableWindowObserver;
class QvisWizard;
class QWidget;
class avtPluginFilter;
class ViewerPlot;
......@@ -47,6 +49,9 @@ class ViewerPlot;
// Jeremy Meredith, Wed Nov 5 10:28:29 PST 2003
// Added ability to disable plugins by default.
//
// Brad Whitlock, Tue Dec 14 09:44:04 PDT 2004
// Added support for operator wizards.
//
// ****************************************************************************
class PLUGIN_API GeneralOperatorPluginInfo
......@@ -72,6 +77,11 @@ class PLUGIN_API GUIOperatorPluginInfo : public virtual CommonOperatorPluginInfo
virtual const char *GetMenuName() const = 0;
virtual QvisPostableWindowObserver *CreatePluginWindow(int type,
AttributeSubject *attr, QvisNotepadArea *notepad) = 0;
virtual QvisWizard *CreatePluginWizard(AttributeSubject *attr,
QWidget *parent, const char *name =0)
{
return 0;
}
virtual const char **XPMIconData() const { return 0; }
};
......
......@@ -21,6 +21,8 @@
class AttributeSubject;
class QvisNotepadArea;
class QvisPostableWindowObserver;
class QvisWizard;
class QWidget;
class avtDatabaseMetaData;
class avtPlot;
......@@ -78,6 +80,9 @@ class avtPlot;
// Brad Whitlock, Fri Mar 26 00:40:29 PDT 2004
// I changed the interface to several methods in the viewer plugin.
//
// Brad Whitlock, Tue Dec 14 09:42:33 PDT 2004
// I added support for plot wizards.
//
// ****************************************************************************
class PLUGIN_API GeneralPlotPluginInfo
......@@ -104,6 +109,11 @@ class PLUGIN_API GUIPlotPluginInfo : public virtual CommonPlotPluginInfo
virtual int GetVariableTypes() const = 0;
virtual QvisPostableWindowObserver *CreatePluginWindow(int type,
AttributeSubject *attr, QvisNotepadArea *notepad) = 0;
virtual QvisWizard *CreatePluginWizard(AttributeSubject *attr,
QWidget *parent, const char *name =0)
{
return 0;
}
virtual const char **XPMIconData() const { return 0; }
};
......
......@@ -218,6 +218,9 @@ AttributeGroup::CopyAttributes(const AttributeGroup *atts)
// Jeremy Meredith, Fri Jan 31 09:48:03 PST 2003
// Made opacity a double.
//
// Brad Whitlock, Thu Dec 9 15:07:10 PST 2004
// Added variablename type.
//
// ****************************************************************************
void
......@@ -296,6 +299,9 @@ AttributeGroup::InterpolateConst(const AttributeGroup *atts1,
case FieldType_linewidth:
ConstInterp<int>::InterpScalar(addrOut,addr1,addr2,f);
break;
case FieldType_variablename:
ConstInterp<std::string>::InterpScalar(addrOut,addr1,addr2,f);
break;
case FieldType_color:
case FieldType_att:
((AttributeGroup*)addrOut)->
......@@ -356,6 +362,9 @@ AttributeGroup::InterpolateConst(const AttributeGroup *atts1,
// Jeremy Meredith, Fri Jan 31 09:47:40 PST 2003
// Made opacity a double, and made line width interpolate linearly.
//
// Brad Whitlock, Thu Dec 9 15:07:46 PST 2004
// Added variablename type.
//
// ****************************************************************************
void
......@@ -434,6 +443,9 @@ AttributeGroup::InterpolateLinear(const AttributeGroup *atts1,
case FieldType_linewidth:
LinInterp<int>::InterpScalar(addrOut,addr1,addr2,f);
break;
case FieldType_variablename:
ConstInterp<std::string>::InterpScalar(addrOut,addr1,addr2,f);
break;
case FieldType_color:
case FieldType_att:
((AttributeGroup*)addrOut)->
......@@ -485,6 +497,9 @@ AttributeGroup::InterpolateLinear(const AttributeGroup *atts1,
// we're the same type of object before attempting any
// comparisons.
//
// Brad Whitlock, Thu Dec 9 15:08:23 PST 2004
// Added variablename type.
//
// ****************************************************************************
bool
......@@ -584,6 +599,10 @@ AttributeGroup::EqualTo(const AttributeGroup *atts) const
if (!(EqualVal<int>::EqualScalar(addr1,addr2)))
return false;
break;
case FieldType_variablename:
if (!(EqualVal<std::string>::EqualScalar(addr1,addr2)))
return false;
break;
case FieldType_color:
case FieldType_att:
if (!(((AttributeGroup*)addr1)->EqualTo((AttributeGroup*)addr2)))
......
......@@ -55,6 +55,9 @@ class DataNode;
// Brad Whitlock, Wed Dec 17 11:51:40 PDT 2003
// I added a third argument to CreateNode.
//
// Brad Whitlock, Thu Dec 9 15:04:41 PST 2004
// I added FieldType_variablename.
//
// ****************************************************************************
class STATE_API AttributeGroup
......@@ -82,6 +85,7 @@ public:
FieldType_opacity,
FieldType_linestyle,
FieldType_linewidth,
FieldType_variablename,
FieldType_att,
FieldType_attVector,
FieldType_enum
......
......@@ -4635,6 +4635,12 @@ avtDatabaseMetaData::DetermineVarType(std::string var_in) const
// Hank Childs, Sat Sep 20 08:49:16 PDT 2003
// Add support for tensors.
//
// Jeremy Meredith, Tue Dec 14 14:02:35 PST 2004
// The code to get the real variable name was a duplicate of two
// other spots in VisIt, but this one was out of date. I
// refactored the best one into ParsingExprList::GetRealVariable
// and made this one point to it.
//
// ****************************************************************************
std::string
......@@ -4652,12 +4658,7 @@ avtDatabaseMetaData::MeshForVar(std::string var) const
// If the variable is an expression, we need to find a "real" variable
// name to work with.
ExprNode *tree = ParsingExprList::GetExpressionTree(var);
while (tree != NULL)
{
var = *tree->GetVarLeaves().begin();
tree = ParsingExprList::GetExpressionTree(var);
}
var = ParsingExprList::GetRealVariable(var);
// If the variable is compound, parse out the variable name.
if (VarIsCompound(var))
......
......@@ -164,6 +164,9 @@ class AttributeSubject;
// This is for plots such as the volume plot which cannot play well with
// volume rendering.
//
// Brad Whitlock, Tue Dec 14 15:29:22 PST 2004
// I made SetVarName be virtual.
//
// ****************************************************************************
class PLOTTER_API avtPlot
......@@ -197,7 +200,7 @@ class PLOTTER_API avtPlot
void SetDataExtents(const std::vector<double> &);
virtual void GetDataExtents(std::vector<double> &);
void SetVarName(const char *name);
virtual void SetVarName(const char *name);
void SetVarUnits(const char *units);
void SetMeshType(const avtMeshType);
......
......@@ -528,6 +528,12 @@ NetworkManager::GetDBFromCache(const string &filename, int time,
// Mark C. Miller, Thu Aug 19 10:28:45 PDT 2004
// Removed #ifdef 0 code block
//
// Jeremy Meredith, Tue Dec 14 14:02:35 PST 2004
// The code to get the real variable name was a duplicate of two
// other spots in VisIt, but this one was out of date. I
// refactored the best one into ParsingExprList::GetRealVariable
// and made this one point to it.
//
// ****************************************************************************
void
NetworkManager::StartNetwork(const string &filename, const string &format,
......@@ -538,19 +544,7 @@ NetworkManager::StartNetwork(const string &filename, const string &format,
{
// If the variable is an expression, we need to find a "real" variable
// name to work with.
std::string leaf = var;
ExprNode *tree = ParsingExprList::GetExpressionTree(leaf);
while (tree != NULL)
{
const set<string> &varLeaves = tree->GetVarLeaves();
if (varLeaves.empty())
{
EXCEPTION1(ImproperUseException,
"After parsing, expression has no real variables.");
}
leaf = *varLeaves.begin();
tree = ParsingExprList::GetExpressionTree(leaf);
}
string leaf = ParsingExprList::GetRealVariable(var);
// Start up the DataNetwork and add the database to it.
workingNet = new DataNetwork;
......
......@@ -290,6 +290,9 @@
# Jeremy Meredith, Tue Nov 23 14:53:07 PST 2004
# Refactored the expression parser into two separate libraries.
#
# Brad Whitlock, Fri Dec 3 14:20:39 PST 2004
# Added QvisVariableButton, QvisWizard.
#
##############################################################################
##
......@@ -383,9 +386,12 @@ HDRMOC = \
QvisText2DInterface.h \
QvisTimeSliderInterface.h \
QvisTurnDownButton.h \
QvisVariableButton.h \
QvisVariableButtonHelper.h \
QvisVCRControl.h \
QvisViewWindow.h \
QvisWindowBase.h \
QvisWizard.h \
SplashScreen.h
# Then, all of the rest of the header files
......
......@@ -18,6 +18,7 @@
#include <qsplitter.h>
#include <QNarrowLineEdit.h>
#include <QvisVariableButton.h>
#define STDMIN(A,B) (((A)<(B)) ? (A) : (B))
#define STDMAX(A,B) (((A)<(B)) ? (B) : (A))
......@@ -234,7 +235,11 @@ QvisExpressionsWindow::~QvisExpressionsWindow()
// categorized submenus, reword some other labels to make them more
// descriptive.
//
// Brad Whitlock, Thu Dec 9 10:50:12 PDT 2004
// I added a variable button that lets us insert variables.
//
// ****************************************************************************
void
QvisExpressionsWindow::CreateWindowContents()
{
......@@ -312,7 +317,7 @@ QvisExpressionsWindow::CreateWindowContents()
row++;
notHidden = new QCheckBox("Show variable in plot menus", f2, "notHidden");
editLayout->addMultiCellWidget(notHidden, row,row, 0,1);
editLayout->addWidget(notHidden, row, 0);
insertFunctionButton = new QPushButton("Insert Function...", f2);
insertFunctionMenu = new QPopupMenu(f2, "insertFunctionMenu");
......@@ -328,7 +333,17 @@ QvisExpressionsWindow::CreateWindowContents()
this, SLOT(insertFunction(int)));
}
insertFunctionButton->setPopup(insertFunctionMenu);
editLayout->addWidget(insertFunctionButton, row, 3);
editLayout->addWidget(insertFunctionButton, row, 2);
// Create a variable button so we can insert variables for the
// active source.
insertVariableButton = new QvisVariableButton(false, false, false, -1, f2,
"insertVariableButton");
insertVariableButton->setChangeTextOnVariableChange(false);
insertVariableButton->setText("Insert Variable...");
connect(insertVariableButton, SIGNAL(activated(const QString &)),
this, SLOT(insertVariable(const QString &)));
editLayout->addWidget(insertVariableButton, row, 3);
row++;
// connect signals
......@@ -452,7 +467,11 @@ QvisExpressionsWindow::UpdateWindowSingleItem()
// Always access the expression list by index, just in case there
// are two expressions with the same name.
//
// Brad Whitlock, Thu Dec 9 14:04:22 PST 2004
// Added a button to insert variable names.
//
// ****************************************************************************
void
QvisExpressionsWindow::UpdateWindowSensitivity()
{
......@@ -474,6 +493,7 @@ QvisExpressionsWindow::UpdateWindowSensitivity()
typeList->setEnabled(enable);
definitionEdit->setEnabled(enable);
insertFunctionButton->setEnabled(enable);
insertVariableButton->setEnabled(enable);
}
// ****************************************************************************
......@@ -801,7 +821,11 @@ QvisExpressionsWindow::displayAllVarsChanged()
// Make sure it's not just a single-char operator before adding the
// function call parentheses.
//
// Brad Whitlock, Thu Dec 9 14:15:01 PST 2004
// Added code to set the focus to the definition edit.
//
// ****************************************************************************
void
QvisExpressionsWindow::insertFunction(int id)
{
......@@ -822,4 +846,69 @@ QvisExpressionsWindow::insertFunction(int id)
col = 0;
definitionEdit->setCursorPosition(line, col);
}
definitionEdit->setFocus();
}
// ****************************************************************************
// Method: QvisExpressionWindow::insertVariable
//
// Purpose:
// This is a Qt slot function that inserts a variable name into the
// current variable definition.
//
// Arguments:
// var : The variable.
//
// Programmer: Brad Whitlock
// Creation: Thu Dec 9 10:52:37 PDT 2004
//
// Modifications:
//
// ****************************************************************************
void
QvisExpressionsWindow::insertVariable(const QString &var)
{
if (!definitionEdit->isEnabled())
return;
// If the variable name contains slashes then put the <> around the
// variable name.
QString newVar(var);
if(var.find("/") != -1)
newVar = QString("<") + var + QString(">");
definitionEdit->insert(newVar);
definitionEdit->setFocus();
}
// ****************************************************************************
// Method: QvisExpressionsWindow::newExpression
//
// Purpose:
// This is a Qt slot function that can be called on the window to add a
// new expression and set the focus of the window to the name line edit
// and select all of its text.
//
// Note: This method is used by the "Create new expression ..." option
// in QvisVariableButtons.
//
// Programmer: Brad Whitlock
// Creation: Thu Dec 9 10:18:13 PDT 2004
//
// Modifications:
//
// ****************************************************************************
void
QvisExpressionsWindow::newExpression()
{
// Add a new expression
addExpression();
// Make the name line edit be the active widget and select its text.
nameEdit->setFocus();
nameEdit->setCursorPosition(0);
nameEdit->selectAll();
}
......@@ -16,6 +16,7 @@ class QMultiLineEdit;
class QLabel;
class QListBox;
class QComboBox;
class QvisVariableButton;
// ****************************************************************************
// Class: QvisExpressionsWindow
......@@ -33,6 +34,10 @@ class QComboBox;
// Reversed the sense of the "hidden" button. Added a list-box-index to
// expresion-list-index map so we didn't have to index expressions by name.
//
// Brad Whitlock, Thu Dec 9 10:15:25 PDT 2004
// Added a newExpression slot function and a variable button that lets
// us pick variables from the active source.
//
// ****************************************************************************
class GUI_API QvisExpressionsWindow : public QvisPostableWindowObserver
......@@ -48,6 +53,7 @@ class GUI_API QvisExpressionsWindow : public QvisPostableWindowObserver
virtual void CreateWindowContents();
public slots:
virtual void apply();
void newExpression();
protected:
void UpdateWindow(bool doAll);
void Apply(bool forceUpdate = false);
......@@ -61,30 +67,32 @@ class GUI_API QvisExpressionsWindow : public QvisPostableWindowObserver
void notHiddenChanged();
void displayAllVarsChanged();
void insertFunction(int);
void insertVariable(const QString &);
void UpdateWindowSingleItem();
void UpdateWindowSensitivity();
private:
// Widgets and layouts.
QListBox *exprListBox;
QListBox *exprListBox;
QLabel *nameEditLabel;
QLabel *definitionEditLabel;
QLabel *typeLabel;
QLabel *nameEditLabel;
QLabel *definitionEditLabel;
QLabel *typeLabel;
QLineEdit *nameEdit;
QComboBox *typeList;
QCheckBox *notHidden;
QMultiLineEdit *definitionEdit;
QLineEdit *nameEdit;
QComboBox *typeList;
QCheckBox *notHidden;
QMultiLineEdit *definitionEdit;
QPushButton *newButton;
QPushButton *delButton;
QPushButton *newButton;
QPushButton *delButton;
QPushButton *insertFunctionButton;
QPopupMenu *insertFunctionMenu;
QPushButton *insertFunctionButton;
QPopupMenu *insertFunctionMenu;
QvisVariableButton *insertVariableButton;
QCheckBox *displayAllVars;
QCheckBox *displayAllVars;
// State information
ExpressionList *exprList;
......
......@@ -89,7 +89,9 @@
#include <QvisSaveWindow.h>
#include <QvisSubsetWindow.h>
#include <QvisQueryOverTimeWindow.h>
#include <QvisVariableButton.h>
#include <QvisViewWindow.h>
#include <QvisWizard.h>
#include <SplashScreen.h>
#include <WindowMetrics.h>
......@@ -1735,6 +1737,11 @@ QvisGUIApplication::AddViewerSpaceArguments()
// Brad Whitlock, Wed May 5 15:58:47 PST 2004
// I moved a line from another method into this one.
//
// Brad Whitlock, Tue Dec 14 09:07:18 PDT 2004
// Connected some new signals from the plot manager widget to this object
// so we can support plot and operator wizards without the plot manager
// widget having to deal with the plugin manager.
//
// ****************************************************************************
void
......@@ -1764,8 +1771,12 @@ QvisGUIApplication::CreateMainWindow()
connect(mainWin, SIGNAL(activatePrintWindow()), this, SLOT(SetPrinterOptions()));
connect(mainWin->GetPlotManager(), SIGNAL(activatePlotWindow(int)),
this, SLOT(ActivatePlotWindow(int)));
connect(mainWin->GetPlotManager(), SIGNAL(addPlot(int, const QString &)),
this, SLOT(AddPlot(int, const QString &)));
connect(mainWin->GetPlotManager(), SIGNAL(activateOperatorWindow(int)),
this, SLOT(ActivateOperatorWindow(int)));
connect(mainWin->GetPlotManager(), SIGNAL(addOperator(int)),
this, SLOT(AddOperator(int)));
connect(mainWin, SIGNAL(refreshFileList()), this, SLOT(RefreshFileList()));
connect(mainWin, SIGNAL(reopenOnNextFrame()),
this, SLOT(RefreshFileListAndNextFrame()));
......@@ -1804,6 +1815,11 @@ QvisGUIApplication::CreateMainWindow()
// Forced creation of ColorTableWindow, so that colortable names will be
// available to other windows as needed.
//
// Brad Whitlock, Thu Dec 9 09:50:33 PDT 2004
// Added code to connect the application's method to show the expression
// window to the variable button so all variable buttons can open the
// expression window.
//
// ****************************************************************************
void
......@@ -1852,6 +1868,12 @@ QvisGUIApplication::SetupWindows()
connect(mainWin, SIGNAL(activateColorTableWindow()),
colorTableWin, SLOT(show()));
//