Commit f167e6a4 authored by hkrishna's avatar hkrishna

PySide & Remote Rendering updates

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@21216 18c085ea-50e0-402c-830e-de6fd14e8384
parent 38f8e22c
......@@ -53,7 +53,7 @@
#include <vtkUnsignedCharArray.h>
#include <vtkBase64Utilities.h>
#include <DebugStream.h>
#include <vtkImageResample.h>
// This array contains strings that correspond to the file types that are
// enumerated in the ImageFileFormat enum.
......@@ -401,3 +401,61 @@ avtImageFileWriter::WriteToByteArray(avtImageRepresentation &imagerep,
return result;
}
const char*
avtImageFileWriter::WriteToByteArray(avtImageRepresentation &imagerep,
int quality,
bool progressive,
size_t& len,
int outputWidth,
int outputHeight)
{
vtkImageData* imagedata = imagerep.GetImageVTK();
vtkImageResample* reslice = vtkImageResample::New();
int extents[6];
imagedata->GetExtent(extents);
reslice->SetOutputSpacing(((double)extents[1])/outputWidth,
((double)extents[3])/outputHeight,
0);
reslice->SetInputData(imagedata);
reslice->Update();
vtkJPEGWriter* writer = vtkJPEGWriter::New();
writer->SetWriteToMemory(true);
writer->SetInputData(reslice->GetOutput());
writer->SetQuality(quality);
writer->SetProgressive(progressive?1:0);
writer->Write();
vtkUnsignedCharArray* array = writer->GetResult();
char * result = NULL;
len = 0;
if(array)
{
vtkIdType size = array->GetSize();
if(size > 0)
{
len = size;
result = new char [len];
memcpy(result,array->GetVoidPointer(0),sizeof(char)*len);
}
}
reslice->Delete();
writer->Delete();
return result;
}
......@@ -117,6 +117,12 @@ class AVTFILEWRITER_API avtImageFileWriter : public avtTerminatingImageSink
int quality,
bool progressive,
size_t& len);
static const char* WriteToByteArray(avtImageRepresentation &imagerep,
int quality,
bool progressive,
size_t& len,
int outputWidth,
int outputHeight);
protected:
bool FileHasExtension(const char *filename, const char *ext)
const;
......
......@@ -1636,8 +1636,7 @@ avtDataTree::GetDatasetAsString()
writer->SetInputData(dataset);
writer->Write();
std::string res = writer->GetOutputString();
std::string res(writer->GetOutputString(),writer->GetOutputStringLength());
delete [] ds;
vaf->Delete();
vu->Delete();
......
......@@ -299,6 +299,9 @@ state/View3DAttributes.C
state/ViewAttributes.C
state/ViewAxisArrayAttributes.C
state/ViewCurveAttributes.C
state/ViewerClientAttributes.C
state/ViewerClientInformation.C
state/ViewerClientInformationElement.C
state/VisItRPC.C
state/VisualCueInfo.C
state/VisualCueList.C
......
This diff is collapsed.
......@@ -46,6 +46,7 @@
#include <Connection.h>
#include <deque>
#include <JSONNode.h>
// ****************************************************************************
// Class: SocketConnection
......@@ -86,20 +87,21 @@ public:
virtual bool NeedsRead(bool blocking = false) const;
virtual int GetDescriptor() const;
protected:
//int Write(MapNode* mapnode);
//void WriteToBuffer(MapNode* mapnode,bool write,int id, int& totalLen, int& totalSize);
// int Write(int id,MapNode *mapnode,JSONNode* data);
// void WriteToBuffer(MapNode *mapnode, JSONNode* data,
// bool write,
// int id,
// int& totalLen,
// int &totalSize);
int Write(int id,MapNode *mapnode);
void WriteToBuffer(MapNode *mapnode,
bool write,
int id,
int& totalLen,
int &totalSize);
int Write(int id,
JSONNode& node,
JSONNode& metadata);
void WriteToBuffer(const JSONNode& node,
const JSONNode& metadata,
bool write,
int id,
int& totalLen,
int &totalSize);
std::deque<unsigned char> buffer;
DESCRIPTOR descriptor;
int zeroesRead;
......
This diff is collapsed.
......@@ -45,6 +45,7 @@
#include <vectortypes.h>
#include <VisItException.h>
#include <MapNode.h>
#include <JSONNode.h>
// Forward declaration
class AttributeGroup;
......@@ -170,8 +171,14 @@ public:
int CalculateMessageSize(Connection &conn);
void Write(MapNode& map);
void WriteMeta(MapNode& map);
void Read(MapNode& map);
void WriteAPI(MapNode& map);
void WriteMetaData(MapNode& map);
//void Read(MapNode& map);
void Write(JSONNode& map);
void WriteAPI(JSONNode& map);
void WriteMetaData(JSONNode& map);
//void Read(JSONNode& map);
void SetSendMetaInformation(bool send) { sendMetaInformation = send; }
bool GetSendMetaInformation() { return sendMetaInformation; }
......@@ -330,9 +337,14 @@ private:
void WriteType(Connection &conn, typeInfo &info);
void ReadType(Connection &conn, int attrId, typeInfo &info);
void WriteType(MapNode &map, int attrId, typeInfo &info);
void WriteTypeMeta(MapNode &map, int attrId,typeInfo &info);
void ReadType(MapNode &map, int attrId, typeInfo &info);
void WriteAPI(MapNode &map, int attrId,typeInfo &info);
//void ReadType(MapNode &map, int attrId, typeInfo &info);
void WriteMetaData(MapNode &map, int attrId,typeInfo &info);
void WriteType(JSONNode &map, int attrId, typeInfo &info);
void WriteAPI(JSONNode &map, int attrId,typeInfo &info);
//void ReadType(JSONNode &map, int attrId, typeInfo &info);
void WriteMetaData(JSONNode &map, int attrId,typeInfo &info);
private:
typeInfoVector typeMap; // Holds typemap for the whole class
int guido;
......
This diff is collapsed.
......@@ -65,16 +65,16 @@ class STATE_API JSONNode
enum JSONType
{
JSONNUMBER,
JSONINTEGER,
JSONLONG,
JSONFLOAT,
JSONDOUBLE,
JSONSTRING,
JSONARRAY,
JSONOBJECT,
JSONBOOL,
JSONNULLVALUE
JSONLONG = 0x1,
JSONDOUBLE = 0x2,
JSONSTRING = 0x4,
JSONARRAY = 0x8,
JSONOBJECT = 0x10,
JSONBOOL = 0x20,
JSONNULLVALUE = 0x40,
JSONINTEGER = JSONLONG,
JSONFLOAT = JSONDOUBLE,
JSONNUMBER = JSONLONG | JSONDOUBLE
};
union number
......@@ -112,16 +112,23 @@ class STATE_API JSONNode
JSONNode(const double& v);
JSONNode(const JSONNode::JSONArray& array);
JSONNode(const JSONNode::JSONObject& obj);
JSONNode(const boolVector& v);
JSONNode(const charVector& v);
JSONNode(const unsignedCharVector& v);
JSONNode(const intVector& v);
JSONNode(const longVector& v);
JSONNode(const floatVector& v);
JSONNode(const doubleVector& v);
JSONNode(const stringVector& v);
virtual ~JSONNode();
JSONType GetType() const { return type; }
JSONType GetType() const { return type; } const
bool isNullValue() const { return json.num.nullValue; }
bool GetBool() const { return json.num.boolValue; }
int GetInt() const { return (int)GetLong(); }
long GetLong() const { return json.num.lnumber; }
float GetFloat() const { return (float)GetDouble(); }
bool GetBool() const { return json.num.boolValue; }
int GetInt() const { return (int)GetLong(); }
long GetLong() const { return json.num.lnumber; }
float GetFloat() const { return (float)GetDouble(); }
double GetDouble() const { return type == JSONINTEGER || type == JSONLONG ?
(double)json.num.lnumber :
json.num.dnumber; }
......@@ -130,6 +137,23 @@ class STATE_API JSONNode
JSONArray& GetArray() { return json.array; }
JSONObject& GetJsonObject() { return json.object; }
bool AsBool() const;
char AsChar() const;
unsigned char AsUnsignedChar() const;
int AsInt() const;
long AsLong() const;
float AsFloat() const;
double AsDouble() const;
std::string AsString() const;
boolVector AsBoolVector() const;
charVector AsCharVector() const;
unsignedCharVector AsUnsignedCharVector() const;
intVector AsIntVector() const;
longVector AsLongVector() const;
floatVector AsFloatVector() const;
doubleVector AsDoubleVector() const;
stringVector AsStringVector() const;
// bool isNullValue() { return json.num.nullValue; }
// bool GetBool() { return json.num.boolValue; }
// int GetInt() { return json.num.integer; }
......@@ -152,6 +176,14 @@ class STATE_API JSONNode
JSONNode &operator=(const JSONArray& v);
JSONNode &operator=(const JSONObject& v);
JSONNode &operator=(const JSONNode& v);
JSONNode &operator=(const boolVector& v);
JSONNode &operator=(const charVector& v);
JSONNode &operator=(const unsignedCharVector& v);
JSONNode &operator=(const intVector& v);
JSONNode &operator=(const longVector& v);
JSONNode &operator=(const floatVector& v);
JSONNode &operator=(const doubleVector& v);
JSONNode &operator=(const stringVector& v);
/// for JSONArray
JSONNode &operator[](int index);
......@@ -183,6 +215,9 @@ class STATE_API JSONNode
private:
std::string EscapeString(const std::string &val) const;
template<typename T>
JSONNode& convertArray(const T& v);
// init & destroy helpers
void Init(const JSONNode&);
void Cleanup();
......
......@@ -39,8 +39,10 @@
#include <MapNode.h>
#include <Connection.h>
#include <visitstream.h>
#include <cstdlib>
using namespace std;
int MapNode::MapNodeType = Variant::STRING_VECTOR_TYPE + 1000;
// ****************************************************************************
// Method: MapNode::MapNode
......@@ -72,9 +74,9 @@ MapNode::MapNode(const XMLNode *node, bool decodeString)
SetValue(*node,decodeString);
}
MapNode::MapNode(const JSONNode &node,bool decodeString)
MapNode::MapNode(const JSONNode &node, bool decodeString)
{
SetValue(node,decodeString);
SetValue(node, decodeString);
}
MapNode::MapNode(const JSONNode *node, bool decodeString)
......@@ -82,6 +84,16 @@ MapNode::MapNode(const JSONNode *node, bool decodeString)
SetValue(*node,decodeString);
}
MapNode::MapNode(const JSONNode &node,const JSONNode &metadata, bool decodeString)
{
SetValue(node, metadata, decodeString);
}
MapNode::MapNode(const JSONNode *node, const JSONNode* metadata, bool decodeString)
{
SetValue(*node,*metadata,decodeString);
}
// ****************************************************************************
// Method: MapNode::~MapNode
//
......@@ -619,7 +631,20 @@ MapNode::SetValue(const JSONNode &node,bool decodeString)
void
MapNode::SetValue(const JSONNode& data, const JSONNode& metadata, bool decodeString)
{
if(data.GetType() == JSONNode::JSONOBJECT)
int data_type = 0;
if(metadata.GetType() == JSONNode::JSONINTEGER){
data_type = metadata.GetInt();
}
else
{
const string name = metadata.GetString();
data_type = isdigit(name[0]) ? atoi(name.c_str()) :
NameToTypeID(name);
}
if(data_type == 0 && data.GetType() == JSONNode::JSONOBJECT)
{
const JSONNode::JSONObject& object = data.GetJsonObject();
const JSONNode::JSONObject& mobject = metadata.GetJsonObject();
......@@ -631,10 +656,27 @@ MapNode::SetValue(const JSONNode& data, const JSONNode& metadata, bool decodeStr
entries[itr->first] = MapNode();
entries[itr->first].SetValue(itr->second,mitr->second,decodeString);
}
} /// There should not be any JSONArrays for MapNode (yet)...
}
else if(data_type == 0 && data.GetType() == JSONNode::JSONARRAY)
{
const JSONNode::JSONArray& array = data.GetArray();
const JSONNode::JSONArray& marray = metadata.GetArray();
char buffer[1024];
for(int i = 0; i < array.size(); ++i) {
sprintf(buffer, "%d", i);
entries[buffer] = MapNode();
entries[buffer].SetValue(array[i], marray[i], decodeString);
}
}
else
{
Variant::SetValue(data,metadata,decodeString);
if(data_type == MapNodeType) {
SetValue(data);
}
else {
Variant::SetValue(data,metadata,decodeString);
}
}
}
......@@ -715,20 +757,25 @@ MapNode::operator ==(const MapNode &obj) const
// Modifications:
//
// ****************************************************************************
int
MapNode::CalculateMessageSize(Connection &conn) const
{
int messageSize = conn.IntSize(conn.DEST);
CalculateMessageSize(&conn);
}
int
MapNode::CalculateMessageSize(Connection *conn) const
{
int messageSize = conn->IntSize(conn->DEST);
if(Type() == EMPTY_TYPE)
{
messageSize += conn.IntSize(conn.DEST);
messageSize += conn->IntSize(conn->DEST);
map<string,MapNode>::const_iterator itr;
for(itr = entries.begin(); itr != entries.end(); ++itr)
{
messageSize += conn.CharSize(conn.DEST) * (itr->first.size() + 1);
messageSize += conn->CharSize(conn->DEST) * (itr->first.size() + 1);
messageSize += itr->second.CalculateMessageSize(conn);
}
}
......@@ -753,22 +800,27 @@ MapNode::CalculateMessageSize(Connection &conn) const
// Modifications:
//
// ****************************************************************************
void
MapNode::Write(Connection &conn) const
{
conn.WriteInt(Type());
Write(&conn);
}
void
MapNode::Write(Connection *conn) const
{
conn->WriteInt(Type());
if(Type() == EMPTY_TYPE)
{
// Write the number of entries
conn.WriteInt(entries.size());
conn->WriteInt(entries.size());
map<string,MapNode>::const_iterator itr;
for(itr = entries.begin(); itr != entries.end(); ++itr)
{
// Write the name of the item
conn.WriteString(itr->first);
conn->WriteString(itr->first);
// Write the item data.
itr->second.Write(conn);
......
......@@ -70,8 +70,10 @@ class STATE_API MapNode : public Variant
MapNode(const MapNode&);
MapNode(const XMLNode&,bool decodeString = true);
MapNode(const XMLNode*,bool decodeString = true);
MapNode(const JSONNode&,bool decodeString = true);
MapNode(const JSONNode*,bool decodeString = true);
explicit MapNode(const JSONNode&, bool decodeString = true);
explicit MapNode(const JSONNode*, bool decodeString = true);
explicit MapNode(const JSONNode&, const JSONNode& metadata, bool decodeString = true);
explicit MapNode(const JSONNode*,const JSONNode *metadata, bool decodeString = true);
MapNode &operator=(const MapNode&);
MapNode &operator=(bool);
MapNode &operator=(char);
......@@ -116,9 +118,12 @@ class STATE_API MapNode : public Variant
virtual JSONNode ToJSONNode(bool encodeString = true, bool id = true) const;
int CalculateMessageSize(Connection &conn) const;
int CalculateMessageSize(Connection *conn) const;
void Write(Connection &conn) const;
void Write(Connection *conn) const;
void Read(Connection &conn);
static int MapNodeType;
private:
virtual JSONNode ToJSONNodeData(bool encodeString) const;
virtual JSONNode ToJSONNodeMetaData(bool id) const;
......
This diff is collapsed.
......@@ -193,8 +193,8 @@ class STATE_API Variant
void SetValue(const Variant&);
void SetValue(const XMLNode&,bool decodeString = true);
void SetValue(const XMLNode*,bool decodeString = true);
void SetValue(const JSONNode&,const JSONNode&, bool decodeString = true);
void SetValue(const JSONNode*,const JSONNode* meta, bool decodeString = true);
virtual void SetValue(const JSONNode&,const JSONNode&, bool decodeString = true);
virtual void SetValue(const JSONNode*,const JSONNode* meta, bool decodeString = true);
void SetValue(bool);
void SetValue(char);
void SetValue(unsigned char);
......@@ -222,13 +222,15 @@ class STATE_API Variant
protected:
void Write(Connection &conn) const;
void Write(Connection *conn) const;
void Read(Connection &conn);
int CalculateMessageSize(Connection &conn) const;
int CalculateMessageSize(Connection *conn) const;
void Init(int);
virtual JSONNode ToJSONNodeMetaData(bool id) const;
private:
static std::string TypeIDToName(int);
static int NameToTypeID(const std::string &);
private:
static void Tokenize(const std::string&,
stringVector &tokens);
static void TokenizeQuotedString(const std::string&,
......
This diff is collapsed.
/*****************************************************************************
*
* Copyright (c) 2000 - 2012, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
#ifndef VIEWERCLIENTATTRIBUTES_H
#define VIEWERCLIENTATTRIBUTES_H
#include <state_exports.h>
#include <string>
#include <AttributeSubject.h>
// ****************************************************************************
// Class: ViewerClientAttributes
//
// Purpose:
// This class contains attributes used for viewer client
//
// Notes: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: omitted
//
// Modifications:
//
// ****************************************************************************
class STATE_API ViewerClientAttributes : public AttributeSubject
{
public:
enum RenderType
{
None,
Image,
Data
};
// These constructors are for objects of this class
ViewerClientAttributes();
ViewerClientAttributes(const ViewerClientAttributes &obj);
protected:
// These constructors are for objects derived from this class
ViewerClientAttributes(private_tmfs_t tmfs);
ViewerClientAttributes(const ViewerClientAttributes &obj, private_tmfs_t tmfs);
public:
virtual ~ViewerClientAttributes();
virtual ViewerClientAttributes& operator = (const ViewerClientAttributes &obj);
virtual bool operator == (const ViewerClientAttributes &obj) const;
virtual bool operator != (const ViewerClientAttributes &obj) const;
private:
void Init();
void Copy(const ViewerClientAttributes &obj);
public:
virtual const std::string TypeName() const;
virtual bool CopyAttributes(const AttributeGroup *);
virtual AttributeSubject *CreateCompatible(const std::string &) const;
virtual AttributeSubject *NewInstance(bool) const;
// Property selection methods
virtual void SelectAll();
void SelectTitle();
void SelectWindowIds();
// Property setting methods
void SetRenderingType(RenderType renderingType_);
void SetId(int id_);
void SetTitle(const std::string &title_);
void SetWindowIds(const intVector &windowIds_);
void SetImageWidth(int imageWidth_);
void SetImageHeight(int imageHeight_);
void SetImageResolutionPcnt(double imageResolutionPcnt_);
void SetExternalClient(bool externalClient_);
// Property getting methods
RenderType GetRenderingType() const;
int GetId() const;
const std::string &GetTitle() const;
std::string &GetTitle();
const intVector &GetWindowIds() const;
intVector &GetWindowIds();
int GetImageWidth() const;
int GetImageHeight() const;
double GetImageResolutionPcnt() const;
bool GetExternalClient() const;
// Persistence methods
virtual bool CreateNode(DataNode *node, bool completeSave, bool forceAdd);
virtual void SetFromNode(DataNode *node);
// Enum conversion functions
static std::string RenderType_ToString(RenderType);
static bool RenderType_FromString(const std::string &, RenderType &);
protected:
static std::string RenderType_ToString(int);
public:
// Keyframing methods
virtual std::string GetFieldName(int index) const;
virtual AttributeGroup::FieldType GetFieldType(int index) const;
virtual std::string GetFieldTypeName(int index) const;
virtual bool FieldsEqual(int index, const AttributeGroup *rhs) const;
// IDs that can be used to identify fields in case statements
enum {
ID_renderingType = 0,
ID_id,
ID_title,
ID_windowIds,
ID_imageWidth,
ID_imageHeight,
ID_imageResolutionPcnt,
ID_externalClient,
ID__LAST
};
private:
int renderingType;
int id;
std::string title;
intVector windowIds;
int imageWidth;
int imageHeight;
double imageResolutionPcnt;
bool externalClient;
// Static class format string for type map.
static const char *TypeMapFormatString;
static const private_tmfs_t TmfsStruct;
};
#define VIEWERCLIENTATTRIBUTES_TMFS "iisi*iidb"
#endif
<?xml version="1.0"?>
<Attribute name="ViewerClientAttributes" purpose="This class contains attributes used for viewer client" persistent="true" keyframe="true" exportAPI="STATE_API" exportInclude="state_exports.h" codefile="ViewerClientAttributes.code">
<Enum name="RenderType">
None