Commit 8880eb72 authored by bonnell's avatar bonnell

Modified Query interface to pass query arguments as MapNode between cli/gui...

Modified Query interface to pass query arguments as MapNode between cli/gui and Viewer to reduce rpc clutter and make adding/changing queries a bit easier.
CLI accepts named arguments (keyword args) or python dictionary.
GUI allows customizable query widgets for more useful control of options.
Query-over-time start/end times and stride now specified in Query Window with other query options, and can be specified as keyword args in cli's QueryOverTime method.
Picks via QueryWindow have been consolidated into one query: "Pick", options have been expanded.
Updated tests to use new argument style.  Left a few old-style calls to ensure they still work.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@16065 18c085ea-50e0-402c-830e-de6fd14e8384
parent 0e9a0bba
......@@ -119,6 +119,9 @@ typedef void (*ProgressCallback)(void *, const char *, const char *,int,int);
// Hank Childs, Fri Dec 24 17:48:48 PST 2010
// Add method QuerySupportsTimeParallelization.
//
// Kathleen Bonnell, Fri Jun 17 16:25:09 PDT 2011
// Added SetInputParams.
//
// ****************************************************************************
class QUERY_API avtDataObjectQuery : public virtual avtDataObjectSink
......@@ -131,6 +134,7 @@ class QUERY_API avtDataObjectQuery : public virtual avtDataObjectSink
virtual const char *GetDescription(void) { return NULL; };
virtual const char *GetShortDescription(void) { return NULL; };
virtual void SetInputParams(const MapNode &params) {;};
virtual bool OriginalData(void) { return false; };
virtual void PerformQuery(QueryAttributes *) = 0;
virtual std::string GetResultMessage(void) = 0;
......
......@@ -48,7 +48,7 @@
#include <avtDataObjectQuery.h>
#include <avtDatasetSink.h>
#include <QueryAttributes.h>
#include <string.h>
#include <string>
class vtkDataSet;
......
This diff is collapsed.
......@@ -57,6 +57,8 @@ class QueryAttributes;
// Creation: March 30, 2004
//
// Modifications:
// Kathleen Biagas, Fri Jul 15 11:15:00 PDT 2011
// Added GetDefaultInputParams.
//
// ****************************************************************************
......@@ -68,6 +70,8 @@ class QUERY_API avtQueryFactory
static avtQueryFactory *Instance();
avtDataObjectQuery *CreateQuery(const QueryAttributes *);
std::string GetDefaultInputParams(
const std::string &queryName);
private:
avtQueryFactory();
......
......@@ -514,7 +514,11 @@ avtQueryOverTimeFilter::SetSILAtts(const SILRestrictionAttributes *silAtts)
// In support of multiple-variable time picks, create an output Tree instead
// of a single grid.
//
// Kathleen Bonnell, Thu Jul 7 11:26:31 PDT 2011
// Kathleen Biagas, Tue Jun 21 09:52:26 PDT 2011
// Change setting of 'multiCurve' to reflect use of MapNode for
// query Input parameters.
//
// Kathleen Biagas, Thu Jul 7 11:26:31 PDT 2011
// Fixed incorrect generation of warning when nResults > 2.
//
// ****************************************************************************
......@@ -620,7 +624,11 @@ avtQueryOverTimeFilter::CreateFinalOutput()
}
stringVector vars = atts.GetQueryAtts().GetVariables();
bool multiCurve = atts.GetQueryAtts().GetTimeCurvePlotType() == QueryAttributes::Multiple_Y_Axes;
bool multiCurve = false;
if (atts.GetQueryAtts().GetQueryInputParams().HasEntry("curve_plot_type"))
{
multiCurve = (atts.GetQueryAtts().GetQueryInputParams().GetEntry("curve_plot_type")->AsInt() == 1);
}
avtDataTree_p tree = CreateTree(times, qRes, vars, multiCurve);
SetOutputDataTree(tree);
finalOutputCreated = true;
......
......@@ -130,6 +130,51 @@ avtConnComponentsSummaryQuery::
}
// ****************************************************************************
// Method: avtConnComponentsSummaryQuery::SetInputParams
//
// Purpose: Allows this query to read input parameters set by user.
//
// Arguments:
// params: MapNode containing input.
//
// Programmer: Kathleen Biagas
// Creation: June 17, 2011
//
// Modifications:
//
// ****************************************************************************
void
avtConnComponentsSummaryQuery::SetInputParams(const MapNode &params)
{
if (params.HasEntry("output_file"))
SetOutputFileName(params.GetEntry("output_file")->AsString());
}
// ****************************************************************************
// Method: avtConnComponentsSummaryQuery::GetDefaultInputParams
//
// Purpose: Retrieve default input parameters.
//
// Arguments:
// params: MapNode to store default values.
//
// Programmer: Kathleen Biagas
// Creation: July 15, 2011
//
// Modifications:
//
// ****************************************************************************
void
avtConnComponentsSummaryQuery::GetDefaultInputParams(MapNode &params)
{
params["output_file"] = std::string("cc_summary.okc");
}
// ****************************************************************************
// Method: avtConnComponentsSummaryQuery::PreExecute
//
......
......@@ -88,6 +88,12 @@ class vtkDataSet;
// Cyrus Harrison, Mon Jun 6 17:02:12 PDT 2011
// Added lengthFilter.
//
// Kathleen Biagas, Tue Jun 21 10:42:07 PDT 2011
// Added SetInputParams.
//
// Kathleen Biagas, Fri Jul 15 16:05:35 PDT 2011
// Added GetDefaultInputParams.
//
// ****************************************************************************
class QUERY_API avtConnComponentsSummaryQuery
......@@ -102,6 +108,9 @@ class QUERY_API avtConnComponentsSummaryQuery
virtual const char *GetDescription(void)
{ return "Generating connected components summary.";};
virtual void SetInputParams(const MapNode &);
static void GetDefaultInputParams(MapNode &);
void SetOutputFileName(const std::string &fname)
{outputFileName = fname; }
protected:
......
......@@ -37,7 +37,7 @@
*****************************************************************************/
// ************************************************************************* //
// avtConnectedComponentsVolumeQuery.h //
// avtConnectedComponentsVolumeQuery.h //
// ************************************************************************* //
#ifndef AVT_CONN_COMPONENTS_VOLUME_QUERY_H
......
......@@ -380,8 +380,9 @@ avtEulerianQuery::PostExecute(void)
for (iter = domToEulerMap.begin(); iter != domToEulerMap.end(); iter++)
{
string domainName;
GetInput()->GetQueryableSource()->GetDomainName(queryAtts.GetVariables()[0],
queryAtts.GetTimeStep(), (*iter).first, domainName);
GetInput()->GetQueryableSource()->GetDomainName(
queryAtts.GetVariables()[0], queryAtts.GetTimeStep(),
(*iter).first, domainName);
if (domainName.size() > 0)
{
SNPRINTF(msgBuff, 500, "Eulerian for %s is %d\n",
......
......@@ -46,6 +46,7 @@
#include <avtOriginatingSource.h>
#include <avtParallel.h>
#include <avtSourceFromAVTDataset.h>
#include <QueryArgumentException.h>
#include <vectortypes.h>
......@@ -109,6 +110,98 @@ avtHohlraumFluxQuery::~avtHohlraumFluxQuery()
delete[] radBins;
}
// ****************************************************************************
// Method: avtHohlraumFluxQuery::SetInputParams
//
// Purpose: Allows this query to read input parameters set by user.
//
// Arguments:
// params MapNode containing input.
//
// Programmer: Kathleen Biagas
// Creation: June 20, 2011
//
// ****************************************************************************
void
avtHohlraumFluxQuery::SetInputParams(const MapNode &params)
{
if (params.HasEntry("vars"))
SetVariableNames(params.GetEntry("vars")->AsStringVector());
else
EXCEPTION1(QueryArgumentException, "vars");
if (params.HasEntry("num_lines"))
SetNumberOfLines(params.GetEntry("num_lines")->AsInt());
if (params.HasEntry("divide_emis_by_absorb"))
SetDivideEmisByAbsorb(params.GetEntry("divide_emis_by_absorb")->AsInt());
if (params.HasEntry("ray_center"))
{
if (params.GetEntry("ray_center")->TypeName() == "doubleVector")
SetRayCenter(params.GetEntry("ray_center")->AsDoubleVector());
else if (params.GetEntry("ray_center")->TypeName() == "intVector")
SetRayCenter(params.GetEntry("ray_center")->AsIntVector());
}
if (params.HasEntry("radius"))
{
if (params.GetEntry("radius")->TypeName() == "double")
SetRadius(params.GetEntry("radius")->AsDouble());
else if (params.GetEntry("radius")->TypeName() == "int")
SetRadius(params.GetEntry("radius")->AsInt());
}
if (params.HasEntry("theta"))
{
if (params.GetEntry("theta")->TypeName() == "double")
SetTheta(params.GetEntry("theta")->AsDouble());
else if (params.GetEntry("theta")->TypeName() == "int")
SetTheta(params.GetEntry("theta")->AsInt());
}
if (params.HasEntry("phi"))
{
if (params.GetEntry("phi")->TypeName() == "double")
SetPhi(params.GetEntry("phi")->AsDouble());
else if (params.GetEntry("phi")->TypeName() == "int")
SetPhi(params.GetEntry("phi")->AsInt());
}
}
// ****************************************************************************
// Method: avtHohlraumFluxQuery::GetDefaultInputParams
//
// Purpose:
// Retrieves default values for input variables.
//
// Programmer: Kathleen Biagas
// Creation: July 15, 2011
//
// Modifications:
//
// ****************************************************************************
void
avtHohlraumFluxQuery::GetDefaultInputParams(MapNode &params)
{
params["num_lines"] = 1000;
params["divide_emis_by_absorb"] = 0;
doubleVector rc;
rc.push_back(0.0);
rc.push_back(0.0);
rc.push_back(0.0);
params["ray_center"] = rc;
params["radius"] = 1.0;
params["theta"] = 0.0;
params["phi"] = 0.0;
stringVector v;
v.push_back("absorbtivity");
v.push_back("emissivitiy");
params["vars"] = v;
}
// ****************************************************************************
// Method: avtHohlraumFluxQuery::SetVariableNames
......@@ -150,14 +243,27 @@ avtHohlraumFluxQuery::SetVariableNames(const stringVector &names)
// Programmer: David Bremer
// Creation: Dec 8, 2006
//
// Modifications:
// Kathleen Biagas, Tue Jun 21 10:39:36 PDT 2011
// Changed arg ifrom 3 floats to doubleVector, to reflect how the
// information is stored in the input parameters MapNode.
//
// ****************************************************************************
void
avtHohlraumFluxQuery::SetRayCenter(float x, float y, float z)
avtHohlraumFluxQuery::SetRayCenter(const doubleVector &rc)
{
rayCenter[0] = rc[0];
rayCenter[1] = rc[1];
rayCenter[2] = rc[2];
}
void
avtHohlraumFluxQuery::SetRayCenter(const intVector &rc)
{
rayCenter[0] = x;
rayCenter[1] = y;
rayCenter[2] = z;
rayCenter[0] = (float)rc[0];
rayCenter[1] = (float)rc[1];
rayCenter[2] = (float)rc[2];
}
......@@ -194,9 +300,14 @@ avtHohlraumFluxQuery::SetRadius(float r)
// ****************************************************************************
void
avtHohlraumFluxQuery::SetThetaPhi(float thetaInDegrees, float phiInDegrees)
avtHohlraumFluxQuery::SetTheta(const double &thetaInDegrees)
{
theta = thetaInDegrees * M_PI / 180.0;
}
void
avtHohlraumFluxQuery::SetPhi(const double &phiInDegrees)
{
phi = phiInDegrees * M_PI / 180.0;
}
......
......@@ -50,7 +50,7 @@
#include <vector>
// ****************************************************************************
// Class: avtDistanceFromBoundaryQuery
// Class: avtHohlraumFluxQuery
//
// Purpose:
// This query calculates flux from a hohlraum capsule by integrating
......@@ -69,6 +69,13 @@
// I added a flag which has the query optionally use the emissivity divided
// by the absorbtivity in place of the emissivity.
//
// Kathleen Biagas, Mon Jun 20 09:05:48 PDT 2011
// Added SetInputParams, changed args to SetRayCenter and SetThetaPhi to
// reflect how information is stored in the input params MapNode.
//
// Kathleen Biagas, Fri Jul 15 15:54:27 PDT 2011
// Added GetDefaultInputParams.
//
// ****************************************************************************
class QUERY_API avtHohlraumFluxQuery : public avtLineScanQuery
......@@ -82,10 +89,15 @@ class QUERY_API avtHohlraumFluxQuery : public avtLineScanQuery
virtual const char *GetDescription(void)
{ return "Calculating Flux For a Hohlraum"; }
virtual void SetInputParams(const MapNode &);
static void GetDefaultInputParams(MapNode &);
void SetVariableNames(const stringVector &names);
void SetRayCenter(float x, float y, float z);
void SetRayCenter(const doubleVector &);
void SetRayCenter(const intVector &);
void SetRadius(float r);
void SetThetaPhi(float thetaInDegrees, float phiInDegrees);
void SetTheta(const double &);
void SetPhi(const double &);
void SetDivideEmisByAbsorb(bool flag);
protected:
......
......@@ -104,6 +104,74 @@ avtLineScanQuery::~avtLineScanQuery()
}
// ****************************************************************************
// Method: avtLineScanQuery::SetInputParams
//
// Purpose:
// Allows this query to read input parameters set by user.
//
// Arguments:
// params: MapNode containing input.
//
// Programmer: Kathleen Biagas
// Creation: June 20, 2011
//
// ****************************************************************************
void
avtLineScanQuery::SetInputParams(const MapNode &params)
{
if (params.HasEntry("num_lines"))
SetNumberOfLines(params.GetEntry("num_lines")->AsInt());
if (params.HasEntry("num_bins"))
SetNumberOfBins(params.GetEntry("num_bins")->AsInt());
double min = 0., max = 1.0;
if (params.HasEntry("min"))
{
if (params.GetEntry("min")->TypeName() == "double")
min = params.GetEntry("min")->AsDouble();
else if (params.GetEntry("min")->TypeName() == "int")
min = params.GetEntry("min")->AsInt();
}
if (params.HasEntry("max"))
{
if (params.GetEntry("max")->TypeName() == "double")
max = params.GetEntry("max")->AsDouble();
else if (params.GetEntry("max")->TypeName() == "int")
max = params.GetEntry("max")->AsInt();
}
SetRange(min, max);
}
// ****************************************************************************
// Method: avtLineScanQuery::GetDefaultInputParams
//
// Purpose:
// Retrieve default input values.
//
// Arguments:
// params: MapNode to store the default values.
//
// Programmer: Kathleen Biagas
// Creation: July 15, 2011
//
// ****************************************************************************
void
avtLineScanQuery::GetDefaultInputParams(MapNode &params)
{
params["num_bins"] = 100;
params["min"] = 0.;
params["max"] = 1.0;
params["num_lines"] = 1000;
}
// ****************************************************************************
// Method: avtLineScanQuery::PreExecute
//
......
......@@ -65,6 +65,13 @@ class avtLineScanFilter;
// Programmer: Hank Childs
// Creation: August 2, 2006
//
// Modifications:
// Kathleen Biagas, Tue Jun 21 11:38:19 PDT 2011
// Added SetInputParams.
//
// Kathleen Biagas, Fri Jul 15 16:08:31 PDT 2011
// Added GetDefaultInputParams.
//
// ****************************************************************************
class QUERY_API avtLineScanQuery : public avtDatasetQuery
......@@ -77,6 +84,9 @@ class QUERY_API avtLineScanQuery : public avtDatasetQuery
virtual const char *GetDescription(void)
{ return "Querying line scans."; };
virtual void SetInputParams(const MapNode &);
static void GetDefaultInputParams(MapNode &);
void SetNumberOfLines(int nl) { numLines = nl; };
void SetNumberOfBins(int nb) { numBins = nb; };
void SetRange(double r1, double r2)
......
......@@ -37,7 +37,7 @@
*****************************************************************************/
// ************************************************************************* //
// avtLineScanTransformQuery.C //
// avtLineScanTransformQuery.C //
// ************************************************************************* //
#include <avtLineScanTransformQuery.h>
......
......@@ -51,7 +51,7 @@
#include <snprintf.h>
#include <DebugStream.h>
#include <PickVarInfo.h>
#include <QueryArgumentException.h>
#include <string>
// ****************************************************************************
......@@ -63,6 +63,8 @@
// Creation: October 22, 2007
//
// Modifications:
// Kathleen Biagas, Tue Jun 21 10:43:25 PDT 2011
// Added domain, node.
//
// ****************************************************************************
......@@ -70,6 +72,8 @@ avtLocateAndPickNodeQuery::avtLocateAndPickNodeQuery()
{
lnq = new avtLocateNodeQuery;
npq = new avtNodePickQuery;
domain = 0;
node = 0;
}
......@@ -100,6 +104,56 @@ avtLocateAndPickNodeQuery::~avtLocateAndPickNodeQuery()
}
// ****************************************************************************
// Method: avtLocateAndPickNodeQuery::SetInputParams
//
// Purpose:
// Allows this query to read input parameters set by user.
//
// Arguments:
// params: MapNode containing input.
//
// Programmer: Kathleen Biagas
// Creation: June 20, 2011
//
// Modifications:
//
// ****************************************************************************
void
avtLocateAndPickNodeQuery::SetInputParams(const MapNode &params)
{
if (params.HasEntry("vars"))
{
const stringVector &v = params.GetEntry("vars")->AsStringVector();
timeCurveSpecs["nResultsToStore"] = (int)v.size();
pickAtts.SetVariables(v);
}
else
EXCEPTION1(QueryArgumentException, "vars");
if (params.HasEntry("ray_start_point"))
pickAtts.SetRayPoint1(params.GetEntry("ray_start_point")->AsDoubleVector());
else
EXCEPTION1(QueryArgumentException, "ray_start_point");
if (params.HasEntry("ray_end_point"))
pickAtts.SetRayPoint2(params.GetEntry("ray_end_point")->AsDoubleVector());
else
EXCEPTION1(QueryArgumentException, "ray_end_point");
if (params.HasEntry("domain"))
domain = params.GetEntry("domain")->AsInt();
else
EXCEPTION1(QueryArgumentException, "domain");
if (params.HasEntry("element"))
node = params.GetEntry("element")->AsInt();
else
EXCEPTION1(QueryArgumentException, "element");
}
// ****************************************************************************
// Method: avtLocateAndPickNodeQuery::PerformQuery
//
......@@ -116,6 +170,9 @@ avtLocateAndPickNodeQuery::~avtLocateAndPickNodeQuery()
// Kathleen Bonnell, Thu Feb 17 09:57:58 PST 2011
// Allow multiple outputs / results.
//
// Kathleen Biagas, Tue Jun 21 10:51:24 PDT 2011
// Domain, Node, RayPoints and variables retrieved during SetInputParams.
//
// ****************************************************************************
void
......@@ -131,9 +188,6 @@ avtLocateAndPickNodeQuery::PerformQuery(QueryAttributes *qa)
pickAtts.SetActiveVariable(dataRequest->GetVariable());
pickAtts.SetGhostType(inAtts.GetContainsGhostZones());
pickAtts.SetTimeStep(qa->GetTimeStep());
pickAtts.SetRayPoint1(qa->GetDarg1());
pickAtts.SetRayPoint2(qa->GetDarg2());
pickAtts.SetVariables(qa->GetVariables());
pickAtts.SetPickType(PickAttributes::Node);
// Do the locate part of the query
......@@ -190,8 +244,7 @@ avtLocateAndPickNodeQuery::PerformQuery(QueryAttributes *qa)
{
char msg[120];
SNPRINTF(msg, 120, "Could not retrieve information from domain "
" %d element %d.", queryAtts.GetDomain(),
queryAtts.GetElement());
" %d node %d.", domain, node);
qa->SetResultsMessage(msg);
qa->SetResultsValue(vals);
}
......@@ -279,24 +332,3 @@ avtLocateAndPickNodeQuery::SetPickAttsForTimeQuery(
pickAtts.SetTimePreserveCoord(pa->GetTimePreserveCoord());
pickAtts.SetPlotBounds(pa->GetPlotBounds());
}
// ****************************************************************************
// Method: avtLocateAndPickNodeQuery::SetNumVars
//
// Purpose:
// Override default nResultsToStore in TimeCurveSpecs.
//
// Programmer: Kathleen Bonnell
// Creation: February 17, 2011
//
// Modifications:
//
// ****************************************************************************
void
avtLocateAndPickNodeQuery::SetNumVars(int nv)
{
timeCurveSpecs["nResultsToStore"] = nv;
}
......@@ -63,6 +63,9 @@ class vtkDataSet;
// Kathleen Bonnell, Thu Feb 17 09:55:14 PST 2011
// Added SetNumVars.
//
// Kathleen Biagas, Mon Jun 20 10:41:02 PDT 2011
// Added SetInputParams, removed SetNumVars, added domain, node.
//
// ****************************************************************************
class QUERY_API avtLocateAndPickNodeQuery : public avtDatasetQuery
......@@ -79,6 +82,7 @@ class QUERY_API avtLocateAndPickNodeQuery : public avtDatasetQuery
virtual const char *GetShortDescription(void)
{ return "Pick Node"; }
virtual void SetInputParams(const MapNode &);
virtual int GetNFilters(void) { return 2; }
......@@ -88,7 +92,6 @@ class QUERY_API avtLocateAndPickNodeQuery : public avtDatasetQuery
virtual void SetInvTransform(const avtMatrix *m);
virtual void SetNeedTransform(const bool v);
virtual void SetNumVars(int v);
protected:
virtual void Execute(vtkDataSet*, const int){;}
......@@ -99,6 +102,8 @@ class QUERY_API avtLocateAndPickNodeQuery : public avtDatasetQuery
void SetPickAtts(const PickAttributes *);
avtLocateQuery *lnq;
avtPickQuery *npq;
int domain;
int node;
};
......
......@@ -51,7 +51,7 @@
#include <snprintf.h>
#include <DebugStream.h>
#include <PickVarInfo.h>
#include <QueryArgumentException.h>
#include <string>
// ****************************************************************************
......@@ -63,6 +63,8 @@
// Creation: October 22, 2007
//
// Modifications:
// Kathleen Biagas, Tue Jun 21 10:09:18 PDT 2011