// **************************************************************************** // Method: ParsingExprList::GetExpressionTree // // Purpose: // Returns the expression tree for the specified expression or NULL if // the expression does not exist. // // Arguments: // varname : The name of the expression for which to get the tree. // // Returns: The expression tree for the specified expression or NULL if // the expression does not exist. // // Note: Moved from ViewerEngineManager.C // // Programmer: Sean Ahern // Creation: Wed Feb 5 13:52:35 PST 2003 // // Modifications: // Jeremy Meredith, Wed Nov 24 12:27:15 PST 2004 // Refactored and changed parse tree classes and return types around. // // **************************************************************************** ExprNode * ParsingExprList::GetExpressionTree(const char *varname) { ExprNode *tree = 0; // Get the expression tree for the expression. //Expression *exp = const_cast<ExpressionList&>(exprList)[varname]; Expression *exp = GetExpression(varname); if (exp != NULL) { ParseTreeNode *t=Instance()->GetParser()->Parse(exp->GetDefinition()); tree = (ExprNode*)t; } else tree = NULL; return tree; }
void ParallelCoordinatesViewerPluginInfo::InitializePlotAtts( AttributeSubject *atts, ViewerPlot *plot) { // If we had scalar names, we can just copy the default atts // and return. if (defaultAtts->GetScalarAxisNames().size() != 0) { // One helpful thing we can do: make sure the user set the // visual axis names. They really should have, but since // we can blindly copy them from the scalar axis names in // this case, no harm doing it for them. if (defaultAtts->GetVisualAxisNames().size() == 0) defaultAtts->SetVisualAxisNames(defaultAtts->GetScalarAxisNames()); *(ParallelCoordinatesAttributes*)atts = *defaultAtts; return; } // Otherwise, we must be an array variable; try to get // some names for its components.... const avtDatabaseMetaData *md = plot->GetMetaData(); const std::string &var = plot->GetVariableName(); const avtArrayMetaData *array = md->GetArray(var); stringVector subNames; if (array) { subNames = array->compNames; } else { Expression *exp = ParsingExprList::GetExpression(plot->GetVariableName()); if (exp == NULL || exp->GetType() != Expression::ArrayMeshVar) { debug3 << "ParallelCoordinatesAttributes::InitializePlotAtts: " << "variable wasn't an array database variable, an " << "array expression, or a list of scalars. This can " << "happen if the user attempts to create this plot " << "without the use off a wizard, e.g. in the case of " << "the cli. Assuming this is the case and continuing " << "without error.\n"; return; } // If we have any problems walking the expression tree, just return; // the worst case scenario if we don't populate the visual axis // name list is that the GUI window is temporarily blank. ExprNode *root = ParsingExprList::GetExpressionTree(exp); if (root->GetTypeName() != "Function") return; FunctionExpr *fn = dynamic_cast<FunctionExpr*>(root); if (fn->GetName() != "array_compose" && fn->GetName() != "array_compose_with_bins") return; ArgsExpr *argsExpr = fn->GetArgsExpr(); std::vector<ArgExpr*> *args = argsExpr ? argsExpr->GetArgs() : NULL; if (!args) return; for (size_t i=0; i<args->size(); i++) { ExprNode *arg = (ExprNode*)((*args)[i]->GetExpr()); if (arg->GetTypeName() == "List") break; subNames.push_back(arg->GetPos().GetText(exp->GetDefinition())); } } doubleVector extMin(subNames.size(), -1e+37); doubleVector extMax(subNames.size(), +1e+37); // Set up the default attributes to contain these values, so // if the user hits reset, the axis names are retained. defaultAtts->SetVisualAxisNames(subNames); defaultAtts->SetExtentMinima(extMin); defaultAtts->SetExtentMaxima(extMax); *(ParallelCoordinatesAttributes*)atts = *defaultAtts; }