Commit 4c945fcf authored by bonnell's avatar bonnell
Browse files

Add ability for Picks to be called with keyword arguments. Fix Pick and Query logging.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@16108 18c085ea-50e0-402c-830e-de6fd14e8384
parent 37423f01
...@@ -2583,14 +2583,14 @@ Variant::Read(Connection &conn) ...@@ -2583,14 +2583,14 @@ Variant::Read(Connection &conn)
// Kathleen Biagas, Thu Sep 1 11:19:23 PDT 2011 // Kathleen Biagas, Thu Sep 1 11:19:23 PDT 2011
// Fix typo (two FLOAT_VECTOR_TYPES if statements). // Fix typo (two FLOAT_VECTOR_TYPES if statements).
// //
// Kathleen Biagas, Tue Sep 6 14:06:24 PDT 2011
// Fix formatting of vectors, strings should be surrounded by quotes.
//
// **************************************************************************** // ****************************************************************************
string & string &
Variant::ConvertToString() Variant::ConvertToString()
{ {
if(dataType == STRING_TYPE)
return *((string *)dataValue);
tmp.clear(); tmp.clear();
char retval[5000]; char retval[5000];
if (dataType == BOOL_TYPE) if (dataType == BOOL_TYPE)
...@@ -2600,7 +2600,7 @@ Variant::ConvertToString() ...@@ -2600,7 +2600,7 @@ Variant::ConvertToString()
} }
else if (dataType == CHAR_TYPE) else if (dataType == CHAR_TYPE)
{ {
sprintf(retval, "%c", AsChar()); sprintf(retval, "\'%c\'", AsChar());
tmp = string(retval); tmp = string(retval);
} }
else if (dataType == UNSIGNED_CHAR_TYPE) else if (dataType == UNSIGNED_CHAR_TYPE)
...@@ -2628,13 +2628,20 @@ Variant::ConvertToString() ...@@ -2628,13 +2628,20 @@ Variant::ConvertToString()
sprintf(retval, "%g", AsDouble()); sprintf(retval, "%g", AsDouble());
tmp = string(retval); tmp = string(retval);
} }
else if (dataType == STRING_TYPE)
{
sprintf(retval, "\"%s\"", AsString().c_str());
tmp = string(retval);
}
else if (dataType == BOOL_VECTOR_TYPE) else if (dataType == BOOL_VECTOR_TYPE)
{ {
tmp = "("; tmp = "(";
const boolVector &vec = AsBoolVector(); const boolVector &vec = AsBoolVector();
for(size_t i=0;i<vec.size();i++) for(size_t i=0;i<vec.size();i++)
{ {
sprintf(retval,"%s ",vec[i] ? "true" : "false"); if (i != 0)
tmp += ", ";
sprintf(retval,"%s",vec[i] ? "true" : "false");
tmp += retval; tmp += retval;
} }
tmp += ")"; tmp += ")";
...@@ -2645,7 +2652,9 @@ Variant::ConvertToString() ...@@ -2645,7 +2652,9 @@ Variant::ConvertToString()
const charVector &vec = AsCharVector(); const charVector &vec = AsCharVector();
for(size_t i=0;i<vec.size();i++) for(size_t i=0;i<vec.size();i++)
{ {
sprintf(retval,"%c ",vec[i]); if (i != 0)
tmp += ", ";
sprintf(retval,"\'%c\'",vec[i]);
tmp += retval; tmp += retval;
} }
tmp += ")"; tmp += ")";
...@@ -2656,7 +2665,9 @@ Variant::ConvertToString() ...@@ -2656,7 +2665,9 @@ Variant::ConvertToString()
const unsignedCharVector &vec = AsUnsignedCharVector(); const unsignedCharVector &vec = AsUnsignedCharVector();
for(size_t i=0;i<vec.size();i++) for(size_t i=0;i<vec.size();i++)
{ {
sprintf(retval,"%d ",vec[i]); if (i != 0)
tmp += ", ";
sprintf(retval,"%d",vec[i]);
tmp += retval; tmp += retval;
} }
tmp += ")"; tmp += ")";
...@@ -2667,7 +2678,9 @@ Variant::ConvertToString() ...@@ -2667,7 +2678,9 @@ Variant::ConvertToString()
const intVector &vec = AsIntVector(); const intVector &vec = AsIntVector();
for(size_t i=0;i<vec.size();i++) for(size_t i=0;i<vec.size();i++)
{ {
sprintf(retval,"%d ",vec[i]); if (i != 0)
tmp += ", ";
sprintf(retval,"%d",vec[i]);
tmp += retval; tmp += retval;
} }
tmp += ")"; tmp += ")";
...@@ -2678,7 +2691,9 @@ Variant::ConvertToString() ...@@ -2678,7 +2691,9 @@ Variant::ConvertToString()
const longVector &vec = AsLongVector(); const longVector &vec = AsLongVector();
for(size_t i=0;i<vec.size();i++) for(size_t i=0;i<vec.size();i++)
{ {
sprintf(retval,"%ld ",vec[i]); if (i != 0)
tmp += ", ";
sprintf(retval,"%ld",vec[i]);
tmp += retval; tmp += retval;
} }
tmp += ")"; tmp += ")";
...@@ -2689,7 +2704,9 @@ Variant::ConvertToString() ...@@ -2689,7 +2704,9 @@ Variant::ConvertToString()
const floatVector &vec = AsFloatVector(); const floatVector &vec = AsFloatVector();
for(size_t i=0;i<vec.size();i++) for(size_t i=0;i<vec.size();i++)
{ {
sprintf(retval,"%g ",vec[i]); if (i != 0)
tmp += ", ";
sprintf(retval,"%g",vec[i]);
tmp += retval; tmp += retval;
} }
tmp += ")"; tmp += ")";
...@@ -2700,7 +2717,9 @@ Variant::ConvertToString() ...@@ -2700,7 +2717,9 @@ Variant::ConvertToString()
const doubleVector &vec = AsDoubleVector(); const doubleVector &vec = AsDoubleVector();
for(size_t i=0;i<vec.size();i++) for(size_t i=0;i<vec.size();i++)
{ {
sprintf(retval,"%g ",vec[i]); if (i != 0)
tmp += ", ";
sprintf(retval,"%g",vec[i]);
tmp += retval; tmp += retval;
} }
tmp += ")"; tmp += ")";
...@@ -2711,7 +2730,9 @@ Variant::ConvertToString() ...@@ -2711,7 +2730,9 @@ Variant::ConvertToString()
const stringVector &vec = AsStringVector(); const stringVector &vec = AsStringVector();
for(size_t i=0;i<vec.size();i++) for(size_t i=0;i<vec.size();i++)
{ {
sprintf(retval,"%s ",vec[i].c_str()); if (i != 0)
tmp += ", ";
sprintf(retval,"\"%s\"",vec[i].c_str());
tmp += retval; tmp += retval;
} }
tmp += ")"; tmp += ")";
......
...@@ -450,7 +450,7 @@ QvisPickQueryWidget::GetQueryParameters(MapNode &params) ...@@ -450,7 +450,7 @@ QvisPickQueryWidget::GetQueryParameters(MapNode &params)
doubleVector p(3); doubleVector p(3);
bool noerrors = true; bool noerrors = true;
int curvePlotType = GetPlotType(); int curvePlotType = GetPlotType();
bool preserveCoord = GetTimePreservesCoord(); int preserveCoord = (int) GetTimePreservesCoord();
int dom = 0, el = 0; int dom = 0, el = 0;
switch (pickType->currentIndex()) switch (pickType->currentIndex())
{ {
......
...@@ -287,7 +287,9 @@ QvisXRayImageQueryWidget::GetIntValues(int whichWidget, int *pt) ...@@ -287,7 +287,9 @@ QvisXRayImageQueryWidget::GetIntValues(int whichWidget, int *pt)
// Creation: June 17, 2011 // Creation: June 17, 2011
// //
// Modifications: // Modifications:
// // Kathleen Biagas, Wed Sep 7 08:40:22 PDT 2011
// Return output_type as string instead of int.
//
// **************************************************************************** // ****************************************************************************
bool bool
QvisXRayImageQueryWidget::GetQueryParameters(MapNode &params) QvisXRayImageQueryWidget::GetQueryParameters(MapNode &params)
...@@ -318,7 +320,7 @@ QvisXRayImageQueryWidget::GetQueryParameters(MapNode &params) ...@@ -318,7 +320,7 @@ QvisXRayImageQueryWidget::GetQueryParameters(MapNode &params)
if (noerrors) if (noerrors)
{ {
params["output_type"] = imageFormat->currentIndex(); params["output_type"] = imageFormat->currentText().toStdString();
params["divide_emis_by_absorb"] = (int)divideFlag->isChecked(); params["divide_emis_by_absorb"] = (int)divideFlag->isChecked();
params["origin"] = origin; params["origin"] = origin;
params["theta"] = t; params["theta"] = t;
......
...@@ -3185,6 +3185,9 @@ ViewerQueryManager::HandlePickCache() ...@@ -3185,6 +3185,9 @@ ViewerQueryManager::HandlePickCache()
// Modifications notes to last couple of years. Move test for non-hidden // Modifications notes to last couple of years. Move test for non-hidden
// active plot and running engine to generic 'Query' method. // active plot and running engine to generic 'Query' method.
// //
// Kathleen Biagas, Wed Sep 7 11:11:19 PDT 2011
// coord argument may be an intVector or a doubleVector.
//
// **************************************************************************** // ****************************************************************************
void void
...@@ -3252,13 +3255,25 @@ ViewerQueryManager::PointQuery(const MapNode &queryParams) ...@@ -3252,13 +3255,25 @@ ViewerQueryManager::PointQuery(const MapNode &queryParams)
Error(tr("%1 requires a 'coord' parameter.\n").arg(qName.c_str())); Error(tr("%1 requires a 'coord' parameter.\n").arg(qName.c_str()));
return; return;
} }
doubleVector pt = queryParams.GetEntry("coord")->AsDoubleVector();
PICK_POINT_INFO ppi; PICK_POINT_INFO ppi;
ppi.callbackData = win; ppi.callbackData = win;
ppi.rayPt1[0] = ppi.rayPt2[0] = pt[0];
ppi.rayPt1[1] = ppi.rayPt2[1] = pt[1]; if (queryParams.GetEntry("coord")->TypeName() == "doubleVector")
ppi.rayPt1[2] = ppi.rayPt2[2] = pt[2]; {
ppi.validPick = true; doubleVector pt = queryParams.GetEntry("coord")->AsDoubleVector();
ppi.rayPt1[0] = ppi.rayPt2[0] = pt[0];
ppi.rayPt1[1] = ppi.rayPt2[1] = pt[1];
ppi.rayPt1[2] = ppi.rayPt2[2] = pt[2];
ppi.validPick = true;
}
else if (queryParams.GetEntry("coord")->TypeName() == "intVector")
{
intVector pt = queryParams.GetEntry("coord")->AsIntVector();
ppi.rayPt1[0] = ppi.rayPt2[0] = (double)pt[0];
ppi.rayPt1[1] = ppi.rayPt2[1] = (double)pt[1];
ppi.rayPt1[2] = ppi.rayPt2[2] = (double)pt[2];
ppi.validPick = true;
}
if (!timeCurve) if (!timeCurve)
{ {
Pick(&ppi); Pick(&ppi);
......
...@@ -1263,6 +1263,14 @@ static std::string log_SetRenderingAttributesRPC(ViewerRPC *rpc) ...@@ -1263,6 +1263,14 @@ static std::string log_SetRenderingAttributesRPC(ViewerRPC *rpc)
return s; return s;
} }
//*****************************************************************************
// Modifications:
// Kathleen Biagas, Wed Sep 7 12:53:16 PDT 2011
// Fix pick logging, vars logging.
//
//*****************************************************************************
static std::string log_QueryRPC(ViewerRPC *rpc) static std::string log_QueryRPC(ViewerRPC *rpc)
{ {
std::vector<std::string> paramNames; std::vector<std::string> paramNames;
...@@ -1280,14 +1288,15 @@ static std::string log_QueryRPC(ViewerRPC *rpc) ...@@ -1280,14 +1288,15 @@ static std::string log_QueryRPC(ViewerRPC *rpc)
{ {
std::string pt; std::string pt;
std::string qn; std::string qn;
bool timePick = false;
if (queryParams.HasEntry("do_time"))
timePick = (bool)queryParams.GetEntry("do_time")->AsInt();
if (queryParams.HasEntry("pick_type")) if (queryParams.HasEntry("pick_type"))
pt = queryParams.GetEntry("pick_type")->AsString(); pt = queryParams.GetEntry("pick_type")->AsString();
if (pt == "ScreenZone" || pt == "Zone") if (pt == "ScreenZone" || pt == "Zone")
qn = "ZonePick"; qn = "ZonePick";
else if (pt == "ScreenNode" || pt == "Node") else if (pt == "ScreenNode" || pt == "Node")
qn = "NodePick"; qn = "NodePick";
else if (pt == "DomainZone")
qn = "PickByZone";
else if (pt == "DomainZone") else if (pt == "DomainZone")
{ {
int global = 0; int global = 0;
...@@ -1311,31 +1320,37 @@ static std::string log_QueryRPC(ViewerRPC *rpc) ...@@ -1311,31 +1320,37 @@ static std::string log_QueryRPC(ViewerRPC *rpc)
else else
return MESSAGE_COMMENT("Pick with no type", MSG_UNSUPPORTED); return MESSAGE_COMMENT("Pick with no type", MSG_UNSUPPORTED);
s = qn + "("; s = qn + "(";
int numPrinted = 0;
for (size_t i = 0; i < paramNames.size(); ++i) for (size_t i = 0; i < paramNames.size(); ++i)
{ {
if ((paramNames[i] == "curve_plot_type" ||
paramNames[i] == "preserve_coord") &&
!timePick)
continue;
if (paramNames[i] != "query_name" && if (paramNames[i] != "query_name" &&
paramNames[i] != "query_type" &&
paramNames[i] != "pick_type" && paramNames[i] != "pick_type" &&
paramNames[i] != "use_global_id" && paramNames[i] != "use_global_id" &&
paramNames[i] != "vars") paramNames[i] != "vars")
{ {
s += ", "; if (numPrinted > 0)
s += ", ";
s += paramNames[i]; s += paramNames[i];
s += "="; s += "=";
s += queryParams.GetEntry(paramNames[i])->ConvertToString(); s += queryParams.GetEntry(paramNames[i])->ConvertToString();
numPrinted++;
} }
} }
std::vector<std::string> vars; std::vector<std::string> vars;
if (queryParams.HasEntry("vars")) if (queryParams.HasEntry("vars"))
queryParams.GetEntry("vars")->AsStringVector(); vars = queryParams.GetEntry("vars")->AsStringVector();
if (!vars.empty() && !(vars.size() == 1 && vars[0] == "default")) if (!vars.empty() && !(vars.size() == 1 && vars[0] == "default"))
{ {
s += "\"vars=("; if (numPrinted > 0)
for (size_t i = 0; i < vars.size(); ++i) s += ", ";
{ s += "vars=";
s += vars[i]; s += queryParams.GetEntry("vars")->ConvertToString();
s += ",";
}
s += ")";
} }
s += ")\n"; s += ")\n";
} }
...@@ -1372,16 +1387,11 @@ static std::string log_QueryRPC(ViewerRPC *rpc) ...@@ -1372,16 +1387,11 @@ static std::string log_QueryRPC(ViewerRPC *rpc)
} }
std::vector<std::string> vars; std::vector<std::string> vars;
if (queryParams.HasEntry("vars")) if (queryParams.HasEntry("vars"))
queryParams.GetEntry("vars")->AsStringVector(); vars = queryParams.GetEntry("vars")->AsStringVector();
if (!vars.empty() && !(vars.size() == 1 && vars[0] == "default")) if (!vars.empty() && !(vars.size() == 1 && vars[0] == "default"))
{ {
s += "\"vars=("; s += ", vars=";
for (size_t i = 0; i < vars.size(); ++i) s += queryParams.GetEntry("vars")->ConvertToString();
{
s += vars[i];
s += ",";
}
s += ")";
} }
s += ")\n"; s += ")\n";
......
...@@ -113,6 +113,10 @@ PyMapNode_Wrap(const MapNode &node) ...@@ -113,6 +113,10 @@ PyMapNode_Wrap(const MapNode &node)
// Programmer: Kathleen Bonnell // Programmer: Kathleen Bonnell
// Creation: July 13, 2011 // Creation: July 13, 2011
// //
// Modifications:
// Kathleen Biagas, Wed Sep 7 11:56:23 PDT 2011
// Allow ints and doubles in same sequence.
//
// **************************************************************************** // ****************************************************************************
bool bool
...@@ -162,20 +166,49 @@ PyDict_To_MapNode(PyObject *obj, MapNode &mn) ...@@ -162,20 +166,49 @@ PyDict_To_MapNode(PyObject *obj, MapNode &mn)
} }
else if (PyInt_Check(item)) else if (PyInt_Check(item))
{ {
intVector mval; int ni = 1, nd = 0, no = 0;
mval.push_back(PyInt_AS_LONG(item));
for (Py_ssize_t i = 1; i < PySequence_Size(value); ++i) for (Py_ssize_t i = 1; i < PySequence_Size(value); ++i)
{ {
item = PySequence_GetItem(value, i); item = PySequence_GetItem(value, i);
if (!PyInt_Check(item)) if (PyFloat_Check(item))
nd++;
else if (PyInt_Check(item))
ni++;
else
no++;
}
if (no != 0)
{
debug3 << "PyDict_To_MapNode: tuples/lists must "
<< "contain same type." << endl;
return false;
}
else if (nd != 0)
{
// process as doubleVector
doubleVector mval;
mval.push_back((double)PyInt_AS_LONG(item));
for (Py_ssize_t i = 1; i < PySequence_Size(value); ++i)
{ {
debug3 << "PyDict_To_MapNode: tuples/lists must " item = PySequence_GetItem(value, i);
<< "contain same type." << endl; if (PyFloat_Check(item))
return false; mval.push_back(PyFloat_AS_DOUBLE(item));
else if (PyInt_Check(item))
mval.push_back((double)PyInt_AS_LONG(item));
} }
mval.push_back(PyInt_AS_LONG(item)); mn[mkey] = mval;
} }
mn[mkey] = mval; else
{
intVector mval;
mval.push_back(PyInt_AS_LONG(item));
for (Py_ssize_t i = 1; i < PySequence_Size(value); ++i)
{
item = PySequence_GetItem(value, i);
mval.push_back(PyInt_AS_LONG(item));
}
mn[mkey] = mval;
}
} }
else if (PyString_Check(item)) else if (PyString_Check(item))
{ {
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment