Commit afabbab9 authored by hkrishna's avatar hkrishna

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 @@
void ViewerClientInformationElement::Init()
{
isRaw = false;
windowId = -1;
ViewerClientInformationElement::SelectAll();
}
......@@ -82,6 +83,7 @@ void ViewerClientInformationElement::Copy(const ViewerClientInformationElement &
rawData = obj.rawData;
format = obj.format;
isRaw = obj.isRaw;
windowId = obj.windowId;
ViewerClientInformationElement::SelectAll();
}
......@@ -242,7 +244,8 @@ ViewerClientInformationElement::operator == (const ViewerClientInformationElemen
return ((data == obj.data) &&
(rawData == obj.rawData) &&
(format == obj.format) &&
(isRaw == obj.isRaw));
(isRaw == obj.isRaw) &&
(windowId == obj.windowId));
}
// ****************************************************************************
......@@ -386,10 +389,11 @@ ViewerClientInformationElement::NewInstance(bool copy) const
void
ViewerClientInformationElement::SelectAll()
{
Select(ID_data, (void *)&data);
Select(ID_rawData, (void *)&rawData);
Select(ID_format, (void *)&format);
Select(ID_isRaw, (void *)&isRaw);
Select(ID_data, (void *)&data);
Select(ID_rawData, (void *)&rawData);
Select(ID_format, (void *)&format);
Select(ID_isRaw, (void *)&isRaw);
Select(ID_windowId, (void *)&windowId);
}
///////////////////////////////////////////////////////////////////////////////
......@@ -446,6 +450,12 @@ ViewerClientInformationElement::CreateNode(DataNode *parentNode, bool completeSa
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.
if(addToParent || forceAdd)
......@@ -490,6 +500,8 @@ ViewerClientInformationElement::SetFromNode(DataNode *parentNode)
SetFormat(node->AsInt());
if((node = searchNode->GetNode("isRaw")) != 0)
SetIsRaw(node->AsBool());
if((node = searchNode->GetNode("windowId")) != 0)
SetWindowId(node->AsInt());
}
///////////////////////////////////////////////////////////////////////////////
......@@ -524,6 +536,13 @@ ViewerClientInformationElement::SetIsRaw(bool isRaw_)
Select(ID_isRaw, (void *)&isRaw);
}
void
ViewerClientInformationElement::SetWindowId(int windowId_)
{
windowId = windowId_;
Select(ID_windowId, (void *)&windowId);
}
///////////////////////////////////////////////////////////////////////////////
// Get property methods
///////////////////////////////////////////////////////////////////////////////
......@@ -564,6 +583,12 @@ ViewerClientInformationElement::GetIsRaw() const
return isRaw;
}
int
ViewerClientInformationElement::GetWindowId() const
{
return windowId;
}
///////////////////////////////////////////////////////////////////////////////
// Select property methods
///////////////////////////////////////////////////////////////////////////////
......@@ -604,10 +629,11 @@ ViewerClientInformationElement::GetFieldName(int index) const
{
switch (index)
{
case ID_data: return "data";
case ID_rawData: return "rawData";
case ID_format: return "format";
case ID_isRaw: return "isRaw";
case ID_data: return "data";
case ID_rawData: return "rawData";
case ID_format: return "format";
case ID_isRaw: return "isRaw";
case ID_windowId: return "windowId";
default: return "invalid index";
}
}
......@@ -632,10 +658,11 @@ ViewerClientInformationElement::GetFieldType(int index) const
{
switch (index)
{
case ID_data: return FieldType_string;
case ID_rawData: return FieldType_ucharVector;
case ID_format: return FieldType_int;
case ID_isRaw: return FieldType_bool;
case ID_data: return FieldType_string;
case ID_rawData: return FieldType_ucharVector;
case ID_format: return FieldType_int;
case ID_isRaw: return FieldType_bool;
case ID_windowId: return FieldType_int;
default: return FieldType_unknown;
}
}
......@@ -660,10 +687,11 @@ ViewerClientInformationElement::GetFieldTypeName(int index) const
{
switch (index)
{
case ID_data: return "string";
case ID_rawData: return "ucharVector";
case ID_format: return "int";
case ID_isRaw: return "bool";
case ID_data: return "string";
case ID_rawData: return "ucharVector";
case ID_format: return "int";
case ID_isRaw: return "bool";
case ID_windowId: return "int";
default: return "invalid index";
}
}
......@@ -710,6 +738,11 @@ ViewerClientInformationElement::FieldsEqual(int index_, const AttributeGroup *rh
retval = (isRaw == obj.isRaw);
}
break;
case ID_windowId:
{ // new scope
retval = (windowId == obj.windowId);
}
break;
default: retval = false;
}
......
......@@ -94,6 +94,7 @@ public:
void SetRawData(const unsignedCharVector &rawData_);
void SetFormat(int format_);
void SetIsRaw(bool isRaw_);
void SetWindowId(int windowId_);
// Property getting methods
const std::string &GetData() const;
......@@ -102,6 +103,7 @@ public:
unsignedCharVector &GetRawData();
int GetFormat() const;
bool GetIsRaw() const;
int GetWindowId() const;
// Persistence methods
virtual bool CreateNode(DataNode *node, bool completeSave, bool forceAdd);
......@@ -121,6 +123,7 @@ public:
ID_rawData,
ID_format,
ID_isRaw,
ID_windowId,
ID__LAST
};
......@@ -129,11 +132,12 @@ private:
unsignedCharVector rawData;
int format;
bool isRaw;
int windowId;
// Static class format string for type map.
static const char *TypeMapFormatString;
static const private_tmfs_t TmfsStruct;
};
#define VIEWERCLIENTINFORMATIONELEMENT_TMFS "su*ib"
#define VIEWERCLIENTINFORMATIONELEMENT_TMFS "su*ibi"
#endif
......@@ -9,4 +9,7 @@
<Field name="isRaw" label="isRaw" type="bool">
false
</Field>
<Field name="windowId" label="windowId" type="int">
-1
</Field>
</Attribute>
......@@ -58,7 +58,7 @@ import java.util.Vector;
public class ViewerClientInformationElement extends AttributeSubject
{
private static int ViewerClientInformationElement_numAdditionalAtts = 4;
private static int ViewerClientInformationElement_numAdditionalAtts = 5;
public ViewerClientInformationElement()
{
......@@ -68,6 +68,7 @@ public class ViewerClientInformationElement extends AttributeSubject
rawData = new Vector();
format = 0;
isRaw = false;
windowId = -1;
}
public ViewerClientInformationElement(int nMoreFields)
......@@ -78,6 +79,7 @@ public class ViewerClientInformationElement extends AttributeSubject
rawData = new Vector();
format = 0;
isRaw = false;
windowId = -1;
}
public ViewerClientInformationElement(ViewerClientInformationElement obj)
......@@ -96,6 +98,7 @@ public class ViewerClientInformationElement extends AttributeSubject
format = obj.format;
isRaw = obj.isRaw;
windowId = obj.windowId;
SelectAll();
}
......@@ -127,7 +130,8 @@ public class ViewerClientInformationElement extends AttributeSubject
return ((data.equals(obj.data)) &&
rawData_equal &&
(format == obj.format) &&
(isRaw == obj.isRaw));
(isRaw == obj.isRaw) &&
(windowId == obj.windowId));
}
// Property setting methods
......@@ -155,11 +159,18 @@ public class ViewerClientInformationElement extends AttributeSubject
Select(3);
}
public void SetWindowId(int windowId_)
{
windowId = windowId_;
Select(4);
}
// Property getting methods
public String GetData() { return data; }
public Vector GetRawData() { return rawData; }
public int GetFormat() { return format; }
public boolean GetIsRaw() { return isRaw; }
public int GetWindowId() { return windowId; }
// Write and read methods.
public void WriteAtts(CommunicationBuffer buf)
......@@ -172,6 +183,8 @@ public class ViewerClientInformationElement extends AttributeSubject
buf.WriteInt(format);
if(WriteSelect(3, buf))
buf.WriteBool(isRaw);
if(WriteSelect(4, buf))
buf.WriteInt(windowId);
}
public void ReadAtts(int index, CommunicationBuffer buf)
......@@ -190,6 +203,9 @@ public class ViewerClientInformationElement extends AttributeSubject
case 3:
SetIsRaw(buf.ReadBool());
break;
case 4:
SetWindowId(buf.ReadInt());
break;
}
}
......@@ -200,6 +216,7 @@ public class ViewerClientInformationElement extends AttributeSubject
str = str + ucharVectorToString("rawData", rawData, indent) + "\n";
str = str + intToString("format", format, indent) + "\n";
str = str + boolToString("isRaw", isRaw, indent) + "\n";
str = str + intToString("windowId", windowId, indent) + "\n";
return str;
}
......@@ -209,5 +226,6 @@ public class ViewerClientInformationElement extends AttributeSubject
private Vector rawData; // vector of Byte objects
private int format;
private boolean isRaw;
private int windowId;
}
......@@ -3563,6 +3563,7 @@ void GetSerializedData(int windowIndex,
element.SetData(QString(data.toBase64()).toStdString());
element.SetFormat(ViewerClientInformation::Image);
element.SetWindowId(vwin->GetWindowId()+1);
elementList.push_back(element);
}
delete [] result;
......@@ -3596,6 +3597,7 @@ void GetSerializedData(int windowIndex,
ViewerClientInformationElement element;
element.SetData(QString(data.toBase64()).toStdString());
element.SetFormat(ViewerClientInformation::Image);
element.SetWindowId(vwin->GetWindowId()+1);
elementList.push_back(element);
}
/// free the memory
......@@ -3611,6 +3613,7 @@ void GetSerializedData(int windowIndex,
ViewerClientInformationElement element;
element.SetData(QString(data.toBase64()).toStdString());
element.SetFormat(ViewerClientInformation::Data);
element.SetWindowId(vwin->GetWindowId()+1);
elementList.push_back(element);
}
}
......
......@@ -15993,8 +15993,8 @@ visit_exec_client_method(void *data)
keepGoing = false;
// Make the interpreter quit.
viewerInitiatedQuit = true;
if(acquireLock)
VisItUnlockPythonInterpreter(myThreadState);
//if(acquireLock)
// VisItUnlockPythonInterpreter(myThreadState);
PyGILState_STATE state = PyGILState_Ensure();
PyRun_SimpleString("import sys; sys.exit(0)");
......@@ -18570,7 +18570,10 @@ initvisit()
PyEval_InitThreads();
// save a pointer to the main PyThreadState object
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.
//
......@@ -18599,7 +18602,6 @@ initvisit()
PyDict_SetItemString(d, "VisItException", VisItError);
VisItInterrupt = PyErr_NewException((char*)"visit.VisItInterrupt", NULL, NULL);
PyDict_SetItemString(d, "VisItInterrupt", VisItInterrupt);
}
// ****************************************************************************
......
......@@ -101,6 +101,8 @@ PyViewerClientInformationElement_ToString(const ViewerClientInformationElement *
else
SNPRINTF(tmpStr, 1000, "%sisRaw = 0\n", prefix);
str += tmpStr;
SNPRINTF(tmpStr, 1000, "%swindowId = %d\n", prefix, atts->GetWindowId());
str += tmpStr;
return str;
}
......@@ -262,6 +264,30 @@ ViewerClientInformationElement_GetIsRaw(PyObject *self, PyObject *args)
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()));
return retval;
}
PyMethodDef PyViewerClientInformationElement_methods[VIEWERCLIENTINFORMATIONELEMENT_NMETH] = {
......@@ -274,6 +300,8 @@ PyMethodDef PyViewerClientInformationElement_methods[VIEWERCLIENTINFORMATIONELEM
{"GetFormat", ViewerClientInformationElement_GetFormat, METH_VARARGS},
{"SetIsRaw", ViewerClientInformationElement_SetIsRaw, METH_VARARGS},
{"GetIsRaw", ViewerClientInformationElement_GetIsRaw, METH_VARARGS},
{"SetWindowId", ViewerClientInformationElement_SetWindowId, METH_VARARGS},
{"GetWindowId", ViewerClientInformationElement_GetWindowId, METH_VARARGS},
{NULL, NULL}
};
......@@ -310,6 +338,8 @@ PyViewerClientInformationElement_getattr(PyObject *self, char *name)
return ViewerClientInformationElement_GetFormat(self, NULL);
if(strcmp(name, "isRaw") == 0)
return ViewerClientInformationElement_GetIsRaw(self, NULL);
if(strcmp(name, "windowId") == 0)
return ViewerClientInformationElement_GetWindowId(self, NULL);
return Py_FindMethod(PyViewerClientInformationElement_methods, self, name);
}
......@@ -332,6 +362,8 @@ PyViewerClientInformationElement_setattr(PyObject *self, char *name, PyObject *a
obj = ViewerClientInformationElement_SetFormat(self, tuple);
else if(strcmp(name, "isRaw") == 0)
obj = ViewerClientInformationElement_SetIsRaw(self, tuple);
else if(strcmp(name, "windowId") == 0)
obj = ViewerClientInformationElement_SetWindowId(self, tuple);
if(obj != NULL)
Py_DECREF(obj);
......
......@@ -45,7 +45,7 @@
//
// Functions exposed to the VisIt module.
//
#define VIEWERCLIENTINFORMATIONELEMENT_NMETH 10
#define VIEWERCLIENTINFORMATIONELEMENT_NMETH 12
void VISITPY_API PyViewerClientInformationElement_StartUp(ViewerClientInformationElement *subj, void *data);
void VISITPY_API PyViewerClientInformationElement_CloseDown();
VISITPY_API PyMethodDef * PyViewerClientInformationElement_GetMethodTable(int *nMethods);
......
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