Commit 8880eb72 authored by bonnell's avatar bonnell
Browse files

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;
......
......@@ -314,13 +314,19 @@ avtQueryFactory::Instance()
// Cyrus Harrison, Wed Jun 15 13:14:49 PDT 2011
// Added Connected Components Length.
//
// Kathleen Biagas, Fri Jun 17 16:26:06 PDT 2011
// Call SetInputParams after query is created, precludes need to set
// individual query options here.
//
// ****************************************************************************
avtDataObjectQuery *
avtQueryFactory::CreateQuery(const QueryAttributes *qa)
{
string qname = qa->GetName();
bool actualData = qa->GetDataType() == QueryAttributes::ActualData;
int actualData = 0;
if (qa->GetQueryInputParams().HasEntry("use_actual_data"))
actualData = qa->GetQueryInputParams().GetEntry("use_actual_data")->AsInt();
avtDataObjectQuery *query = NULL;
bool foundAQuery = false;
......@@ -380,64 +386,31 @@ avtQueryFactory::CreateQuery(const QueryAttributes *qa)
}
else if (qname == "Line Scan Transform")
{
avtLineScanTransformQuery *lst =
new avtLineScanTransformQuery();
lst->SetNumberOfLines(qa->GetElement()); // Element == intarg1
lst->SetNumberOfBins(qa->GetDomain()); // Domain == intarg2
lst->SetRange(qa->GetDarg1()[0], qa->GetDarg2()[0]);
query = lst;
query = new avtLineScanTransformQuery();
}
else if (qname == "Chord Length Distribution - aggregate")
{
avtAggregateChordLengthDistributionQuery *cldq =
new avtAggregateChordLengthDistributionQuery();
cldq->SetNumberOfLines(qa->GetElement()); // Element == intarg1
cldq->SetNumberOfBins(qa->GetDomain()); // Domain == intarg2
cldq->SetRange(qa->GetDarg1()[0], qa->GetDarg2()[0]);
query = cldq;
query = new avtAggregateChordLengthDistributionQuery();
}
else if (qname == "Chord Length Distribution - individual")
{
avtIndividualChordLengthDistributionQuery *cldq =
new avtIndividualChordLengthDistributionQuery();
cldq->SetNumberOfLines(qa->GetElement()); // Element == intarg1
cldq->SetNumberOfBins(qa->GetDomain()); // Domain == intarg2
cldq->SetRange(qa->GetDarg1()[0], qa->GetDarg2()[0]);
query = cldq;
query = new avtIndividualChordLengthDistributionQuery();
}
else if (qname == "Ray Length Distribution - aggregate")
{
avtAggregateRayLengthDistributionQuery *cldq =
new avtAggregateRayLengthDistributionQuery();
cldq->SetNumberOfLines(qa->GetElement()); // Element == intarg1
cldq->SetNumberOfBins(qa->GetDomain()); // Domain == intarg2
cldq->SetRange(qa->GetDarg1()[0], qa->GetDarg2()[0]);
query = cldq;
query = new avtAggregateRayLengthDistributionQuery();
}
else if (qname == "Ray Length Distribution - individual")
{
avtIndividualRayLengthDistributionQuery *cldq =
new avtIndividualRayLengthDistributionQuery();
cldq->SetNumberOfLines(qa->GetElement()); // Element == intarg1
cldq->SetNumberOfBins(qa->GetDomain()); // Domain == intarg2
cldq->SetRange(qa->GetDarg1()[0], qa->GetDarg2()[0]);
query = cldq;
query = new avtIndividualRayLengthDistributionQuery();
}
else if (qname == "Mass Distribution")
{
avtMassDistributionQuery *mdq = new avtMassDistributionQuery();
mdq->SetNumberOfLines(qa->GetElement()); // Element == intarg1
mdq->SetNumberOfBins(qa->GetDomain()); // Domain == intarg2
mdq->SetRange(qa->GetDarg1()[0], qa->GetDarg2()[0]);
query = mdq;
query = new avtMassDistributionQuery();
}
else if (qname == "Distance From Boundary")
{
avtDistanceFromBoundaryQuery *mdq = new avtDistanceFromBoundaryQuery();
mdq->SetNumberOfLines(qa->GetElement()); // Element == intarg1
mdq->SetNumberOfBins(qa->GetDomain()); // Domain == intarg2
mdq->SetRange(qa->GetDarg1()[0], qa->GetDarg2()[0]);
query = mdq;
query = new avtDistanceFromBoundaryQuery();
}
else if (qname == "Kurtosis")
{
......@@ -496,15 +469,11 @@ avtQueryFactory::CreateQuery(const QueryAttributes *qa)
}
else if (qname == "Variable by Zone")
{
avtVariableByZoneQuery *vzq = new avtVariableByZoneQuery();
vzq->SetNumVars((int)qa->GetVariables().size());
query = vzq;
query = new avtVariableByZoneQuery();
}
else if (qname == "Variable by Node")
{
avtVariableByNodeQuery *vnq = new avtVariableByNodeQuery();
vnq->SetNumVars((int)qa->GetVariables().size());
query = vnq;
query = new avtVariableByNodeQuery();
}
else if (qname == "MinMax")
{
......@@ -595,16 +564,7 @@ avtQueryFactory::CreateQuery(const QueryAttributes *qa)
}
else if (qname == "Hohlraum Flux")
{
avtHohlraumFluxQuery *mdq = new avtHohlraumFluxQuery();
mdq->SetVariableNames(qa->GetVariables());
mdq->SetNumberOfLines(qa->GetElement()); // Element == intarg1
mdq->SetDivideEmisByAbsorb((qa->GetDomain() == 0) ? false : true); // Domain == intarg2
mdq->SetRayCenter(qa->GetDarg1()[0],
qa->GetDarg1()[1],
qa->GetDarg1()[2]);
mdq->SetRadius(qa->GetDarg2()[0]);
mdq->SetThetaPhi(qa->GetDarg2()[1], qa->GetDarg2()[2]);
query = mdq;
query = new avtHohlraumFluxQuery();
}
else if( qname == "Number of Connected Components")
{
......@@ -636,48 +596,19 @@ avtQueryFactory::CreateQuery(const QueryAttributes *qa)
}
else if( qname == "Connected Components Summary")
{
avtConnComponentsSummaryQuery *ccl_query
=new avtConnComponentsSummaryQuery();
ccl_query->SetOutputFileName(qa->GetVariables()[0]);
query = ccl_query;
query = new avtConnComponentsSummaryQuery();
}
else if( qname == "Locate and Pick Zone")
{
avtLocateAndPickZoneQuery *lpzq = new avtLocateAndPickZoneQuery();
lpzq->SetNumVars((int)qa->GetVariables().size());
query = lpzq;
query = new avtLocateAndPickZoneQuery();
}
else if( qname == "Locate and Pick Node")
{
avtLocateAndPickNodeQuery *lpnq = new avtLocateAndPickNodeQuery();
lpnq->SetNumVars((int)qa->GetVariables().size());
query = lpnq;
query = new avtLocateAndPickNodeQuery();
}
else if( qname == "Shapelet Decomposition")
{
avtShapeletDecompositionQuery *shapelet_query =
new avtShapeletDecompositionQuery();
if(qa->GetDarg1().size() == 1)
{
if(qa->GetDarg1()[0] < 1.0)
EXCEPTION1(VisItException,
"Shapelet Decomposition requries "
"beta and nmax >= 1.");
shapelet_query->SetBeta(qa->GetDarg1()[0]);
}
else
shapelet_query->SetBeta(1.0);
if(qa->GetElement() < 1)
shapelet_query->SetNMax(1);
else
shapelet_query->SetNMax(qa->GetElement()); // Element == int arg1
shapelet_query->SetDecompOutputFileName("");
if(qa->GetVariables().size() >1)
shapelet_query->SetRecompOutputFileName(qa->GetVariables()[1]);
else
shapelet_query->SetRecompOutputFileName("");
query = shapelet_query;
query = new avtShapeletDecompositionQuery();
}
else if( qname == "Memory Usage")
{
......@@ -693,17 +624,7 @@ avtQueryFactory::CreateQuery(const QueryAttributes *qa)
}
else if (qname == "XRay Image")
{
avtXRayImageQuery *mdq = new avtXRayImageQuery();
mdq->SetVariableNames(qa->GetVariables());
mdq->SetOutputType(qa->GetElement()); // Element == intarg1
mdq->SetDivideEmisByAbsorb((qa->GetDomain() == 0) ? false : true); // Domain == intarg2
mdq->SetOrigin(qa->GetDarg1()[0],
qa->GetDarg1()[1],
qa->GetDarg1()[2]);
mdq->SetThetaPhi(qa->GetDarg2()[0], qa->GetDarg2()[1]);
mdq->SetWidthHeight(qa->GetDarg2()[2], qa->GetDarg2()[3]);
mdq->SetImageSize((int)qa->GetDarg2()[4], (int)qa->GetDarg2()[5]);
query = mdq;
query = new avtXRayImageQuery();
}
else if (qname == "Python")
{
......@@ -730,9 +651,7 @@ avtQueryFactory::CreateQuery(const QueryAttributes *qa)
}
else if (qname == "Streamline Info")
{
avtStreamlineInfoQuery *slq = new avtStreamlineInfoQuery();
slq->SetDumpSteps(qa->GetDumpSteps());
query = slq;
query = new avtStreamlineInfoQuery();
}
if (query == NULL && !foundAQuery)
......@@ -743,7 +662,122 @@ avtQueryFactory::CreateQuery(const QueryAttributes *qa)
"the avtQueryFactory.");
}
if (query != NULL)
{
TRY
{
query->SetInputParams(qa->GetQueryInputParams());
}
CATCH2(VisItException, e)
{
string msg = qname + " did not find all of its input parameters. (";
msg += e.Message();
msg += ") Developers: if you are developing this query, make ";
msg += "sure the map node containing the input parameter has been ";
msg += "set up correctly in the gui and in the cli.";
EXCEPTION1(VisItException, msg.c_str());
}
ENDTRY
}
return query;
}
// ****************************************************************************
// Method: avtQueryFactory::GetDefaultInputParams
//
// Purpose:
// Retrieve default input values for named query.
//
// Arguments:
// qname The name of the query.
//
// Returns: A string representation of the MapNode parameters.
//
// Programmer: Kathleen Biagas
// Creation: July 15, 2011
//
// Modifications:
//
// ****************************************************************************
string
avtQueryFactory::GetDefaultInputParams(const string &qname)
{
MapNode params;
string retval;
if (qname == "XRay Image")
{
avtXRayImageQuery::GetDefaultInputParams(params);
retval = params.ToXML();
}
else if (qname == "Hohlraum Flux")
{
avtHohlraumFluxQuery::GetDefaultInputParams(params);
retval = params.ToXML();
}
else if( qname == "Connected Components Summary")
{
avtConnComponentsSummaryQuery::GetDefaultInputParams(params);
retval = params.ToXML();
}
else if (qname == "Chord Length Distribution - aggregate" ||
qname == "Chord Length Distribution - individual" ||
qname == "Ray Length Distribution - aggregate" ||
qname == "Ray Length Distribution - individual" ||
qname == "Mass Distribution" ||
qname == "Line Scan Transform" ||
qname == "Distance From Boundary")
{
avtLineScanQuery::GetDefaultInputParams(params);
retval = params.ToXML();
}
else if (qname == "Node Coords")
{
avtNodeCoordsQuery::GetDefaultInputParams(params);
retval = params.ToXML();
}
else if (qname == "Zone Center")
{
avtZoneCenterQuery::GetDefaultInputParams(params);
retval = params.ToXML();
}
else if( qname == "Shapelet Decomposition")
{
avtShapeletDecompositionQuery::GetDefaultInputParams(params);
retval = params.ToXML();
}
else if (qname == "Streamline Info")
{
avtStreamlineInfoQuery::GetDefaultInputParams(params);
retval = params.ToXML();
}
else if (qname == "Min" ||
qname == "Max" ||
qname == "MinMax")
{
avtMinMaxQuery::GetDefaultInputParams(params);
retval = params.ToXML();
}
else if (qname == "NumNodes")
{
avtNumNodesQuery::GetDefaultInputParams(params);
retval = params.ToXML();
}
else if (qname == "NumZones")
{
avtNumZonesQuery::GetDefaultInputParams(params);
retval = params.ToXML();
}
else if (qname == "TrajectoryByZone")
{
avtTrajectoryByZone::GetDefaultInputParams(params);
retval = params.ToXML();
}
else if (qname == "TrajectoryByNode")
{
avtTrajectoryByNode::GetDefaultInputParams(params);
retval = params.ToXML();
}
return retval;
}
......@@ -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;