Commit afabbab9 authored by hkrishna's avatar hkrishna
Browse files

extending ViewerClient to send additional information to remote services

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@23410 18c085ea-50e0-402c-830e-de6fd14e8384
parent 2acd65d9
IF(NOT DEFINED VISIT_QT5)
INCLUDE(CMake/FindVisItQt4.cmake)
ELSE()
INCLUDE(CMake/FindVisItQt5.cmake)
ENDIF()
# Configure for Qt5..
IF(NOT DEFINED VISIT_QT_DIR)
MESSAGE(FATAL_ERROR "Qt5 installation directory not specified")
ENDIF()
SET(QT_MOC_EXECUTABLE ${VISIT_QT_DIR}/bin/moc)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
#set(QT5_INCLUDE_DIRS "")
set(QT5_LIBRARIES "")
set(visit_qt_modules Core Gui Widgets OpenGL Network PrintSupport Xml UiTools)
find_package (Qt5 REQUIRED ${visit_qt_modules})
foreach(mod ${visit_qt_modules})
string(TOUPPER ${mod} upper_mod)
if(NOT VISIT_QT_SKIP_INSTALL)
if(WIN32 AND EXISTS ${VISIT_QT_DIR}/lib/Qt5${mod}.lib)
THIRD_PARTY_INSTALL_LIBRARY(${VISIT_QT_DIR}/lib/Qt5${mod}.lib)
endif()
# headers
foreach(H ${Qt5${mod}_INCLUDE_DIRS})
if(${H} MATCHES "/include/Qt")
INSTALL(DIRECTORY ${H}
DESTINATION ${VISIT_INSTALLED_VERSION_INCLUDE}/qt/include
FILE_PERMISSIONS OWNER_WRITE OWNER_READ
GROUP_WRITE GROUP_READ
WORLD_READ
DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE
GROUP_WRITE GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
PATTERN ".svn" EXCLUDE
)
endif()
endforeach()
endif()
endforeach()
set(QT_QTUITOOLS_LIBRARY ${Qt5UiTools_LIBRARIES})
set(QT_QTOPENGL_LIBRARY ${Qt5OpenGL_LIBRARIES})
# if/when we drop support for qt 4, perhaps leave these split and
# add Widgets or PrintSupport only where needed
set(QT_QTGUI_LIBRARY ${Qt5Gui_LIBRARIES}
${Qt5Widgets_LIBRARIES}
${Qt5PrintSupport_LIBRARIES})
set(QT_QTNETWORK_LIBRARY ${Qt5Network_LIBRARIES})
set(QT_QTXML_LIBRARY ${Qt5Xml_LIBRARIES})
# why is core not named the same as the others?
set(QT_CORE_LIBRARY ${Qt5Core_LIBRARIES})
if(NOT VISIT_QT_SKIP_INSTALL)
# moc
get_target_property(moc_location Qt5::moc LOCATION)
MESSAGE("moc location: ${moc_location}")
install(PROGRAMS ${moc_location}
DESTINATION ${VISIT_INSTALLED_VERSION_BIN}
PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE
GROUP_WRITE GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
endif()
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
void ViewerClientInformationElement::Init() void ViewerClientInformationElement::Init()
{ {
isRaw = false; isRaw = false;
windowId = -1;
ViewerClientInformationElement::SelectAll(); ViewerClientInformationElement::SelectAll();
} }
...@@ -82,6 +83,7 @@ void ViewerClientInformationElement::Copy(const ViewerClientInformationElement & ...@@ -82,6 +83,7 @@ void ViewerClientInformationElement::Copy(const ViewerClientInformationElement &
rawData = obj.rawData; rawData = obj.rawData;
format = obj.format; format = obj.format;
isRaw = obj.isRaw; isRaw = obj.isRaw;
windowId = obj.windowId;
ViewerClientInformationElement::SelectAll(); ViewerClientInformationElement::SelectAll();
} }
...@@ -242,7 +244,8 @@ ViewerClientInformationElement::operator == (const ViewerClientInformationElemen ...@@ -242,7 +244,8 @@ ViewerClientInformationElement::operator == (const ViewerClientInformationElemen
return ((data == obj.data) && return ((data == obj.data) &&
(rawData == obj.rawData) && (rawData == obj.rawData) &&
(format == obj.format) && (format == obj.format) &&
(isRaw == obj.isRaw)); (isRaw == obj.isRaw) &&
(windowId == obj.windowId));
} }
// **************************************************************************** // ****************************************************************************
...@@ -386,10 +389,11 @@ ViewerClientInformationElement::NewInstance(bool copy) const ...@@ -386,10 +389,11 @@ ViewerClientInformationElement::NewInstance(bool copy) const
void void
ViewerClientInformationElement::SelectAll() ViewerClientInformationElement::SelectAll()
{ {
Select(ID_data, (void *)&data); Select(ID_data, (void *)&data);
Select(ID_rawData, (void *)&rawData); Select(ID_rawData, (void *)&rawData);
Select(ID_format, (void *)&format); Select(ID_format, (void *)&format);
Select(ID_isRaw, (void *)&isRaw); Select(ID_isRaw, (void *)&isRaw);
Select(ID_windowId, (void *)&windowId);
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
...@@ -446,6 +450,12 @@ ViewerClientInformationElement::CreateNode(DataNode *parentNode, bool completeSa ...@@ -446,6 +450,12 @@ ViewerClientInformationElement::CreateNode(DataNode *parentNode, bool completeSa
node->AddNode(new DataNode("isRaw", isRaw)); node->AddNode(new DataNode("isRaw", isRaw));
} }
if(completeSave || !FieldsEqual(ID_windowId, &defaultObject))
{
addToParent = true;
node->AddNode(new DataNode("windowId", windowId));
}
// Add the node to the parent node. // Add the node to the parent node.
if(addToParent || forceAdd) if(addToParent || forceAdd)
...@@ -490,6 +500,8 @@ ViewerClientInformationElement::SetFromNode(DataNode *parentNode) ...@@ -490,6 +500,8 @@ ViewerClientInformationElement::SetFromNode(DataNode *parentNode)
SetFormat(node->AsInt()); SetFormat(node->AsInt());
if((node = searchNode->GetNode("isRaw")) != 0) if((node = searchNode->GetNode("isRaw")) != 0)
SetIsRaw(node->AsBool()); SetIsRaw(node->AsBool());
if((node = searchNode->GetNode("windowId")) != 0)
SetWindowId(node->AsInt());
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
...@@ -524,6 +536,13 @@ ViewerClientInformationElement::SetIsRaw(bool isRaw_) ...@@ -524,6 +536,13 @@ ViewerClientInformationElement::SetIsRaw(bool isRaw_)
Select(ID_isRaw, (void *)&isRaw); Select(ID_isRaw, (void *)&isRaw);
} }
void
ViewerClientInformationElement::SetWindowId(int windowId_)
{
windowId = windowId_;
Select(ID_windowId, (void *)&windowId);
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Get property methods // Get property methods
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
...@@ -564,6 +583,12 @@ ViewerClientInformationElement::GetIsRaw() const ...@@ -564,6 +583,12 @@ ViewerClientInformationElement::GetIsRaw() const
return isRaw; return isRaw;
} }
int
ViewerClientInformationElement::GetWindowId() const
{
return windowId;
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Select property methods // Select property methods
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
...@@ -604,10 +629,11 @@ ViewerClientInformationElement::GetFieldName(int index) const ...@@ -604,10 +629,11 @@ ViewerClientInformationElement::GetFieldName(int index) const
{ {
switch (index) switch (index)
{ {
case ID_data: return "data"; case ID_data: return "data";
case ID_rawData: return "rawData"; case ID_rawData: return "rawData";
case ID_format: return "format"; case ID_format: return "format";
case ID_isRaw: return "isRaw"; case ID_isRaw: return "isRaw";
case ID_windowId: return "windowId";
default: return "invalid index"; default: return "invalid index";
} }
} }
...@@ -632,10 +658,11 @@ ViewerClientInformationElement::GetFieldType(int index) const ...@@ -632,10 +658,11 @@ ViewerClientInformationElement::GetFieldType(int index) const
{ {
switch (index) switch (index)
{ {
case ID_data: return FieldType_string; case ID_data: return FieldType_string;
case ID_rawData: return FieldType_ucharVector; case ID_rawData: return FieldType_ucharVector;
case ID_format: return FieldType_int; case ID_format: return FieldType_int;
case ID_isRaw: return FieldType_bool; case ID_isRaw: return FieldType_bool;
case ID_windowId: return FieldType_int;
default: return FieldType_unknown; default: return FieldType_unknown;
} }
} }
...@@ -660,10 +687,11 @@ ViewerClientInformationElement::GetFieldTypeName(int index) const ...@@ -660,10 +687,11 @@ ViewerClientInformationElement::GetFieldTypeName(int index) const
{ {
switch (index) switch (index)
{ {
case ID_data: return "string"; case ID_data: return "string";
case ID_rawData: return "ucharVector"; case ID_rawData: return "ucharVector";
case ID_format: return "int"; case ID_format: return "int";
case ID_isRaw: return "bool"; case ID_isRaw: return "bool";
case ID_windowId: return "int";
default: return "invalid index"; default: return "invalid index";
} }
} }
...@@ -710,6 +738,11 @@ ViewerClientInformationElement::FieldsEqual(int index_, const AttributeGroup *rh ...@@ -710,6 +738,11 @@ ViewerClientInformationElement::FieldsEqual(int index_, const AttributeGroup *rh
retval = (isRaw == obj.isRaw); retval = (isRaw == obj.isRaw);
} }
break; break;
case ID_windowId:
{ // new scope
retval = (windowId == obj.windowId);
}
break;
default: retval = false; default: retval = false;
} }
......
...@@ -94,6 +94,7 @@ public: ...@@ -94,6 +94,7 @@ public:
void SetRawData(const unsignedCharVector &rawData_); void SetRawData(const unsignedCharVector &rawData_);
void SetFormat(int format_); void SetFormat(int format_);
void SetIsRaw(bool isRaw_); void SetIsRaw(bool isRaw_);
void SetWindowId(int windowId_);
// Property getting methods // Property getting methods
const std::string &GetData() const; const std::string &GetData() const;
...@@ -102,6 +103,7 @@ public: ...@@ -102,6 +103,7 @@ public:
unsignedCharVector &GetRawData(); unsignedCharVector &GetRawData();
int GetFormat() const; int GetFormat() const;
bool GetIsRaw() const; bool GetIsRaw() const;
int GetWindowId() const;
// Persistence methods // Persistence methods
virtual bool CreateNode(DataNode *node, bool completeSave, bool forceAdd); virtual bool CreateNode(DataNode *node, bool completeSave, bool forceAdd);
...@@ -121,6 +123,7 @@ public: ...@@ -121,6 +123,7 @@ public:
ID_rawData, ID_rawData,
ID_format, ID_format,
ID_isRaw, ID_isRaw,
ID_windowId,
ID__LAST ID__LAST
}; };
...@@ -129,11 +132,12 @@ private: ...@@ -129,11 +132,12 @@ private:
unsignedCharVector rawData; unsignedCharVector rawData;
int format; int format;
bool isRaw; bool isRaw;
int windowId;
// Static class format string for type map. // Static class format string for type map.
static const char *TypeMapFormatString; static const char *TypeMapFormatString;
static const private_tmfs_t TmfsStruct; static const private_tmfs_t TmfsStruct;
}; };
#define VIEWERCLIENTINFORMATIONELEMENT_TMFS "su*ib" #define VIEWERCLIENTINFORMATIONELEMENT_TMFS "su*ibi"
#endif #endif
...@@ -9,4 +9,7 @@ ...@@ -9,4 +9,7 @@
<Field name="isRaw" label="isRaw" type="bool"> <Field name="isRaw" label="isRaw" type="bool">
false false
</Field> </Field>
<Field name="windowId" label="windowId" type="int">
-1
</Field>
</Attribute> </Attribute>
...@@ -58,7 +58,7 @@ import java.util.Vector; ...@@ -58,7 +58,7 @@ import java.util.Vector;
public class ViewerClientInformationElement extends AttributeSubject public class ViewerClientInformationElement extends AttributeSubject
{ {
private static int ViewerClientInformationElement_numAdditionalAtts = 4; private static int ViewerClientInformationElement_numAdditionalAtts = 5;
public ViewerClientInformationElement() public ViewerClientInformationElement()
{ {
...@@ -68,6 +68,7 @@ public class ViewerClientInformationElement extends AttributeSubject ...@@ -68,6 +68,7 @@ public class ViewerClientInformationElement extends AttributeSubject
rawData = new Vector(); rawData = new Vector();
format = 0; format = 0;
isRaw = false; isRaw = false;
windowId = -1;
} }
public ViewerClientInformationElement(int nMoreFields) public ViewerClientInformationElement(int nMoreFields)
...@@ -78,6 +79,7 @@ public class ViewerClientInformationElement extends AttributeSubject ...@@ -78,6 +79,7 @@ public class ViewerClientInformationElement extends AttributeSubject
rawData = new Vector(); rawData = new Vector();
format = 0; format = 0;
isRaw = false; isRaw = false;
windowId = -1;
} }
public ViewerClientInformationElement(ViewerClientInformationElement obj) public ViewerClientInformationElement(ViewerClientInformationElement obj)
...@@ -96,6 +98,7 @@ public class ViewerClientInformationElement extends AttributeSubject ...@@ -96,6 +98,7 @@ public class ViewerClientInformationElement extends AttributeSubject
format = obj.format; format = obj.format;
isRaw = obj.isRaw; isRaw = obj.isRaw;
windowId = obj.windowId;
SelectAll(); SelectAll();
} }
...@@ -127,7 +130,8 @@ public class ViewerClientInformationElement extends AttributeSubject ...@@ -127,7 +130,8 @@ public class ViewerClientInformationElement extends AttributeSubject
return ((data.equals(obj.data)) && return ((data.equals(obj.data)) &&
rawData_equal && rawData_equal &&
(format == obj.format) && (format == obj.format) &&
(isRaw == obj.isRaw)); (isRaw == obj.isRaw) &&
(windowId == obj.windowId));
} }
// Property setting methods // Property setting methods
...@@ -155,11 +159,18 @@ public class ViewerClientInformationElement extends AttributeSubject ...@@ -155,11 +159,18 @@ public class ViewerClientInformationElement extends AttributeSubject
Select(3); Select(3);
} }
public void SetWindowId(int windowId_)
{
windowId = windowId_;
Select(4);
}
// Property getting methods // Property getting methods
public String GetData() { return data; } public String GetData() { return data; }
public Vector GetRawData() { return rawData; } public Vector GetRawData() { return rawData; }
public int GetFormat() { return format; } public int GetFormat() { return format; }
public boolean GetIsRaw() { return isRaw; } public boolean GetIsRaw() { return isRaw; }
public int GetWindowId() { return windowId; }
// Write and read methods. // Write and read methods.
public void WriteAtts(CommunicationBuffer buf) public void WriteAtts(CommunicationBuffer buf)
...@@ -172,6 +183,8 @@ public class ViewerClientInformationElement extends AttributeSubject ...@@ -172,6 +183,8 @@ public class ViewerClientInformationElement extends AttributeSubject
buf.WriteInt(format); buf.WriteInt(format);
if(WriteSelect(3, buf)) if(WriteSelect(3, buf))
buf.WriteBool(isRaw); buf.WriteBool(isRaw);
if(WriteSelect(4, buf))
buf.WriteInt(windowId);
} }
public void ReadAtts(int index, CommunicationBuffer buf) public void ReadAtts(int index, CommunicationBuffer buf)
...@@ -190,6 +203,9 @@ public class ViewerClientInformationElement extends AttributeSubject ...@@ -190,6 +203,9 @@ public class ViewerClientInformationElement extends AttributeSubject
case 3: case 3:
SetIsRaw(buf.ReadBool()); SetIsRaw(buf.ReadBool());
break; break;
case 4:
SetWindowId(buf.ReadInt());
break;
} }
} }
...@@ -200,6 +216,7 @@ public class ViewerClientInformationElement extends AttributeSubject ...@@ -200,6 +216,7 @@ public class ViewerClientInformationElement extends AttributeSubject
str = str + ucharVectorToString("rawData", rawData, indent) + "\n"; str = str + ucharVectorToString("rawData", rawData, indent) + "\n";
str = str + intToString("format", format, indent) + "\n"; str = str + intToString("format", format, indent) + "\n";
str = str + boolToString("isRaw", isRaw, indent) + "\n"; str = str + boolToString("isRaw", isRaw, indent) + "\n";
str = str + intToString("windowId", windowId, indent) + "\n";
return str; return str;
} }
...@@ -209,5 +226,6 @@ public class ViewerClientInformationElement extends AttributeSubject ...@@ -209,5 +226,6 @@ public class ViewerClientInformationElement extends AttributeSubject
private Vector rawData; // vector of Byte objects private Vector rawData; // vector of Byte objects
private int format; private int format;
private boolean isRaw; private boolean isRaw;
private int windowId;
} }
...@@ -3563,6 +3563,7 @@ void GetSerializedData(int windowIndex, ...@@ -3563,6 +3563,7 @@ void GetSerializedData(int windowIndex,
element.SetData(QString(data.toBase64()).toStdString()); element.SetData(QString(data.toBase64()).toStdString());
element.SetFormat(ViewerClientInformation::Image); element.SetFormat(ViewerClientInformation::Image);
element.SetWindowId(vwin->GetWindowId()+1);
elementList.push_back(element); elementList.push_back(element);
} }
delete [] result; delete [] result;
...@@ -3596,6 +3597,7 @@ void GetSerializedData(int windowIndex, ...@@ -3596,6 +3597,7 @@ void GetSerializedData(int windowIndex,
ViewerClientInformationElement element; ViewerClientInformationElement element;
element.SetData(QString(data.toBase64()).toStdString()); element.SetData(QString(data.toBase64()).toStdString());
element.SetFormat(ViewerClientInformation::Image); element.SetFormat(ViewerClientInformation::Image);
element.SetWindowId(vwin->GetWindowId()+1);
elementList.push_back(element); elementList.push_back(element);
} }
/// free the memory /// free the memory
...@@ -3611,6 +3613,7 @@ void GetSerializedData(int windowIndex, ...@@ -3611,6 +3613,7 @@ void GetSerializedData(int windowIndex,
ViewerClientInformationElement element; ViewerClientInformationElement element;
element.SetData(QString(data.toBase64()).toStdString()); element.SetData(QString(data.toBase64()).toStdString());
element.SetFormat(ViewerClientInformation::Data); element.SetFormat(ViewerClientInformation::Data);
element.SetWindowId(vwin->GetWindowId()+1);
elementList.push_back(element); elementList.push_back(element);
} }
} }
......
...@@ -15993,8 +15993,8 @@ visit_exec_client_method(void *data) ...@@ -15993,8 +15993,8 @@ visit_exec_client_method(void *data)
keepGoing = false; keepGoing = false;
// Make the interpreter quit. // Make the interpreter quit.
viewerInitiatedQuit = true; viewerInitiatedQuit = true;
if(acquireLock) //if(acquireLock)
VisItUnlockPythonInterpreter(myThreadState); // VisItUnlockPythonInterpreter(myThreadState);
PyGILState_STATE state = PyGILState_Ensure(); PyGILState_STATE state = PyGILState_Ensure();
PyRun_SimpleString("import sys; sys.exit(0)"); PyRun_SimpleString("import sys; sys.exit(0)");
...@@ -18570,7 +18570,10 @@ initvisit() ...@@ -18570,7 +18570,10 @@ initvisit()
PyEval_InitThreads(); PyEval_InitThreads();
// save a pointer to the main PyThreadState object // save a pointer to the main PyThreadState object
mainThreadState = PyThreadState_Get(); mainThreadState = PyThreadState_Get();
///http://porky.linuxjournal.com:8080/LJ/073/3641.html
///according to the above article PyEval_InitThreads() is
///acquiring lock and needs to be released.
PyEval_ReleaseLock();
// //
// Initialize the module, but only do it one time. // Initialize the module, but only do it one time.
// //
...@@ -18599,7 +18602,6 @@ initvisit() ...@@ -18599,7 +18602,6 @@ initvisit()
PyDict_SetItemString(d, "VisItException", VisItError); PyDict_SetItemString(d, "VisItException", VisItError);
VisItInterrupt = PyErr_NewException((char*)"visit.VisItInterrupt", NULL, NULL); VisItInterrupt = PyErr_NewException((char*)"visit.VisItInterrupt", NULL, NULL);
PyDict_SetItemString(d, "VisItInterrupt", VisItInterrupt); PyDict_SetItemString(d, "VisItInterrupt", VisItInterrupt);
} }
// **************************************************************************** // ****************************************************************************
......
...@@ -101,6 +101,8 @@ PyViewerClientInformationElement_ToString(const ViewerClientInformationElement * ...@@ -101,6 +101,8 @@ PyViewerClientInformationElement_ToString(const ViewerClientInformationElement *
else else
SNPRINTF(tmpStr, 1000, "%sisRaw = 0\n", prefix); SNPRINTF(tmpStr, 1000, "%sisRaw = 0\n", prefix);
str += tmpStr; str += tmpStr;
SNPRINTF(tmpStr, 1000, "%swindowId = %d\n", prefix, atts->GetWindowId());
str += tmpStr;
return str; return str;
} }
...@@ -262,6 +264,30 @@ ViewerClientInformationElement_GetIsRaw(PyObject *self, PyObject *args) ...@@ -262,6 +264,30 @@ ViewerClientInformationElement_GetIsRaw(PyObject *self, PyObject *args)
return retval; return retval;
} }
/*static*/ PyObject *
ViewerClientInformationElement_SetWindowId(PyObject *self, PyObject *args)
{
ViewerClientInformationElementObject *obj = (ViewerClientInformationElementObject *)self;
int ival;
if(!PyArg_ParseTuple(args, "i", &ival))
return NULL;
// Set the windowId in the object.
obj->data->SetWindowId((int)ival);
Py_INCREF(Py_None);
return Py_None;
}
/*static*/ PyObject *
ViewerClientInformationElement_GetWindowId(PyObject *self, PyObject *args)
{
ViewerClientInformationElementObject *obj = (ViewerClientInformationElementObject *)self;
PyObject *retval = PyInt_FromLong(long(obj->data->GetWindowId()));