Commit 690b2d61 authored by hrchilds's avatar hrchilds
Browse files

Merge Rob Sisneros' operator_variables branch to trunk, allowing for

construction of operator variables.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@12394 18c085ea-50e0-402c-830e-de6fd14e8384
parent 71308e85
......@@ -263,6 +263,9 @@ avtExpressionEvaluatorFilter::Execute(void)
// Brad Whitlock, Tue Jan 20 15:57:01 PST 2009
// I changed the name of a type conversion function.
//
// Rob Sisneros, Sun Aug 29 20:13:10 CDT 2010
// Add a check for variables from operators.
//
// ****************************************************************************
void
......@@ -297,6 +300,16 @@ avtExpressionEvaluatorFilter::VerifyVariableTypes(void)
avtVarTypeToString(vt).c_str());
EXCEPTION1(VisItException, msg);
}
// If the expression is from an operator, and has gotten this far,
// something is wrong.
if(exp->GetFromOperator())
{
char msg[1024];
sprintf(msg, "The expression variable \"%s\" was declared as an operator"
" expression. This variable must be removed from the contract"
" and created by the operator.", varname.c_str());
EXCEPTION1(VisItException, msg);
}
}
}
......
......@@ -119,6 +119,12 @@ class ExpressionList;
// Brad Whitlock, Thu Feb 4 16:04:19 PST 2010
// I added a GetCategoryName method.
//
// Rob Sisneros, Sun Aug 29 20:13:10 CDT 2010
// Add infrastructure for operators to create variables.
//
// Hank Childs, Tue Aug 31 10:20:08 PDT 2010
// Remove unused method GetCreateVariables.
//
// ****************************************************************************
class PLUGIN_API GeneralOperatorPluginInfo
......@@ -138,6 +144,7 @@ class PLUGIN_API CommonOperatorPluginInfo : public virtual GeneralOperatorPlugin
virtual AttributeSubject *AllocAttributes() = 0;
virtual void CopyAttributes(AttributeSubject *to,
AttributeSubject *from) = 0;
virtual ExpressionList *GetCreatedExpressions(const char *mesh) {return NULL;}
};
class PLUGIN_API GUIOperatorPluginInfo : public virtual CommonOperatorPluginInfo
......@@ -175,7 +182,6 @@ class PLUGIN_API ViewerOperatorPluginInfo : public virtual CommonOperatorPluginI
virtual bool Removeable() const { return true; }
virtual bool Moveable() const { return true; }
virtual bool AllowsSubsequentOperators() const { return true; }
virtual ExpressionList *GetCreatedVariables(const char *mesh) {return NULL;}
};
class PLUGIN_API EngineOperatorPluginInfo : public virtual CommonOperatorPluginInfo
......
......@@ -79,14 +79,11 @@ Expression::ExprType_FromString(const std::string &s, Expression::ExprType &val)
return false;
}
// Type map format string
const char *Expression::TypeMapFormatString = "ssbibbsb";
// ****************************************************************************
// Method: Expression::Expression
//
// Purpose:
// Constructor for the Expression class.
// Init utility for the Expression class.
//
// Note: Autogenerated by xml2atts.
//
......@@ -97,8 +94,7 @@ const char *Expression::TypeMapFormatString = "ssbibbsb";
//
// ****************************************************************************
Expression::Expression() :
AttributeSubject(Expression::TypeMapFormatString)
void Expression::Init()
{
name = "notset";
definition = "notset";
......@@ -106,15 +102,18 @@ Expression::Expression() :
type = ScalarMeshVar;
fromDB = false;
fromOperator = false;
operatorName = "__none__";
dbName = "__none__";
autoExpression = false;
Expression::SelectAll();
}
// ****************************************************************************
// Method: Expression::Expression
//
// Purpose:
// Copy constructor for the Expression class.
// Copy utility for the Expression class.
//
// Note: Autogenerated by xml2atts.
//
......@@ -125,8 +124,7 @@ Expression::Expression() :
//
// ****************************************************************************
Expression::Expression(const Expression &obj) :
AttributeSubject(Expression::TypeMapFormatString)
void Expression::Copy(const Expression &obj)
{
name = obj.name;
definition = obj.definition;
......@@ -134,10 +132,101 @@ Expression::Expression(const Expression &obj) :
type = obj.type;
fromDB = obj.fromDB;
fromOperator = obj.fromOperator;
operatorName = obj.operatorName;
meshName = obj.meshName;
dbName = obj.dbName;
autoExpression = obj.autoExpression;
SelectAll();
Expression::SelectAll();
}
// Type map format string
const char *Expression::TypeMapFormatString = EXPRESSION_TMFS;
const AttributeGroup::private_tmfs_t Expression::TmfsStruct = {EXPRESSION_TMFS};
// ****************************************************************************
// Method: Expression::Expression
//
// Purpose:
// Default constructor for the Expression class.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: omitted
//
// Modifications:
//
// ****************************************************************************
Expression::Expression() :
AttributeSubject(Expression::TypeMapFormatString)
{
Expression::Init();
}
// ****************************************************************************
// Method: Expression::Expression
//
// Purpose:
// Constructor for the derived classes of Expression class.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: omitted
//
// Modifications:
//
// ****************************************************************************
Expression::Expression(private_tmfs_t tmfs) :
AttributeSubject(tmfs.tmfs)
{
Expression::Init();
}
// ****************************************************************************
// Method: Expression::Expression
//
// Purpose:
// Copy constructor for the Expression class.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: omitted
//
// Modifications:
//
// ****************************************************************************
Expression::Expression(const Expression &obj) :
AttributeSubject(Expression::TypeMapFormatString)
{
Expression::Copy(obj);
}
// ****************************************************************************
// Method: Expression::Expression
//
// Purpose:
// Copy constructor for derived classes of the Expression class.
//
// Note: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: omitted
//
// Modifications:
//
// ****************************************************************************
Expression::Expression(const Expression &obj, private_tmfs_t tmfs) :
AttributeSubject(tmfs.tmfs)
{
Expression::Copy(obj);
}
// ****************************************************************************
......@@ -179,16 +268,9 @@ Expression&
Expression::operator = (const Expression &obj)
{
if (this == &obj) return *this;
name = obj.name;
definition = obj.definition;
hidden = obj.hidden;
type = obj.type;
fromDB = obj.fromDB;
fromOperator = obj.fromOperator;
dbName = obj.dbName;
autoExpression = obj.autoExpression;
SelectAll();
Expression::Copy(obj);
return *this;
}
......@@ -217,6 +299,8 @@ Expression::operator == (const Expression &obj) const
(type == obj.type) &&
(fromDB == obj.fromDB) &&
(fromOperator == obj.fromOperator) &&
(operatorName == obj.operatorName) &&
(meshName == obj.meshName) &&
(dbName == obj.dbName) &&
(autoExpression == obj.autoExpression));
}
......@@ -368,6 +452,8 @@ Expression::SelectAll()
Select(ID_type, (void *)&type);
Select(ID_fromDB, (void *)&fromDB);
Select(ID_fromOperator, (void *)&fromOperator);
Select(ID_operatorName, (void *)&operatorName);
Select(ID_meshName, (void *)&meshName);
Select(ID_dbName, (void *)&dbName);
Select(ID_autoExpression, (void *)&autoExpression);
}
......@@ -438,6 +524,18 @@ Expression::CreateNode(DataNode *parentNode, bool completeSave, bool forceAdd)
node->AddNode(new DataNode("fromOperator", fromOperator));
}
if(completeSave || !FieldsEqual(ID_operatorName, &defaultObject))
{
addToParent = true;
node->AddNode(new DataNode("operatorName", operatorName));
}
if(completeSave || !FieldsEqual(ID_meshName, &defaultObject))
{
addToParent = true;
node->AddNode(new DataNode("meshName", meshName));
}
if(completeSave || !FieldsEqual(ID_dbName, &defaultObject))
{
addToParent = true;
......@@ -512,6 +610,10 @@ Expression::SetFromNode(DataNode *parentNode)
SetFromDB(node->AsBool());
if((node = searchNode->GetNode("fromOperator")) != 0)
SetFromOperator(node->AsBool());
if((node = searchNode->GetNode("operatorName")) != 0)
SetOperatorName(node->AsString());
if((node = searchNode->GetNode("meshName")) != 0)
SetMeshName(node->AsString());
if((node = searchNode->GetNode("dbName")) != 0)
SetDbName(node->AsString());
if((node = searchNode->GetNode("autoExpression")) != 0)
......@@ -564,6 +666,20 @@ Expression::SetFromOperator(bool fromOperator_)
Select(ID_fromOperator, (void *)&fromOperator);
}
void
Expression::SetOperatorName(const std::string &operatorName_)
{
operatorName = operatorName_;
Select(ID_operatorName, (void *)&operatorName);
}
void
Expression::SetMeshName(const std::string &meshName_)
{
meshName = meshName_;
Select(ID_meshName, (void *)&meshName);
}
void
Expression::SetDbName(const std::string &dbName_)
{
......@@ -630,6 +746,30 @@ Expression::GetFromOperator() const
return fromOperator;
}
const std::string &
Expression::GetOperatorName() const
{
return operatorName;
}
std::string &
Expression::GetOperatorName()
{
return operatorName;
}
const std::string &
Expression::GetMeshName() const
{
return meshName;
}
std::string &
Expression::GetMeshName()
{
return meshName;
}
const std::string &
Expression::GetDbName() const
{
......@@ -664,6 +804,18 @@ Expression::SelectDefinition()
Select(ID_definition, (void *)&definition);
}
void
Expression::SelectOperatorName()
{
Select(ID_operatorName, (void *)&operatorName);
}
void
Expression::SelectMeshName()
{
Select(ID_meshName, (void *)&meshName);
}
void
Expression::SelectDbName()
{
......@@ -700,6 +852,8 @@ Expression::GetFieldName(int index) const
case ID_type: return "type";
case ID_fromDB: return "fromDB";
case ID_fromOperator: return "fromOperator";
case ID_operatorName: return "operatorName";
case ID_meshName: return "meshName";
case ID_dbName: return "dbName";
case ID_autoExpression: return "autoExpression";
default: return "invalid index";
......@@ -732,6 +886,8 @@ Expression::GetFieldType(int index) const
case ID_type: return FieldType_enum;
case ID_fromDB: return FieldType_bool;
case ID_fromOperator: return FieldType_bool;
case ID_operatorName: return FieldType_string;
case ID_meshName: return FieldType_string;
case ID_dbName: return FieldType_string;
case ID_autoExpression: return FieldType_bool;
default: return FieldType_unknown;
......@@ -764,6 +920,8 @@ Expression::GetFieldTypeName(int index) const
case ID_type: return "enum";
case ID_fromDB: return "bool";
case ID_fromOperator: return "bool";
case ID_operatorName: return "string";
case ID_meshName: return "string";
case ID_dbName: return "string";
case ID_autoExpression: return "bool";
default: return "invalid index";
......@@ -822,6 +980,16 @@ Expression::FieldsEqual(int index_, const AttributeGroup *rhs) const
retval = (fromOperator == obj.fromOperator);
}
break;
case ID_operatorName:
{ // new scope
retval = (operatorName == obj.operatorName);
}
break;
case ID_meshName:
{ // new scope
retval = (meshName == obj.meshName);
}
break;
case ID_dbName:
{ // new scope
retval = (dbName == obj.dbName);
......@@ -948,3 +1116,4 @@ Expression::GetTypeId(const std::string s)
return Unknown;
}
......@@ -113,3 +113,7 @@ Expression::GetTypeId(const std::string s)
return Unknown;
}
Function: AddMeshName
Declaration:
Definition:
......@@ -42,6 +42,7 @@
#include <string>
#include <AttributeSubject.h>
// ****************************************************************************
// Class: Expression
//
......@@ -74,13 +75,23 @@ public:
Species
};
// These constructors are for objects of this class
Expression();
Expression(const Expression &obj);
protected:
// These constructors are for objects derived from this class
Expression(private_tmfs_t tmfs);
Expression(const Expression &obj, private_tmfs_t tmfs);
public:
virtual ~Expression();
virtual Expression& operator = (const Expression &obj);
virtual bool operator == (const Expression &obj) const;
virtual bool operator != (const Expression &obj) const;
private:
void Init();
void Copy(const Expression &obj);
public:
virtual const std::string TypeName() const;
virtual bool CopyAttributes(const AttributeGroup *);
......@@ -91,6 +102,8 @@ public:
virtual void SelectAll();
void SelectName();
void SelectDefinition();
void SelectOperatorName();
void SelectMeshName();
void SelectDbName();
// Property setting methods
......@@ -100,6 +113,8 @@ public:
void SetType(ExprType type_);
void SetFromDB(bool fromDB_);
void SetFromOperator(bool fromOperator_);
void SetOperatorName(const std::string &operatorName_);
void SetMeshName(const std::string &meshName_);
void SetDbName(const std::string &dbName_);
void SetAutoExpression(bool autoExpression_);
......@@ -112,6 +127,10 @@ public:
ExprType GetType() const;
bool GetFromDB() const;
bool GetFromOperator() const;
const std::string &GetOperatorName() const;
std::string &GetOperatorName();
const std::string &GetMeshName() const;
std::string &GetMeshName();
const std::string &GetDbName() const;
std::string &GetDbName();
bool GetAutoExpression() const;
......@@ -137,6 +156,7 @@ public:
static int GetNumTypes();
static const char * GetTypeString(const Expression::ExprType t);
static Expression::ExprType GetTypeId(const std::string s);
// IDs that can be used to identify fields in case statements
enum {
......@@ -146,8 +166,11 @@ public:
ID_type,
ID_fromDB,
ID_fromOperator,
ID_operatorName,
ID_meshName,
ID_dbName,
ID_autoExpression
ID_autoExpression,
ID__LAST
};
private:
......@@ -157,11 +180,15 @@ private:
int type;
bool fromDB;
bool fromOperator;
std::string operatorName;
std::string meshName;
std::string dbName;
bool autoExpression;
// Static class format string for type map.
static const char *TypeMapFormatString;
static const private_tmfs_t TmfsStruct;
};
#define EXPRESSION_TMFS "ssbibbsssb"
#endif
<?xml version="1.0"?>
<Attribute name="Expression" purpose="This class contains an expression." persistent="true" exportAPI="STATE_API" exportInclude="state_exports.h" codefile="Expression.code">
<Attribute name="Expression" purpose="This class contains an expression." persistent="true" keyframe="true" exportAPI="STATE_API" exportInclude="state_exports.h" codefile="Expression.code">
<Enum name="ExprType">
Unknown
ScalarMeshVar
......@@ -30,6 +30,11 @@
<Field name="fromOperator" label="fromOperator" type="bool">
false
</Field>
<Field name="operatorName" label="operatorName" type="string">
__none__
</Field>
<Field name="meshName" label="meshName" type="string">
</Field>
<Field name="dbName" label="dbName" type="string">
__none__
</Field>
......@@ -42,4 +47,6 @@
</Function>
<Function name="GetTypeId" user="true" member="true">
</Function>
<Function name="AddMeshName" user="true" member="true">
</Function>
</Attribute>
......@@ -1099,6 +1099,10 @@ QvisCMFEWizard::UpdateSourceList()
// Creation: August 2, 2010
//
// Modifications:
//
// Rob Sisneros, Sun Aug 29 20:13:10 CDT 2010
// Add support for operators that create expressions.
//
// Cyrus Harrison, Mon Aug 30 11:59:25 PDT 2010
// Simplify wizard & add ability to open new databases.
//
......@@ -1133,7 +1137,7 @@ QvisCMFEWizard::UpdateDonorField(void)
!FileServerList::ANY_STATE,
FileServerList::GET_NEW_MD);
populator->PopulateVariableLists(filename, md, sil, exprList,false);
populator->PopulateVariableLists(filename, md, sil, exprList,NULL,false);
donorFieldVar->ResetPopulator(populator);
donorFieldVar->setText(tr("<Select>"));
......@@ -1180,7 +1184,7 @@ QvisCMFEWizard::UpdateTargetMesh(void)
!FileServerList::ANY_STATE,
FileServerList::GET_NEW_MD);
populator->PopulateVariableLists(target_source, md, sil, exprList,false);
populator->PopulateVariableLists(target_source, md, sil, exprList,NULL,false);
targetMeshVar->ResetPopulator(populator);
......
......@@ -90,6 +90,7 @@
#include <ObserverToCallback.h>
#include <PickAttributes.h>
#include <QueryAttributes.h>
#include <ParsingExprList.h>
#include <PlotList.h>
#include <Plot.h>
#include <PluginManagerAttributes.h>
......@@ -6965,6 +6966,12 @@ QvisGUIApplication::HandleMetaDataUpdate()
// Brad Whitlock, Tue Jun 24 11:53:56 PDT 2008
// Get the plugin manager from the viewer proxy.
//
// Rob Sisneros, Sun Aug 29 20:13:10 CDT 2010
// Add support for operators that add expressions.
//
// Hank Childs, Tue Aug 31 10:10:39 PDT 2010
// Move Rob's auto-add operator code to the viewer.
//
// ****************************************************************************
void
......
......@@ -65,6 +65,9 @@
#include <Expression.h>
#include <GlobalAttributes.h>
#include <NameSimplifier.h>
#include <OperatorPluginInfo.h>
#include <OperatorPluginManager.h>
#include <ParsingExprList.h>
#include <PluginManagerAttributes.h>
#include <QvisPlotListBoxItem.h>
#include <QvisPlotListBox.h>
......@@ -1609,6 +1612,9 @@ QvisPlotManagerWidget::EnablePluginMenus()
// Mark C. Miller, Thu Jun 14 10:26:37 PDT 2007
// Added support to treat all databases as time varying
//
// Rob Sisneros, Sun Aug 29 20:13:10 CDT 2010
// Add support for operators that create expressions.
//
// ****************************************************************************
bool
......@@ -1622,6 +1628,8 @@ QvisPlotManagerWidget::PopulateVariableLists(VariableMenuPopulator &populator,
FileServerList::ANY_STATE,
!FileServerList::GET_NEW_MD);
OperatorPluginManager *oPM = GetViewerProxy()->GetOperatorPluginManager();
if (fileServer->GetTreatAllDBsAsTimeVarying() ||
(md && md->GetMustRepopulateOnStateChange()))
{
......@@ -1638,7 +1646,7 @@ QvisPlotManagerWidget::PopulateVariableLists(VariableMenuPopulator &populator,
FileServerList::GET_NEW_MD);
return populator.PopulateVariableLists(filename.FullName(),
md, sil, exprList,
md, sil, exprList, oPM,
fileServer->GetTreatAllDBsAsTimeVarying());
}
else
......@@ -1651,7 +1659,7 @@ QvisPlotManagerWidget::PopulateVariableLists(VariableMenuPopulator &populator,
!FileServerList::GET_NEW_MD);
return populator.PopulateVariableLists(filename.FullName(),
md, sil, exprList,
md, sil, exprList, oPM,
fileServer->GetTreatAllDBsAsTimeVarying());
}
}
......
......@@ -77,10 +77,15 @@
<Field name="emptyVal" label="Value for Bins With No Data" type="double">
0.000000
</Field>
<Function name="CopyAttributes" user="false" member="true">
</Function>
<Function name="CreateConstructionAtts" user="true" member="true">
</Function>